| ofs | hex dump | ascii |
|---|
| 0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 01 ff 00 00 02 5e 08 06 00 00 00 ba 59 0c | .PNG........IHDR.......^......Y. |
| 0020 | 68 00 00 00 04 67 41 4d 41 00 00 b1 8f 0b fc 61 05 00 00 00 09 70 48 59 73 00 00 2e 22 00 00 2e | h....gAMA......a.....pHYs..."... |
| 0040 | 22 01 aa e2 dd 92 00 00 00 19 74 45 58 74 53 6f 66 74 77 61 72 65 00 70 61 69 6e 74 2e 6e 65 74 | ".........tEXtSoftware.paint.net |
| 0060 | 20 34 2e 30 2e 31 37 33 6e 9f 63 00 00 b1 af 49 44 41 54 78 5e ed bd 79 c0 2d 55 79 e6 9b 08 de | .4.0.173n.c....IDATx^..y.-Uy.... |
| 0080 | 44 66 95 4e 72 e8 0c 7d af 26 ad 49 df 16 6d cc ed e4 e2 41 24 49 df 8e 38 64 e8 ee dc 20 09 78 | Df.Nr..}.&.I..m....A$I..8d.....x |
| 00a0 | bb 83 ca 18 24 83 89 80 63 4b 3a 1a 0c 0e c0 21 28 f3 a0 08 1c 64 16 88 03 22 b3 80 ca e4 00 22 | ....$...cK:....!(....d..."....." |
| 00c0 | e7 30 cb 99 98 0f 59 b7 9e aa ef dd df bb df fd ae 9a f7 de 55 b5 9f 3f 7e df fe 6a d5 aa 55 ab | .0....Y.............U..?~..j..U. |
| 00e0 | d6 5a b5 9e 77 8d f5 13 21 04 42 08 21 3d 67 ed fd f7 87 53 57 1d 1b 4e 3b e1 38 97 23 de 7d 70 | .Z..w...!.B.!=g....SW..N;.8.#.}p |
| 0100 | 78 db ef ed 59 8a 57 bf e2 65 e1 97 7f f1 e7 66 c0 8a f0 f2 5f f8 d9 f4 77 e5 2e 3b 8f c5 01 71 | x...Y.W..e.....f...._...w..;...q |
| 0120 | b6 cf 48 da c3 75 24 84 10 32 3d 1e 5c bb 66 42 a8 45 f4 f6 7a eb 1b 53 de f4 86 d7 a5 02 99 89 | ..H..u$..2=.\.fB.E..z..S........ |
| 0140 | e3 f2 ef 96 5b fe 44 52 73 2f 06 db 6f bd 45 92 5c 7e 1a 92 66 b8 8e 84 10 42 ca 73 cb 8d 37 4c | ....[.DRs/..o.E.\~..f....B.s..7L |
| 0160 | 88 78 26 de 2b 52 c1 06 9e b8 91 62 f6 fe fd 37 25 49 ec a7 3b a9 8f eb 48 08 21 64 9c 9b af bb | .x&.+R.....b...7%I..;...H.!d.... |
| 0180 | 36 15 77 88 d1 ca 5d 5e b5 70 ad f0 79 b1 e2 a5 db 24 c9 ef e7 09 a9 8f eb 48 08 21 24 fc c4 37 | 6.w...]^.p..y....$.......H.!$..7 |
| 01a0 | af bf 2e ec b9 fb ae 61 a7 1d b7 9d 10 a5 3e b2 3c c6 6e c7 dc 97 87 15 00 7a 2d a4 07 63 56 c8 | .......a......>.<.n......z-..cV. |
| 01c0 | bd 77 da 71 9b 89 78 db 7c 21 cd 71 1d 09 21 64 d1 b9 ec 82 f3 67 da b2 87 e8 69 01 c6 ff 9e 48 | .w.q..x.|!.q..!d.....g....i....H |
| 01e0 | 62 e2 de e9 27 ae 1a 9b 33 80 63 fc fe cb bf fc cb 18 cf 3f ff bc fb db 25 6c dc f0 2c 36 6d 6c | b...'...3.c........?....%l..,6ml |
| 0200 | de 90 e6 b8 8e 84 10 b2 e8 78 2d d0 32 60 92 9a 08 38 5a d0 18 26 c0 04 be 23 0f 3b 64 24 d6 00 | .........x-.2`...8Z..&...#.;d$.. |
| 0220 | b3 f3 cb 88 71 d7 fc 4c 03 7d 5f a4 8d 4d 53 9b 37 a4 39 ae 23 21 84 2c 32 10 66 2b 40 82 88 3b | ....q..L.}_..MS.7.9.#!.,2.f+@..; |
| 0240 | 5a e1 07 ec fb b6 91 98 6b 31 d3 c4 04 b5 8a d0 ce 4b 94 e7 01 c5 7f 36 b8 8e 84 10 b2 c8 78 5d | Z.......k1.......K.....6......x] |
| 0260 | cf 1f ff c8 07 d3 d6 ba 27 58 a4 3d 28 fe b3 c1 75 24 84 90 45 66 ff 7d f6 9a 10 20 4f a8 48 fb | ........'X.=(...u$..Ef.}....O.H. |
| 0280 | 50 fc 67 83 eb 48 08 21 8b 0c c6 e9 b5 f8 a0 9b 5f ba de 17 a9 0b 7e 1e 50 fc 67 83 eb 48 08 21 | P.g..H.!........_.....~.P.g..H.! |
| 02a0 | 8b 0c b6 b7 d5 e2 83 63 08 93 16 7e 1a 01 d3 81 e2 3f 1b 5c 47 42 08 59 64 d0 d2 d7 e2 83 c9 7d | .......c...~.....?.\GB.Yd......} |
| 02c0 | 10 26 08 be 60 45 8b b4 03 c5 7f 36 b8 8e 84 10 b2 c8 d8 65 7e 10 7f 0a fe 6c a0 f8 cf 06 d7 91 | .&..`E.....6.......e~....l...... |
| 02e0 | 10 42 16 19 2b 3e 98 e9 ef 09 15 69 1f 8a ff 6c 70 1d 09 21 64 91 b1 e2 83 dd f4 3c a1 22 ed 43 | .B..+>.....i...lp..!d......<.".C |
| 0300 | f1 9f 0d ae 23 21 84 2c 2a de 06 3f 10 24 4f a8 34 32 2c e0 0d 0f 94 39 17 03 db 0c e3 fe 30 40 | ....#!.,*..?.$O.42,....9......0@ |
| 0320 | 64 1b 5f 41 b6 fc f5 c0 f7 f1 65 a7 c1 3c 5e d8 c2 16 c6 fa eb 85 b8 ef 81 6f df bb f6 9e 08 78 | d._A......e..<^..........o.....x |
| 0340 | 4e 1b be cd 23 d2 1c d7 91 10 42 16 15 88 aa 15 9f aa 42 26 82 8e 1d 00 f3 44 59 ef e5 3f b4 2f | N...#.....B.......B&.....DY..?./ |
| 0360 | 04 e2 39 6d ba 94 c1 4b 7f 9b 47 a4 39 ae 23 21 84 2c 2a 9e f8 e4 b5 ce f3 ce d9 70 ea 90 6d 27 | ..9m...K..G.9.#!.,*........p..m' |
| 0380 | bc dc b2 d6 5f e2 c3 b7 03 f0 dd 00 31 2c b0 3f 81 fc af b7 1e ce 03 9f 2a b6 69 50 05 7c f9 50 | ...._.......1,.?........*.iP.|.P |
| 03a0 | 7f 68 e8 cd 7b ac 4c e3 8d 1e 05 2f 4d 8a 40 18 36 0d ec 3d 49 73 5c 47 42 08 59 54 3c f1 f1 44 | .h..{.L..../M.@.6..=Is\GB.YT<..D |
| 03c0 | 0a a2 6f 85 5f 1f a3 bb 1e d7 42 bc 45 90 45 94 bd 2e 7c 88 a8 8d 4b 5f c9 4b b7 22 8e fe f0 07 | ..o._.....B.E.E...|...K_.K.".... |
| 03e0 | 46 e9 0e d0 23 62 c3 27 cd 71 1d 09 21 64 51 c1 27 73 b5 f8 00 88 92 16 f6 bc d6 be 20 46 04 5a | F...#b.'.q..!dQ.'s...........F.Z |
| 0400 | e8 f6 1e 43 47 a7 5b 55 60 20 c9 f5 00 bd 1c 36 7c d2 1c d7 91 10 42 16 15 2b 3e 10 6f 4f a4 04 | ...CG.[U`......6|.....B..+>.oO.. |
| 0420 | 31 04 ac 41 20 e2 bf 68 e2 85 61 04 3c 77 dd 6e 7f 0c 63 8c a7 ff 8a 24 58 ff 5e a4 3e ae 23 21 | 1..A...h..a.<w.n..c....$X.^.>.#! |
| 0440 | 84 2c 2a 93 e2 bf c2 15 a9 18 62 04 48 0f c2 6b 5e f9 f2 24 58 ff 5e 43 44 be 88 08 a3 c7 a6 4d | .,*.......b.H..k^..$X.^CD......M |
| 0460 | 0c 6d 40 79 df 55 b0 f7 20 cd 71 1d 09 21 64 51 f1 c4 c7 8a 55 19 c4 88 c0 af bd c7 90 d1 c3 1d | .m@y.U....q..!dQ....U........... |
| 0480 | 5e ba 14 41 f1 9f 0d ae 23 21 84 2c 2a 98 41 af c5 a7 6c 0b 56 77 fb e3 7f 8a 7f 79 f1 d7 69 67 | ^..A....#!.,*.A...l.Vw.....y..ig |
| 04a0 | 7b 5e 38 e6 3f 1d 5c 47 42 08 59 54 20 5a 5a 7c 60 0c 78 42 85 5f fd bf 3d 4f f1 af 36 5c 22 60 | {^8.?.\GB.YT.ZZ|`.xB._..=O..6\"` |
| 04c0 | 7f 00 9d fe f8 a2 a2 bd 07 69 8e eb 48 08 21 8b 0a 44 4b 8b 0f ba a1 b5 b8 5b 3c 03 00 88 11 81 | .........i..H.!..DK......[<..... |
| 04e0 | ef 02 d8 7b 0c 19 3c 2f 9e bb 6e b7 bf 35 be 16 cd 78 9a 15 ae 23 21 84 2c 2a e8 66 d6 e2 83 d9 | ...{..</..n..5...x...#!.,*.f.... |
| 0500 | e7 22 4c 31 a1 17 b4 bb 88 18 5a c2 f6 1e 43 46 f7 78 e8 b4 f1 b0 e9 88 63 6b 7c 51 fc a7 83 eb | ."L1......Z...CF.x......ck|Q.... |
| 0520 | 48 08 21 8b 8a d7 f2 84 30 6d 7e ee b9 31 a1 d2 f8 22 46 f1 d7 69 92 87 4e 3f 6b 7c a1 e7 c5 de | H.!.....0m~..1..."F..i..N?k|.... |
| 0540 | 83 34 c7 75 24 84 90 45 65 a7 1d b7 1d 13 1f 88 98 27 ee fa d8 73 93 bd fa b1 d3 9f bd c7 90 11 | .4.u$..Ee........'...s.......... |
| 0560 | f1 87 68 eb f4 f0 f0 d2 d5 1a 5f e8 79 b1 f7 20 cd 71 1d 09 21 64 51 d1 c2 03 ca 7e cb 5f 84 4c | ..h......._.y....q..!dQ....~._.L |
| 0580 | 7e e5 7a 1b fe d0 91 d5 12 55 5a fe 02 d2 0e db 21 4b da 01 6c 87 6c ef 41 9a e3 3a 12 42 c8 a2 | ~.z......UZ.....!K..l.l.A..:.B.. |
| 05a0 | a2 85 07 60 d3 1a 4f a8 8a 90 eb 6d f8 43 47 0f 77 78 e9 52 84 a4 9b b0 68 c3 26 b3 c2 75 24 84 | ...`..O....m.CG.wx.R....h.&..u$. |
| 05c0 | 90 45 c5 8a 8f 16 7f db 4d 1d 03 9f 00 96 eb 6d f8 43 87 e2 df 0f 5c 47 42 08 59 54 3c f1 81 28 | .E......M......m.C....\GB.YT<..( |
| 05e0 | 95 15 7e 80 6b 70 ed 4e 3b 6e 93 04 e9 df 67 a8 c8 84 bd 3a e2 8f 34 d6 69 2f e1 d8 7b 90 e6 b8 | ..~.kp.N;n....g....:..4.i/..{... |
| 0600 | 8e 84 10 b2 a8 78 e2 a3 c5 49 8b 95 46 af 06 10 f1 47 2b d8 86 3f 74 64 cc 1e 13 1d 75 fa e4 a1 | .....x...I..F....G+..?td....u... |
| 0620 | d3 55 a7 3d a0 f8 4f 07 d7 91 10 42 16 11 7c 53 df 8a cf e5 17 5e 30 26 54 c0 1a 01 f6 78 91 c5 | .U.=..O....B..|S.....^0&T....x.. |
| 0640 | 5f d2 4d a7 47 0c 9d 6e f8 5f 3e 0a a4 b1 e1 93 76 70 1d 09 21 64 11 11 d1 d6 68 b1 2a 0b 66 a8 | _.M.G..n._>.....vp..!d....h.*.f. |
| 0660 | e3 da 45 dc 9a b6 49 ba 79 e9 6f c3 27 ed e0 3a 12 42 c8 22 52 46 fc bd 56 bf 6d c1 ea 8d 6e ec | ..E...I.y.o.'..:.B."RF..V.m...n. |
| 0680 | 3d 86 8e a4 9b 4d a7 32 9c ba ea d8 51 ba 0b 36 7c d2 0e ae 23 21 84 2c 22 79 e2 9f 27 66 d6 00 | =....M.2....Q..6|...#!.,"y..'f.. |
| 06a0 | c0 c6 34 b8 76 d1 c4 5f c4 bb ec 97 10 2d 6c f9 cf 0e d7 91 10 42 16 11 4f 7c b4 b0 e7 19 00 02 | ..4.v.._.....-l......B..O|...... |
| 06c0 | fc 2c 6a cb 5f d2 0f 73 1d bc b4 b1 d8 f4 94 74 13 30 79 d0 de 83 b4 83 eb 48 08 21 8b 48 99 6e | .,j._..s.......t.0y......H.!.H.n |
| 06e0 | ff 32 c8 72 b7 45 fb a2 9f 4c d8 ab f3 39 5f 6d 34 09 8b 38 61 72 56 b8 8e 84 10 b2 88 94 11 7f | .2.r.E...L...9_m4..8arV......... |
| 0700 | af 17 c0 b6 60 e5 cb 74 10 43 7b 8f 21 23 c3 1d 7b ee be eb 58 7a e4 a1 d3 8e e2 3f 3b 5c 47 42 | ....`..t.C{.!#..{...Xz.....?;\GB |
| 0720 | 08 59 44 bc 6e 67 2d 54 16 08 97 15 7e 00 d1 c2 f5 30 26 ec 3d 86 8c a4 9f fe 0c 72 19 24 0d c5 | .YD.ng-T....~....0&.=......r.$.. |
| 0740 | 78 10 28 fe d3 c3 75 24 84 90 45 04 5f a2 b3 e2 63 85 ca 43 1b 01 f8 dd 61 69 a3 9b 45 15 7f fc | x.(...u$..E._...c..C....ai..E... |
| 0760 | da 34 2a 83 18 4d 02 3e 12 64 ef 41 da c1 75 24 84 90 45 64 b2 e5 b9 c2 6d d9 03 cf 5d dc e4 7a | .4*..M.>.d.A..u$..Ed....m...]..z |
| 0780 | 1b fe d0 11 f1 3e e6 a8 0f 45 d3 2d 06 fc 5b f1 47 7e d8 7b 90 76 70 1d 09 21 64 11 b1 dd fe 7a | .....>...E.-..[.G~.{.vp..!d....z |
| 07a0 | c9 5a 15 31 93 eb 6d f8 43 47 c4 1b 4b fe bc 74 29 42 26 4a 0a c8 0f 7b 0f d2 0e ae 23 21 84 2c | .Z.1..m.CG..K..t)B&J...{....#!., |
| 07c0 | 22 de 98 73 5e 0b 3f 76 2c d7 db f0 87 8e 88 3f 86 3b aa 18 4b 82 fd 96 3f c5 7f 7a b8 8e 84 10 | "..s^.?v,......?.;..K...?..z.... |
| 07e0 | b2 88 e4 b5 fc 3d 44 e0 b4 d0 e1 83 36 b8 76 cb 2d 11 a4 7f 9f a1 22 e9 86 4f 1a 4b 7a 54 41 ae | .....=D.....6.v.-....."..O.KzTA. |
| 0800 | pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tango.Core.Helpers;
using Tango.MachineStudio.Common.StudioApplication;
using Tango.MachineStudio.Common.Navigation;
using System.Reflection;
using System.Collections;
using Tango.Core;
using Tango.Logging;
using Tango.MachineStudio.Common.Modules;
using Tango.MachineStudio.Common;
using Tango.Settings;
using System.Windows;
using Tango.Integration.ExternalBridge;
using Tango.MachineStudio.Common.EventLogging;
using Tango.BL.Enumerations;
using Tango.Core.DI;
using Tango.BL.Entities;
using Tango.BL;
using Tango.MachineStudio.UI.ViewModels;
using Tango.MachineStudio.Common.Notifications;
using Tango.MachineStudio.UI.Views;
using Tango.Integration.Operation;
using Tango.MachineStudio.UI.Windows;
using Tango.BL.Builders;
namespace Tango.MachineStudio.UI.StudioApplication
{
/// <summary>
/// Represents the default Machine Studio <see cref="IStudioApplicationManager">Application Manager</see>.
/// </summary>
/// <seealso cref="Tango.Core.ExtendedObject" />
/// <seealso cref="Tango.MachineStudio.Common.StudioApplication.IStudioApplicationManager" />
public class DefaultStudioApplicationManager : ExtendedObject, IStudioApplicationManager
{
private INavigationManager _navigationManager;
private IStudioModuleLoader _moduleLoader;
private INotificationProvider _notification;
private List<Window> _openedWindows;
private List<IStudioViewModel> _notified_view_models;
private bool _isDialogShown;
/// <summary>
/// Occurs when the application is ready.
/// </summary>
public event EventHandler ApplicationReady;
/// <summary>
/// Occurs when the connected machine session has been lost and an automatic reconnection with the last machine is required.
/// </summary>
public event EventHandler ReconnectionRequired;
/// <summary>
/// Initializes a new instance of the <see cref="DefaultStudioApplicationManager" /> class.
/// </summary>
/// <param name="navigationManager">The navigation manager.</param>
public DefaultStudioApplicationManager(INavigationManager navigationManager, IStudioModuleLoader moduleLoader, INotificationProvider notification)
{
_moduleLoader = moduleLoader;
_navigationManager = navigationManager;
_notification = notification;
_openedWindows = new List<Window>();
_notified_view_models = new List<IStudioViewModel>();
Application.Current.MainWindow.ContentRendered += (_, __) =>
{
TangoIOC.Default.GetAllInstancesByBase<IStudioViewModel>().ToList().ForEach(x => x.OnApplicationStarted());
};
}
/// <summary>
/// Gets a value indicating whether Machine Studio is shutting down.
/// </summary>
public bool IsShuttingDown { get; private set; }
/// <summary>
/// Occurs when the connected machine property has changed.
/// </summary>
public event EventHandler<IExternalBridgeClient> ConnectedMachineChanged;
/// <summary>
/// Gets or sets the machine.
/// </summary>
public Machine Machine { get; private set; }
private IExternalBridgeClient _connectedMachine;
/// <summary>
/// Gets or sets the currently connected machine if any.
/// </summary>
public IExternalBridgeClient ConnectedMachine
{
get { return _connectedMachine; }
private set
{
if (_connectedMachine != value)
{
_connectedMachine = value;
RaisePropertyChangedAuto();
RaisePropertyChanged(nameof(IsMachineConnected));
RaisePropertyChanged(nameof(IsMachineConnectedViaTCP));
if (_connectedMachine != null)
{
_connectedMachine.StateChanged -= ConnectedMachine_StateChanged;
_connectedMachine.StateChanged += ConnectedMachine_StateChanged;
}
ConnectedMachineChanged?.Invoke(this, _connectedMachine);
}
}
}
/// <summary>
/// Gets a value indicating whether the <see cref="P:Tango.MachineStudio.Common.StudioApplication.IStudioApplicationManager.ConnectedMachine" /> is valid and connected through TCP/IP.
/// </summary>
public bool IsMachineConnectedViaTCP
{
get { return IsMachineConnected && ConnectedMachine is ExternalBridgeTcpClient; }
}
/// <summary>
/// Handles the <see cref="ConnectedMachine"/> state changed event.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
private void ConnectedMachine_StateChanged(object sender, Transport.TransportComponentState e)
{
if (e == Transport.TransportComponentState.Disconnected || e == Transport.TransportComponentState.Failed)
{
bool reconnect = ConnectedMachine is IExternalBridgeSecureClient;
ConnectedMachine = null;
if (e == Transport.TransportComponentState.Failed)
{
String failed_reason = (sender as IMachineOperator).FailedStateException.Message;
if (!_isDialogShown)
{
_isDialogShown = true;
ConnectionLostViewVM vm = new ConnectionLostViewVM()
{
Exception = failed_reason,
AutoReconnect = reconnect,
};
InvokeUI(() =>
{
_notification.ShowModalDialog<ConnectionLostViewVM, ConnectionLostView>(vm, (x) =>
{
_isDialogShown = false;
ReconnectionRequired?.Invoke(this, new EventArgs());
}, () =>
{
_isDialogShown = false;
});
});
}
}
}
}
/// <summary>
/// Gets a value indicating whether the <see cref="P:Tango.MachineStudio.Common.StudioApplication.IStudioApplicationManager.ConnectedMachine" /> is valid.
/// </summary>
public bool IsMachineConnected
{
get { return ConnectedMachine != null; }
}
/// <summary>
/// Gets the machine studio application version.
/// </summary>
public Version Version
{
get
{
return AssemblyHelper.GetCurrentAssemblyVersion();
}
}
/// <summary>
/// Shutdown the application.
/// </summary>
public async void ShutDown()
{
if (IsShuttingDown) return;
IsShuttingDown = true;
try
{
Rect r = new Rect(
MainWindow.Instance.Left,
MainWindow.Instance.Top,
MainWindow.Instance.Width,
MainWindow.Instance.Height);
await Task.Factory.StartNew(async () =>
{
try
{
//Do Shutdown Procedures...
foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<IStudioViewModel>())
{
try
{
var result = await vm.OnShutdownRequest();
if (!result)
{
IsShuttingDown = false;
return;
}
}
catch (Exception ex)
{
LogManager.Log(ex, "Error on shutdown request with " + vm.GetType().Name);
}
}
foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<IStudioViewModel>())
{
vm.OnShuttingDown();
}
var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>();
settings.LastBounds = r;
settings.StudioModulesBounds.Clear();
foreach (var window in _openedWindows.OfType<Windows.ModuleWindow>())
{
window.Invoke(() =>
{
var context = window.ModuleContext;
if (context != null)
{
settings.StudioModulesBounds.Add(new MachineStudioSettings.StudioModuleBounds()
{
Bounds = window.RestoreBounds,
State = window.WindowState,
Name = context.Module.Name,
});
}
});
}
var mainViewVM = TangoIOC.Default.GetInstance<MainViewVM>();
settings.LastMainModuleName = mainViewVM.CurrentModule != null ? mainViewVM.CurrentModule.Name : null;
try
{
SettingsManager.Default.Save();
}
catch (Exception ex)
{
LogManager.Log(ex, "Error saving settings.");
}
await _navigationManager.NavigateTo(NavigationView.ShutdownView);
Thread.Sleep(1500);
foreach (var window in _openedWindows)
{
ThreadsHelper.InvokeUI(() =>
{
window.Close();
});
}
try
{
if (ConnectedMachine != null)
{
ConnectedMachine.Disconnect().Wait();
}
}
catch (Exception ex)
{
LogManager.Log(ex, "Error disconnecting from machine.");
}
var eventLogger = TangoIOC.Default.GetInstance<IEventLogger>();
if (eventLogger != null)
{
//eventLogger.Log(EventTypes.APPLICATION_TERMINATED, "Application Terminated!");
eventLogger.FlushAll();
}
Thread.Sleep(1500);
Environment.Exit(0);
}
catch
{
Environment.Exit(0);
}
});
}
catch (Exception ex)
{
IsShuttingDown = false;
LogManager.Log(ex, "An error occurred while shutting down machine studio.");
}
}
/// <summary>
/// Notify the application manager about an external opened window.
/// When application exists. All registered windows will be closed.
/// </summary>
/// <param name="window">The window.</param>
public void RegisterOpenedWindow(Window window)
{
_openedWindows.Add(window);
window.Closed += (x, y) => { _openedWindows.Remove(window); };
}
public bool IsModuleInNewWindow(IStudioModule module)
{
return _openedWindows.Exists(x => (x as ModuleWindow).ModuleContext.Module == module);
}
/// <summary>
/// Gets the core libraries version.
/// </summary>
public Version CoreVersion
{
get
{
return typeof(ExtendedObject).Assembly.GetName().Version;
}
}
/// <summary>
/// Gets the build date.
/// </summary>
public string BuildDate
{
get
{
return AssemblyHelper.GetCurrentAssemblyBuildDate().ToShortDateString();
}
}
/// <summary>
/// Gets the change log.
/// </summary>
public string ChangeLog
{
get
{
return EmbeddedResourceHelper.GetEmbeddedResourceText("Tango.MachineStudio.UI.ChangeLog.txt");
}
}
/// <summary>
/// Raises the application ready event.
/// </summary>
public void NotifyApplicationReady()
{
TangoIOC.Default.GetAllInstancesByBase<IStudioViewModel>().ToList().ForEach(x =>
{
if (!_notified_view_models.Contains(x))
{
x.OnApplicationReady();
_notified_view_models.Add(x);
}
});
ApplicationReady?.Invoke(this, new EventArgs());
}
/// <summary>
/// Sets the connected machine.
/// </summary>
/// <param name="connectedMachine">The connected machine.</param>
public void SetConnectedMachine(IExternalBridgeClient connectedMachine)
{
if (connectedMachine != null)
{
Machine = ObservablesStaticCollections.Instance.Machines.SingleOrDefault(x => x.SerialNumber == connectedMachine.SerialNumber);
if (Machine == null)
{
throw new NullReferenceException($"The specified machine '{connectedMachine.SerialNumber}' could not be found on the database.");
}
connectedMachine.SetMachine(Machine);
ConnectedMachine = connectedMachine;
var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>();
ConnectedMachine.JobUploadStrategy = settings.JobUploadStrategy;
}
else
{
Machine = null;
ConnectedMachine = null;
}
}
}
}
|