asp.net open pdf in new window code behind : Adjust size of pdf application Library tool html asp.net wpf online ITU-TR-2006-763-part700

§2.4
Creatingequalitycomparers 29
Whencreatingahash-basedcollectionofcollections,anequalitycomparerforthe
outercollection’sitems(whicharethemselvesinnercollections)shouldbecre-
atedandgivenexplicitly;seesections8.3and9.17.
Theequalitycomparerclasseslistedingure2.2deneitemequalityanditem
hashfunctionsthatsatisfytherequirementson
Equals(T,T)
and
GetHashCode(T)
mentionedabove,andbehaveasfollows:
 Forprimitiveitemtypes,theequalitycomparerclassesCharEqualityComparer,
IntEqualityComparer and soon dene equality as thebuilt-in equality for
thosetypes,withcorrespondinghashfunctions.
 ForanitemtypeTthatimplementsISequenced<W>,soeachouteritemisase-
quencedcollectionofinneritemsoftypeW,thedefaultequalitycomparerisa
SequencedCollectionEqualityComparer<T,W>.Thisequalitycomparerimple-
mentsinterfaceIEqualityComparer<T>anddenestheequality
Equals(T,T)
oftwocollectionsbycomparingtheiritemsoftypeW,usingthe
Equals(W,W)
methodoftheirequalitycomparers,intheorderinwhichtheyappearinthe
collections. Correspondingly,itdenesthehashfunction
GetHashCode(T)
for
acollectionusingthe
GetHashCode(W)
methodoftheirequalitycomparersina
waythatdependsontheorderinwhichtheitemsappear.
 For r an itemtype Tthat implements ICollection<W>, so each outeritem is
anunsequencedcollectionofinneritemsoftypeW,thedefaultequalitycom-
parer is an n UnsequencedCollectionEqualityComparer<T,W>. . This s equality
comparerimplementsinterfaceSCG.IEqualityComparer<T>anddenesthe
equality
Equals(T,T)
oftwo collections s by comparing their items using the
Equals(W,W)
method oftheir equality y comparers, disregarding the order in
whichtheitemsappear. Correspondingly,itdenesthe
GetHashCode(T)
hash
functionofacollectionusingthe
GetHashCode(W)
methodofitsitemequality
comparerinawaythatdoesnotdependontheorderinwhichtheitemsap-
pear.
 ForanitemtypeTthatimplementsIEquatable<T>,thedefaultequalitycom-
parerisanEquatableEqualityComparer<T>,whichusesT’smethod
Equals(T)
todeneequalityandusesT’s
GetHashCode()
ashashfunction.
 ForanyotheritemtypeT,thedefaultequalitycomparerisaNaturalEquali-
tyComparer<T>,whichusesT’smethod
Equals(Object)
todeneequalityand
usesT’s
GetHashCode()
methodcomputehashcodes.
IfTisavaluetype,thesemethodsmayhavebeenoverriddenintypeTorelse
arethedefaultmethodsinheritedfromSystem.ValueType.Inthelattercase,
the
Equals(Object)
methodusesreectiontocomparetheeldsofthevalue
forequality,andthe
GetHashCode()
methodsimilarlyusesoneormoreelds
ofthevaluetypetocomputeahashvalue.Forefciencyandcorrectnessitis
advisabletooverride
Equals(Object)
and
GetHashCode()
inavaluetypeT.
Adjust size of pdf - Compress reduce PDF size in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
C# Code & .NET API to Compress & Decompress PDF Document
pdf markup text size; pdf file compression
Adjust size of pdf - VB.NET PDF File Compress Library: Compress reduce PDF size in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Compression and Decompression Control SDK
adjust file size of pdf; best way to compress pdf file
30 Comparabletypes
§2.5
IfTisareferencetype,thesemethodsmayhavebeenoverridden intypeT
ora baseclass,orelsearethedefault methodsinheritedfromclassObject.
Thedefault
Equals(Object)
methodfromObject fora referencetypesimply
comparesobjectreferences.
 AReferenceEqualityComparer<T>,whereTmustbeareferencetype,denes
