c# pdf viewer open source : Rearrange pdf pages in reader software application project winforms html azure UWP World%20of%20Warcraft%20Programming%20(2nd%20Edition)56-part1856

Chapter 26
Creating Unit Frames with Group Templates 519
self.unit.name:SetTextColor(r, g, b)
else
self.unit.name:SetTextColor(1, 1, 1)
end
Figure 26-5 shows a raid group with names colored to indicate threat level.
Figure 26-5: SquareUnitFrames showing threat levels for party members
Showing Dead Players
Right now if someone in your group were to die, it would be difficult to see if
theywereactually deadorjustverylow on health.Youcan fix thisbychanging
the status bar’s color to gray and filling it in. Change your implementation of
SquareUnitFrames_ResetHealthBar
to the following:
function SquareUnitFrames_ResetHealthBar(button, unit)
local class = select(2, UnitClass(unit)) or “WARRIOR“
local classColor = RAID_CLASS_COLORS[class]
local alive = not UnitIsDeadOrGhost(unit)
if alive then
button.healthBar:SetStatusBarColor(classColor.r, i
classColor.g, classColor.b)
button.healthBar:SetMinMaxValues(0, UnitHealthMax(unit))
button.healthBar:SetValue(UnitHealth(unit))
button.dead = false
else
button.healthBar:SetStatusBarColor(0.3, 0.3, 0.3)
button.healthBar:SetMinMaxValues(0, 1)
button.healthBar:SetValue(1)
button.dead = true
end
end
The first two lines are the same, but then you use the
UnitIsDeadOrGhost
function to (shockingly) check to see if the unit is either dead or a ghost. You
then either color the status bar based on the class color, or change it to grey
and fill it in. You also set a flag on the unit button that you’ll use in the event
handler to indicate whether the status bar is currently showing the player as
dead or alive.
Change the
UNIT_HEALTH
and
UNIT_MAXHEALTH
portion of the event handler
to the following:
if event == “UNIT_MAXHEALTH“ then
if self.unit.dead ~= UnitIsDeadOrGhost(unit) then
SquareUnitFrames_ResetUnitButton(self.unit, unit)
Rearrange pdf pages in reader - 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 reorder pages in pdf reader; reorder pdf page
Rearrange pdf pages in 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 move pdf pages around; reorder pages pdf
520
Part III
Advanced Addon Techniques
else
self.unit.healthBar:SetMinMaxValues(0, UnitHealthMax(unit))
self.unit.healthBar:SetValue(UnitHealth(unit))
end
elseif event == “UNIT_HEALTH“ then
if self.unit.dead ~= UnitIsDeadOrGhost(unit) then
SquareUnitFrames_ResetUnitButton(self.unit, unit)
else
self.unit.healthBar:SetValue(UnitHealth(unit))
end
Here you just check to see if your flag is different from the return of
UnitIsDeadOrGhost
and then adjust the frame accordingly. When a unit dies
the API still shows it as having power, so color that grey as well. Open up
SquareUnitFrames_ResetPowerBar
and replace the last three lines:
button.powerBar:SetStatusBarColor(powerColor.r, powerColor.g, i
powerColor.b)
button.powerBar:SetMinMaxValues(0, UnitPowerMax(unit))
button.powerBar:SetValue(UnitPower(unit))
with the following:
local alive = not UnitIsDeadOrGhost(unit)
if alive then
button.powerBar:SetStatusBarColor(powerColor.r, i
powerColor.g, powerColor.b)
else
button.powerBar:SetStatusBarColor(0.3, 0.3, 0.3)
end
button.powerBar:SetMinMaxValues(0, UnitPowerMax(unit))
button.powerBar:SetValue(UnitPower(unit))
Change the event handler by replacing the power event conditions with the
following code:
elseif event == “UNIT_“ .. powerToken then
if self.unit.dead ~= UnitIsDeadOrGhost(unit) then
SquareUnitFrames_ResetPowerBar(self.unit, unit)
else
self.unit.powerBar:SetValue(UnitPower(unit))
end
elseif event == “UNIT_MAX“ .. powerToken then
if self.unit.dead ~= UnitIsDeadOrGhost(unit) then
SquareUnitFrames_ResetPowerBar(self.unit, unit)
else
self.unit.powerBar:SetMinMaxValues(0, UnitPowerMax(unit))
self.unit.powerBar:SetValue(UnitPower(unit))
end
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.
reorder pdf pages; how to change page order in pdf document
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
rearrange pdf pages reader; how to move pages in pdf converter professional
Chapter 26
Creating Unit Frames with Group Templates 521
Figure 26-6 shows the unit frames with a dead unit, which is much easierto
see when it’s shaded.
Figure 26-6: SquareUnitFrames showing a dead unit shaded out
Displaying Unit Names
Currently, whenever
SquareUnitFrames
displays a name that is longer than
four characters (and some names that are shorter), it is truncated with an
ellipsis (‘‘ ... ’’) at the end. This isn’t very desirable—an ellipsis takes up
much of the unit button’s width, space that could be better used to display
more characters of the name—but WoW doesn’t really provide an easy way
to fit as much of a name as possible in a font string of limited width.
What you can do instead is try different substrings of the name in order to
fitas many characters as you can in a 30-pixel-wide font string. This algorithm
might look like this:
local substring(name, length)
for length=#name, 1, -1 do
substring = string.sub(name, 1, length)
button.name:SetText(substring)
if button.name:GetStringWidth() <= 30 then
button.shortname = substring
return
end
end
First you take the entire string and set a font string to display it. Then you
check to see what the width of the resulting display is. You continue to take
one less character andas soon as you have something that is less than or equal
to 30 pixels in width, you accept it and store it in the button (so you can re-use
it later instead of re-calculating it).
This process, however, will have a big problem with names that contain
non-alphanumeric characters, such as letters with accents and other spe-
cial symbols. These characters are encoded using a standard called UTF-8.
Although UTF-8 is very far outside the scope of this book, you can read more
information aboutit at
http://en.wikipedia.org/wiki/Utf8
.What you need
toknow is that although each of thosespecial characters can be representedby
multiple bytes, Lua’s string library treats each byte as an individual character.
The following is sample output fromWorld of Warcraft:
> print(string.len(“Gr¨uber“))
7
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
how to move pages within a pdf; how to reorder pages in pdf
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
rearrange pages in pdf document; move pages in pdf file
522
Part III
Advanced Addon Techniques
Even though Gr¨uber has only six visible characters, it’s actually made up
of seven different characters from the Lua string library’s point of view. If
you tried to examine the substring between character positions 1 and 3 you
would only get half of the ‘‘¨u’’ character. That’s because Lua’s built-in string
processing functions aren’t UTF-8 aware.
Luckily we’ve done the work so you don’t have to, and have created
a function that takes in a string, a start index, and a number of char-
acters to retrieve. Define this function directly above your definition of
SquareUnitFrames_ResetName
(you can include the comments if you’d like):
-- This function can return a substring of a UTF-8 string, properly
-- handling UTF-8 codepoints.
Rather than taking a start index and
-- optionally an end index, it takes the string, the start index, and
-- the number of characters to select from the string.
--
-- UTF-8 Reference:
-- 0xxxxxx - ASCII character
-- 110yyyxx - 2 byte UTF codepoint
-- 1110yyyy - 3 byte UTF codepoint
-- 11110zzz - 4 byte UTF codepoint
local function utf8sub(str, start, numChars)
local currentIndex = start
while numChars > 0 and currentIndex <= #str do
local char = string.byte(str, currentIndex)
if char >= 240 then
currentIndex = currentIndex + 4
elseif char >= 225 then
currentIndex = currentIndex + 3
elseif char >= 192 then
currentIndex = currentIndex + 2
else
currentIndex = currentIndex + 1
end
numChars = numChars - 1
end
return str:sub(start, currentIndex - 1)
end
Next, change the definition of
SquareUnitFrames_ResetName
to the
following:
function SquareUnitFrames_ResetName(button, unit)
local name = UnitName(unit) or “Unknown“
local substring
for length=#name, 1, -1 do
substring = utf8sub(name, 1, length)
button.name:SetText(substring)
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
rearrange pdf pages online; rearrange pages in pdf file
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 pdf page order; how to reverse pages in pdf
Chapter 26
Creating Unit Frames with Group Templates 523
if button.name:GetStringWidth() <= 30 then
return
end
end
local status = UnitThreatSituation(unit)
if status and status > 0 then
local r, g, b = GetThreatStatusColor(status)
button.name:SetTextColor(r, g, b)
else
button.name:SetTextColor(1, 1, 1)
end
end
Sure, it’s a lot of code to accomplish something that should be relatively
easy, but it makes the frames look so much neater. Figure 26-7 shows the
difference between the old version and the new improved version.
Figure 26-7: SquareUnitFrames showing truncated names, and the version using the
fitting algorithm
Adding Pets to SquareUnitFrames
The state handlers system makes it extremely easy to add a pet frame that is
shown/hidden correctly, even when the player is in combat. The first thing
youneed to doiscreate the frame definition in the XML file.Add the following
after the
</Button>
tag for the unit sub-button, but before the
</Frames>
tag
for the XML template:
<Button name=“$parent_Pet“ parentKey=“pet“
inherits=“SecureHandlerShowHideTemplate,SecureUnitButtonTemplate“>
<Size x=“34“ y=“5“/>
<Anchors>
<Anchor point=“BOTTOMLEFT“>
<Offset x=“1“ y=“1“/>
</Anchor>
</Anchors>
<Frames>
<StatusBar name=“$parent_HealthBar“ parentKey=“healthBar“
setAllPoints=“true“>
<BarTexture file=“Interface\Buttons\UI-Listbox-Highlight2“/>
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
how to reorder pdf pages in; how to move pages around in a pdf document
524
Part III
Advanced Addon Techniques
<BarColor r=“0.0“ g=“1.0“ b=“0.0“/>
</StatusBar>
</Frames>
<Attributes>
<Attribute name=“useparent-unit“ type=“boolean“ value=“true“/>
<Attribute name=“unitsuffix“ type=“string“ value=“pet“/>
<Attribute name=“*type1“ type=“string“ value=“target“/>
</Attributes>
<HighlightTexture file=“Interface\Buttons\UI-Listbox-Highlight2“
alphaMode=“ADD“/>
</Button>
This definition inherits from
SecureHandlerShowHideTemplate
as well as
SecureUnitButtonTemplate
.This enables you to run code when the frame
is shown or hidden, and allows you to enable left-click to target the unit.
The frame is hidden by default, and you’ll register it to be shown whenever
the unit has a pet. The
unitsuffix
attribute here, when combined with
useparent-unit
,ensures that the frame inherits the unit attribute from its
parent, and adds
pet
to the end, giving you the pet’s unit identifier.
Add the following code to the end of
SquareUnitFrames_InitialConfig
:
RegisterUnitWatch(frame.pet)
frame.pet:SetFrameRef(“unit“, frame.unit)
frame.pet:SetAttribute(“_onshow“, [[
local unit = self:GetFrameRef(“unit“)
unit:SetHeight(28)
]])
frame.pet:SetAttribute(“_onhide“, [[
local unit = self:GetFrameRef(“unit“)
unit:SetHeight(34)
]])
frame.pet.unit = frame.unit
frame.pet:HookScript(“OnShow“, SquareUnitFrames_Pet_OnShow)
frame.pet:HookScript(“OnHide“, SquareUnitFrames_Pet_OnHide)
The first line simply registers the pet frame to be shown/hidden based on
theexistenceofthe unit it’s set to display. Next twosecuresnippetsarecreated
that will be run when the frame is shown and hidden. The first changes the
height of the unit frame to be 6 pixels smaller, and the second changes it back
to the original height.
Next, you set
button.pet.unit
to be equal to
button.unit
.This allows
you to easily access the unit button from within the pet button’s handlers.
Finally, you hook the
OnShow
and
OnHide
widget scripts so you can run some
non-secure code. This is because non-secure frames cannot be altered from
secure snippets, and vice versa. You want to hide the power bar (which is not
secure), so this is the best way to accomplish this.
Chapter 26
Creating Unit Frames with Group Templates 525
Define these two functions somewhere in your Lua file before the header
show at the end:
function SquareUnitFrames_Pet_OnShow(self)
self.unit.healthBar:SetHeight(28)
self.unit.powerBar:Hide()
end
function SquareUnitFrames_Pet_OnHide(self)
self.unit.healthBar:SetHeight(30)
self.unit.powerBar:Show()
end
The height of the health bar is changed and the power bar is shown or
hidden. What all of this will accomplish is making the unit frame a bit smaller,
and removing the power bar. Then the pet health bar is placed below the unit
frames (but big enough that it can still be easily seen and clicked).
Add a function that resets the pet button when requested, so it can be used
elsewhere in the code:
function SquareUnitFrames_ResetPetButton(button, unit)
if UnitExists(unit) then
local health = UnitHealth(unit)
local maxHealth = UnitHealth(unit)
button.healthBar:SetMinMaxValues(0, maxHealth)
button.healthBar:SetValue(health)
end
end
Adda call tothis function in the
SquareUnitFrames_Frame_OnShow
function,
right after the call to
SquareUnitFrames_ResetUnitButton
(note that you
append
pet
to the end of the unit token so it looks at the correct unit):
SquareUnitFrames_ResetPetButton(button.pet, unit .. “pet“)
Finally, add event handlers for the unit’s health by adding the following to
the
OnEvent
script.This code shouldbeaddedin the outermost
else
statement,
after the first
UnitIsUnit
block (if you’re confused, youcan always skip to the
end of the chapter and see where it lies in the context of the whole function):
elseif arg1 and UnitIsUnit(unit .. “pet“, arg1) then
if event == “UNIT_MAXHEALTH“ then
self.pet.healthBar:SetMinMaxValues(0, UnitHealthMax(arg1))
self.pet.healthBar:SetValue(UnitHealth(arg1))
elseif event == “UNIT_HEALTH“ then
self.pet.healthBar:SetValue(UnitHealth(arg1))
end
end
526
Part III
Advanced Addon Techniques
It’s a relatively small amount of code to write for such a big change to
functionality. Figure 26-8 shows a warlock without a pet and with an imp
summoned and fighting.
Figure 26-8: SquareUnitFrames for a warlock without a pet (left) and with a summoned
pet (right).
Creating a SecureGroupPetHeaderTemplate
If instead of adding pets to an existing frame, you just want to have a header
consistingsolely of pets,Blizzardhas provideda templatejustforthis purpose.
In addition to the attributes allowed by the
SecureGroupHeaderTemplate
,the
following two attributes can be used to customize the display of party/
raid pets:
useOwnerUnit
(boolean)—When
true
,the
unit
attributeon thecreated
frames corresponds to the owner’s unit instead of the pet’s unit.
filterOnPet
(boolean)—When
true
,the pet’s names are used when
sorting and filtering.
In addition to these specific attributes, the pet header accepts the same
attributes as the normal secure group header.
Summary
Although stringent limitations exist as to what can be accomplished in an
addon, a number of powerful templates allow developers to make extremely
functionaladdons.This chapterintroducedyoutothegroupheadertemplates,
and created an extensive party/raid addon.
The Code
SquareUnitFrames
SquareUnitFrames.toc
## Interface: 30300
## Title: SquareUnitFrames
## Notes: Square shaped party/raid frames
SquareUnitFrames.xml
SquareUnitFrames.lua
Chapter 26
Creating Unit Frames with Group Templates 527
SquareUnitFrames.xml
<Ui
xmlns=“http://www.blizzard.com/wow/ui/“
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance“
xsi:schemaLocation=“http://www.blizzard.com/wow/ui/
http://wowprogramming.com/FrameXML/UI.xsd“>
<Frame name=“SquareUnitFrames_UnitTemplate“ virtual=“true“>
<Size x=“36“ y=“36“/>
<Layers>
<Layer level=“BACKGROUND“>
<Texture setAllPoints=“true“>
<Color r=“0.0“ g=“0.0“ b=“0.0“/>
</Texture>
</Layer>
</Layers>
<Frames>
<Button name=“$parent_Unit“ parentKey=“unit“
inherits=“SecureUnitButtonTemplate“>
<Size x=“34“ y=“34“/>
<Anchors>
<Anchor point=“TOPLEFT“>
<Offset x=“1“ y=“-1“/>
</Anchor>
</Anchors>
<Layers>
<Layer level=“OVERLAY“>
<FontString name=“$parent_Name“ parentKey=“name“
inherits=“GameFontHighlight“ setAllPoints=“true“/>
<Texture name=“$parent_Selected“ parentKey=“selected“
setAllPoints=“true“
file=“Interface\Buttons\CheckButtonHilight“
alphaMode=“ADD“ hidden=“true“/>
</Layer>
</Layers>
<Frames>
<StatusBar name=“$parent_HealthBar“
parentKey=“healthBar“>
<Size x=“34“ y=“30“/>
<Anchors>
<Anchor point=“TOPLEFT“/>
</Anchors>
<BarTexture
file=“Interface\Buttons\UI-Listbox-Highlight2“/>
<BarColor r=“1.0“ g=“1.0“ b=“1.0“/>
</StatusBar>
<StatusBar name=“$parent_PowerBar“ parentKey=“powerBar“>
<Size x=“34“ y=“3“/>
<Anchors>
<Anchor point=“TOPLEFT“
528
Part III
Advanced Addon Techniques
relativeTo=“$parent_HealthBar“
relativePoint=“BOTTOMLEFT“>
<Offset x=“0“ y=“-1“/>
</Anchor>
</Anchors>
<BarTexture
file=“Interface\TargetingFrame\UI-TargetingFrame-i
BarFill“/>
<BarColor r=“1.0“ g=“1.0“ b=“1.0“/>
</StatusBar>
</Frames>
<Scripts>
<OnDragStart
function=“SquareUnitFrames_Button_OnDragStart“/>
<OnDragStop
function=“SquareUnitFrames_Button_OnDragStop“/>
<OnHide function=“SquareUnitFrames_Button_OnDragStop“/>
</Scripts>
<Attributes>
<Attribute name=“useparent-unit“ type=“boolean“
value=“true“/>
<Attribute name=“*type1“ type=“string“ value=“target“/>
</Attributes>
<HighlightTexture
file=“Interface\Buttons\ButtonHilight-Square“
alphaMode=“ADD“/>
</Button>
<Button name=“$parent_Pet“ parentKey=“pet“
inherits=“SecureHandlerShowHideTemplate,i
SecureUnitButtonTemplate“>
<Size x=“34“ y=“5“/>
<Anchors>
<Anchor point=“BOTTOMLEFT“>
<Offset x=“1“ y=“1“/>
</Anchor>
</Anchors>
<Frames>
<StatusBar name=“$parent_HealthBar“ parentKey=“healthBar“
setAllPoints=“true“>
<BarTexture
file=“Interface\Buttons\UI-Listbox-Highlight2“/>
<BarColor r=“0.0“ g=“1.0“ b=“0.0“/>
</StatusBar>
</Frames>
<Attributes>
<Attribute name=“useparent-unit“ type=“boolean“
value=“true“/>
<Attribute name=“unitsuffix“ type=“string“ value=“pet“/>
<Attribute name=“*type1“ type=“string“ value=“target“/>
</Attributes>
Documents you may be interested
Documents you may be interested