Produced by Araxis Merge on 2/1/2017 2:56:49 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | C:\Araxis_Merge_Comprasion\Pub_un\BTSSS_CIF_122016.zip\BTSSS_CIF_12_20_16\clean\CRM\trunk\SDK\SampleCode\CS\ModernAndMobileApps\ModernSoapApp\Common | LayoutAwarePage.cs | Tue Dec 20 19:51:47 2016 UTC |
| 2 | Wed Feb 1 19:56:49 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 560 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | // ======= ========== ========== ========== ========== ========== ========== == | |||||
| 2 | // | |||||
| 3 | // This f ile is par t of the M icrosoft D ynamics CR M SDK Code Samples. | |||||
| 4 | // | |||||
| 5 | // Copyri ght (C) Mi crosoft Co rporation. All righ ts reserve d. | |||||
| 6 | // | |||||
| 7 | // This s ource code is intend ed only as a supplem ent to Mic rosoft | |||||
| 8 | // Develo pment Tool s and/or o nline docu mentation. See thes e other | |||||
| 9 | // materi als for de tailed inf ormation r egarding M icrosoft c ode sample s. | |||||
| 10 | // | |||||
| 11 | // THIS C ODE AND IN FORMATION ARE PROVID ED "AS IS" WITHOUT W ARRANTY OF ANY | |||||
| 12 | // KIND, EITHER EXP RESSED OR IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E | |||||
| 13 | // IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR A | |||||
| 14 | // PARTIC ULAR PURPO SE. | |||||
| 15 | // | |||||
| 16 | // ======= ========== ========== ========== ========== ========== ========== == | |||||
| 17 | ||||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.Collect ions.Gener ic; | |||||
| 20 | using Syst em.Compone ntModel; | |||||
| 21 | using Syst em.Linq; | |||||
| 22 | using Wind ows.Founda tion; | |||||
| 23 | using Wind ows.Founda tion.Colle ctions; | |||||
| 24 | using Wind ows.System ; | |||||
| 25 | using Wind ows.UI.Cor e; | |||||
| 26 | using Wind ows.UI.Vie wManagemen t; | |||||
| 27 | using Wind ows.UI.Xam l; | |||||
| 28 | using Wind ows.UI.Xam l.Controls ; | |||||
| 29 | using Wind ows.UI.Xam l.Navigati on; | |||||
| 30 | ||||||
| 31 | namespace ModernSoap App.Common | |||||
| 32 | { | |||||
| 33 | /// <s ummary> | |||||
| 34 | /// Ty pical impl ementation of Page t hat provid es several important convenien ces: | |||||
| 35 | /// <l ist type=" bullet"> | |||||
| 36 | /// <i tem> | |||||
| 37 | /// <d escription >Applicati on view st ate to vis ual state mapping</d escription > | |||||
| 38 | /// </ item> | |||||
| 39 | /// <i tem> | |||||
| 40 | /// <d escription >GoBack, G oForward, and GoHome event han dlers</des cription> | |||||
| 41 | /// </ item> | |||||
| 42 | /// <i tem> | |||||
| 43 | /// <d escription >Mouse and keyboard shortcuts for naviga tion</desc ription> | |||||
| 44 | /// </ item> | |||||
| 45 | /// <i tem> | |||||
| 46 | /// <d escription >State man agement fo r navigati on and pro cess lifet ime manage ment</desc ription> | |||||
| 47 | /// </ item> | |||||
| 48 | /// <i tem> | |||||
| 49 | /// <d escription >A default view mode l</descrip tion> | |||||
| 50 | /// </ item> | |||||
| 51 | /// </ list> | |||||
| 52 | /// </ summary> | |||||
| 53 | [Windo ws.Foundat ion.Metada ta.WebHost Hidden] | |||||
| 54 | public class Lay outAwarePa ge : Page | |||||
| 55 | { | |||||
| 56 | // / <summary > | |||||
| 57 | // / Identifi es the <se e cref="De faultViewM odel"/> de pendency p roperty. | |||||
| 58 | // / </summar y> | |||||
| 59 | pu blic stati c readonly Dependenc yProperty DefaultVie wModelProp erty = | |||||
| 60 | Dependen cyProperty .Register( "DefaultVi ewModel", typeof(IOb servableMa p<String, Object>), | |||||
| 61 | typeof(L ayoutAware Page), nul l); | |||||
| 62 | ||||||
| 63 | pr ivate List <Control> _layoutAwa reControls ; | |||||
| 64 | ||||||
| 65 | // / <summary > | |||||
| 66 | // / Initiali zes a new instance o f the <see cref="Lay outAwarePa ge"/> clas s. | |||||
| 67 | // / </summar y> | |||||
| 68 | pu blic Layou tAwarePage () | |||||
| 69 | { | |||||
| 70 | if (Wind ows.Applic ationModel .DesignMod e.DesignMo deEnabled) return; | |||||
| 71 | ||||||
| 72 | // Creat e an empty default v iew model | |||||
| 73 | this.Def aultViewMo del = new Observable Dictionary <String, O bject>(); | |||||
| 74 | ||||||
| 75 | // When this page is part of the visua l tree mak e two chan ges: | |||||
| 76 | // 1) Ma p applicat ion view s tate to vi sual state for the p age | |||||
| 77 | // 2) Ha ndle keybo ard and mo use naviga tion reque sts | |||||
| 78 | this.Loa ded += (se nder, e) = > | |||||
| 79 | { | |||||
| 80 | this .StartLayo utUpdates( sender, e) ; | |||||
| 81 | ||||||
| 82 | // K eyboard an d mouse na vigation o nly apply when occup ying the e ntire wind ow | |||||
| 83 | if ( this.Actua lHeight == Window.Cu rrent.Boun ds.Height && | |||||
| 84 | this.Actua lWidth == Window.Cur rent.Bound s.Width) | |||||
| 85 | { | |||||
| 86 | // Listen to the win dow direct ly so focu s isn't re quired | |||||
| 87 | Window.Cur rent.CoreW indow.Disp atcher.Acc eleratorKe yActivated += | |||||
| 88 | CoreDi spatcher_A ccelerator KeyActivat ed; | |||||
| 89 | Window.Cur rent.CoreW indow.Poin terPressed += | |||||
| 90 | this.C oreWindow_ PointerPre ssed; | |||||
| 91 | } | |||||
| 92 | }; | |||||
| 93 | ||||||
| 94 | // Undo the same c hanges whe n the page is no lon ger visibl e | |||||
| 95 | this.Unl oaded += ( sender, e) => | |||||
| 96 | { | |||||
| 97 | this .StopLayou tUpdates(s ender, e); | |||||
| 98 | Wind ow.Current .CoreWindo w.Dispatch er.Acceler atorKeyAct ivated -= | |||||
| 99 | CoreDispat cher_Accel eratorKeyA ctivated; | |||||
| 100 | Wind ow.Current .CoreWindo w.PointerP ressed -= | |||||
| 101 | this.CoreW indow_Poin terPressed ; | |||||
| 102 | }; | |||||
| 103 | } | |||||
| 104 | ||||||
| 105 | // / <summary > | |||||
| 106 | // / An imple mentation of <see cr ef="IObser vableMap&l t;String, Object> "/> design ed to be | |||||
| 107 | // / used as a trivial view model . | |||||
| 108 | // / </summar y> | |||||
| 109 | pr otected IO bservableM ap<String, Object> D efaultView Model | |||||
| 110 | { | |||||
| 111 | get | |||||
| 112 | { | |||||
| 113 | retu rn this.Ge tValue(Def aultViewMo delPropert y) as IObs ervableMap <String, O bject>; | |||||
| 114 | } | |||||
| 115 | ||||||
| 116 | set | |||||
| 117 | { | |||||
| 118 | this .SetValue( DefaultVie wModelProp erty, valu e); | |||||
| 119 | } | |||||
| 120 | } | |||||
| 121 | ||||||
| 122 | #r egion Navi gation sup port | |||||
| 123 | ||||||
| 124 | // / <summary > | |||||
| 125 | // / Invoked as an even t handler to navigat e backward in the pa ge's assoc iated | |||||
| 126 | // / <see cre f="Frame"/ > until it reaches t he top of the naviga tion stack . | |||||
| 127 | // / </summar y> | |||||
| 128 | // / <param n ame="sende r">Instanc e that tri ggered the event.</p aram> | |||||
| 129 | // / <param n ame="e">Ev ent data d escribing the condit ions that led to the event.</p aram> | |||||
| 130 | pr otected vi rtual void GoHome(ob ject sende r, RoutedE ventArgs e ) | |||||
| 131 | { | |||||
| 132 | // Use t he navigat ion frame to return to the top most page | |||||
| 133 | if (this .Frame != null) | |||||
| 134 | { | |||||
| 135 | whil e (this.Fr ame.CanGoB ack) this. Frame.GoBa ck(); | |||||
| 136 | } | |||||
| 137 | } | |||||
| 138 | ||||||
| 139 | // / <summary > | |||||
| 140 | // / Invoked as an even t handler to navigat e backward in the na vigation s tack | |||||
| 141 | // / associat ed with th is page's <see cref= "Frame"/>. | |||||
| 142 | // / </summar y> | |||||
| 143 | // / <param n ame="sende r">Instanc e that tri ggered the event.</p aram> | |||||
| 144 | // / <param n ame="e">Ev ent data d escribing the condit ions that led to the | |||||
| 145 | // / event.</ param> | |||||
| 146 | pr otected vi rtual void GoBack(ob ject sende r, RoutedE ventArgs e ) | |||||
| 147 | { | |||||
| 148 | // Use t he navigat ion frame to return to the pre vious page | |||||
| 149 | if (this .Frame != null && th is.Frame.C anGoBack) this.Frame .GoBack(); | |||||
| 150 | } | |||||
| 151 | ||||||
| 152 | // / <summary > | |||||
| 153 | // / Invoked as an even t handler to navigat e forward in the nav igation st ack | |||||
| 154 | // / associat ed with th is page's <see cref= "Frame"/>. | |||||
| 155 | // / </summar y> | |||||
| 156 | // / <param n ame="sende r">Instanc e that tri ggered the event.</p aram> | |||||
| 157 | // / <param n ame="e">Ev ent data d escribing the condit ions that led to the | |||||
| 158 | // / event.</ param> | |||||
| 159 | pr otected vi rtual void GoForward (object se nder, Rout edEventArg s e) | |||||
| 160 | { | |||||
| 161 | // Use t he navigat ion frame to move to the next page | |||||
| 162 | if (this .Frame != null && th is.Frame.C anGoForwar d) this.Fr ame.GoForw ard(); | |||||
| 163 | } | |||||
| 164 | ||||||
| 165 | // / <summary > | |||||
| 166 | // / Invoked on every k eystroke, including system key s such as Alt key co mbinations , when | |||||
| 167 | // / this pag e is activ e and occu pies the e ntire wind ow. Used to detect keyboard n avigation | |||||
| 168 | // / between pages even when the page itsel f doesn't have focus . | |||||
| 169 | // / </summar y> | |||||
| 170 | // / <param n ame="sende r">Instanc e that tri ggered the event.</p aram> | |||||
| 171 | // / <param n ame="args" >Event dat a describi ng the con ditions th at led to the event. </param> | |||||
| 172 | pr ivate void CoreDispa tcher_Acce leratorKey Activated( CoreDispat cher sende r, | |||||
| 173 | Accelera torKeyEven tArgs args ) | |||||
| 174 | { | |||||
| 175 | var virt ualKey = a rgs.Virtua lKey; | |||||
| 176 | ||||||
| 177 | // Only investigat e further when Left, Right, or the dedic ated Previ ous or Nex t keys | |||||
| 178 | // are p ressed | |||||
| 179 | if ((arg s.EventTyp e == CoreA ccelerator KeyEventTy pe.SystemK eyDown || | |||||
| 180 | args .EventType == CoreAc celeratorK eyEventTyp e.KeyDown) && | |||||
| 181 | (vir tualKey == VirtualKe y.Left || virtualKey == Virtua lKey.Right || | |||||
| 182 | (int )virtualKe y == 166 | | (int)vir tualKey == 167)) | |||||
| 183 | { | |||||
| 184 | var coreWindow = Window. Current.Co reWindow; | |||||
| 185 | var downState = CoreVirt ualKeyStat es.Down; | |||||
| 186 | bool menuKey = (coreWind ow.GetKeyS tate(Virtu alKey.Menu ) & downSt ate) == do wnState; | |||||
| 187 | bool controlKe y = (coreW indow.GetK eyState(Vi rtualKey.C ontrol) & downState) == downSt ate; | |||||
| 188 | bool shiftKey = (coreWin dow.GetKey State(Virt ualKey.Shi ft) & down State) == downState; | |||||
| 189 | bool noModifie rs = !menu Key && !co ntrolKey & & !shiftKe y; | |||||
| 190 | bool onlyAlt = menuKey & & !control Key && !sh iftKey; | |||||
| 191 | ||||||
| 192 | if ( ((int)virt ualKey == 166 && noM odifiers) || | |||||
| 193 | (virtualKe y == Virtu alKey.Left && onlyAl t)) | |||||
| 194 | { | |||||
| 195 | // When th e previous key or Al t+Left are pressed n avigate ba ck | |||||
| 196 | args.Handl ed = true; | |||||
| 197 | this.GoBac k(this, ne w RoutedEv entArgs()) ; | |||||
| 198 | } | |||||
| 199 | else if (((int )virtualKe y == 167 & & noModifi ers) || | |||||
| 200 | (virtualKe y == Virtu alKey.Righ t && onlyA lt)) | |||||
| 201 | { | |||||
| 202 | // When th e next key or Alt+Ri ght are pr essed navi gate forwa rd | |||||
| 203 | args.Handl ed = true; | |||||
| 204 | this.GoFor ward(this, new Route dEventArgs ()); | |||||
| 205 | } | |||||
| 206 | } | |||||
| 207 | } | |||||
| 208 | ||||||
| 209 | // / <summary > | |||||
| 210 | // / Invoked on every m ouse click , touch sc reen tap, or equival ent intera ction when this | |||||
| 211 | // / page is active and occupies the entire window. Used to de tect brows er-style n ext and | |||||
| 212 | // / previous mouse but ton clicks to naviga te between pages. | |||||
| 213 | // / </summar y> | |||||
| 214 | // / <param n ame="sende r">Instanc e that tri ggered the event.</p aram> | |||||
| 215 | // / <param n ame="args" >Event dat a describi ng the con ditions th at led to the event. </param> | |||||
| 216 | pr ivate void CoreWindo w_PointerP ressed(Cor eWindow se nder, | |||||
| 217 | PointerE ventArgs a rgs) | |||||
| 218 | { | |||||
| 219 | var prop erties = a rgs.Curren tPoint.Pro perties; | |||||
| 220 | ||||||
| 221 | // Ignor e button c hords with the left, right, an d middle b uttons | |||||
| 222 | if (prop erties.IsL eftButtonP ressed || properties .IsRightBu ttonPresse d || | |||||
| 223 | prop erties.IsM iddleButto nPressed) return; | |||||
| 224 | ||||||
| 225 | // If ba ck or fowa rd are pre ssed (but not both) navigate a ppropriate ly | |||||
| 226 | bool bac kPressed = propertie s.IsXButto n1Pressed; | |||||
| 227 | bool for wardPresse d = proper ties.IsXBu tton2Press ed; | |||||
| 228 | if (back Pressed ^ forwardPre ssed) | |||||
| 229 | { | |||||
| 230 | args .Handled = true; | |||||
| 231 | if ( backPresse d) this.Go Back(this, new Route dEventArgs ()); | |||||
| 232 | if ( forwardPre ssed) this .GoForward (this, new RoutedEve ntArgs()); | |||||
| 233 | } | |||||
| 234 | } | |||||
| 235 | ||||||
| 236 | #e ndregion | |||||
| 237 | ||||||
| 238 | #r egion Visu al state s witching | |||||
| 239 | ||||||
| 240 | // / <summary > | |||||
| 241 | // / Invoked as an even t handler, typically on the <s ee cref="F rameworkEl ement.Load ed"/> | |||||
| 242 | // / event of a <see cr ef="Contro l"/> withi n the page , to indic ate that t he sender should | |||||
| 243 | // / start re ceiving vi sual state managemen t changes that corre spond to a pplication view | |||||
| 244 | // / state ch anges. | |||||
| 245 | // / </summar y> | |||||
| 246 | // / <param n ame="sende r">Instanc e of <see cref="Cont rol"/> tha t supports visual st ate | |||||
| 247 | // / manageme nt corresp onding to view state s.</param> | |||||
| 248 | // / <param n ame="e">Ev ent data t hat descri bes how th e request was made.< /param> | |||||
| 249 | // / <remarks >The curre nt view st ate will i mmediately be used t o set the correspond ing | |||||
| 250 | // / visual s tate when layout upd ates are r equested. A corresp onding | |||||
| 251 | // / <see cre f="Framewo rkElement. Unloaded"/ > event ha ndler conn ected to | |||||
| 252 | // / <see cre f="StopLay outUpdates "/> is str ongly enco uraged. I nstances o f | |||||
| 253 | // / <see cre f="LayoutA warePage"/ > automati cally invo ke these h andlers in their Loa ded and | |||||
| 254 | // / Unloaded events.</ remarks> | |||||
| 255 | // / <seealso cref="Det ermineVisu alState"/> | |||||
| 256 | // / <seealso cref="Inv alidateVis ualState"/ > | |||||
| 257 | pu blic void StartLayou tUpdates(o bject send er, Routed EventArgs e) | |||||
| 258 | { | |||||
| 259 | var cont rol = send er as Cont rol; | |||||
| 260 | if (cont rol == nul l) return; | |||||
| 261 | if (this ._layoutAw areControl s == null) | |||||
| 262 | { | |||||
| 263 | // S tart liste ning to vi ew state c hanges whe n there ar e controls intereste d in updat es | |||||
| 264 | Wind ow.Current .SizeChang ed += this .WindowSiz eChanged; | |||||
| 265 | this ._layoutAw areControl s = new Li st<Control >(); | |||||
| 266 | } | |||||
| 267 | this._la youtAwareC ontrols.Ad d(control) ; | |||||
| 268 | ||||||
| 269 | // Set t he initial visual st ate of the control | |||||
| 270 | VisualSt ateManager .GoToState (control, DetermineV isualState (Applicati onView.Val ue), false ); | |||||
| 271 | } | |||||
| 272 | ||||||
| 273 | pr ivate void WindowSiz eChanged(o bject send er, Window SizeChange dEventArgs e) | |||||
| 274 | { | |||||
| 275 | this.Inv alidateVis ualState() ; | |||||
| 276 | } | |||||
| 277 | ||||||
| 278 | // / <summary > | |||||
| 279 | // / Invoked as an even t handler, typically on the <s ee cref="F rameworkEl ement.Unlo aded"/> | |||||
| 280 | // / event of a <see cr ef="Contro l"/>, to i ndicate th at the sen der should start rec eiving | |||||
| 281 | // / visual s tate manag ement chan ges that c orrespond to applica tion view state chan ges. | |||||
| 282 | // / </summar y> | |||||
| 283 | // / <param n ame="sende r">Instanc e of <see cref="Cont rol"/> tha t supports visual st ate | |||||
| 284 | // / manageme nt corresp onding to view state s.</param> | |||||
| 285 | // / <param n ame="e">Ev ent data t hat descri bes how th e request was made.< /param> | |||||
| 286 | // / <remarks >The curre nt view st ate will i mmediately be used t o set the correspond ing | |||||
| 287 | // / visual s tate when layout upd ates are r equested.< /remarks> | |||||
| 288 | // / <seealso cref="Sta rtLayoutUp dates"/> | |||||
| 289 | pu blic void StopLayout Updates(ob ject sende r, RoutedE ventArgs e ) | |||||
| 290 | { | |||||
| 291 | var cont rol = send er as Cont rol; | |||||
| 292 | if (cont rol == nul l || this. _layoutAwa reControls == null) return; | |||||
| 293 | this._la youtAwareC ontrols.Re move(contr ol); | |||||
| 294 | if (this ._layoutAw areControl s.Count == 0) | |||||
| 295 | { | |||||
| 296 | // S top listen ing to vie w state ch anges when no contro ls are int erested in updates | |||||
| 297 | this ._layoutAw areControl s = null; | |||||
| 298 | Wind ow.Current .SizeChang ed -= this .WindowSiz eChanged; | |||||
| 299 | } | |||||
| 300 | } | |||||
| 301 | ||||||
| 302 | // / <summary > | |||||
| 303 | // / Translat es <see cr ef="Applic ationViewS tate"/> va lues into strings fo r visual s tate | |||||
| 304 | // / manageme nt within the page. The defau lt impleme ntation us es the nam es of enum values. | |||||
| 305 | // / Subclass es may ove rride this method to control t he mapping scheme us ed. | |||||
| 306 | // / </summar y> | |||||
| 307 | // / <param n ame="viewS tate">View state for which a v isual stat e is desir ed.</param > | |||||
| 308 | // / <returns >Visual st ate name u sed to dri ve the | |||||
| 309 | // / <see cre f="VisualS tateManage r"/></retu rns> | |||||
| 310 | // / <seealso cref="Inv alidateVis ualState"/ > | |||||
| 311 | pr otected vi rtual stri ng Determi neVisualSt ate(Applic ationViewS tate viewS tate) | |||||
| 312 | { | |||||
| 313 | return v iewState.T oString(); | |||||
| 314 | } | |||||
| 315 | ||||||
| 316 | // / <summary > | |||||
| 317 | // / Updates all contro ls that ar e listenin g for visu al state c hanges wit h the corr ect | |||||
| 318 | // / visual s tate. | |||||
| 319 | // / </summar y> | |||||
| 320 | // / <remarks > | |||||
| 321 | // / Typicall y used in conjunctio n with ove rriding <s ee cref="D etermineVi sualState" /> to | |||||
| 322 | // / signal t hat a diff erent valu e may be r eturned ev en though the view s tate has n ot | |||||
| 323 | // / changed. | |||||
| 324 | // / </remark s> | |||||
| 325 | pu blic void Invalidate VisualStat e() | |||||
| 326 | { | |||||
| 327 | if (this ._layoutAw areControl s != null) | |||||
| 328 | { | |||||
| 329 | stri ng visualS tate = Det ermineVisu alState(Ap plicationV iew.Value) ; | |||||
| 330 | fore ach (var l ayoutAware Control in this._lay outAwareCo ntrols) | |||||
| 331 | { | |||||
| 332 | VisualStat eManager.G oToState(l ayoutAware Control, v isualState , false); | |||||
| 333 | } | |||||
| 334 | } | |||||
| 335 | } | |||||
| 336 | ||||||
| 337 | #e ndregion | |||||
| 338 | ||||||
| 339 | #r egion Proc ess lifeti me managem ent | |||||
| 340 | ||||||
| 341 | pr ivate Stri ng _pageKe y; | |||||
| 342 | ||||||
| 343 | // / <summary > | |||||
| 344 | // / Invoked when this page is ab out to be displayed in a Frame . | |||||
| 345 | // / </summar y> | |||||
| 346 | // / <param n ame="e">Ev ent data t hat descri bes how th is page wa s reached. The Para meter | |||||
| 347 | // / property provides the group to be disp layed.</pa ram> | |||||
| 348 | pr otected ov erride voi d OnNaviga tedTo(Navi gationEven tArgs e) | |||||
| 349 | { | |||||
| 350 | // Retur ning to a cached pag e through navigation shouldn't trigger s tate loadi ng | |||||
| 351 | if (this ._pageKey != null) r eturn; | |||||
| 352 | ||||||
| 353 | var fram eState = S uspensionM anager.Ses sionStateF orFrame(th is.Frame); | |||||
| 354 | this._pa geKey = "P age-" + th is.Frame.B ackStackDe pth; | |||||
| 355 | ||||||
| 356 | if (e.Na vigationMo de == Navi gationMode .New) | |||||
| 357 | { | |||||
| 358 | // C lear exist ing state for forwar d navigati on when ad ding a new page to t he | |||||
| 359 | // n avigation stack | |||||
| 360 | var nextPageKe y = this._ pageKey; | |||||
| 361 | int nextPageIn dex = this .Frame.Bac kStackDept h; | |||||
| 362 | whil e (frameSt ate.Remove (nextPageK ey)) | |||||
| 363 | { | |||||
| 364 | nextPageIn dex++; | |||||
| 365 | nextPageKe y = "Page- " + nextPa geIndex; | |||||
| 366 | } | |||||
| 367 | ||||||
| 368 | // P ass the na vigation p arameter t o the new page | |||||
| 369 | this .LoadState (e.Paramet er, null); | |||||
| 370 | } | |||||
| 371 | else | |||||
| 372 | { | |||||
| 373 | // P ass the na vigation p arameter a nd preserv ed page st ate to the page, usi ng | |||||
| 374 | // t he same st rategy for loading s uspended s tate and r ecreating pages disc arded | |||||
| 375 | // f rom cache | |||||
| 376 | this .LoadState (e.Paramet er, (Dicti onary<Stri ng, Object >)frameSta te[this._p ageKey]); | |||||
| 377 | } | |||||
| 378 | } | |||||
| 379 | ||||||
| 380 | // / <summary > | |||||
| 381 | // / Invoked when this page will no longer be display ed in a Fr ame. | |||||
| 382 | // / </summar y> | |||||
| 383 | // / <param n ame="e">Ev ent data t hat descri bes how th is page wa s reached. The Para meter | |||||
| 384 | // / property provides the group to be disp layed.</pa ram> | |||||
| 385 | pr otected ov erride voi d OnNaviga tedFrom(Na vigationEv entArgs e) | |||||
| 386 | { | |||||
| 387 | var fram eState = S uspensionM anager.Ses sionStateF orFrame(th is.Frame); | |||||
| 388 | var page State = ne w Dictiona ry<String, Object>() ; | |||||
| 389 | this.Sav eState(pag eState); | |||||
| 390 | frameSta te[_pageKe y] = pageS tate; | |||||
| 391 | } | |||||
| 392 | ||||||
| 393 | // / <summary > | |||||
| 394 | // / Populate s the page with cont ent passed during na vigation. Any saved state is also | |||||
| 395 | // / provided when recr eating a p age from a prior ses sion. | |||||
| 396 | // / </summar y> | |||||
| 397 | // / <param n ame="navig ationParam eter">The parameter value pass ed to | |||||
| 398 | // / <see cre f="Frame.N avigate(Ty pe, Object )"/> when this page was initia lly reques ted. | |||||
| 399 | // / </param> | |||||
| 400 | // / <param n ame="pageS tate">A di ctionary o f state pr eserved by this page during an earlier | |||||
| 401 | // / session. This wil l be null the first time a pag e is visit ed.</param > | |||||
| 402 | pr otected vi rtual void LoadState (Object na vigationPa rameter, D ictionary< String, Ob ject> page State) | |||||
| 403 | { | |||||
| 404 | } | |||||
| 405 | ||||||
| 406 | // / <summary > | |||||
| 407 | // / Preserve s state as sociated w ith this p age in cas e the appl ication is suspended or the | |||||
| 408 | // / page is discarded from the n avigation cache. Va lues must conform to the seria lization | |||||
| 409 | // / requirem ents of <s ee cref="S uspensionM anager.Ses sionState" />. | |||||
| 410 | // / </summar y> | |||||
| 411 | // / <param n ame="pageS tate">An e mpty dicti onary to b e populate d with ser ializable state.</pa ram> | |||||
| 412 | pr otected vi rtual void SaveState (Dictionar y<String, Object> pa geState) | |||||
| 413 | { | |||||
| 414 | } | |||||
| 415 | ||||||
| 416 | #e ndregion | |||||
| 417 | ||||||
| 418 | // / <summary > | |||||
| 419 | // / Implemen tation of IObservabl eMap that supports r eentrancy for use as a default view | |||||
| 420 | // / model. | |||||
| 421 | // / </summar y> | |||||
| 422 | pr ivate clas s Observab leDictiona ry<K, V> : IObservab leMap<K, V > | |||||
| 423 | { | |||||
| 424 | private class Obse rvableDict ionaryChan gedEventAr gs : IMapC hangedEven tArgs<K> | |||||
| 425 | { | |||||
| 426 | publ ic Observa bleDiction aryChanged EventArgs( Collection Change cha nge, K key ) | |||||
| 427 | { | |||||
| 428 | this.Colle ctionChang e = change ; | |||||
| 429 | this.Key = key; | |||||
| 430 | } | |||||
| 431 | ||||||
| 432 | publ ic Collect ionChange Collection Change { g et; privat e set; } | |||||
| 433 | publ ic K Key { get; priv ate set; } | |||||
| 434 | } | |||||
| 435 | ||||||
| 436 | private Dictionary <K, V> _di ctionary = new Dicti onary<K, V >(); | |||||
| 437 | public e vent MapCh angedEvent Handler<K, V> MapCha nged; | |||||
| 438 | ||||||
| 439 | private void Invok eMapChange d(Collecti onChange c hange, K k ey) | |||||
| 440 | { | |||||
| 441 | var eventHandl er = MapCh anged; | |||||
| 442 | if ( eventHandl er != null ) | |||||
| 443 | { | |||||
| 444 | eventHandl er(this, n ew Observa bleDiction aryChanged EventArgs( change, ke y)); | |||||
| 445 | } | |||||
| 446 | } | |||||
| 447 | ||||||
| 448 | public v oid Add(K key, V val ue) | |||||
| 449 | { | |||||
| 450 | this ._dictiona ry.Add(key , value); | |||||
| 451 | this .InvokeMap Changed(Co llectionCh ange.ItemI nserted, k ey); | |||||
| 452 | } | |||||
| 453 | ||||||
| 454 | public v oid Add(Ke yValuePair <K, V> ite m) | |||||
| 455 | { | |||||
| 456 | this .Add(item. Key, item. Value); | |||||
| 457 | } | |||||
| 458 | ||||||
| 459 | public b ool Remove (K key) | |||||
| 460 | { | |||||
| 461 | if ( this._dict ionary.Rem ove(key)) | |||||
| 462 | { | |||||
| 463 | this.Invok eMapChange d(Collecti onChange.I temRemoved , key); | |||||
| 464 | return tru e; | |||||
| 465 | } | |||||
| 466 | retu rn false; | |||||
| 467 | } | |||||
| 468 | ||||||
| 469 | public b ool Remove (KeyValueP air<K, V> item) | |||||
| 470 | { | |||||
| 471 | V cu rrentValue ; | |||||
| 472 | if ( this._dict ionary.Try GetValue(i tem.Key, o ut current Value) && | |||||
| 473 | Object.Equ als(item.V alue, curr entValue) && this._d ictionary. Remove(ite m.Key)) | |||||
| 474 | { | |||||
| 475 | this.Invok eMapChange d(Collecti onChange.I temRemoved , item.Key ); | |||||
| 476 | return tru e; | |||||
| 477 | } | |||||
| 478 | retu rn false; | |||||
| 479 | } | |||||
| 480 | ||||||
| 481 | public V this[K ke y] | |||||
| 482 | { | |||||
| 483 | get | |||||
| 484 | { | |||||
| 485 | return thi s._diction ary[key]; | |||||
| 486 | } | |||||
| 487 | set | |||||
| 488 | { | |||||
| 489 | this._dict ionary[key ] = value; | |||||
| 490 | this.Invok eMapChange d(Collecti onChange.I temChanged , key); | |||||
| 491 | } | |||||
| 492 | } | |||||
| 493 | ||||||
| 494 | public v oid Clear( ) | |||||
| 495 | { | |||||
| 496 | var priorKeys = this._di ctionary.K eys.ToArra y(); | |||||
| 497 | this ._dictiona ry.Clear() ; | |||||
| 498 | fore ach (var k ey in prio rKeys) | |||||
| 499 | { | |||||
| 500 | this.Invok eMapChange d(Collecti onChange.I temRemoved , key); | |||||
| 501 | } | |||||
| 502 | } | |||||
| 503 | ||||||
| 504 | public I Collection <K> Keys | |||||
| 505 | { | |||||
| 506 | get { return t his._dicti onary.Keys ; } | |||||
| 507 | } | |||||
| 508 | ||||||
| 509 | public b ool Contai nsKey(K ke y) | |||||
| 510 | { | |||||
| 511 | retu rn this._d ictionary. ContainsKe y(key); | |||||
| 512 | } | |||||
| 513 | ||||||
| 514 | public b ool TryGet Value(K ke y, out V v alue) | |||||
| 515 | { | |||||
| 516 | retu rn this._d ictionary. TryGetValu e(key, out value); | |||||
| 517 | } | |||||
| 518 | ||||||
| 519 | public I Collection <V> Values | |||||
| 520 | { | |||||
| 521 | get { return t his._dicti onary.Valu es; } | |||||
| 522 | } | |||||
| 523 | ||||||
| 524 | public b ool Contai ns(KeyValu ePair<K, V > item) | |||||
| 525 | { | |||||
| 526 | retu rn this._d ictionary. Contains(i tem); | |||||
| 527 | } | |||||
| 528 | ||||||
| 529 | public i nt Count | |||||
| 530 | { | |||||
| 531 | get { return t his._dicti onary.Coun t; } | |||||
| 532 | } | |||||
| 533 | ||||||
| 534 | public b ool IsRead Only | |||||
| 535 | { | |||||
| 536 | get { return f alse; } | |||||
| 537 | } | |||||
| 538 | ||||||
| 539 | public I Enumerator <KeyValueP air<K, V>> GetEnumer ator() | |||||
| 540 | { | |||||
| 541 | retu rn this._d ictionary. GetEnumera tor(); | |||||
| 542 | } | |||||
| 543 | ||||||
| 544 | System.C ollections .IEnumerat or System. Collection s.IEnumera ble.GetEnu merator() | |||||
| 545 | { | |||||
| 546 | retu rn this._d ictionary. GetEnumera tor(); | |||||
| 547 | } | |||||
| 548 | ||||||
| 549 | public v oid CopyTo (KeyValueP air<K, V>[ ] array, i nt arrayIn dex) | |||||
| 550 | { | |||||
| 551 | int arraySize = array.Le ngth; | |||||
| 552 | fore ach (var p air in thi s._diction ary) | |||||
| 553 | { | |||||
| 554 | if (arrayI ndex >= ar raySize) b reak; | |||||
| 555 | array[arra yIndex++] = pair; | |||||
| 556 | } | |||||
| 557 | } | |||||
| 558 | } | |||||
| 559 | } | |||||
| 560 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.