equalityforreferencetypeTasobjectreferenceequality,usingclassObject’s
staticmethod
ReferenceEquals(Object,Object)
,anddenesitshashcodeus-
ingtheoriginal
GetHashCode()
methodfromclassObject,evenif
GetHashCode()
hasbeenoverriddenbyToroneofitsbaseclasses. ClassReferenceEquality-
Comparer<T>hasasinglestaticpropertyDefaultwhosevalueistherefer-
enceequalitycomparerfortypeT.
 AKeyValuePairEqualityComparer<K,V>implementstheinterfaceIEquality-
Comparer<KeyValuePair<K,V>>,denesequalityoftwo(key,value)pairsas
equalityoftheirkeys,anddenesthehashcodeofthe(key,value)pairasthe
hashcodeofthekey.
The
Equals(Object)
and
GetHashCode()
methodsforacollectionclassarethestan-
dard ones inherited from class Object. . In n particular,
coll1.Equals(coll2)
tests
whethercollections
coll1
and
coll2
arethesameobjectreference,notwhetherthey
containthesameitems.
Totestwhethercollections
coll1
and
coll2
containthesameitemsinsomeorder,
use
UnsequencedCollectionEqualityComparer<T,W>.Equals(coll1, coll2)
. HereT
isthetypeofthecollections
coll1
and
coll2
, andW is theiritemtype. . Totest
whethersequencedcollections
coll1
and
coll2
containthesameitemsinthesame
order,use
SequencedCollectionEqualityComparer<T,W>.Equals(coll1, coll2)
.
2.5 Comparabletypes
InterfaceIComparable<T>fromCLInamespaceSystemdescribesasinglemethod:
int
CompareTo
(T y)
returnsanegativenumberifthegivenvalueislessthan
y
,zeroifitisequalto
y
,andapositivenumberifitisgreaterthan
y
.
Todescribetherequirementsonmethod
CompareTo
,letusdenethat and+
aretheoppositesignsofeachotherandthat0istheoppositesignofitself.Thenthe
CompareTo
mustsatisfy:
 Asanorderingrelationitmustbereexivesothat
x.CompareTo(x)
iszero.
 Asanorderingrelationitmustbetransitivesoif
x.CompareTo(y)
hasagiven
sign,and
y.CompareTo(z)
havethesamesignoriszero,then
x.CompareTo(z)
hasthesamesign.
 Asanorderingrelationitmustbeanti-symmetricso
x.CompareTo(y)
and
y.Compare(x)
musthaveoppositesigns.
VB.NET Image: How to Draw Annotation on Doc Images with Image SDK
multi-page TIFF, Microsoft Office Word and PDF file that, you are also able to adjust various image control the annotation shapes, the outline size (width and
pdf compress; change font size pdf
C# Image: Zoom Image and Document Page in C#.NET Web Viewer
jpeg), gif, bmp (bitmap), tiff / multi-page tiff, PDF, etc. APIs for Visual C# .NET developers to adjust the image & document page viewing size with this
adjust size of pdf; 300 dpi pdf file size
§2.7
Comparers 31
 Itmustbetotalsoitmustneverthrowanexception. Throwinganexception
in
CompareTo
maycorrupttheinternalstateofacollection.
Theresultof
CompareTo
shouldbeunaffectedby modicationstoitems. . This s can
beensuredbylettingthecomparerdependonlyonimmutable(read-only)eldsof
items.Ifanitemismodiedinawaythataffectstheresultsofcomparisonswhile
itisstoredinacollection,thenthecollectionwillnotworkproperlyandmayfailin
arbitraryways.
Manybuilt-intypesinC#,suchas
long
,doimplementIComparable<
long
>,and
hencesupportcomparisonwiththemselves.
Interface System.IComparable is a a legacy y version of IComparable<T>; it t de-
scribesasinglemethod:
int
CompareTo
(Object y)
returnsa negativenumber ifthegiven value e is
lessthan
y
,zeroifitisequalto
y
,andapositivenumberifitisgreaterthan
y
.
UseIComparable<T>wheneverpossibleforbettertypesafety,andtoavoidtheover-
headofboxingwhenTisavaluetype.
2.6 Comparers
InterfaceIComparer<T>fromCLInamespaceSystem.Collections.Genericdescribes
onemethod:
int
Compare
(T x, , T T y)
mustreturnanegativenumberwhen
x
islessthan
y
,zerowhentheyareequal,andapositivenumberwhen
y
isgreaterthan
x
.
Todescribetherequirementsonmethod
Compare
,letusdenethat and+are
theoppositesignsofeachotherandthat0istheoppositesignofitself. Thenthe
Compare
methodinanimplementationofSCG.IComparer<T>mustsatisfy:
 Asanorderingrelationitmustbereexivesothat
