c# pdf viewer open source : Rearrange pdf pages reader Library SDK component asp.net .net html mvc World%20of%20Warcraft%20Programming%20(2nd%20Edition)28-part1825

Chapter 12
Interacting with Widgets 239
<CheckedTexture file=“Interface\Buttons\CheckButtonHilight“ “ i
alphaMode=“ADD“/>
</CheckButton>
<Frame name=“BagBuddy“ parent=“UIParent“>
<Size x=“384“ y=“512“/>
<Anchors>
<Anchor point=“CENTER“ relativePoint=“CENTER“ “ i
relativeTo=“UIParent“/>
</Anchors>
<Layers>
<Layer level=“BACKGROUND“>
<Texture name=“$parent_Portrait“ parentKey=“portrait“ i
file=“Interface\Icons\INV_Misc_EngGizmos_30“>
<Size x=“60“ y=“60“/>
<Anchors>
<Anchor point=“TOPLEFT“>
<Offset x=“7“ y=“-6“/>
</Anchor>
</Anchors>
</Texture>
</Layer>
<Layer level=“OVERLAY“>
<FontString name=“$parent_Title“ parentKey=“title“ “ i
inherits=“GameFontNormal“ text=“BagBuggy“>
<Anchors>
<Anchor point=“TOP“>
<Offset x=“0“ y=“-18“/>
</Anchor>
</Anchors>
</FontString>
<FontString name=“$parent_Status“ parentKey=“status“ i
inherits=“GameFontHighlight“>
<Anchors>
<Anchor point=“CENTER“ relativePoint=“BOTTOM“>
<Offset x=“-10“ y=“150“/>
</Anchor>
</Anchors>
</FontString>
</Layer>
<Layer level=“BORDER“>
<Texture file=“Interface\BankFrame\UI-BankFrame-TopLeft“>
<Anchors>
<Anchor point=“TOPLEFT“/>
</Anchors>
</Texture>
<Texture file=“Interface\BankFrame\UI-BankFrame-TopRight“>
<Anchors>
<Anchor point=“TOPRIGHT“/>
Rearrange pdf pages reader - re-order PDF pages in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support Customizing Page Order of PDF Document in C# Project
move pdf pages; how to move pages in a pdf file
Rearrange pdf pages reader - VB.NET PDF Page Move Library: re-order PDF pages in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Sort PDF Document Pages Using VB.NET Demo Code
how to rearrange pages in a pdf file; reverse page order pdf
240
Part II
Programming in World of Warcraft
</Anchors>
</Texture>
<Texture file=“Interface\BankFrame\UI-BankFrame-BotLeft“>
<Anchors>
<Anchor point=“BOTTOMLEFT“/>
</Anchors>
</Texture>
<Texture file=“Interface\BankFrame\UI-BankFrame-BotRight“>
<Anchors>
<Anchor point=“BOTTOMRIGHT“/>
</Anchors>
</Texture>
</Layer>
</Layers>
<Frames>
<Button name=“$parent_Close“ parentKey=“close“ “ i
inherits=“UIPanelCloseButton“>
<Anchors>
<Anchor point=“TOPRIGHT“>
<Offset x=“-30“ y=“-8“/>
</Anchor>
</Anchors>
</Button>
<Button name=“BagBuddy_PrevButton“ parentKey=“prev“>
<Size x=“32“ y=“32“/>
<Anchors>
<Anchor point=“CENTER“ relativeTo=“BagBuddy“ “ i
relativePoint=“BOTTOMLEFT“>
<Offset>
<AbsDimension x=“50“ y=“150“/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnClick function=“BagBuddy_PrevPage“/>
</Scripts>
<NormalTexture i
file=“Interface\Buttons\UI-SpellbookIcon-PrevPage-Up“/>
<PushedTexture i
file=“Interface\Buttons\UI-SpellbookIcon-PrevPage-Down“/>
<DisabledTexture i
file=“Interface\Buttons\UI-SpellbookIcon-PrevPage-Disabled“/>
<HighlightTexture i
file=“Interface\Buttons\UI-Common-MouseHilight“ alphaMode=“ADD“/>
</Button>
<Button name=“BagBuddy_NextButton“ parentKey=“next“>
<Size x=“32“ y=“32“/>
<Anchors>
<Anchor point=“CENTER“ relativeTo=“BagBuddy“ “ i
C# TIFF: How to Reorder, Rearrange & Sort TIFF Pages Using C# Code
C# TIFF - Sort TIFF File Pages Order in C#.NET. Reorder, Rearrange and Sort TIFF Document Pages in C#.NET Application. C# TIFF Page Sorting Overview.
pdf reverse page order; switch page order pdf
VB.NET TIFF: Modify TIFF File by Adding, Deleting & Sort TIFF
you want to change or rearrange current TIFF &ltsummary> ''' Sort TIFF document pages in designed powerful & profession imaging controls, PDF document, image
reorder pages of pdf; rearrange pages in pdf file
Chapter 12
Interacting with Widgets 241
relativePoint=“BOTTOMRIGHT“>
<Offset>
<AbsDimension x=“-70“ y=“150“/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnClick function=“BagBuddy_NextPage“/>
</Scripts>
<NormalTexture i
file=“Interface\Buttons\UI-SpellbookIcon-NextPage-Up“/>
<PushedTexture i
file=“Interface\Buttons\UI-SpellbookIcon-NextPage-Down“/>
<DisabledTexture i
file=“Interface\Buttons\UI-SpellbookIcon-NextPage-Disabled“/>
<HighlightTexture i
file=“Interface\Buttons\UI-Common-MouseHilight“ alphaMode=“ADD“/>
</Button>
<EditBox name=“$parent_Input“ parentKey=“input“ i
autoFocus=“false“>
<Size x=“400“ y=“20“/>
<Anchors>
<Anchor point=“BOTTOMLEFT“>
<Offset x=“32“ y=“100“/>
</Anchor>
</Anchors>
<Scripts>
<OnEscapePressed>
self:ClearFocus()
</OnEscapePressed>
<OnTextChanged>
BagBuddy_Update()
</OnTextChanged>
</Scripts>
<FontString inherits=“GameFontHighlight“/>
</EditBox>
</Frames>
<Scripts>
<OnLoad function=“BagBuddy_OnLoad“/>
</Scripts>
</Frame>
</Ui>
VB.NET PDF File & Page Process Library SDK for vb.net, ASP.NET
page directly. Moreover, when you get a PDF document which is out of order, you need to rearrange the PDF document pages. In these
rearrange pdf pages in preview; reorder pdf page
C# PowerPoint - How to Process PowerPoint
pages simply with a few lines of C# code. C# Codes to Sort Slides Order. If you want to use a very easy PPT slide dealing solution to sort and rearrange
reorder pdf pages online; move pages in pdf
VB.NET Word: How to Process MS Word in VB.NET Library in .NET
well programmed Word pages sorter to rearrange Word pages in extracting single or multiple Word pages at one & profession imaging controls, PDF document, image
how to move pages around in a pdf document; pdf reorder pages online
Process Images in Web Image Viewer | Online Tutorials
used document types are supported, including PDF, multi-page easy to process image and file pages with the deleting a thumbnail, and you can rearrange the file
change page order pdf preview; how to move pages within a pdf
CH A P T E R
13
Responding to Game Events
By this point you should be fairly comfortable making new frames, textures,
and font strings. You’ve defined several templates for use in your own
addons, explored Blizzard’s own FrameXML templates, and learned how
to make your widgets more interactive by responding to widget scripts
and user input. This chapter introduces the next aspect of user interface
programming: responding to changes in the game client using the event
system and event-based programming.
Understanding Events
Events are a way for the game client to notify addons of a change in the state
of the game. For example, when the player’s health changes, the user interface
needs tobeinformed soit can updatethe status bar. If itweren’tforevents,the
game client would need to continuously update the health bar, which would
be very wasteful.
Events range from the extremely detailed to simple notifications that some-
thing has changed. A good example of the former is the
UNIT_COMBAT
event.
This event is usedfor the combatnotifications that appear on the player frame.
It fires whenever a unit takes damage, is healed, or performs some other
combat action (such as dodging, missing, or parrying). When the event is
finally triggered, it provides the following information:
The unit that was affected
The action type that occurred (wound, dodge, heal, and so on)
243
VB.NET PowerPoint: Sort and Reorder PowerPoint Slides by Using VB.
page will teach you to rearrange and readjust amount of robust PPT slides/pages editing methods and powerful & profession imaging controls, PDF document, image
reorder pages in pdf; how to rearrange pages in a pdf reader
244
Part II
Programming in World of Warcraft
Amodifier to the action, such as crushing or critical
The amount of damage or healing that was received
Anumber indicating the type of damage that was dealt
Registering for Events
Todoanything meaningful with game events, youmust firstregisterforthem.
Like many otherthingsin theuserinterface,you dothis through frames.Every
frameobject hasa
RegisterEvent()
methodforthis purpose.Itexpectsa single
string argument, the name of the event. Run the following code in-game to
create a new frame, and register for the
UNIT_COMBAT
event:
MyEventFrame = CreateFrame(“Frame“, “MyEventFrame“, UIParent)
MyEventFrame:RegisterEvent(“UNIT_COMBAT“)
You cannot register for more than one event at a time, but you can simply
call
RegisterEvent()
multiple times, or write a helper function that can do
multiple registrations for you.
Once a frame has been registered for an event, it will continue to receive
event information until the event has been unregistered. The
Unregister
Event()
event is provided for this purpose, taking the same argument as
RegisterEvent()
.
Responding to Events with OnEvent
To actually respond to events, you must set an
OnEvent
widget script for the
frame that has registered for events. Each widget script can have at most one
handler, so you will likely register for multiple events on the same frame, and
your handler mustbe capable of differentiating between different events. This
is done by examining the arguments that are passed to your handler:
self
—The frame that registered for the event
event
—The event that is being triggered
...
—A list of additional arguments to the event
Becausethehandleris given the name of the event as well as the frame itself,
you can use basic conditional statements to differentiate between different
events. For example, if you register for both
UNIT_HEALTH
and
UNIT_MANA
and
need to distinguish between them, you could do the following:
if event == “UNIT_HEALTH“ then
-- do something with the unit health
elseif event == “UNIT_MANA“ then
Chapter 13
Responding to Game Events 245
-- do something different with mana
end
Addan
OnEvent
script to the
MyEventFrame
you createdpreviously. Run the
following code in-game:
function MyEventFrame_OnEvent(self, event, ...)
print(“Event handler“, event, ...)
end
MyEventFrame:SetScript(“OnEvent“, MyEventFrame_OnEvent)
Alternatively, you could just create the new function inline:
MyEventFrame:SetScript(“OnEvent“, function(self, event, ...)
print(“Event handler“, event, ...)
end)
An even shorter form (that doesn’t allow you to add a custom message to
the start) simply sets the print function as the script handler:
MyEventFrame:SetScript(“OnEvent“, print)
The result of any of these will be a message sent to the chat frame each time
the event occurs. You can test this by fighting with something in-game. You
should receive messages for both you and your enemy. Figure 13-1 shows
some messages fromcombat.
Figure 13-1: Event messages for UNIT_COMBAT
In this case you can see that the event has five arguments that are passed to
the handler. You’ll work with the
UNIT_COMBAT
event more in Chapter 14 and
learn what each of these arguments are.
This simple methodof setting up event handlers to print debug information
can be useful when working on an addon because it lets you see easily which
arguments weresent with a given event. Alternatively,youcoulduse the new
/eventtrace
command that was added to WoW in 3.2. It is discussed at the
end of this chapter.
246
Part II
Programming in World of Warcraft
Query Events
Therearecertain APIcalls thatrequirecommunication with theserver,instead
of getting their information locally from the game client. For example, when
youwanttoupdateyourguildroster,youcallthe
GuildRoster()
function.You
might expect theinformation to be available immediately,but the information
is allstoredon theserversoyoumust waitforthe
GUILD_ROSTER_UPDATE
event,
which signifies that the data has been received by the client and is available.
When working with an API system, always read the relateddocumentation
so you will understand how the information becomes available.
Tracking Changes to Inventory for BagBuddy
The event-based system used in World of Warcraft is conceptually simple,
but in practice it can be a bit tricky to work this. In this section, you’ll use
the
BAG_UPDATE
event to add some functionality to BagBuddy. To sort the
inventory with the most recently looteditems first, you mustmonitor changes
to the player’s inventory. The
BAG_UPDATE
event fires whenever something
changes in the player’s bags, so it gives you just what you need.
Examining the BAG_UPDATE Event
BAG_UPDATE
is a very interesting event because it can fire for a number of
reasons, and doesn’t really provide much information. In fact, there is only
one argument to the event: the numeric index of the bag that was updated.
The event fires whenever the state of the player’s containers changes, such as
when the player moves items from one bag to another, or loots a new item.
If you write a simple addon to monitor the event, you might see that it
can fire multiple times back to back. For example, if you loot two items and
one of them goes into an existing stack, and the other goes into a new slot
elsewhere in your inventory, the event then fires for each of the bags that
changed. In addition, the
BAG_UPDATE
event’s first argument is sometimes a
negative number due to the internal implementation of the player’s inventory
and equipment.As a result, you’ll need to ignore anynegative values, andrun
your handler only when a legitimate bag has been updated.
Tracking New Inventory Items
For the purposes of BagBuddy, you just want to watch to see new items enter
the inventory so you can somehow tag them with the time they were looted.
Then when yougo through the display loop in
BagBuddy_Update
,youcan sort
according to that value.
Chapter 13
Responding to Game Events 247
You’llneedaplacetostoretheitemcounts foreach bag,soaddthefollowing
to the end of
BagBuddy_OnLoad
in
BagBuddy.lua
:
self.bagCounts = {}
Now add the following function definition somewhere in
BagBuddy.lua
:
function BagBuddy_ScanBag(bag, initial)
if not BagBuddy.bagCounts[bag] then
BagBuddy.bagCounts[bag] = {}
end
local itemCounts = {}
for slot = 0, GetContainerNumSlots(bag) do
local texture, count, locked, quality, readable, lootable, link = i
GetContainerItemInfo(bag, slot)
if texture then
local itemId = tonumber(link:match(“|Hitem:(%d+):“))
if not itemCounts[itemId] then
itemCounts[itemId] = count
else
itemCounts[itemId] = itemCounts[itemId] + count
end
end
end
if initial then
for itemId, count in pairs(itemCounts) do
BagBuddy_ItemTimes[itemId] = BagBuddy_ItemTimes[itemId] or time()
end
else
for itemId, count in pairs(itemCounts) do
local oldCount = BagBuddy.bagCounts[bag][itemId] or 0
if count > oldCount then
BagBuddy_ItemTimes[itemId] = time()
end
end
end
BagBuddy.bagCounts[bag] = itemCounts
end
This function takes a numerical bag index, and a flag called
initial
.The
flag will indicate whether the function is being called on the first scan of a
session because there would be no prior count with which to compare.
Next, the function loops over all of the slots in the given bag and checks to
see if there is an item in the slot. If so, it parses the item ID from the hyperlink
and updates the local
itemCounts
table with the new count.
248
Part II
Programming in World of Warcraft
Item times are stored in the global
BagBuddy_ItemTimes
tables, which we
will create in a later section. When the
initial
flag is set, the item times are
setusing the priorvalue, if possible, or the currenttime. At any other time, the
item counts are compared to the previous item counts. If the count has gone
up, then the item time is set to the current time. Finally, the new
itemCounts
table is stored in
BagBuddy.bagCounts
so it can be used on the next inventory
change.
Notethatyou’re using the itemnumber heretostoretheloottime, otherwise
items with different unique IDs would show up as distinct items. Ideally you
would use the item string (excluding the unique ID portion) so you can
differentiate between items that have different enchants or sockets. This
version just lumps those types of items into a single stack for simplicity.
Writing a New Sorting Function
The previous version of this addon sorted items by name, but now you want
to include item loot time as part of the sorting. Insert a new sorting function
by adding the following definition before
BagBuddy_Update()
:
local function itemTimeNameSort(a, b)
-- If the two items were looted at the same time
local aTime = BagBuddy.itemTimes[a.num]
local bTime = BagBuddy.itemTimes[b.num]
if aTime == bTime then
return a.name < b.name
else
return aTime >= bTime
end
end
The function checks to see if the loot times are the same, in which case it
sorts the items by name. If the times are different, then they are sorted in
descending order(by using
>=
insteadof
<
)in the comparison.Tousethis new
sorting function, you need to make some small changes to the update.
Altering BagBuddy_Update
Thechanges to
BagBuddy_Update
areverysimple;youjust needtoaddthe item
number to the entry table and call the new sort function. In
BagBuddy_Update
,
the new item table code should be changed to the following (changed line is
highlighted):
if not items[itemNum] then
items[itemNum] = {
texture = texture,
Documents you may be interested
Documents you may be interested