c# pdf viewer open source : How to move pages within a pdf document SDK software API .net winforms wpf sharepoint World%20of%20Warcraft%20Programming%20(2nd%20Edition)39-part1837

Chapter 17
Creating Slash Commands 349
numberFinish = numberFinish + 1
if message:match(END_PATTERN, numberFinish) then
return operatorFunction, number
else
return operatorFunction, number, getpairs(message, i
numberFinish)
end
end
local function tokenize(message)
local _, finish, number = message:find(NUMBER_PATTERN)
if not number then
reportError(NUMBER_ERROR:format(1))
return
end
finish = finish + 1
if message:match(END_PATTERN, finish) == ““ then
return number
else
return number, getpairs(message, finish)
end
end
SLASH_SIMPLECALC1 = “/calculate“
SLASH_SIMPLECALC2 = “/calc“
SlashCmdList[“SIMPLECALC“] = function(message)
errorState = false
print(calculate(tokenize(message)))
end
How to move pages within a pdf document - re-order PDF pages in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support Customizing Page Order of PDF Document in C# Project
how to move pages around in pdf file; pdf change page order online
How to move pages within a pdf document - 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
rearrange pages in pdf online; how to move pages around in a pdf document
VB.NET PDF Page Insert Library: insert pages into PDF file in vb.
Able to add and insert one or multiple pages to existing adobe PDF document of adding and inserting a new blank page to the existing PDF document within a well
how to move pages within a pdf; how to change page order in pdf document
C# PowerPoint - How to Process PowerPoint
It enables you to move out useless PowerPoint document pages simply with a dealing solution to sort and rearrange PowerPoint slides order within C#.NET
move pdf pages; how to rearrange pdf pages reader
CH A P T E R
18
Responding to Graphic Updates
with OnUpdate
Although most code written in World of Warcraft is event-based, in certain
situations code should be run more frequently (possibly based on time).
Although there is no simple API method to accomplish this in World of
Warcraft, you can use
OnUpdate
scripts to fill these needs.
For example you can use
OnUpdate
scripts to do the following:
Delay code by a set amount of time.
Group events that fire rapidly together into a single batch to process.
Run code repeatedly, with time in between.
This chapter introduces the graphic update system that drives
OnUpdate
scripts, and leads you through creating simple addons to implement each of
these scripts.
Understanding Graphic Updates
AstandardmeasureforgraphicsperformanceinagamelikeWorldofWarcraft
is your framerate, which is measured in frames per second (FPS). The graphics
engine redraws the screen that many times to show changes to the interface
and the game world. You can view your framerate (see Figure 18-1) by
pressing Ctrl+R.
Everytime the screen is redrawn,the
OnUpdate
script fires for anyframethat
is visible (even if it has no graphical components). In addition, the arguments
to the script tell you how much time has passed since the last screen refresh.
Together, these can be used to make a very primitive (but effective) timer.
351
C# Word - Process Word Document in C#
It enables you to move out useless Word document pages simply with a You are capable of extracting pages from Microsoft Word document within C#.NET
change page order pdf; how to rearrange pdf pages online
C# TIFF: C#.NET Code to Process TIFF, RasterEdge XDoc.Tiff for .
are: TIFF, JPEG, GIF, BMP, PNG, PDF, Word and to program more personalized TIFF document manipulating solutions & a high-level model of the pages within a Tiff
how to move pages in pdf reader; how to reorder pages in pdf file
352
Part III
Advanced Addon Techniques
Figure 18-1: Framerate being displayed in-game
Delaying Code Using OnUpdate
Say you have a function, such as one that says a random witty phrase, that
you want to run in the future. You can write a helper function that uses an
OnUpdate
script to run code in the future. Run the following code in-game:
if not DelayFrame then
DelayFrame = CreateFrame(“Frame“)
DelayFrame:Hide()
end
function Delay(delay, func)
DelayFrame.func = func
DelayFrame.delay = delay
DelayFrame:Show()
end
DelayFrame:SetScript(“OnUpdate“, function(self, elapsed)
self.delay = self.delay - elapsed
if self.delay <= 0 then
self:Hide()
self.func()
end
end)
This codedefines a new function called
Delay()
that takes atime in seconds,
and a function to be run. It sets up the
DelayFrame
and when the correct
amount of time has passed it calls the function. The following defines a little
bit of code that uses this function to send taunting messages during combat:
if not TauntFrame then
TauntFrame = CreateFrame(“Frame“)
end
local tauntMessages = {
“Is that the best you can do?“,
“My grandmother can hit harder than that!“,
“Now you’re making me angry!“,
“Was that supposed to hurt?“,
“Vancleef pay big for your head!“,
“You too slow! Me too strong!“,
}
C# HTML5 PDF Viewer SDK to view PDF document online in C#.NET
Page: Replace PDF Pages. Page: Move Page Position. Page: Extract View PDF document in continuous pages display mode Search text within file by using Ignore case or
rearrange pages in pdf file; how to move pages in pdf
VB.NET PDF- View PDF Online with VB.NET HTML5 PDF Viewer
Page: Replace PDF Pages. Page: Move Page Position. Page: Copy View PDF document in continuous pages display mode. Search text within file by using Ignore case or
how to move pages in pdf files; pdf rearrange pages online
Chapter 18
Responding to Graphic Updates with OnUpdate
353
TauntFrame.CHANCE = 0.5
-- Chance that a message will happen
TauntFrame.DELAY = 3.0
-- Maximum delay before a message is sent
local isDelayed = false
local function sendTauntMessage()
local msgId = math.random(#tauntMessages)
SendChatMessage(tauntMessages[msgId], “SAY“)
isDelayed = false
end
TauntFrame:RegisterEvent(“UNIT_COMBAT“)
TauntFrame:SetScript(“OnEvent“, function(self, event, unit, action, ...)
if unit == “player“ and action ~= “HEAL“ and not isDelayed then
local chance = math.random(100)
if chance <= (100 * self.CHANCE) then
local delayTime = math.random() * self.DELAY
Delay(delayTime, sendTauntMessage)
isDelayed = true
end
end
end)
First this code creates a frame so it can register events, and then it defines
asmall table of taunting messages. Next, two simple configuration variables
are created and stored within the new frame. A function is created to actually
handle the choosing and sending of messages.
When the player is hit in combat and there isn’t already a delayed message
waiting to be sent, you generate a random number between 1 and 100. If
this number is less than or equal to 100 times the configured chance, the
sendTauntMessage()
function is scheduled for a random time in the future.
Figure 18-2 shows this addon in action.
Figure 18-2: Taunt messages being sent during combat
The chance for the message to trigger, as well as the delay, can be con-
figured while the code is running by changing
TauntFrame.CHANCE
and
TauntFrame.DELAY
to new values. You can experiment to find a balance
that is good for you.
VB.NET PDF Convert to Word SDK: Convert PDF to Word library in vb.
NET solution that supports converting each PDF page to Word document file by VB.NET code. All PDF pages can be converted to separate Word files within a short
change pdf page order online; reordering pdf pages
VB.NET PDF Convert to Tiff SDK: Convert PDF to tiff images in vb.
When converting PDF document to TIFF image using VB.NET program, do you know about a flexible raster image format for handling images and data within a single
reorder pages in pdf; how to move pages in a pdf file
354
Part III
Advanced Addon Techniques
Grouping Events to Avoid Over-Processing
The following simple bit of code watches the player’s inventory and warns
him when it falls below a certain threshold. You can use the
BAG_UPDATE
event
to watch for changes to the player’s bags.
if not BagWatchFrame then
BagWatchFrame = CreateFrame(“Frame“)
end
BagWatchFrame.WARN_LEVEL = 0.2
BagWatchFrame.message = “You are running low on bag space!“
BagWatchFrame.fullMessage = “Your bags are full!“
local function bagWatch_OnEvent(self, event, bag, ...)
local maxSlots, freeSlots = 0, 0
for idx = 0, 4 do
maxSlots = maxSlots + GetContainerNumSlots(idx)
freeSlots = freeSlots + GetContainerNumFreeSlots(idx)
end
local percFree = freeSlots / maxSlots
local msg
if percFree == self.percFree then
-- Don’t warn the user at the same level more than once
elseif percFree == 0 then
msg = BagWatchFrame.fullMessage
elseif percFree <= self.WARN_LEVEL then
msg = BagWatchFrame.message
end
if msg then?
RaidNotice_AddMessage(RaidWarningFrame, msg,
i
ChatTypeInfo[“RAID_WARNING“])
end
self.percFree = percFree
end
BagWatchFrame:RegisterEvent(“BAG_UPDATE“)
BagWatchFrame:SetScript(“OnEvent“, bagWatch_OnEvent)
Thiscodeis settowarn theplayerwhen he hasless than 20%ofhis bagspace
free. It uses the
GetContainerNumSlots()
and
GetContainerNumFreeSlots()
functions to determine how much space each bag has, and how much is free.
When the percentage of free slots is less than
BagWatchFrame.WARN_LEVEL
,the
code calls
RaidNotice_AddMessage()
toadda message totheraidnotice frame.
Figure 18-3 shows the addon warning as the player fills his last two slots.
VB.NET Image: VB Code to Read and Recognize EAN-13 Barcode from
Within document management library in VB platform, users can read and EAN-13 from MS Word and PDF document page, in notice, don't forget to move your activated
change page order in pdf reader; reorder pdf pages
C# Image: C# Code to Encode & Decode JBIG2 Images in RasterEdge .
images codec into PDF documents for a better PDF compression; RasterEdge JBIG2 codec SDK controls within C# project Move license text to the new project folder
move pages in pdf document; move pages within pdf
Chapter 18
Responding to Graphic Updates with OnUpdate
355
Figure 18-3: Free slot warning displayed in the RaidWarningFrame
Thereis aproblemwith thiscode thatcan beseen when using the Equipment
Manager. The EquipmentManageris asystemthatallows youtosavemultiple
gearsets,andswitchthemwitha singlebutton.That’saccomplishedbyrapidly
equipping (or un-equipping) items as necessary. The Equipment Manager is
disabled by default, but can be enabled on the Controls menu under Interface
Options.
Depending on your latency to the server, the number of items you are
equipping or un-equipping, and the number of slots you have free in your
bags, you may find this code warning you multiple times for the same
equipment change. That is because the
BAG_UPDATE
event is firing more than
once ina shortperiodoftime.Youcan usean
OnUpdate
to helpfix this problem,
as you see in the next section.
Grouping Multiple Events
The original code can be altered to not immediately trigger the bag scan, but
instead to schedule it for some time in the future using an
OnUpdate
.Edit the
code as follows, noting the highlighted differences from the previous version:
if not BagWatchFrame then
BagWatchFrame = CreateFrame(“Frame“)
end
BagWatchFrame.THROTTLE = 0.5
BagWatchFrame.WARN_LEVEL = 0.2
BagWatchFrame.message = “You are running low on bag space!“
BagWatchFrame.fullMessage = “Your bags are full!“
local function bagWatch_ScanBags(frame)
local maxSlots, freeSlots = 0, 0
for idx = 0, 4 do
maxSlots = maxSlots + GetContainerNumSlots(idx)
freeSlots = freeSlots + GetContainerNumFreeSlots(idx)
end
local percFree = freeSlots / maxSlots
local msg
if percFree == frame.percFree then
356
Part III
Advanced Addon Techniques
-- Don’t warn the user at the same level more than once
elseif percFree == 0 then
msg = frame.fullMessage
elseif percFree <= frame.WARN_LEVEL then
msg = frame.message
end
if msg then
RaidNotice_AddMessage(RaidWarningFrame, msg, i
ChatTypeInfo[“RAID_WARNING“])
end
frame.percFree = percFree
end
BagWatchFrame:RegisterEvent(“BAG_UPDATE“)
local counter = 0
BagWatchFrame:SetScript(“OnUpdate“, function(self, elapsed)
counter = counter + elapsed
if counter >= self.THROTTLE then
bagWatch_ScanBags(self)
counter = 0
self:Hide()
end
end)
BagWatchFrame:SetScript(“OnEvent“, function(self, event, ...)
BagWatchFrame:Show()
end)
Ratherthancallingthebag scan function (which has beenrenamed) directly,
the
OnEvent
handler justshows
BagWatchFrame
,causing the
OnUpdate
script to
fire. Once the configured amount of time has passed (in this case 0.5 seconds),
the bag scan will occur. This means that even if several
BAG_UPDATE
events fire
within that half-second period,the scan will only be run once.
Repeating Code with OnUpdate
You can also use
OnUpdate
scripts to run code repeatedly in order to perform
some periodic calculation. For example, you could alter the CombatTracker
addon you created in Chapter 14 to update the frame every second or so
during combat, giving you a running average instead of only displaying at
the end.
Add the following function to the end of
CombatTracker.lua
:
local throttle = 1.0
local counter = 0
function CombatTracker_OnUpdate(self, elapsed)
counter = counter + elapsed
if counter >= throttle then
Chapter 18
Responding to Graphic Updates with OnUpdate
357
CombatTracker_UpdateText()
counter = 0
end
end
Finally, you should set the
OnUpdate
script when the player enters combat,
and clear it when the player leaves combat. Under thePLAYER_REGEN_ENABLED
condition in
CombatTracker_OnEvent()
,add the following:
frame:SetScript(“OnUpdate“, nil)
Within the
PLAYER_REGEN_DISABLED
condition, add this line:
frame:SetScript(“OnUpdate“, CombatTracker_OnUpdate)
Now as long as you are in combat the calculation will be updated every
second.
Considering Performance with OnUpdate Scripts
Remember that the code in your
OnUpdate
handler is called on every screen
update. If the screen refreshes at 60 frames per second, then your script will
be called 60 times per second. As a result you should be sure to consider
performance when writing your functions. Don’t over-scrutinize your code
intosomemonster,butbeawarethatapoorlywritten
OnUpdate
scriptcanaffect
the frame rate of the client. In particularyou should consider the following:
Thegameclientrunscodesequentially.Asa result,all
OnUpdate
scriptsare
run before the client continues to process events or update the graphics.
If your function does not need to run every screen refresh, you can use a
throttle to introduce a delay.
Local variables are faster than global variables, so you can squeeze out a
bit of extra performance by using them.
Summary
This chapter discussed using
OnUpdate
scripts to introduce delays or run code
periodically. You created a number of small addons that use
OnUpdate
scripts
to perform various tasks.
The next chapter introduces you to function hooking, and using a combi-
nation of an
OnUpdate
timer and function hooking to alter the default user
interface.
Documents you may be interested
Documents you may be interested