Compare(x,x)
iszero.
 Asanorderingrelation n itmust betransitivesoif
Compare(x,y)
hasa given
sign,and
Compare(y,z)
havethesamesignoriszero,then
Compare(x,z)
has
thesamesign.
 Asanorderingrelationitmustbeanti-symmetricso
Compare(x,y)
and
Compare(y,x)
musthaveoppositesigns.
 Itmustbetotalsoitmustneverthrowanexception. Throwinganexception
inacomparermaycorrupttheinternalstateofacollection.
Acomparershouldbeunaffectedbymodicationstoitems. Thiscan n beensured
bylettingthecomparerdependonlyonimmutable(read-only)eldsofitems.Ifan
itemismodiedinawaythataffectstheresultsofcomparisonswhileitisstored
inacollection,thenthecollectionwillnotworkproperlyandmayfailinarbitrary
ways.
VB.NET Image: VB.NET Code to Create Watermark on Images in .NET
font type "Times New Roman", size "16", and style "Bold"), and then adjust brush color provide powerful & profession imaging controls, PDF document, tiff
pdf compression settings; can pdf files be compressed
C# PowerPoint: How to Set PowerPoint Rendering Parameters in C#
this SDK to render PowerPoint (2007 or above) slide into PDF document or Generally, you are allowed to set image resolution, image size, batch conversion and
batch pdf compression; compress pdf
32 Creatingcomparers
§2.7
2.7 Creatingcomparers
ThestaticclassC5.Comparer<T>isafactory.Onecannotcreateobjectinstancesof
it,butcanuseittoproduceadefaultcomparer(ordering)foragiventypeT. The
classhasonestaticproperty:
static Comparer<T>.
DefaultoftypeSCG.IComparer<T>isthedefaultcom-
parerfortypeT;seegure2.3.
Whencreatingasortedcollection ofcollections,acomparerfortheoutercollec-
tion’sitems(whicharethemselvesinnercollections)mustoftenbecreatedexplic-
itly;seesection8.3and9.17. Sinceeveryevaluationof
Comparer<T>.Default
fora
given
T
returnsthesamecomparerobject,referencecomparisonofcomparerscan
beusedtocheckwhethertwo(inner)collectionshavethesamecomparers,provided
thecomparerswerecreatedbytheComparer<T>class.
ItemtypeT
Comparer<T>.Default
char
CharComparer
sbyte
SByteComparer
byte
ByteComparer
short
ShortComparer
ushort
UShortComparer
int
IntComparer
uint
UIntComparer
float
FloatComparer
double
DoubleComparer
decimal
DecimalComparer
implementsSystem.IComparable<T> NaturalComparer<T>
implementsSystem.IComparable
NaturalComparerO<T>
Figure2.3:Defaultcomparersforvarioustypes.
Thecomparerclasseslistedingure2.3 denecomparermethodsthatbehaveas
follows:
 Fortheprimitivetypecomparers,
Compare(x, y)
usestheprimitivecompari-
sonoperators(
<
)and(
>
)toreturnapositivenumberif
x > > y
,anegativenum-
berif
x < < y
,andzerootherwise,
 ANaturalComparer<T> > simplyuses the
Compare(T,T)
methodfromtypeT,
whichmustimplementSystem.IComparable<T>;otherwiseNotComparable-
Exceptionisthrown.
 A A NaturalComparerO<T> > simply y uses s the
Compare(Object,Object)
method
fromtypeT,whichmustimplementSystem.IComparable;otherwiseNotCom-
parableExceptionisthrown.
C# PDF: Use C# APIs to Control Fully on PDF Rendering Process
PDF document PDFDocument doc = new PDFDocument(@"c:\sample.pdf"); // compute zoom new Rectangle(0, 0, originalWidth, originalHeight), size); // adjust with a
batch reduce pdf file size; change font size pdf text box
VB.NET Excel: VB Methods to Set and Customize Excel Rendering
on the fixed image size ration that the size is limited by Adjust Image Scaling Factor. supports converting Excel to other document files, like PDF with online
can a pdf file be compressed; change file size of pdf document
§2.7
Creatingcomparers 33
AKeyValuePairComparer<K,V>implementsSCG.IComparer<KeyValuePair<K,V>>
anddenescomparisonoftwo(key,value)pairsby comparisonoftheirkeysonly.
Theclasshasasingleconstructor:
KeyValuePairComparer<K,V>(SCG.IComparer<K> cmp)
createsanew(key,value)
paircomparerwhose
Compare(K x,K y)
methodjustcalls
cmp.Compare(x,y)
to
comparethekeysoftwo(key,value)pairs.
ADelegateComparer<T>encapsulatesa delegateoftypeSystem.Comparison<T>
andusesthattoimplementSCG.IComparer<T>. Forthatpurposeithasasingle
constructor:
DelegateComparer<T>(System.Comparison<T> csn)
createsanewcomparer
whose
Compare(T x,T T y)
methodjustcallsthedelegate
csn(x,y)
andreturns
itsresult.Thegivendelegate
csn
mustsatisfytherequirementsonacomparer
mentionedabove.Inparticular,itmustneverthrowanexception.
Thisis useful for creating comparers inline, forinstancewhen creating a sorted
collectionorwhensortingarraysorlists.Foranexample,seepattern92.
C# PDF Convert: How to Convert Word, Excel, PowerPoint, Tiff
Support rendering image to a PDF document page, no change for image size. Able to adjust and customize image resolution to meet various C# PDF conversion
pdf page size may not be reduced; change page size pdf acrobat
C# Word: How to Draw Text, Line & Image in C#.NET Word Project
copy the sample codes below to adjust text properties such as image color, picture size, location of powerful & profession imaging controls, PDF document, image
can a pdf be compressed; change page size pdf
34 Creatingcomparers
§2.7
C# Word: Set Rendering Options with C# Word Document Rendering
& raster and vector images, such as PDF, tiff, png rendering application still enables users to adjust and set developers can choose a target size or resolution
pdf page size dimensions; pdf form change font size
VB.NET Image: Image Resizer Control SDK to Resize Picture & Photo
VB.NET Code for Adjusting Image Size. In order to resizer control add-on, can I adjust the sizes of powerful & profession imaging controls, PDF document, image
pdf optimized format; pdf change page size
Chapter3
Auxiliarytypes
Inadditiontotheinterfacesdescribingthecollectionconceptsanddictionarycon-
cepts,andtheclassesimplementingthecollectionsanddictionaries,therearesev-
eral auxiliary enumtypes, structtypes,delegatetypes and d exception types. . Ad-
ditionalauxiliarytypesthatareprimarilyofinteresttolibrarydevelopersarede-
scribedinchapter14.
3.1 EnumtypeEventTypeEnum
TheenumtypeEventTypeEnumis usedtoreport which event handlers arecur-
rentlyassociatedwithacollectionordictionary,andtoreportwhicheventscanbe
listenedtoatall.Seesection8.8.5foreventsandeventhandlers,andseeproperties
ActiveEvents
and
ListenableEvents
inICollectionValue<T>(section4.2).Theenum
typehasthefollowingvalueswhichcanbecombined,likeags,usingthebitwise
operatoror(
|
)toformothervaluesoftypeEventTypeEnum:
Enumvalue Correspondingevents
Added
ItemsAdded
All
Basic | | Inserted | | RemovedAt
Basic
Added | | Changed d | | Cleared | | Removed
Changed
CollectionChanged
Cleared
CollectionCleared
Inserted
ItemInserted
None
None
Removed
ItemsRemoved
RemovedAt
ItemRemovedAt
Forinstance, totestwhetheraCollectionChangedHandleris associatedwithcol-
lection
coll
,evaluate
(coll.ActiveEvents & & EventTypeEnum.Changed) ) != = 0
.Totest
fornoeventhandler,evaluate
coll.ActiveEvents == EventTypeEnum.None
.
35
36 EnumtypeSpeed
§3.4
3.2 EnumtypeEnumerationDirection
TheenumtypeEnumerationDirectionisusedtoreporttheenumerationdirection
ofadirectedcollectionordirectedenumerable;forinstancebyproperty
Direction
ininterfaceIDirectedEnumerable<T>(section4.4). Theenumtypehastwovalues
whicharemutuallyexclusive:
Enumvalue Meaning
Forwards
Thenaturalenumerationorder
Backwards
Theoppositeofthenaturalenumerationorder
3.3 EnumtypeSpeed
EnumtypeSpeedhasvalues
Constant
,
Log
,
Linear
and
PotentiallyInfinite
and
isusedinternally intheC5 library. . This s typeandtheproperties
ContainsSpeed
(section4.1),
CountSpeed
(section4.2)and
IndexingSpeed
(section4.6)areusedto
determinethemostefcientwaytotestequalityoftwocollections.
Forinstance,ifoneneedstodeterminewhethercollections
coll1
and
coll2
are
equal, and
coll1.ContainsSpeed
is
Linear
and
coll2.ContainsSpeed
is
Constant
,
thenitisfastertoenumerateallitems
x
of
coll1
andtestwhether
coll2.Contains(x)
thantodotheopposite.ThisisexploitedinC5’scollectionequalitycomparerssyn-
thesizedbytheC5.Comparer<T>class(section2.7).
ThepossiblevaluesofenumtypeSpeedare:
 PotentiallyInfinitemeansthat t theoperationmay not terminate. . For
instance,countingthenumberofitemsinahypotheticallazilygeneratedand
potentiallyinnitecollectionmaynotterminate. Notethatalloperationson
C5’scollectionclassesordictionaryclassesdoterminate.
 LinearmeansthattheoperationtakestimeO(n),wherenisthesizeofthe
collection. Forinstance,thisisthecaseforitemlookupwith
Contains(x)
on
non-hashedlists.
 LogmeansthatatheoperationtakestimeO(logn),wherenisthesizeofthe
collection. Forinstance,thisisthecaseforitemlookupwith
Contains(x)
on
treesets,treebags,andsortedarrays.
 ConstantmeansthattheoperationtakestimeO(1),thatis,constanttime.
Forinstance,thisisthecaseforitemindexing
this[i]
onarraylists,andis
theexpectedtimeforitemlookupwith
Contains(x)
onhashsets,hashbags,
andhashedlists.
§3.5
RecordstructtypesRec<T1,T2>,... 37
3.4 RecordstructtypesRec<T1,T2>,...
Ingenericfunctionlibrariesitisconvenienttohavewaystorepresentrecords,such
aspairs,triples,andquadruples.ThispurposeisservedbytheRecfamilyofrecord
structtypes,declaredasshownbelow.
public struct Rec<T1,T2> : IEquatable<Rec<T1,T2>>, IShowable {
public readonly T1 1 X1;
public readonly T2 2 X2;
public Rec(T1 x1, , T2 2 x2) {
this.X1 = = x1; this.X2 = x2;
}
public override int GetHashCode() { ... . }
public override bool Equals(Object o) { { ... . }
public override bool Equals(Rec<T1,T2> > that) ) { ... . }
public static bool l operator==(Rec<T1,T2> r1, , Rec<T1,T2> r2) { { ... . }
public static bool l operator!=(Rec<T1,T2> r1, , Rec<T1,T2> r2) { { ... . }
public bool Show(StringBuilder r sb, , ref f int t rest, IFormatProvider fmp) { { ... . }
}
public struct Rec<T1,T2,T3> : : IEquatable<Rec<T1,T2,T3>>, IShowable e { ... . }
public struct Rec<T1,T2,T3,T4> > : : IEquatable<Rec<T1,T2,T3,T4>>, , IShowable { { ... }
Notethattheelds
X1
,
X2
,...arepublicbutread-only,topreventtheconfusionthat
resultsfromupdatingaeldofa copyofa structvalue,ratherthantheoriginal
structvalue.
The
Equals(Object o)
methodofarecordtypereturnsfalsewhen
o
is
null
oris
notaboxedinstanceoftherecordtype;otherwisecomparestherecordseldbyeld
usingtheir
Equals
methods.
The
Equals(Rec<T1,T2>)
methodintypeRec<T1,T2>andtheoperators(
==
)and
(
!=
)comparetherecordeldsusingthe
Equals
methodsfortheeldtypesT1and
T2.
3.5 StructtypeKeyValuePair<K,V>
AstructoftypeKeyValuePair<K,V>isusedrepresentpairsofakeyoftypeKand
anassociatedvalueoftypeV. Ithaspublic c elds
Key
and
Value
. Itis s similarto
Rec<K,V>,buttheeldsarecalled
Key
and
Value
ratherthan
X1
and
X2
,andthe
formattingby
ToString
isdifferent. Thenaturalcomparerandequalitycomparer
foraKeyValuePair<K,V>comparesthekeysonly;thevaluesareignored.
38 Delegatetypes
§3.6
3.6 Delegatetypes
ThedelegatetypefamiliesActandFundescribedbelowareusedbyseveralmethods
ininterfaceICollectionValue<T>andelsewhere.Foreventhandlertypes,whichare
delegatetypestoo,seesection8.8.
3.6.1 ActiondelegatetypesAct<A1>,Act<A1,A2>,...
DelegatetypeAct<A1>isthetypeoffunctionsormethodsfromA1to
void
,used
toperformsomeside-effectoractionforagivencollectionitem
x
.TypeAct<A1>is
partofafamilyofsuchactiondelegatetypeswithzerotofourarguments,declared
asfollows:
public delegate void Act();
public delegate void Act<A1>(A1 1 x1);
public delegate void Act<A1,A2>(A1 x1, A2 x2);
public delegate void Act<A1,A2,A3>(A1 x1, A2 x2, A3 x3);
public delegate void Act<A1,A2,A3,A4>(A1 1 x1, , A2 x1, , A3 3 x3, A4 x4);
ThetypeAct<T>correspondstoSystem.Action<T>inintheCLIor.NETclassli-
brary.
3.6.2 FunctiondelegatetypesFun<A1,R>,Fun<A1,A2,R>,...
DelegatetypeFun<A1,R>isthetypeoffunctionsormethodsfromA1toR,usedto
computesometransformationforagivencollectionitem
x
.TypeFun<A1,R>ispart
ofafamilyofsuchfunctiondelegatetypeswithzerotofourarguments,declaredas
follows:
public delegate R R Fun<R>();
public delegate R R Fun<A1,R>(A1 x1);
public delegate R R Fun<A1,A1,R>(A1 1 x1, A2 2 x2);
public delegate R R Fun<A1,A2,A3,R>(A1 1 x1, , A2 2 x2, A3 3 x3);
public delegate R R Fun<A1,A2,A3,A4,R>(A1 x1, , A2 x1, , A3 3 x3, A4 4 x4);
ThetypeFun<A1,R>isthetypeoffunctionsorconvertersfromtypeA1totypeR,
andcorrespondstoSystem.Converter<A1,R>intheCLIor.NETclasslibrary. The
typeFun<T,bool>isthetypeofpredicatesforvaluesoftypeTandcorrespondsto
typeSystem.Predicate<T>intheCLIor.NETclasslibrary.
Documents you may be interested
Documents you may be interested