ufo56

kairos.exe source

Jan 24th, 2017
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 448.42 KB | None | 0 0
  1. // Decompiled with JetBrains decompiler
  2. // Type: KairosPlanet.Properties.Resources
  3. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  4. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  6.  
  7. using System.CodeDom.Compiler;
  8. using System.ComponentModel;
  9. using System.Diagnostics;
  10. using System.Globalization;
  11. using System.Resources;
  12. using System.Runtime.CompilerServices;
  13.  
  14. namespace KairosPlanet.Properties
  15. {
  16. [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
  17. [DebuggerNonUserCode]
  18. [CompilerGenerated]
  19. public class Resources
  20. {
  21. private static ResourceManager resourceMan;
  22. private static CultureInfo resourceCulture;
  23.  
  24. [EditorBrowsable(EditorBrowsableState.Advanced)]
  25. public static ResourceManager ResourceManager
  26. {
  27. get
  28. {
  29. if (object.ReferenceEquals((object) Resources.resourceMan, (object) null))
  30. Resources.resourceMan = new ResourceManager("KairosPlanet.Properties.Resources", typeof (Resources).Assembly);
  31. return Resources.resourceMan;
  32. }
  33. }
  34.  
  35. [EditorBrowsable(EditorBrowsableState.Advanced)]
  36. public static CultureInfo Culture
  37. {
  38. get
  39. {
  40. return Resources.resourceCulture;
  41. }
  42. set
  43. {
  44. Resources.resourceCulture = value;
  45. }
  46. }
  47.  
  48. public static string ActivationError_TryReinstallModule
  49. {
  50. get
  51. {
  52. return Resources.ResourceManager.GetString("ActivationError_TryReinstallModule", Resources.resourceCulture);
  53. }
  54. }
  55.  
  56. public static string Cancel
  57. {
  58. get
  59. {
  60. return Resources.ResourceManager.GetString("Cancel", Resources.resourceCulture);
  61. }
  62. }
  63.  
  64. public static string ChangePasswordUC_ChangePasswordButtonContent
  65. {
  66. get
  67. {
  68. return Resources.ResourceManager.GetString("ChangePasswordUC_ChangePasswordButtonContent", Resources.resourceCulture);
  69. }
  70. }
  71.  
  72. public static string ChangePasswordUC_ConfirmNewPasswordTitle
  73. {
  74. get
  75. {
  76. return Resources.ResourceManager.GetString("ChangePasswordUC_ConfirmNewPasswordTitle", Resources.resourceCulture);
  77. }
  78. }
  79.  
  80. public static string ChangePasswordUC_CurrentPasswordTitle
  81. {
  82. get
  83. {
  84. return Resources.ResourceManager.GetString("ChangePasswordUC_CurrentPasswordTitle", Resources.resourceCulture);
  85. }
  86. }
  87.  
  88. public static string ChangePasswordUC_NewPasswordTitle
  89. {
  90. get
  91. {
  92. return Resources.ResourceManager.GetString("ChangePasswordUC_NewPasswordTitle", Resources.resourceCulture);
  93. }
  94. }
  95.  
  96. public static string ChangePasswordUC_Title
  97. {
  98. get
  99. {
  100. return Resources.ResourceManager.GetString("ChangePasswordUC_Title", Resources.resourceCulture);
  101. }
  102. }
  103.  
  104. public static string ContactInformationUC_AddressTitle
  105. {
  106. get
  107. {
  108. return Resources.ResourceManager.GetString("ContactInformationUC_AddressTitle", Resources.resourceCulture);
  109. }
  110. }
  111.  
  112. public static string ContactInformationUC_CityTitle
  113. {
  114. get
  115. {
  116. return Resources.ResourceManager.GetString("ContactInformationUC_CityTitle", Resources.resourceCulture);
  117. }
  118. }
  119.  
  120. public static string ContactInformationUC_Email1Title
  121. {
  122. get
  123. {
  124. return Resources.ResourceManager.GetString("ContactInformationUC_Email1Title", Resources.resourceCulture);
  125. }
  126. }
  127.  
  128. public static string ContactInformationUC_Email2Title
  129. {
  130. get
  131. {
  132. return Resources.ResourceManager.GetString("ContactInformationUC_Email2Title", Resources.resourceCulture);
  133. }
  134. }
  135.  
  136. public static string ContactInformationUC_Telephone1Title
  137. {
  138. get
  139. {
  140. return Resources.ResourceManager.GetString("ContactInformationUC_Telephone1Title", Resources.resourceCulture);
  141. }
  142. }
  143.  
  144. public static string ContactInformationUC_Telephone2Title
  145. {
  146. get
  147. {
  148. return Resources.ResourceManager.GetString("ContactInformationUC_Telephone2Title", Resources.resourceCulture);
  149. }
  150. }
  151.  
  152. public static string ContactInformationUC_Title
  153. {
  154. get
  155. {
  156. return Resources.ResourceManager.GetString("ContactInformationUC_Title", Resources.resourceCulture);
  157. }
  158. }
  159.  
  160. public static string ContactInformationUC_ZipCodeTitle
  161. {
  162. get
  163. {
  164. return Resources.ResourceManager.GetString("ContactInformationUC_ZipCodeTitle", Resources.resourceCulture);
  165. }
  166. }
  167.  
  168. public static string Error
  169. {
  170. get
  171. {
  172. return Resources.ResourceManager.GetString("Error", Resources.resourceCulture);
  173. }
  174. }
  175.  
  176. public static string Error_ConfirmNewPasswordIsEmpty
  177. {
  178. get
  179. {
  180. return Resources.ResourceManager.GetString("Error_ConfirmNewPasswordIsEmpty", Resources.resourceCulture);
  181. }
  182. }
  183.  
  184. public static string Error_ConnectionError
  185. {
  186. get
  187. {
  188. return Resources.ResourceManager.GetString("Error_ConnectionError", Resources.resourceCulture);
  189. }
  190. }
  191.  
  192. public static string Error_EmailIsEmpty
  193. {
  194. get
  195. {
  196. return Resources.ResourceManager.GetString("Error_EmailIsEmpty", Resources.resourceCulture);
  197. }
  198. }
  199.  
  200. public static string Error_EnterCurrentPasswordToChange
  201. {
  202. get
  203. {
  204. return Resources.ResourceManager.GetString("Error_EnterCurrentPasswordToChange", Resources.resourceCulture);
  205. }
  206. }
  207.  
  208. public static string Error_NewPasswordIsEmpty
  209. {
  210. get
  211. {
  212. return Resources.ResourceManager.GetString("Error_NewPasswordIsEmpty", Resources.resourceCulture);
  213. }
  214. }
  215.  
  216. public static string Error_PasswordIsEmpty
  217. {
  218. get
  219. {
  220. return Resources.ResourceManager.GetString("Error_PasswordIsEmpty", Resources.resourceCulture);
  221. }
  222. }
  223.  
  224. public static string Error_PasswordOrEmailInvalid
  225. {
  226. get
  227. {
  228. return Resources.ResourceManager.GetString("Error_PasswordOrEmailInvalid", Resources.resourceCulture);
  229. }
  230. }
  231.  
  232. public static string Error_PasswordsNotIdentical
  233. {
  234. get
  235. {
  236. return Resources.ResourceManager.GetString("Error_PasswordsNotIdentical", Resources.resourceCulture);
  237. }
  238. }
  239.  
  240. public static string Error_ServerReturnIncorrectData
  241. {
  242. get
  243. {
  244. return Resources.ResourceManager.GetString("Error_ServerReturnIncorrectData", Resources.resourceCulture);
  245. }
  246. }
  247.  
  248. public static string Error_UserDeletedError
  249. {
  250. get
  251. {
  252. return Resources.ResourceManager.GetString("Error_UserDeletedError", Resources.resourceCulture);
  253. }
  254. }
  255.  
  256. public static string Error_UserPasswordIncorrect
  257. {
  258. get
  259. {
  260. return Resources.ResourceManager.GetString("Error_UserPasswordIncorrect", Resources.resourceCulture);
  261. }
  262. }
  263.  
  264. public static string FemaleGender
  265. {
  266. get
  267. {
  268. return Resources.ResourceManager.GetString("FemaleGender", Resources.resourceCulture);
  269. }
  270. }
  271.  
  272. public static string InformationNotSpecified
  273. {
  274. get
  275. {
  276. return Resources.ResourceManager.GetString("InformationNotSpecified", Resources.resourceCulture);
  277. }
  278. }
  279.  
  280. public static string LoginUC_AutoLoginTitle
  281. {
  282. get
  283. {
  284. return Resources.ResourceManager.GetString("LoginUC_AutoLoginTitle", Resources.resourceCulture);
  285. }
  286. }
  287.  
  288. public static string LoginUC_LoginBtn
  289. {
  290. get
  291. {
  292. return Resources.ResourceManager.GetString("LoginUC_LoginBtn", Resources.resourceCulture);
  293. }
  294. }
  295.  
  296. public static string LoginUC_RecoverPasswordHyperLink
  297. {
  298. get
  299. {
  300. return Resources.ResourceManager.GetString("LoginUC_RecoverPasswordHyperLink", Resources.resourceCulture);
  301. }
  302. }
  303.  
  304. public static string LoginUC_RegisterBtn
  305. {
  306. get
  307. {
  308. return Resources.ResourceManager.GetString("LoginUC_RegisterBtn", Resources.resourceCulture);
  309. }
  310. }
  311.  
  312. public static string MainMenu_Profile
  313. {
  314. get
  315. {
  316. return Resources.ResourceManager.GetString("MainMenu_Profile", Resources.resourceCulture);
  317. }
  318. }
  319.  
  320. public static string MainMenu_ProfileContact
  321. {
  322. get
  323. {
  324. return Resources.ResourceManager.GetString("MainMenu_ProfileContact", Resources.resourceCulture);
  325. }
  326. }
  327.  
  328. public static string MainMenu_ProfilePassword
  329. {
  330. get
  331. {
  332. return Resources.ResourceManager.GetString("MainMenu_ProfilePassword", Resources.resourceCulture);
  333. }
  334. }
  335.  
  336. public static string MainMenu_ProfilePersonal
  337. {
  338. get
  339. {
  340. return Resources.ResourceManager.GetString("MainMenu_ProfilePersonal", Resources.resourceCulture);
  341. }
  342. }
  343.  
  344. public static string MainMenu_ServiceCategories
  345. {
  346. get
  347. {
  348. return Resources.ResourceManager.GetString("MainMenu_ServiceCategories", Resources.resourceCulture);
  349. }
  350. }
  351.  
  352. public static string MainMenu_Services
  353. {
  354. get
  355. {
  356. return Resources.ResourceManager.GetString("MainMenu_Services", Resources.resourceCulture);
  357. }
  358. }
  359.  
  360. public static string MainMenu_SessionHistory
  361. {
  362. get
  363. {
  364. return Resources.ResourceManager.GetString("MainMenu_SessionHistory", Resources.resourceCulture);
  365. }
  366. }
  367.  
  368. public static string MainMenu_Settings
  369. {
  370. get
  371. {
  372. return Resources.ResourceManager.GetString("MainMenu_Settings", Resources.resourceCulture);
  373. }
  374. }
  375.  
  376. public static string MainMenu_Statistics
  377. {
  378. get
  379. {
  380. return Resources.ResourceManager.GetString("MainMenu_Statistics", Resources.resourceCulture);
  381. }
  382. }
  383.  
  384. public static string MainMenu_StatisticsSummary
  385. {
  386. get
  387. {
  388. return Resources.ResourceManager.GetString("MainMenu_StatisticsSummary", Resources.resourceCulture);
  389. }
  390. }
  391.  
  392. public static string MainWindow_Exit
  393. {
  394. get
  395. {
  396. return Resources.ResourceManager.GetString("MainWindow_Exit", Resources.resourceCulture);
  397. }
  398. }
  399.  
  400. public static string MainWindow_LogOut
  401. {
  402. get
  403. {
  404. return Resources.ResourceManager.GetString("MainWindow_LogOut", Resources.resourceCulture);
  405. }
  406. }
  407.  
  408. public static string MainWindow_Open
  409. {
  410. get
  411. {
  412. return Resources.ResourceManager.GetString("MainWindow_Open", Resources.resourceCulture);
  413. }
  414. }
  415.  
  416. public static string MaleGender
  417. {
  418. get
  419. {
  420. return Resources.ResourceManager.GetString("MaleGender", Resources.resourceCulture);
  421. }
  422. }
  423.  
  424. public static string Message_NewPackageIsAvailable
  425. {
  426. get
  427. {
  428. return Resources.ResourceManager.GetString("Message_NewPackageIsAvailable", Resources.resourceCulture);
  429. }
  430. }
  431.  
  432. public static string NetworkState_None
  433. {
  434. get
  435. {
  436. return Resources.ResourceManager.GetString("NetworkState_None", Resources.resourceCulture);
  437. }
  438. }
  439.  
  440. public static string NetworkState_Offline
  441. {
  442. get
  443. {
  444. return Resources.ResourceManager.GetString("NetworkState_Offline", Resources.resourceCulture);
  445. }
  446. }
  447.  
  448. public static string NetworkState_Online
  449. {
  450. get
  451. {
  452. return Resources.ResourceManager.GetString("NetworkState_Online", Resources.resourceCulture);
  453. }
  454. }
  455.  
  456. public static string PersonalInformationUC_BirthDateTitle
  457. {
  458. get
  459. {
  460. return Resources.ResourceManager.GetString("PersonalInformationUC_BirthDateTitle", Resources.resourceCulture);
  461. }
  462. }
  463.  
  464. public static string PersonalInformationUC_CountryTitle
  465. {
  466. get
  467. {
  468. return Resources.ResourceManager.GetString("PersonalInformationUC_CountryTitle", Resources.resourceCulture);
  469. }
  470. }
  471.  
  472. public static string PersonalInformationUC_CreationDateTitle
  473. {
  474. get
  475. {
  476. return Resources.ResourceManager.GetString("PersonalInformationUC_CreationDateTitle", Resources.resourceCulture);
  477. }
  478. }
  479.  
  480. public static string PersonalInformationUC_EmailTitle
  481. {
  482. get
  483. {
  484. return Resources.ResourceManager.GetString("PersonalInformationUC_EmailTitle", Resources.resourceCulture);
  485. }
  486. }
  487.  
  488. public static string PersonalInformationUC_GenderTitle
  489. {
  490. get
  491. {
  492. return Resources.ResourceManager.GetString("PersonalInformationUC_GenderTitle", Resources.resourceCulture);
  493. }
  494. }
  495.  
  496. public static string PersonalInformationUC_NameTitle
  497. {
  498. get
  499. {
  500. return Resources.ResourceManager.GetString("PersonalInformationUC_NameTitle", Resources.resourceCulture);
  501. }
  502. }
  503.  
  504. public static string PersonalInformationUC_TelephoneTitle
  505. {
  506. get
  507. {
  508. return Resources.ResourceManager.GetString("PersonalInformationUC_TelephoneTitle", Resources.resourceCulture);
  509. }
  510. }
  511.  
  512. public static string PersonalInformationUC_Title
  513. {
  514. get
  515. {
  516. return Resources.ResourceManager.GetString("PersonalInformationUC_Title", Resources.resourceCulture);
  517. }
  518. }
  519.  
  520. public static string PersonalInformationUC_UserStatusTitle
  521. {
  522. get
  523. {
  524. return Resources.ResourceManager.GetString("PersonalInformationUC_UserStatusTitle", Resources.resourceCulture);
  525. }
  526. }
  527.  
  528. public static string Refresh_NewPackage
  529. {
  530. get
  531. {
  532. return Resources.ResourceManager.GetString("Refresh_NewPackage", Resources.resourceCulture);
  533. }
  534. }
  535.  
  536. public static string Save
  537. {
  538. get
  539. {
  540. return Resources.ResourceManager.GetString("Save", Resources.resourceCulture);
  541. }
  542. }
  543.  
  544. public static string SaveEditButton_Edit
  545. {
  546. get
  547. {
  548. return Resources.ResourceManager.GetString("SaveEditButton_Edit", Resources.resourceCulture);
  549. }
  550. }
  551.  
  552. public static string SaveEditButton_Save
  553. {
  554. get
  555. {
  556. return Resources.ResourceManager.GetString("SaveEditButton_Save", Resources.resourceCulture);
  557. }
  558. }
  559.  
  560. public static string ScreenManager_ModuleInstalled
  561. {
  562. get
  563. {
  564. return Resources.ResourceManager.GetString("ScreenManager_ModuleInstalled", Resources.resourceCulture);
  565. }
  566. }
  567.  
  568. public static string ScreenManager_Success
  569. {
  570. get
  571. {
  572. return Resources.ResourceManager.GetString("ScreenManager_Success", Resources.resourceCulture);
  573. }
  574. }
  575.  
  576. public static string ServicesUC_BackHyperLink
  577. {
  578. get
  579. {
  580. return Resources.ResourceManager.GetString("ServicesUC_BackHyperLink", Resources.resourceCulture);
  581. }
  582. }
  583.  
  584. public static string ServicesVM_ProductDescriptionFileName
  585. {
  586. get
  587. {
  588. return Resources.ResourceManager.GetString("ServicesVM_ProductDescriptionFileName", Resources.resourceCulture);
  589. }
  590. }
  591.  
  592. public static string ServiceVM_Activate
  593. {
  594. get
  595. {
  596. return Resources.ResourceManager.GetString("ServiceVM_Activate", Resources.resourceCulture);
  597. }
  598. }
  599.  
  600. public static string ServiceVM_Buy
  601. {
  602. get
  603. {
  604. return Resources.ResourceManager.GetString("ServiceVM_Buy", Resources.resourceCulture);
  605. }
  606. }
  607.  
  608. public static string ServiceVM_Details
  609. {
  610. get
  611. {
  612. return Resources.ResourceManager.GetString("ServiceVM_Details", Resources.resourceCulture);
  613. }
  614. }
  615.  
  616. public static string ServiceVM_Install
  617. {
  618. get
  619. {
  620. return Resources.ResourceManager.GetString("ServiceVM_Install", Resources.resourceCulture);
  621. }
  622. }
  623.  
  624. public static string ServiceVM_Order
  625. {
  626. get
  627. {
  628. return Resources.ResourceManager.GetString("ServiceVM_Order", Resources.resourceCulture);
  629. }
  630. }
  631.  
  632. public static string SessionHistoryUC_Date
  633. {
  634. get
  635. {
  636. return Resources.ResourceManager.GetString("SessionHistoryUC_Date", Resources.resourceCulture);
  637. }
  638. }
  639.  
  640. public static string SessionHistoryUC_DateAxis
  641. {
  642. get
  643. {
  644. return Resources.ResourceManager.GetString("SessionHistoryUC_DateAxis", Resources.resourceCulture);
  645. }
  646. }
  647.  
  648. public static string SessionHistoryUC_Duration
  649. {
  650. get
  651. {
  652. return Resources.ResourceManager.GetString("SessionHistoryUC_Duration", Resources.resourceCulture);
  653. }
  654. }
  655.  
  656. public static string SessionHistoryUC_DurationAxis
  657. {
  658. get
  659. {
  660. return Resources.ResourceManager.GetString("SessionHistoryUC_DurationAxis", Resources.resourceCulture);
  661. }
  662. }
  663.  
  664. public static string SessionHistoryUC_EmtyChartMessage
  665. {
  666. get
  667. {
  668. return Resources.ResourceManager.GetString("SessionHistoryUC_EmtyChartMessage", Resources.resourceCulture);
  669. }
  670. }
  671.  
  672. public static string SessionHistoryUC_EndTime
  673. {
  674. get
  675. {
  676. return Resources.ResourceManager.GetString("SessionHistoryUC_EndTime", Resources.resourceCulture);
  677. }
  678. }
  679.  
  680. public static string SessionHistoryUC_PeriodFrom
  681. {
  682. get
  683. {
  684. return Resources.ResourceManager.GetString("SessionHistoryUC_PeriodFrom", Resources.resourceCulture);
  685. }
  686. }
  687.  
  688. public static string SessionHistoryUC_PeriodTo
  689. {
  690. get
  691. {
  692. return Resources.ResourceManager.GetString("SessionHistoryUC_PeriodTo", Resources.resourceCulture);
  693. }
  694. }
  695.  
  696. public static string SessionHistoryUC_SessionHistory
  697. {
  698. get
  699. {
  700. return Resources.ResourceManager.GetString("SessionHistoryUC_SessionHistory", Resources.resourceCulture);
  701. }
  702. }
  703.  
  704. public static string SessionHistoryUC_ShowPeriod
  705. {
  706. get
  707. {
  708. return Resources.ResourceManager.GetString("SessionHistoryUC_ShowPeriod", Resources.resourceCulture);
  709. }
  710. }
  711.  
  712. public static string SessionHistoryUC_StartTime
  713. {
  714. get
  715. {
  716. return Resources.ResourceManager.GetString("SessionHistoryUC_StartTime", Resources.resourceCulture);
  717. }
  718. }
  719.  
  720. public static string SessionHistoryUC_Total
  721. {
  722. get
  723. {
  724. return Resources.ResourceManager.GetString("SessionHistoryUC_Total", Resources.resourceCulture);
  725. }
  726. }
  727.  
  728. public static string SessionStatisticsUC_CurrentMonthTitle
  729. {
  730. get
  731. {
  732. return Resources.ResourceManager.GetString("SessionStatisticsUC_CurrentMonthTitle", Resources.resourceCulture);
  733. }
  734. }
  735.  
  736. public static string SessionStatisticsUC_CurrentSessionNonActive
  737. {
  738. get
  739. {
  740. return Resources.ResourceManager.GetString("SessionStatisticsUC_CurrentSessionNonActive", Resources.resourceCulture);
  741. }
  742. }
  743.  
  744. public static string SessionStatisticsUC_CurrentSessionTitle
  745. {
  746. get
  747. {
  748. return Resources.ResourceManager.GetString("SessionStatisticsUC_CurrentSessionTitle", Resources.resourceCulture);
  749. }
  750. }
  751.  
  752. public static string SessionStatisticsUC_LastMonthTitle
  753. {
  754. get
  755. {
  756. return Resources.ResourceManager.GetString("SessionStatisticsUC_LastMonthTitle", Resources.resourceCulture);
  757. }
  758. }
  759.  
  760. public static string SessionStatisticsUC_RetrievingDataFromServerText
  761. {
  762. get
  763. {
  764. return Resources.ResourceManager.GetString("SessionStatisticsUC_RetrievingDataFromServerText", Resources.resourceCulture);
  765. }
  766. }
  767.  
  768. public static string SessionStatisticsUC_TimeLeftToEarnMoney
  769. {
  770. get
  771. {
  772. return Resources.ResourceManager.GetString("SessionStatisticsUC_TimeLeftToEarnMoney", Resources.resourceCulture);
  773. }
  774. }
  775.  
  776. public static string SessionStatisticsUC_TimeOnline
  777. {
  778. get
  779. {
  780. return Resources.ResourceManager.GetString("SessionStatisticsUC_TimeOnline", Resources.resourceCulture);
  781. }
  782. }
  783.  
  784. public static string SessionStatisticsUC_Title
  785. {
  786. get
  787. {
  788. return Resources.ResourceManager.GetString("SessionStatisticsUC_Title", Resources.resourceCulture);
  789. }
  790. }
  791.  
  792. public static string SessionStatisticsUC_TodayTitle
  793. {
  794. get
  795. {
  796. return Resources.ResourceManager.GetString("SessionStatisticsUC_TodayTitle", Resources.resourceCulture);
  797. }
  798. }
  799.  
  800. public static string SessionStatisticsUC_TotalTitle
  801. {
  802. get
  803. {
  804. return Resources.ResourceManager.GetString("SessionStatisticsUC_TotalTitle", Resources.resourceCulture);
  805. }
  806. }
  807.  
  808. public static string SessionStatisticsUC_YesterdayTitle
  809. {
  810. get
  811. {
  812. return Resources.ResourceManager.GetString("SessionStatisticsUC_YesterdayTitle", Resources.resourceCulture);
  813. }
  814. }
  815.  
  816. public static string Settings
  817. {
  818. get
  819. {
  820. return Resources.ResourceManager.GetString("Settings", Resources.resourceCulture);
  821. }
  822. }
  823.  
  824. public static string SettingsUC_ConnectionMethod_Title
  825. {
  826. get
  827. {
  828. return Resources.ResourceManager.GetString("SettingsUC_ConnectionMethod_Title", Resources.resourceCulture);
  829. }
  830. }
  831.  
  832. public static string SettingsUC_ICMPUsed
  833. {
  834. get
  835. {
  836. return Resources.ResourceManager.GetString("SettingsUC_ICMPUsed", Resources.resourceCulture);
  837. }
  838. }
  839.  
  840. public static string SettingsUC_IsAutoLoginTitle
  841. {
  842. get
  843. {
  844. return Resources.ResourceManager.GetString("SettingsUC_IsAutoLoginTitle", Resources.resourceCulture);
  845. }
  846. }
  847.  
  848. public static string SettingsUC_IsHttpiPingUsed_Inner
  849. {
  850. get
  851. {
  852. return Resources.ResourceManager.GetString("SettingsUC_IsHttpiPingUsed_Inner", Resources.resourceCulture);
  853. }
  854. }
  855.  
  856. public static string SettingsUC_LanguageSelectedText
  857. {
  858. get
  859. {
  860. return Resources.ResourceManager.GetString("SettingsUC_LanguageSelectedText", Resources.resourceCulture);
  861. }
  862. }
  863.  
  864. public static string SettingsUC_LanguageTitle
  865. {
  866. get
  867. {
  868. return Resources.ResourceManager.GetString("SettingsUC_LanguageTitle", Resources.resourceCulture);
  869. }
  870. }
  871.  
  872. public static string SettingsUC_RestartNow
  873. {
  874. get
  875. {
  876. return Resources.ResourceManager.GetString("SettingsUC_RestartNow", Resources.resourceCulture);
  877. }
  878. }
  879.  
  880. public static string SettingsUC_RunOnStartUpTitle
  881. {
  882. get
  883. {
  884. return Resources.ResourceManager.GetString("SettingsUC_RunOnStartUpTitle", Resources.resourceCulture);
  885. }
  886. }
  887.  
  888. public static string StatusMessage_CanNotLoadServices
  889. {
  890. get
  891. {
  892. return Resources.ResourceManager.GetString("StatusMessage_CanNotLoadServices", Resources.resourceCulture);
  893. }
  894. }
  895.  
  896. public static string StatusMessage_IsRefreshing
  897. {
  898. get
  899. {
  900. return Resources.ResourceManager.GetString("StatusMessage_IsRefreshing", Resources.resourceCulture);
  901. }
  902. }
  903.  
  904. public static string StatusMessage_NoNewPurchases
  905. {
  906. get
  907. {
  908. return Resources.ResourceManager.GetString("StatusMessage_NoNewPurchases", Resources.resourceCulture);
  909. }
  910. }
  911.  
  912. public static string StatusMessage_ServicesLoading
  913. {
  914. get
  915. {
  916. return Resources.ResourceManager.GetString("StatusMessage_ServicesLoading", Resources.resourceCulture);
  917. }
  918. }
  919.  
  920. public static string StatusMessage_TryActivateKeyRefresh
  921. {
  922. get
  923. {
  924. return Resources.ResourceManager.GetString("StatusMessage_TryActivateKeyRefresh", Resources.resourceCulture);
  925. }
  926. }
  927.  
  928. public static string Tray_LogIn
  929. {
  930. get
  931. {
  932. return Resources.ResourceManager.GetString("Tray_LogIn", Resources.resourceCulture);
  933. }
  934. }
  935.  
  936. public static string Tray_LogOut
  937. {
  938. get
  939. {
  940. return Resources.ResourceManager.GetString("Tray_LogOut", Resources.resourceCulture);
  941. }
  942. }
  943.  
  944. public static string Tray_ModuleCrashOrNotFoundMainFiledMessage
  945. {
  946. get
  947. {
  948. return Resources.ResourceManager.GetString("Tray_ModuleCrashOrNotFoundMainFiledMessage", Resources.resourceCulture);
  949. }
  950. }
  951.  
  952. public static string Tray_ModuleNotInstalledMessage
  953. {
  954. get
  955. {
  956. return Resources.ResourceManager.GetString("Tray_ModuleNotInstalledMessage", Resources.resourceCulture);
  957. }
  958. }
  959.  
  960. public static string Tray_NotificationTitle
  961. {
  962. get
  963. {
  964. return Resources.ResourceManager.GetString("Tray_NotificationTitle", Resources.resourceCulture);
  965. }
  966. }
  967.  
  968. public static string User_EmailTitle
  969. {
  970. get
  971. {
  972. return Resources.ResourceManager.GetString("User_EmailTitle", Resources.resourceCulture);
  973. }
  974. }
  975.  
  976. public static string User_PasswordTitle
  977. {
  978. get
  979. {
  980. return Resources.ResourceManager.GetString("User_PasswordTitle", Resources.resourceCulture);
  981. }
  982. }
  983.  
  984. public static string VersionUC_CurrentVersionCaption
  985. {
  986. get
  987. {
  988. return Resources.ResourceManager.GetString("VersionUC_CurrentVersionCaption", Resources.resourceCulture);
  989. }
  990. }
  991.  
  992. public static string VersionUC_DownloadNewAppVersion
  993. {
  994. get
  995. {
  996. return Resources.ResourceManager.GetString("VersionUC_DownloadNewAppVersion", Resources.resourceCulture);
  997. }
  998. }
  999.  
  1000. public static string VersionUC_LinkToSiteText
  1001. {
  1002. get
  1003. {
  1004. return Resources.ResourceManager.GetString("VersionUC_LinkToSiteText", Resources.resourceCulture);
  1005. }
  1006. }
  1007.  
  1008. public static string VersionUC_NewVersionCaption
  1009. {
  1010. get
  1011. {
  1012. return Resources.ResourceManager.GetString("VersionUC_NewVersionCaption", Resources.resourceCulture);
  1013. }
  1014. }
  1015.  
  1016. public static string VersionUC_NewVersionIsAvailable
  1017. {
  1018. get
  1019. {
  1020. return Resources.ResourceManager.GetString("VersionUC_NewVersionIsAvailable", Resources.resourceCulture);
  1021. }
  1022. }
  1023.  
  1024. internal Resources()
  1025. {
  1026. }
  1027. }
  1028. }
  1029. ?// Decompiled with JetBrains decompiler
  1030. // Type: KairosPlanet.Properties.Settings
  1031. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1032. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1033. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1034.  
  1035. using System.CodeDom.Compiler;
  1036. using System.Configuration;
  1037. using System.Runtime.CompilerServices;
  1038.  
  1039. namespace KairosPlanet.Properties
  1040. {
  1041. [GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
  1042. [CompilerGenerated]
  1043. internal sealed class Settings : ApplicationSettingsBase
  1044. {
  1045. private static Settings defaultInstance = (Settings) SettingsBase.Synchronized((SettingsBase) new Settings());
  1046.  
  1047. public static Settings Default
  1048. {
  1049. get
  1050. {
  1051. return Settings.defaultInstance;
  1052. }
  1053. }
  1054. }
  1055. }
  1056. ?// Decompiled with JetBrains decompiler
  1057. // Type: KairosPlanet.ModuleErrorState
  1058. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1059. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1060. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1061.  
  1062. namespace KairosPlanet
  1063. {
  1064. internal enum ModuleErrorState
  1065. {
  1066. NoError,
  1067. CrashOrNotFoundMainFile,
  1068. ModuleNotInstalledMessage,
  1069. }
  1070. }
  1071. ?// Decompiled with JetBrains decompiler
  1072. // Type: KairosPlanet.Managers.Data.PurchaseManager
  1073. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1074. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1075. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1076.  
  1077. using Inc.Logging;
  1078. using IncMap;
  1079. using KairosPlanet.Managers.Interfaces;
  1080. using KairosPlanet.Properties;
  1081. using System;
  1082. using System.Collections.Generic;
  1083. using System.Collections.ObjectModel;
  1084. using System.Linq;
  1085. using WinApp.Data.Model;
  1086. using WinApp.Managers.Interfaces;
  1087. using WinApp.Module;
  1088. using WinApp.Service.Repository.Interface;
  1089.  
  1090. namespace KairosPlanet.Managers.Data
  1091. {
  1092. public class PurchaseManager : IPurchaseManager
  1093. {
  1094. private ObservableCollection<Purchase> _currentPurchases;
  1095. private bool _needUpdate;
  1096.  
  1097. public ObservableCollection<Purchase> Purchases
  1098. {
  1099. get
  1100. {
  1101. if (this._currentPurchases == null)
  1102. this._currentPurchases = new ObservableCollection<Purchase>();
  1103. if (this._needUpdate)
  1104. this.UpdatePurchases();
  1105. return this._currentPurchases;
  1106. }
  1107. }
  1108.  
  1109. public PurchaseManager()
  1110. {
  1111. this._needUpdate = true;
  1112. }
  1113.  
  1114. public void UpdatePurchases()
  1115. {
  1116. Purchase[] purchases = Map.Get<ISessionManager>().GetPurchases();
  1117. if (purchases == null)
  1118. {
  1119. Logger.WriteWarning((object) this, "UpdatePurchases()", "Purchases is not loaded");
  1120. }
  1121. else
  1122. {
  1123. this._needUpdate = false;
  1124. Logger.WriteInfo((object) this, "UpdatePurchases()", "Loaded purchases count: " + (object) purchases.Length);
  1125. List<Purchase> list = Enumerable.ToList<Purchase>((IEnumerable<Purchase>) purchases);
  1126. int count = list.Count;
  1127. foreach (Purchase purchase in list)
  1128. Logger.WriteInfo((object) this, "UpdatePurchases", string.Format("UpdatePurchases(): purchase: ProductId='{0}', PackageStatus='{1}', Status='{2}'", (object) purchase.ProductId, (object) purchase.PackageStatus, (object) purchase.Status));
  1129. foreach (Purchase purchase in list)
  1130. {
  1131. if (!this.Purchases.Contains(purchase))
  1132. this.Purchases.Add(purchase);
  1133. else
  1134. this.Purchases[this.Purchases.IndexOf(purchase)] = purchase;
  1135. }
  1136. }
  1137. }
  1138.  
  1139. [Obsolete]
  1140. public Purchase[] GetNewPurchases()
  1141. {
  1142. Purchase[] purchases = Map.Get<ISessionManager>().GetPurchases();
  1143. if (purchases == null)
  1144. {
  1145. Logger.WriteWarning((object) this, "GetNewPurchases()", "Purchases is not loaded");
  1146. return (Purchase[]) null;
  1147. }
  1148. Logger.WriteInfo((object) this, "GetNewPurchases()", "Loaded purchases count: " + (object) purchases.Length);
  1149. Purchase[] purchaseArray = Enumerable.ToArray<Purchase>(Enumerable.Where<Purchase>((IEnumerable<Purchase>) purchases, (Func<Purchase, bool>) (x => !this.Purchases.Contains(x))));
  1150. if (purchaseArray.Length <= 0)
  1151. return new Purchase[0];
  1152. return purchaseArray;
  1153. }
  1154.  
  1155. public bool ActivateModule(Purchase purchase)
  1156. {
  1157. try
  1158. {
  1159. if (purchase == null)
  1160. {
  1161. Logger.WriteError((object) this, "ActivateInstalledModule", "Exit from action of activation: purchase is null");
  1162. return false;
  1163. }
  1164. Logger.WriteInfo((object) this, "ActivateInstalledModule", "Start action of activation");
  1165. IModuleResolver moduleResolver = Map.Get<IModuleResolver>();
  1166. ModuleInfo moduleInfo = Map.Get<IModuleResolver>().GetModuleInfo(purchase.ProductId);
  1167. IModuleManager moduleManager = moduleResolver.GetModuleManager(moduleInfo);
  1168. if (moduleManager == null)
  1169. {
  1170. Logger.WriteError((object) this, "ActivateInstalledModule", "Exit from action of activation: module manager is empty");
  1171. return false;
  1172. }
  1173. Module moduleByProductId = Map.Get<IModuleRepository>().GetModuleByProductId(purchase.ProductId);
  1174. if (moduleByProductId.StateEnum != ModuleState.Installed && moduleByProductId.StateEnum != ModuleState.InstalledAndActivated)
  1175. {
  1176. Logger.WriteError((object) this, "ActivateInstalledModule", "Exit from action of activation: install for module not executed");
  1177. return false;
  1178. }
  1179. Logger.WriteInfo((object) this, "ActivateInstalledModule", "Start activation on server");
  1180. string str = Map.Get<ISessionManager>().Activation(purchase.Id);
  1181. if (string.IsNullOrEmpty(str))
  1182. {
  1183. Logger.WriteError((object) this, "ActivateInstalledModule", "Exit from action of activation: security key is not received");
  1184. Map.Get<IScreenManager>().ShowStatusMessage(Resources.ActivationError_TryReinstallModule, 5, false);
  1185. return false;
  1186. }
  1187. moduleManager.SetSecurityKey(str, purchase.ProductId, purchase.Id, (IModuleCallback) moduleResolver);
  1188. Logger.WriteInfo((object) this, "ActivateInstalledModule", "Activation on server executed");
  1189. moduleByProductId.StateEnum = ModuleState.InstalledAndActivated;
  1190. Map.Get<IModuleRepository>().Save(moduleByProductId);
  1191. Logger.WriteInfo((object) this, "ActivateInstalledModule", string.Format(Resources.ScreenManager_ModuleInstalled, (object) purchase.ProductId));
  1192. return true;
  1193. }
  1194. catch (Exception ex)
  1195. {
  1196. Logger.WriteError((object) this, "ModuleInstalled", "Activate module after install for product with Id = '" + (object) purchase.ProductId + "' error:", ex);
  1197. throw;
  1198. }
  1199. }
  1200. }
  1201. }
  1202. ?// Decompiled with JetBrains decompiler
  1203. // Type: KairosPlanet.Managers.StatisticManager
  1204. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1205. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1206. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1207.  
  1208. using IncMap;
  1209. using System;
  1210. using System.Collections.Generic;
  1211. using System.Linq;
  1212. using WinApp.Api.Data;
  1213. using WinApp.Managers.Interfaces;
  1214.  
  1215. namespace KairosPlanet.Managers
  1216. {
  1217. public class StatisticManager
  1218. {
  1219. private static object _lockObject = new object();
  1220. private int _refreshStatisticminutsInterval = 10;
  1221. private static StatisticManager _instance;
  1222. private Statistic[] _cachedStatistics;
  1223. private DateTime? _gettedStatisticsDate;
  1224.  
  1225. public static StatisticManager Instance
  1226. {
  1227. get
  1228. {
  1229. if (StatisticManager._instance == null)
  1230. {
  1231. lock (StatisticManager._lockObject)
  1232. {
  1233. if (StatisticManager._instance == null)
  1234. StatisticManager._instance = new StatisticManager();
  1235. }
  1236. }
  1237. return StatisticManager._instance;
  1238. }
  1239. }
  1240.  
  1241. private StatisticManager()
  1242. {
  1243. }
  1244.  
  1245. public void SetNeedRefreshStatistics()
  1246. {
  1247. lock (StatisticManager._lockObject)
  1248. {
  1249. this._cachedStatistics = (Statistic[]) null;
  1250. this._gettedStatisticsDate = new DateTime?();
  1251. }
  1252. }
  1253.  
  1254. public Statistic[] GetStatistics()
  1255. {
  1256. if (!this._gettedStatisticsDate.HasValue || this._gettedStatisticsDate.Value.Subtract(DateTime.Now).Minutes > this._refreshStatisticminutsInterval)
  1257. {
  1258. lock (StatisticManager._lockObject)
  1259. {
  1260. if (this._gettedStatisticsDate.HasValue)
  1261. {
  1262. if (this._gettedStatisticsDate.Value.Subtract(DateTime.Now).Minutes <= this._refreshStatisticminutsInterval)
  1263. goto label_6;
  1264. }
  1265. this._cachedStatistics = Map.Get<ISessionManager>().GetStatistics();
  1266. this._gettedStatisticsDate = this._cachedStatistics == null ? new DateTime?() : new DateTime?(DateTime.Now);
  1267. }
  1268. }
  1269. label_6:
  1270. return this._cachedStatistics;
  1271. }
  1272.  
  1273. public Statistic[] GetStatistics(DateTime periodStart, DateTime periodEnd)
  1274. {
  1275. return Enumerable.ToArray<Statistic>(Enumerable.Where<Statistic>((IEnumerable<Statistic>) this.GetStatistics(), (Func<Statistic, bool>) (s =>
  1276. {
  1277. if (s.CreatedDate >= periodStart)
  1278. return s.CreatedDate.AddSeconds((double) s.Lifetime) <= periodEnd;
  1279. return false;
  1280. })));
  1281. }
  1282. }
  1283. }
  1284. ?// Decompiled with JetBrains decompiler
  1285. // Type: KairosPlanet.Managers.Interfaces.IPurchaseManager
  1286. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1287. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1288. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1289.  
  1290. using System;
  1291. using System.Collections.ObjectModel;
  1292. using WinApp.Data.Model;
  1293.  
  1294. namespace KairosPlanet.Managers.Interfaces
  1295. {
  1296. internal interface IPurchaseManager
  1297. {
  1298. ObservableCollection<Purchase> Purchases { get; }
  1299.  
  1300. void UpdatePurchases();
  1301.  
  1302. [Obsolete]
  1303. Purchase[] GetNewPurchases();
  1304.  
  1305. bool ActivateModule(Purchase purchase);
  1306. }
  1307. }
  1308. ?// Decompiled with JetBrains decompiler
  1309. // Type: KairosPlanet.Managers.Network.SessionMonitor
  1310. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1311. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1312. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1313.  
  1314. using Inc.Logging;
  1315. using IncMap;
  1316. using KairosPlanet;
  1317. using KairosPlanet.Managers.Interfaces;
  1318. using KairosPlanet.Properties;
  1319. using System;
  1320. using System.Collections.Generic;
  1321. using System.Linq;
  1322. using System.Timers;
  1323. using WinApp;
  1324. using WinApp.Api;
  1325. using WinApp.Api.Data;
  1326. using WinApp.Data.Model;
  1327. using WinApp.Managers;
  1328. using WinApp.Managers.Interfaces;
  1329. using WinApp.Managers.Network;
  1330. using WinApp.Service.Repository.Interface;
  1331. using WinApp.Tray.RichNotifyIcon;
  1332. using WinApp.ViewModel;
  1333.  
  1334. namespace KairosPlanet.Managers.Network
  1335. {
  1336. public class SessionMonitor
  1337. {
  1338. private static SessionMonitor _instance = new SessionMonitor();
  1339. private static bool _showedTrayMessage = false;
  1340. private SessionState _sessionState;
  1341. private Timer _sessionMonitorTimer;
  1342. private string _activeModuleSecureKey;
  1343. private bool _secondAttempt;
  1344.  
  1345. public static SessionMonitor Instance
  1346. {
  1347. get
  1348. {
  1349. return SessionMonitor._instance;
  1350. }
  1351. }
  1352.  
  1353. public PingResponse FirstSessionPing { get; set; }
  1354.  
  1355. internal SessionState SessionState
  1356. {
  1357. get
  1358. {
  1359. return this._sessionState;
  1360. }
  1361. private set
  1362. {
  1363. if (this._sessionState == value)
  1364. return;
  1365. this._sessionState = value;
  1366. Logger.WriteInfo((object) this, "SessionState", "SessionState changed status on '" + (object) this._sessionState + "'");
  1367. if (this.SessionStateChanged == null)
  1368. return;
  1369. this.SessionStateChanged((object) this, new SessionStateEventArgs(value));
  1370. }
  1371. }
  1372.  
  1373. internal event EventHandler<SessionStateEventArgs> SessionStateChanged;
  1374.  
  1375. internal event SessionMonitor.PingEventHandler PingEvent;
  1376.  
  1377. private SessionMonitor()
  1378. {
  1379. }
  1380.  
  1381. public bool PingSession()
  1382. {
  1383. try
  1384. {
  1385. PingResponse pingResponse = Map.Get<ISessionManager>().PingSession(this._activeModuleSecureKey);
  1386. if (pingResponse != null)
  1387. this.InvokePingEvent(pingResponse.Lifetime);
  1388. if (pingResponse != null)
  1389. this.FirstSessionPing = pingResponse;
  1390. return pingResponse != null;
  1391. }
  1392. catch (ApiException ex)
  1393. {
  1394. if (string.Equals(ex.StatusDescription, "Secret key not found"))
  1395. this.TryGetNewSecureKey();
  1396. else
  1397. Logger.WriteError((object) this, "PingSession()", "Error during operation Ping on SessionMonitor", (Exception) ex);
  1398. return false;
  1399. }
  1400. catch (Exception ex)
  1401. {
  1402. Logger.WriteError((object) this, "PingSession()", "Error during operation Ping on SessionMonitor", ex);
  1403. return false;
  1404. }
  1405. }
  1406.  
  1407. public void InvokePingEvent(long lifeTime)
  1408. {
  1409. if (this.PingEvent == null)
  1410. return;
  1411. this.PingEvent((object) this, new PingEventArgs(lifeTime));
  1412. }
  1413.  
  1414. internal void SetSessionStateToLogon()
  1415. {
  1416. NetworkMonitor.NetworkStateChanged -= new EventHandler<NetworkStateEventArgs>(this.OnNetworkStateChanged);
  1417. NetworkMonitor.NetworkStateChanged += new EventHandler<NetworkStateEventArgs>(this.OnNetworkStateChanged);
  1418. if (Map.Get<ISessionManager>().CurrentUser != null)
  1419. {
  1420. this.SessionState = SessionState.LogOn;
  1421. this.TryChangeStateToAccrual();
  1422. }
  1423. else
  1424. {
  1425. Logger.WriteInfo((object) this, "SetSessionStateToLogon()", "??????? ?????? ?? ???? ??????? ? ????????? LogOn, ??? ??? ???????????? ???????????");
  1426. this.SessionState = SessionState.LogOff;
  1427. }
  1428. }
  1429.  
  1430. internal void SetSessionStateToSuspended()
  1431. {
  1432. this.SessionState = SessionState.Suspended;
  1433. NetworkMonitor.CheckServerOn(true);
  1434. }
  1435.  
  1436. private static bool GetPackageModuleIsActive()
  1437. {
  1438. if (!AppVM.Instance.ActivePackageId.HasValue)
  1439. return false;
  1440. Module moduleByProductId = Map.Get<IModuleRepository>().GetModuleByProductId(AppVM.Instance.ActivePackageId.Value);
  1441. return moduleByProductId != null && moduleByProductId.StateEnum == ModuleState.InstalledAndActivated;
  1442. }
  1443.  
  1444. private void TryChangeStateToAccrual()
  1445. {
  1446. if (!AppVM.Instance.ActivePackageId.HasValue || AppVM.Instance.ActivePackageId.Value == 0L)
  1447. {
  1448. Logger.WriteWarning((object) this, "CheckActivePackageToAccrual", "??????? ??? ??????????? ?????????? ?? ???????????. ??? ????????? ??????.");
  1449. AppVM.Instance.ModuleErrorState = ModuleErrorState.ModuleNotInstalledMessage;
  1450. if (SessionMonitor._showedTrayMessage)
  1451. return;
  1452. ((TaskbarIcon) Map.Get<IAppTray>()).ShowBalloonTip(Resources.Tray_NotificationTitle, Resources.Tray_ModuleNotInstalledMessage, BalloonIcon.Info);
  1453. SessionMonitor._showedTrayMessage = true;
  1454. }
  1455. else
  1456. {
  1457. this.SessionState = SessionState.Suspended;
  1458. if (!SessionMonitor.GetPackageModuleIsActive())
  1459. {
  1460. Logger.WriteError((object) this, "CheckActivePackageToAccrual", "Ping not execute. The package module is not active or not installed");
  1461. AppVM.Instance.ModuleErrorState = ModuleErrorState.ModuleNotInstalledMessage;
  1462. if (SessionMonitor._showedTrayMessage)
  1463. return;
  1464. ((TaskbarIcon) Map.Get<IAppTray>()).ShowBalloonTip(Resources.Tray_NotificationTitle, Resources.Tray_ModuleNotInstalledMessage, BalloonIcon.Info);
  1465. SessionMonitor._showedTrayMessage = true;
  1466. }
  1467. else
  1468. {
  1469. this._activeModuleSecureKey = Map.Get<IModuleResolver>().GetActiveModuleSecureKey();
  1470. if (string.IsNullOrEmpty(this._activeModuleSecureKey))
  1471. {
  1472. Logger.WriteError((object) this, "CheckActivePackageToAccrual", "Ping not execute. The secure key not exists");
  1473. AppVM.Instance.ModuleErrorState = ModuleErrorState.CrashOrNotFoundMainFile;
  1474. if (SessionMonitor._showedTrayMessage)
  1475. return;
  1476. ((TaskbarIcon) Map.Get<IAppTray>()).ShowBalloonTip(Resources.Tray_NotificationTitle, Resources.Tray_ModuleCrashOrNotFoundMainFiledMessage, BalloonIcon.Info);
  1477. SessionMonitor._showedTrayMessage = true;
  1478. }
  1479. else
  1480. {
  1481. AppVM.Instance.ModuleErrorState = ModuleErrorState.NoError;
  1482. this.CheckSessionPing();
  1483. }
  1484. }
  1485. }
  1486. }
  1487.  
  1488. private bool TryGetNewSecureKey()
  1489. {
  1490. if (!AppVM.Instance.ActivePackageId.HasValue)
  1491. return false;
  1492. try
  1493. {
  1494. long productId = AppVM.Instance.ActivePackageId.Value;
  1495. IScreenManager screenManager = Map.Get<IScreenManager>();
  1496. screenManager.DoVisualSafe(screenManager.ShowStatusMessage(Resources.StatusMessage_TryActivateKeyRefresh, 5, false));
  1497. Logger.WriteInfo((object) this, "TryGetNewSecureKey", "??????? ????????? ?????? ????? ????????? ?? ???????? ? ID = " + (object) productId);
  1498. DateTime? lastTime = Enumerable.Max<Purchase, DateTime?>(Enumerable.Where<Purchase>((IEnumerable<Purchase>) Map.Get<IPurchaseManager>().Purchases, (Func<Purchase, bool>) (x => x.ProductId == productId)), (Func<Purchase, DateTime?>) (x => x.Date));
  1499. if (Map.Get<IPurchaseManager>().ActivateModule(Enumerable.SingleOrDefault<Purchase>((IEnumerable<Purchase>) Map.Get<IPurchaseManager>().Purchases, (Func<Purchase, bool>) (x =>
  1500. {
  1501. if (x.ProductId != productId)
  1502. return false;
  1503. DateTime? date = x.Date;
  1504. DateTime? nullable = lastTime;
  1505. if (date.HasValue != nullable.HasValue)
  1506. return false;
  1507. if (date.HasValue)
  1508. return date.GetValueOrDefault() == nullable.GetValueOrDefault();
  1509. return true;
  1510. }))))
  1511. {
  1512. this._activeModuleSecureKey = Map.Get<IModuleResolver>().GetActiveModuleSecureKey();
  1513. return true;
  1514. }
  1515. Logger.WriteError((object) this, "CheckActivePackageToAccrual", "Ping not execute. The secure key not exists");
  1516. AppVM.Instance.ModuleErrorState = ModuleErrorState.CrashOrNotFoundMainFile;
  1517. if (!SessionMonitor._showedTrayMessage)
  1518. {
  1519. ((TaskbarIcon) Map.Get<IAppTray>()).ShowBalloonTip(Resources.Tray_NotificationTitle, Resources.Tray_ModuleCrashOrNotFoundMainFiledMessage, BalloonIcon.Info);
  1520. SessionMonitor._showedTrayMessage = true;
  1521. }
  1522. return false;
  1523. }
  1524. catch (Exception ex)
  1525. {
  1526. Logger.WriteError((object) this, "TryGetNewSecureKey", "?????? ??? ?????????? ????? ?????????: " + ex.Message);
  1527. return false;
  1528. }
  1529. }
  1530.  
  1531. private void CheckSessionPing()
  1532. {
  1533. bool flag = false;
  1534. if (this.PingSession())
  1535. {
  1536. this._secondAttempt = false;
  1537. flag = this.SessionState != SessionState.InAccrual;
  1538. this.SessionState = SessionState.InAccrual;
  1539. NetworkMonitor.CheckServerOff();
  1540. }
  1541. else if (this._secondAttempt)
  1542. this.SetSessionStateToSuspended();
  1543. else
  1544. this._secondAttempt = true;
  1545. this.StartSessionMonitorTimer(this._secondAttempt || flag);
  1546. }
  1547.  
  1548. private void StartSessionMonitorTimer(bool shortInterval)
  1549. {
  1550. if (this._sessionMonitorTimer == null)
  1551. {
  1552. this._sessionMonitorTimer = new Timer(30000.0);
  1553. this._sessionMonitorTimer.Elapsed += new ElapsedEventHandler(this.OnSessionMonitorTimerTick);
  1554. Logger.WriteInfo(typeof (NetworkMonitor), "StartSessionMonitorTimer()", "??????? ?????? ????? ??????");
  1555. }
  1556. else
  1557. this._sessionMonitorTimer.Interval = shortInterval ? 30000.0 : 180000.0;
  1558. this._sessionMonitorTimer.Start();
  1559. }
  1560.  
  1561. private void OnSessionMonitorTimerTick(object sender, ElapsedEventArgs e)
  1562. {
  1563. this._sessionMonitorTimer.Stop();
  1564. this.CheckSessionPing();
  1565. }
  1566.  
  1567. private void OnNetworkStateChanged(object sender, NetworkStateEventArgs e)
  1568. {
  1569. if (e.State != NetworkState.ServerOnline)
  1570. return;
  1571. Logger.WriteInfo((object) this, "OnNetworkStateChanged()", "???? ? ?????? Online");
  1572. this.SetSessionStateToLogon();
  1573. }
  1574.  
  1575. public delegate void PingEventHandler(object sender, PingEventArgs e);
  1576. }
  1577. }
  1578. ?// Decompiled with JetBrains decompiler
  1579. // Type: KairosPlanet.Managers.Network.SessionState
  1580. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1581. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1582. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1583.  
  1584. namespace KairosPlanet.Managers.Network
  1585. {
  1586. internal enum SessionState
  1587. {
  1588. LogOff,
  1589. LogOn,
  1590. Suspended,
  1591. InAccrual,
  1592. }
  1593. }
  1594. ?// Decompiled with JetBrains decompiler
  1595. // Type: KairosPlanet.Managers.Network.SessionStateEventArgs
  1596. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1597. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1598. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1599.  
  1600. using System;
  1601.  
  1602. namespace KairosPlanet.Managers.Network
  1603. {
  1604. internal class SessionStateEventArgs : EventArgs
  1605. {
  1606. public SessionState State { get; private set; }
  1607.  
  1608. public SessionStateEventArgs(SessionState state)
  1609. {
  1610. this.State = state;
  1611. }
  1612. }
  1613. }
  1614. ?// Decompiled with JetBrains decompiler
  1615. // Type: KairosPlanet.Managers.Localization.UnifyCultureInfo
  1616. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1617. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1618. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1619.  
  1620. using System.Globalization;
  1621.  
  1622. namespace KairosPlanet.Managers.Localization
  1623. {
  1624. public class UnifyCultureInfo : CultureInfo
  1625. {
  1626. public override DateTimeFormatInfo DateTimeFormat
  1627. {
  1628. get
  1629. {
  1630. DateTimeFormatInfo dateTimeFormat = base.DateTimeFormat;
  1631. dateTimeFormat.ShortDatePattern = "yyyy-MM-dd";
  1632. return dateTimeFormat;
  1633. }
  1634. set
  1635. {
  1636. base.DateTimeFormat = value;
  1637. }
  1638. }
  1639.  
  1640. public UnifyCultureInfo(string name)
  1641. : base(name)
  1642. {
  1643. }
  1644.  
  1645. public UnifyCultureInfo(string name, bool useUserOverride)
  1646. : base(name, useUserOverride)
  1647. {
  1648. }
  1649.  
  1650. public UnifyCultureInfo(int culture)
  1651. : base(culture)
  1652. {
  1653. }
  1654.  
  1655. public UnifyCultureInfo(int culture, bool useUserOverride)
  1656. : base(culture, useUserOverride)
  1657. {
  1658. }
  1659. }
  1660. }
  1661. ?// Decompiled with JetBrains decompiler
  1662. // Type: KairosPlanet.ViewModel.Services.RtfReplaseser
  1663. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1664. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1665. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1666.  
  1667. using System.Collections.Generic;
  1668. using System.Text;
  1669.  
  1670. namespace KairosPlanet.ViewModel.Services
  1671. {
  1672. public class RtfReplaseser
  1673. {
  1674. private static string _open = "<%";
  1675. private static string _close = "%>";
  1676. private bool _pasteSpase = true;
  1677. private string _inStr;
  1678. private StringBuilder _outStr;
  1679. private Dictionary<string, string> _dictionary;
  1680.  
  1681. private RtfReplaseser()
  1682. {
  1683. }
  1684.  
  1685. public static string Replase(string text, Dictionary<string, string> dictionary)
  1686. {
  1687. return new RtfReplaseser().OnReplase(text, dictionary);
  1688. }
  1689.  
  1690. private void Replace()
  1691. {
  1692. string str = string.Empty;
  1693. string key = string.Empty;
  1694. bool flag = false;
  1695. int index = 0;
  1696. this._outStr = new StringBuilder();
  1697. foreach (char ch in this._inStr)
  1698. {
  1699. if (!flag)
  1700. {
  1701. str += (string) (object) ch;
  1702. key += (string) (object) ch;
  1703. if ((int) RtfReplaseser._open[index] == (int) ch)
  1704. {
  1705. ++index;
  1706. if (RtfReplaseser._open.Length == index)
  1707. {
  1708. flag = true;
  1709. str = string.Empty;
  1710. index = 0;
  1711. }
  1712. }
  1713. else
  1714. {
  1715. this._outStr.Append(key);
  1716. index = 0;
  1717. str = key = string.Empty;
  1718. }
  1719. }
  1720. else
  1721. {
  1722. str += (string) (object) ch;
  1723. key += (string) (object) ch;
  1724. if ((int) ch == 32)
  1725. {
  1726. this._outStr.Append(key);
  1727. index = 0;
  1728. str = key = string.Empty;
  1729. flag = false;
  1730. }
  1731. if ((int) RtfReplaseser._close[index] == (int) ch)
  1732. {
  1733. ++index;
  1734. if (RtfReplaseser._close.Length == index)
  1735. {
  1736. if (this._dictionary.ContainsKey(key))
  1737. this._outStr.Append(this._dictionary[key]);
  1738. else if (!this._pasteSpase)
  1739. this._outStr.Append(key);
  1740. str = key = string.Empty;
  1741. index = 0;
  1742. flag = false;
  1743. }
  1744. }
  1745. }
  1746. }
  1747. }
  1748.  
  1749. private string OnReplase(string text, Dictionary<string, string> dictionary)
  1750. {
  1751. this._inStr = text;
  1752. this._dictionary = dictionary;
  1753. this.Replace();
  1754. return this._outStr.ToString();
  1755. }
  1756. }
  1757. }
  1758. ?// Decompiled with JetBrains decompiler
  1759. // Type: WinApp.View.AppTray
  1760. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1761. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1762. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1763.  
  1764. using System;
  1765. using System.CodeDom.Compiler;
  1766. using System.ComponentModel;
  1767. using System.Diagnostics;
  1768. using System.Drawing;
  1769. using System.Windows;
  1770. using System.Windows.Controls;
  1771. using System.Windows.Markup;
  1772. using WinApp.Managers.Interfaces;
  1773. using WinApp.Tray.RichNotifyIcon;
  1774. using WinApp.ViewModel.Tray;
  1775.  
  1776. namespace WinApp.View
  1777. {
  1778. internal class AppTray : TaskbarIcon, IAppTray, IComponentConnector
  1779. {
  1780. private readonly AppTrayVM _viewModel;
  1781. private bool _contentLoaded;
  1782.  
  1783. public UIElement Tray
  1784. {
  1785. get
  1786. {
  1787. return (UIElement) this;
  1788. }
  1789. }
  1790.  
  1791. public AppTray()
  1792. {
  1793. this.InitializeComponent();
  1794. this.DataContext = (object) (this._viewModel = new AppTrayVM()
  1795. {
  1796. NoLoginContextMenu = (ContextMenu) this.Resources[(object) "NoLoginContextMenu"],
  1797. FullContextMenu = (ContextMenu) this.Resources[(object) "FullContextMenu"]
  1798. });
  1799. }
  1800.  
  1801. ~AppTray()
  1802. {
  1803. this.Visibility = Visibility.Collapsed;
  1804. this.Icon = (Icon) null;
  1805. this.Dispose();
  1806. }
  1807.  
  1808. public void Refresh()
  1809. {
  1810. this._viewModel.Refresh();
  1811. }
  1812.  
  1813. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  1814. [DebuggerNonUserCode]
  1815. public void InitializeComponent()
  1816. {
  1817. if (this._contentLoaded)
  1818. return;
  1819. this._contentLoaded = true;
  1820. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/apptray.xaml", UriKind.Relative));
  1821. }
  1822.  
  1823. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  1824. [DebuggerNonUserCode]
  1825. internal Delegate _CreateDelegate(Type delegateType, string handler)
  1826. {
  1827. return Delegate.CreateDelegate(delegateType, (object) this, handler);
  1828. }
  1829.  
  1830. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  1831. [DebuggerNonUserCode]
  1832. [EditorBrowsable(EditorBrowsableState.Never)]
  1833. void IComponentConnector.Connect(int connectionId, object target)
  1834. {
  1835. this._contentLoaded = true;
  1836. }
  1837. }
  1838. }
  1839. ?// Decompiled with JetBrains decompiler
  1840. // Type: WinApp.View.Base.IWindowArrangeView
  1841. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1842. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1843. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1844.  
  1845. using System.Windows;
  1846.  
  1847. namespace WinApp.View.Base
  1848. {
  1849. public interface IWindowArrangeView
  1850. {
  1851. double WindowHeight { get; }
  1852.  
  1853. double WindowWidth { get; }
  1854.  
  1855. ResizeMode ResizeMode { get; }
  1856. }
  1857. }
  1858. ?// Decompiled with JetBrains decompiler
  1859. // Type: WinApp.View.Base.WindowCommon
  1860. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1861. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1862. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1863.  
  1864. using System.Windows;
  1865. using System.Windows.Controls;
  1866. using System.Windows.Data;
  1867. using System.Windows.Media;
  1868. using Telerik.Windows.Controls;
  1869.  
  1870. namespace WinApp.View.Base
  1871. {
  1872. internal class WindowCommon : RadWindow
  1873. {
  1874. public static readonly DependencyProperty TaskbarIconProperty = DependencyProperty.Register("TaskbarIcon", typeof (ImageSource), typeof (WindowCommon), new PropertyMetadata((object) null));
  1875. private Window _parentWindow;
  1876.  
  1877. public ImageSource TaskbarIcon
  1878. {
  1879. get
  1880. {
  1881. return (ImageSource) ((DependencyObject) this).GetValue(WindowCommon.TaskbarIconProperty);
  1882. }
  1883. set
  1884. {
  1885. ((DependencyObject) this).SetValue(WindowCommon.TaskbarIconProperty, (object) value);
  1886. }
  1887. }
  1888.  
  1889. public Window ParentWindow
  1890. {
  1891. get
  1892. {
  1893. if (this._parentWindow == null)
  1894. {
  1895. this._parentWindow = (Window) ParentOfTypeExtensions.ParentOfType<Window>((DependencyObject) this);
  1896. if (this._parentWindow == null)
  1897. return (Window) null;
  1898. this._parentWindow.SetBinding(FrameworkElement.DataContextProperty, (BindingBase) new Binding("DataContext")
  1899. {
  1900. Source = (object) this
  1901. });
  1902. BindingExpression bindingExpression = ((FrameworkElement) this).GetBindingExpression(HeaderedContentControl.HeaderProperty);
  1903. if (bindingExpression != null)
  1904. this._parentWindow.SetBinding(Window.TitleProperty, (BindingBase) bindingExpression.ParentBinding);
  1905. else
  1906. this._parentWindow.SetValue(Window.TitleProperty, ((HeaderedContentControl) this).Header);
  1907. this._parentWindow.SetBinding(Window.IconProperty, (BindingBase) new Binding("TaskbarIcon")
  1908. {
  1909. Source = (object) this
  1910. });
  1911. }
  1912. return this._parentWindow;
  1913. }
  1914. }
  1915.  
  1916. protected bool ShowInTaskbar
  1917. {
  1918. get
  1919. {
  1920. if (this.ParentWindow == null)
  1921. return false;
  1922. return this.ParentWindow.ShowInTaskbar;
  1923. }
  1924. set
  1925. {
  1926. if (this.ParentWindow == null)
  1927. return;
  1928. this.ParentWindow.ShowInTaskbar = value;
  1929. }
  1930. }
  1931.  
  1932. public WindowCommon()
  1933. {
  1934. base.\u002Ector();
  1935. ((FrameworkElement) this).Loaded += new RoutedEventHandler(this.OnLoaded);
  1936. }
  1937.  
  1938. protected virtual void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
  1939. {
  1940. this.ShowInTaskbar = true;
  1941. }
  1942. }
  1943. }
  1944. ?// Decompiled with JetBrains decompiler
  1945. // Type: WinApp.View.MainViewUC
  1946. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  1947. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  1948. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  1949.  
  1950. using System;
  1951. using System.CodeDom.Compiler;
  1952. using System.ComponentModel;
  1953. using System.Diagnostics;
  1954. using System.Windows;
  1955. using System.Windows.Controls;
  1956. using System.Windows.Markup;
  1957. using Telerik.Windows.Controls;
  1958. using WinApp.View.Base;
  1959. using WinApp.ViewModel;
  1960.  
  1961. namespace WinApp.View
  1962. {
  1963. internal class MainViewUC : UserControl, IWindowArrangeView, IComponentConnector
  1964. {
  1965. private readonly MainViewVM _viewModel;
  1966. internal RadTreeView Menu;
  1967. internal FlowDocumentScrollViewer ErrorBox;
  1968. private bool _contentLoaded;
  1969.  
  1970. public MainViewVM ViewModel
  1971. {
  1972. get
  1973. {
  1974. return this._viewModel;
  1975. }
  1976. }
  1977.  
  1978. public double WindowHeight
  1979. {
  1980. get
  1981. {
  1982. return 600.0;
  1983. }
  1984. }
  1985.  
  1986. public double WindowWidth
  1987. {
  1988. get
  1989. {
  1990. return 1000.0;
  1991. }
  1992. }
  1993.  
  1994. public ResizeMode ResizeMode
  1995. {
  1996. get
  1997. {
  1998. return ResizeMode.CanResize;
  1999. }
  2000. }
  2001.  
  2002. public MainViewUC()
  2003. {
  2004. this.InitializeComponent();
  2005. this.DataContext = (object) (this._viewModel = new MainViewVM(this));
  2006. }
  2007.  
  2008. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2009. [DebuggerNonUserCode]
  2010. public void InitializeComponent()
  2011. {
  2012. if (this._contentLoaded)
  2013. return;
  2014. this._contentLoaded = true;
  2015. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/mainviewuc.xaml", UriKind.Relative));
  2016. }
  2017.  
  2018. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2019. [DebuggerNonUserCode]
  2020. [EditorBrowsable(EditorBrowsableState.Never)]
  2021. void IComponentConnector.Connect(int connectionId, object target)
  2022. {
  2023. switch (connectionId)
  2024. {
  2025. case 1:
  2026. this.Menu = (RadTreeView) target;
  2027. break;
  2028. case 2:
  2029. this.ErrorBox = (FlowDocumentScrollViewer) target;
  2030. break;
  2031. default:
  2032. this._contentLoaded = true;
  2033. break;
  2034. }
  2035. }
  2036. }
  2037. }
  2038. ?// Decompiled with JetBrains decompiler
  2039. // Type: WinApp.View.LoginUC
  2040. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2041. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2042. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2043.  
  2044. using System;
  2045. using System.CodeDom.Compiler;
  2046. using System.ComponentModel;
  2047. using System.Diagnostics;
  2048. using System.Windows;
  2049. using System.Windows.Controls;
  2050. using System.Windows.Markup;
  2051. using Telerik.Windows.Controls;
  2052. using WinApp.View.Base;
  2053. using WinApp.ViewModel;
  2054.  
  2055. namespace WinApp.View
  2056. {
  2057. internal class LoginUC : UserControl, IWindowArrangeView, IComponentConnector
  2058. {
  2059. internal RadWatermarkTextBox LoginBox;
  2060. private bool _contentLoaded;
  2061.  
  2062. public double WindowHeight
  2063. {
  2064. get
  2065. {
  2066. return 500.0;
  2067. }
  2068. }
  2069.  
  2070. public double WindowWidth
  2071. {
  2072. get
  2073. {
  2074. return 400.0;
  2075. }
  2076. }
  2077.  
  2078. public ResizeMode ResizeMode
  2079. {
  2080. get
  2081. {
  2082. return ResizeMode.CanMinimize;
  2083. }
  2084. }
  2085.  
  2086. public LoginVM ViewModel { get; private set; }
  2087.  
  2088. public LoginUC()
  2089. : this(new LoginVM())
  2090. {
  2091. }
  2092.  
  2093. public LoginUC(LoginVM loginVm)
  2094. {
  2095. this.InitializeComponent();
  2096. this.DataContext = (object) (this.ViewModel = loginVm);
  2097. this.ViewModel.Initialize();
  2098. }
  2099.  
  2100. private void LoginUC_OnLoaded(object sender, RoutedEventArgs e)
  2101. {
  2102. ((UIElement) this.LoginBox).Focus();
  2103. }
  2104.  
  2105. [DebuggerNonUserCode]
  2106. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2107. public void InitializeComponent()
  2108. {
  2109. if (this._contentLoaded)
  2110. return;
  2111. this._contentLoaded = true;
  2112. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/loginuc.xaml", UriKind.Relative));
  2113. }
  2114.  
  2115. [DebuggerNonUserCode]
  2116. [EditorBrowsable(EditorBrowsableState.Never)]
  2117. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2118. void IComponentConnector.Connect(int connectionId, object target)
  2119. {
  2120. switch (connectionId)
  2121. {
  2122. case 1:
  2123. ((FrameworkElement) target).Loaded += new RoutedEventHandler(this.LoginUC_OnLoaded);
  2124. break;
  2125. case 2:
  2126. this.LoginBox = (RadWatermarkTextBox) target;
  2127. break;
  2128. default:
  2129. this._contentLoaded = true;
  2130. break;
  2131. }
  2132. }
  2133. }
  2134. }
  2135. ?// Decompiled with JetBrains decompiler
  2136. // Type: WinApp.View.ChangePasswordUC
  2137. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2138. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2139. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2140.  
  2141. using System;
  2142. using System.CodeDom.Compiler;
  2143. using System.ComponentModel;
  2144. using System.Diagnostics;
  2145. using System.Windows;
  2146. using System.Windows.Controls;
  2147. using System.Windows.Markup;
  2148. using WinApp.ViewModel.Controls;
  2149.  
  2150. namespace WinApp.View
  2151. {
  2152. internal class ChangePasswordUC : UserControl, IComponentConnector
  2153. {
  2154. private bool _contentLoaded;
  2155.  
  2156. public ChangePasswordVM ViewModel { get; private set; }
  2157.  
  2158. public ChangePasswordUC()
  2159. {
  2160. this.InitializeComponent();
  2161. this.DataContext = (object) (this.ViewModel = new ChangePasswordVM());
  2162. }
  2163.  
  2164. [DebuggerNonUserCode]
  2165. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2166. public void InitializeComponent()
  2167. {
  2168. if (this._contentLoaded)
  2169. return;
  2170. this._contentLoaded = true;
  2171. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/changepassworduc.xaml", UriKind.Relative));
  2172. }
  2173.  
  2174. [DebuggerNonUserCode]
  2175. [EditorBrowsable(EditorBrowsableState.Never)]
  2176. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2177. void IComponentConnector.Connect(int connectionId, object target)
  2178. {
  2179. this._contentLoaded = true;
  2180. }
  2181. }
  2182. }
  2183. ?// Decompiled with JetBrains decompiler
  2184. // Type: WinApp.View.SessionHistoryUC
  2185. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2186. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2187. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2188.  
  2189. using System;
  2190. using System.CodeDom.Compiler;
  2191. using System.ComponentModel;
  2192. using System.Diagnostics;
  2193. using System.Windows;
  2194. using System.Windows.Controls;
  2195. using System.Windows.Markup;
  2196. using WinApp.ViewModel.Controls;
  2197.  
  2198. namespace WinApp.View
  2199. {
  2200. internal class SessionHistoryUC : UserControl, IComponentConnector
  2201. {
  2202. private bool _contentLoaded;
  2203.  
  2204. public SessionHistoryVM ViewModel { get; private set; }
  2205.  
  2206. public SessionHistoryUC()
  2207. {
  2208. this.InitializeComponent();
  2209. this.DataContext = (object) (this.ViewModel = new SessionHistoryVM());
  2210. }
  2211.  
  2212. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2213. [DebuggerNonUserCode]
  2214. public void InitializeComponent()
  2215. {
  2216. if (this._contentLoaded)
  2217. return;
  2218. this._contentLoaded = true;
  2219. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/sessionhistoryuc.xaml", UriKind.Relative));
  2220. }
  2221.  
  2222. [DebuggerNonUserCode]
  2223. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2224. [EditorBrowsable(EditorBrowsableState.Never)]
  2225. void IComponentConnector.Connect(int connectionId, object target)
  2226. {
  2227. this._contentLoaded = true;
  2228. }
  2229. }
  2230. }
  2231. ?// Decompiled with JetBrains decompiler
  2232. // Type: WinApp.View.Helpers.TelerikThemeManager
  2233. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2234. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2235. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2236.  
  2237. using Inc.Logging;
  2238. using System.Windows;
  2239. using System.Windows.Media;
  2240. using Telerik.Windows.Controls;
  2241.  
  2242. namespace WinApp.View.Helpers
  2243. {
  2244. internal class TelerikThemeManager : DependencyObject
  2245. {
  2246. public TelerikThemeManager()
  2247. {
  2248. TelerikThemeManager.ApplyTheme();
  2249. }
  2250.  
  2251. public static void ApplyTheme()
  2252. {
  2253. MetroColors.get_PaletteInstance().set_AccentColor(Color.FromArgb(byte.MaxValue, (byte) 61, (byte) 86, (byte) 109));
  2254. MetroColors.get_PaletteInstance().set_StrongColor(Color.FromArgb(byte.MaxValue, (byte) 63, (byte) 63, (byte) 63));
  2255. TelerikThemeManager.ApplyTheme((Theme) new MetroTheme());
  2256. }
  2257.  
  2258. public static void ApplyTheme(Theme theme)
  2259. {
  2260. Logger.WriteInfo(typeof (TelerikThemeManager), "ApplyTheme()", string.Format("?????????? ???? '{0}'...", (object) theme));
  2261. StyleManager.set_ApplicationTheme(theme);
  2262. Logger.WriteInfo(typeof (TelerikThemeManager), "ApplyTheme()", "???? ??????? ?????????");
  2263. }
  2264. }
  2265. }
  2266. ?// Decompiled with JetBrains decompiler
  2267. // Type: WinApp.View.Helpers.WebHelper
  2268. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2269. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2270. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2271.  
  2272. using System;
  2273. using System.IO;
  2274. using System.Net;
  2275. using WinApp.Managers.Configuration;
  2276.  
  2277. namespace WinApp.View.Helpers
  2278. {
  2279. public static class WebHelper
  2280. {
  2281. public static Stream DownloadImage(Uri uri, string savePath)
  2282. {
  2283. HttpWebRequest httpWebRequest = WebRequest.Create(uri) as HttpWebRequest;
  2284. if (httpWebRequest == null)
  2285. return Stream.Null;
  2286. httpWebRequest.UserAgent = ConfigurationManager.GetUserAgent();
  2287. WebResponse response = httpWebRequest.GetResponse();
  2288. using (Stream responseStream = response.GetResponseStream())
  2289. {
  2290. byte[] numArray = new byte[response.ContentLength];
  2291. int offset = 0;
  2292. while (responseStream != null)
  2293. {
  2294. int num = responseStream.Read(numArray, offset, numArray.Length - offset);
  2295. offset += num;
  2296. if (num <= 0)
  2297. {
  2298. string directoryName = Path.GetDirectoryName(savePath);
  2299. if (!Directory.Exists(directoryName))
  2300. Directory.CreateDirectory(directoryName);
  2301. System.IO.File.WriteAllBytes(savePath, numArray);
  2302. return (Stream) new MemoryStream(numArray);
  2303. }
  2304. }
  2305. return Stream.Null;
  2306. }
  2307. }
  2308. }
  2309. }
  2310. ?// Decompiled with JetBrains decompiler
  2311. // Type: WinApp.View.Helpers.PasswordBoxAssistant
  2312. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2313. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2314. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2315.  
  2316. using System.Windows;
  2317. using System.Windows.Controls;
  2318.  
  2319. namespace WinApp.View.Helpers
  2320. {
  2321. public static class PasswordBoxAssistant
  2322. {
  2323. public static readonly DependencyProperty BoundPassword = DependencyProperty.RegisterAttached("BoundPassword", typeof (string), typeof (PasswordBoxAssistant), new PropertyMetadata((object) string.Empty, new PropertyChangedCallback(PasswordBoxAssistant.OnBoundPasswordChanged)));
  2324. public static readonly DependencyProperty BindPassword = DependencyProperty.RegisterAttached("BindPassword", typeof (bool), typeof (PasswordBoxAssistant), new PropertyMetadata((object) false, new PropertyChangedCallback(PasswordBoxAssistant.OnBindPasswordChanged)));
  2325. private static readonly DependencyProperty _updatingPassword = DependencyProperty.RegisterAttached("_updatingPassword", typeof (bool), typeof (PasswordBoxAssistant), new PropertyMetadata((object) false));
  2326.  
  2327. public static void SetBindPassword(DependencyObject dp, bool value)
  2328. {
  2329. dp.SetValue(PasswordBoxAssistant.BindPassword, (object) (bool) (value ? 1 : 0));
  2330. }
  2331.  
  2332. public static bool GetBindPassword(DependencyObject dp)
  2333. {
  2334. return (bool) dp.GetValue(PasswordBoxAssistant.BindPassword);
  2335. }
  2336.  
  2337. public static string GetBoundPassword(DependencyObject dp)
  2338. {
  2339. return (string) dp.GetValue(PasswordBoxAssistant.BoundPassword);
  2340. }
  2341.  
  2342. public static void SetBoundPassword(DependencyObject dp, string value)
  2343. {
  2344. dp.SetValue(PasswordBoxAssistant.BoundPassword, (object) value);
  2345. }
  2346.  
  2347. private static void OnBoundPasswordChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  2348. {
  2349. PasswordBox passwordBox = d as PasswordBox;
  2350. if (d == null || !PasswordBoxAssistant.GetBindPassword(d) || passwordBox == null)
  2351. return;
  2352. passwordBox.PasswordChanged -= new RoutedEventHandler(PasswordBoxAssistant.HandlePasswordChanged);
  2353. string str = (string) e.NewValue;
  2354. if (!PasswordBoxAssistant.GetUpdatingPassword((DependencyObject) passwordBox))
  2355. passwordBox.Password = str;
  2356. passwordBox.PasswordChanged += new RoutedEventHandler(PasswordBoxAssistant.HandlePasswordChanged);
  2357. }
  2358.  
  2359. private static void OnBindPasswordChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)
  2360. {
  2361. PasswordBox passwordBox = dp as PasswordBox;
  2362. if (passwordBox == null)
  2363. return;
  2364. bool flag1 = (bool) e.OldValue;
  2365. bool flag2 = (bool) e.NewValue;
  2366. if (flag1)
  2367. passwordBox.PasswordChanged -= new RoutedEventHandler(PasswordBoxAssistant.HandlePasswordChanged);
  2368. if (!flag2)
  2369. return;
  2370. passwordBox.PasswordChanged += new RoutedEventHandler(PasswordBoxAssistant.HandlePasswordChanged);
  2371. }
  2372.  
  2373. private static void HandlePasswordChanged(object sender, RoutedEventArgs e)
  2374. {
  2375. PasswordBox passwordBox = sender as PasswordBox;
  2376. PasswordBoxAssistant.SetUpdatingPassword((DependencyObject) passwordBox, true);
  2377. if (passwordBox == null)
  2378. return;
  2379. PasswordBoxAssistant.SetBoundPassword((DependencyObject) passwordBox, passwordBox.Password);
  2380. PasswordBoxAssistant.SetUpdatingPassword((DependencyObject) passwordBox, false);
  2381. }
  2382.  
  2383. private static bool GetUpdatingPassword(DependencyObject dp)
  2384. {
  2385. return (bool) dp.GetValue(PasswordBoxAssistant._updatingPassword);
  2386. }
  2387.  
  2388. private static void SetUpdatingPassword(DependencyObject dp, bool value)
  2389. {
  2390. dp.SetValue(PasswordBoxAssistant._updatingPassword, (object) (bool) (value ? 1 : 0));
  2391. }
  2392. }
  2393. }
  2394. ?// Decompiled with JetBrains decompiler
  2395. // Type: WinApp.View.Helpers.CommandBindingExtension
  2396. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2397. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2398. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2399.  
  2400. using System;
  2401. using System.Reflection;
  2402. using System.Windows;
  2403. using System.Windows.Input;
  2404. using System.Windows.Markup;
  2405.  
  2406. namespace WinApp.View.Helpers
  2407. {
  2408. [MarkupExtensionReturnType(typeof (ICommand))]
  2409. public class CommandBindingExtension : MarkupExtension
  2410. {
  2411. private object targetObject;
  2412. private object targetProperty;
  2413. private bool dataContextChangeHandlerSet;
  2414.  
  2415. [ConstructorArgument("commandName")]
  2416. public string CommandName { get; set; }
  2417.  
  2418. public CommandBindingExtension()
  2419. {
  2420. }
  2421.  
  2422. public CommandBindingExtension(string commandName)
  2423. {
  2424. this.CommandName = commandName;
  2425. }
  2426.  
  2427. public override object ProvideValue(IServiceProvider serviceProvider)
  2428. {
  2429. IProvideValueTarget provideValueTarget = serviceProvider.GetService(typeof (IProvideValueTarget)) as IProvideValueTarget;
  2430. if (provideValueTarget != null)
  2431. {
  2432. this.targetObject = provideValueTarget.TargetObject;
  2433. this.targetProperty = provideValueTarget.TargetProperty;
  2434. }
  2435. if (!string.IsNullOrEmpty(this.CommandName))
  2436. {
  2437. ParserContext privateFieldValue1 = this.GetPrivateFieldValue<ParserContext>((object) serviceProvider, "_context");
  2438. if (privateFieldValue1 != null)
  2439. {
  2440. FrameworkElement privateFieldValue2 = this.GetPrivateFieldValue<FrameworkElement>((object) privateFieldValue1, "_rootElement");
  2441. if (privateFieldValue2 != null)
  2442. {
  2443. object dataContext = privateFieldValue2.DataContext;
  2444. if (!this.dataContextChangeHandlerSet)
  2445. {
  2446. privateFieldValue2.DataContextChanged += new DependencyPropertyChangedEventHandler(this.rootElement_DataContextChanged);
  2447. this.dataContextChangeHandlerSet = true;
  2448. }
  2449. if (dataContext != null)
  2450. {
  2451. ICommand command = this.GetCommand(dataContext, this.CommandName);
  2452. if (command != null)
  2453. return (object) command;
  2454. }
  2455. }
  2456. }
  2457. }
  2458. return (object) CommandBindingExtension.DummyCommand.Instance;
  2459. }
  2460.  
  2461. private ICommand GetCommand(object dataContext, string commandName)
  2462. {
  2463. PropertyInfo property = dataContext.GetType().GetProperty(commandName);
  2464. if (property != null)
  2465. {
  2466. ICommand command = property.GetValue(dataContext, (object[]) null) as ICommand;
  2467. if (command != null)
  2468. return command;
  2469. }
  2470. return (ICommand) null;
  2471. }
  2472.  
  2473. private void AssignCommand(ICommand command)
  2474. {
  2475. if (this.targetObject == null || this.targetProperty == null)
  2476. return;
  2477. if (this.targetProperty is DependencyProperty)
  2478. (this.targetObject as DependencyObject).SetValue(this.targetProperty as DependencyProperty, (object) command);
  2479. else
  2480. (this.targetProperty as PropertyInfo).SetValue(this.targetObject, (object) command, (object[]) null);
  2481. }
  2482.  
  2483. private void rootElement_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
  2484. {
  2485. FrameworkElement frameworkElement = sender as FrameworkElement;
  2486. if (frameworkElement == null)
  2487. return;
  2488. object dataContext = frameworkElement.DataContext;
  2489. if (dataContext == null)
  2490. return;
  2491. ICommand command = this.GetCommand(dataContext, this.CommandName);
  2492. if (command == null)
  2493. return;
  2494. this.AssignCommand(command);
  2495. }
  2496.  
  2497. private T GetPrivateFieldValue<T>(object target, string fieldName)
  2498. {
  2499. FieldInfo field = target.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
  2500. if (field != null)
  2501. return (T) field.GetValue(target);
  2502. return default (T);
  2503. }
  2504.  
  2505. private class DummyCommand : ICommand
  2506. {
  2507. private static CommandBindingExtension.DummyCommand _instance;
  2508.  
  2509. public static CommandBindingExtension.DummyCommand Instance
  2510. {
  2511. get
  2512. {
  2513. if (CommandBindingExtension.DummyCommand._instance == null)
  2514. CommandBindingExtension.DummyCommand._instance = new CommandBindingExtension.DummyCommand();
  2515. return CommandBindingExtension.DummyCommand._instance;
  2516. }
  2517. }
  2518.  
  2519. public event EventHandler CanExecuteChanged;
  2520.  
  2521. private DummyCommand()
  2522. {
  2523. }
  2524.  
  2525. public bool CanExecute(object parameter)
  2526. {
  2527. return false;
  2528. }
  2529.  
  2530. public void Execute(object parameter)
  2531. {
  2532. }
  2533. }
  2534. }
  2535. }
  2536. ?// Decompiled with JetBrains decompiler
  2537. // Type: WinApp.View.Helpers.VisualDescendantsExtention
  2538. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2539. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2540. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2541.  
  2542. using System.Collections.Generic;
  2543. using System.Windows;
  2544. using System.Windows.Media;
  2545.  
  2546. namespace WinApp.View.Helpers
  2547. {
  2548. public static class VisualDescendantsExtention
  2549. {
  2550. public static IEnumerable<T> GetVisualDescendants<T>(this DependencyObject depObj) where T : DependencyObject
  2551. {
  2552. if (depObj != null)
  2553. {
  2554. for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); ++i)
  2555. {
  2556. DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
  2557. if (child is T)
  2558. yield return (T) child;
  2559. foreach (T obj in VisualDescendantsExtention.GetVisualDescendants<T>(child))
  2560. yield return obj;
  2561. }
  2562. }
  2563. }
  2564. }
  2565. }
  2566. ?// Decompiled with JetBrains decompiler
  2567. // Type: WinApp.View.PersonalInformationUC
  2568. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2569. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2570. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2571.  
  2572. using IncMap;
  2573. using System;
  2574. using System.CodeDom.Compiler;
  2575. using System.ComponentModel;
  2576. using System.Diagnostics;
  2577. using System.Windows;
  2578. using System.Windows.Controls;
  2579. using System.Windows.Markup;
  2580. using WinApp.Managers.Interfaces;
  2581. using WinApp.ViewModel.Controls;
  2582.  
  2583. namespace WinApp.View
  2584. {
  2585. internal class PersonalInformationUC : UserControl, IComponentConnector
  2586. {
  2587. private bool _contentLoaded;
  2588.  
  2589. public PersonalInformationVM ViewModel { get; private set; }
  2590.  
  2591. public PersonalInformationUC()
  2592. {
  2593. this.InitializeComponent();
  2594. this.DataContext = (object) (this.ViewModel = new PersonalInformationVM(Map.Get<ISessionManager>().CurrentUser));
  2595. }
  2596.  
  2597. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2598. [DebuggerNonUserCode]
  2599. public void InitializeComponent()
  2600. {
  2601. if (this._contentLoaded)
  2602. return;
  2603. this._contentLoaded = true;
  2604. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/personalinformationuc.xaml", UriKind.Relative));
  2605. }
  2606.  
  2607. [DebuggerNonUserCode]
  2608. [EditorBrowsable(EditorBrowsableState.Never)]
  2609. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2610. void IComponentConnector.Connect(int connectionId, object target)
  2611. {
  2612. this._contentLoaded = true;
  2613. }
  2614. }
  2615. }
  2616. ?// Decompiled with JetBrains decompiler
  2617. // Type: WinApp.View.ContactInformationUC
  2618. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2619. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2620. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2621.  
  2622. using IncMap;
  2623. using System;
  2624. using System.CodeDom.Compiler;
  2625. using System.ComponentModel;
  2626. using System.Diagnostics;
  2627. using System.Windows;
  2628. using System.Windows.Controls;
  2629. using System.Windows.Markup;
  2630. using WinApp.Managers.Interfaces;
  2631. using WinApp.ViewModel.Controls;
  2632.  
  2633. namespace WinApp.View
  2634. {
  2635. internal class ContactInformationUC : UserControl, IComponentConnector
  2636. {
  2637. private bool _contentLoaded;
  2638.  
  2639. public ContactInformationVM ViewModel { get; private set; }
  2640.  
  2641. public ContactInformationUC()
  2642. {
  2643. this.InitializeComponent();
  2644. this.DataContext = (object) (this.ViewModel = new ContactInformationVM(Map.Get<ISessionManager>().CurrentUser));
  2645. }
  2646.  
  2647. [DebuggerNonUserCode]
  2648. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2649. public void InitializeComponent()
  2650. {
  2651. if (this._contentLoaded)
  2652. return;
  2653. this._contentLoaded = true;
  2654. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/contactinformationuc.xaml", UriKind.Relative));
  2655. }
  2656.  
  2657. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2658. [DebuggerNonUserCode]
  2659. [EditorBrowsable(EditorBrowsableState.Never)]
  2660. void IComponentConnector.Connect(int connectionId, object target)
  2661. {
  2662. this._contentLoaded = true;
  2663. }
  2664. }
  2665. }
  2666. ?// Decompiled with JetBrains decompiler
  2667. // Type: WinApp.View.ServicesUC
  2668. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2669. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2670. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2671.  
  2672. using System;
  2673. using System.CodeDom.Compiler;
  2674. using System.ComponentModel;
  2675. using System.Diagnostics;
  2676. using System.Linq;
  2677. using System.Windows;
  2678. using System.Windows.Controls;
  2679. using System.Windows.Input;
  2680. using System.Windows.Markup;
  2681. using Telerik.Windows;
  2682. using Telerik.Windows.Controls;
  2683. using WinApp.View.Helpers;
  2684. using WinApp.ViewModel.Controls;
  2685. using WinApp.ViewModel.Services;
  2686.  
  2687. namespace WinApp.View
  2688. {
  2689. internal class ServicesUC : UserControl, IComponentConnector, IStyleConnector
  2690. {
  2691. private readonly ServicesControlVM _viewModel;
  2692. private bool _contentLoaded;
  2693.  
  2694. public ServicesUC()
  2695. {
  2696. this.InitializeComponent();
  2697. this.DataContext = (object) (this._viewModel = new ServicesControlVM());
  2698. }
  2699.  
  2700. private void Service_OnMouseLeftUp(object sender, MouseButtonEventArgs e)
  2701. {
  2702. RadTileViewItem radTileViewItem = sender as RadTileViewItem;
  2703. if (radTileViewItem == null)
  2704. return;
  2705. ServiceVM serviceVm = (ServiceVM) null;
  2706. if (((FrameworkElement) radTileViewItem).DataContext != null)
  2707. serviceVm = ((FrameworkElement) radTileViewItem).DataContext as ServiceVM;
  2708. if (serviceVm == null || !serviceVm.IsEnableMainButton || radTileViewItem.get_TileState() == 1)
  2709. return;
  2710. radTileViewItem.set_TileState((TileViewItemState) 1);
  2711. }
  2712.  
  2713. private void RadTileView_OnTileStateChanged(object sender, RadRoutedEventArgs e)
  2714. {
  2715. RadTileViewItem radTileViewItem = ((RoutedEventArgs) e).Source as RadTileViewItem;
  2716. if (radTileViewItem == null)
  2717. return;
  2718. RadFluidContentControl fluidContentControl = Enumerable.SingleOrDefault<RadFluidContentControl>(VisualDescendantsExtention.GetVisualDescendants<RadFluidContentControl>((DependencyObject) radTileViewItem));
  2719. if (fluidContentControl == null)
  2720. return;
  2721. switch ((int) radTileViewItem.get_TileState())
  2722. {
  2723. case 0:
  2724. fluidContentControl.set_State((FluidContentControlState) 1);
  2725. break;
  2726. case 1:
  2727. fluidContentControl.set_State((FluidContentControlState) 2);
  2728. break;
  2729. case 2:
  2730. fluidContentControl.set_State((FluidContentControlState) 0);
  2731. break;
  2732. }
  2733. }
  2734.  
  2735. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2736. [DebuggerNonUserCode]
  2737. public void InitializeComponent()
  2738. {
  2739. if (this._contentLoaded)
  2740. return;
  2741. this._contentLoaded = true;
  2742. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/servicesuc.xaml", UriKind.Relative));
  2743. }
  2744.  
  2745. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2746. [DebuggerNonUserCode]
  2747. [EditorBrowsable(EditorBrowsableState.Never)]
  2748. void IComponentConnector.Connect(int connectionId, object target)
  2749. {
  2750. if (connectionId == 1)
  2751. ((RadTileView) target).add_TileStateChanged(new EventHandler<RadRoutedEventArgs>(this.RadTileView_OnTileStateChanged));
  2752. else
  2753. this._contentLoaded = true;
  2754. }
  2755.  
  2756. [DebuggerNonUserCode]
  2757. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2758. [EditorBrowsable(EditorBrowsableState.Never)]
  2759. void IStyleConnector.Connect(int connectionId, object target)
  2760. {
  2761. if (connectionId != 2)
  2762. return;
  2763. ((Style) target).Setters.Add((SetterBase) new EventSetter()
  2764. {
  2765. Event = UIElement.MouseLeftButtonUpEvent,
  2766. Handler = (Delegate) new MouseButtonEventHandler(this.Service_OnMouseLeftUp)
  2767. });
  2768. ((Style) target).Setters.Add((SetterBase) new EventSetter()
  2769. {
  2770. Event = (RoutedEvent) RadTileViewItem.TileStateChangedEvent,
  2771. Handler = (Delegate) new EventHandler<RadRoutedEventArgs>(this.RadTileView_OnTileStateChanged)
  2772. });
  2773. }
  2774. }
  2775. }
  2776. ?// Decompiled with JetBrains decompiler
  2777. // Type: WinApp.View.SettingsUC
  2778. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2779. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2780. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2781.  
  2782. using System;
  2783. using System.CodeDom.Compiler;
  2784. using System.ComponentModel;
  2785. using System.Diagnostics;
  2786. using System.Windows;
  2787. using System.Windows.Controls;
  2788. using System.Windows.Markup;
  2789. using WinApp.ViewModel.Controls;
  2790.  
  2791. namespace WinApp.View
  2792. {
  2793. internal class SettingsUC : UserControl, IComponentConnector
  2794. {
  2795. private bool _contentLoaded;
  2796.  
  2797. public SettingsVM ViewModel { get; private set; }
  2798.  
  2799. public SettingsUC()
  2800. {
  2801. this.InitializeComponent();
  2802. this.DataContext = (object) (this.ViewModel = new SettingsVM());
  2803. }
  2804.  
  2805. [DebuggerNonUserCode]
  2806. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2807. public void InitializeComponent()
  2808. {
  2809. if (this._contentLoaded)
  2810. return;
  2811. this._contentLoaded = true;
  2812. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/settingsuc.xaml", UriKind.Relative));
  2813. }
  2814.  
  2815. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2816. [EditorBrowsable(EditorBrowsableState.Never)]
  2817. [DebuggerNonUserCode]
  2818. void IComponentConnector.Connect(int connectionId, object target)
  2819. {
  2820. this._contentLoaded = true;
  2821. }
  2822. }
  2823. }
  2824. ?// Decompiled with JetBrains decompiler
  2825. // Type: WinApp.View.MainWindow
  2826. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2827. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2828. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2829.  
  2830. using Inc.Logging;
  2831. using IncMap;
  2832. using System;
  2833. using System.CodeDom.Compiler;
  2834. using System.ComponentModel;
  2835. using System.Diagnostics;
  2836. using System.Windows;
  2837. using System.Windows.Controls;
  2838. using System.Windows.Markup;
  2839. using Telerik.Windows.Controls;
  2840. using WinApp.Managers.Interfaces;
  2841. using WinApp.View.Base;
  2842. using WinApp.ViewModel;
  2843.  
  2844. namespace WinApp.View
  2845. {
  2846. internal class MainWindow : WindowCommon, IMainWindow, IComponentConnector
  2847. {
  2848. private WindowState _lastWindowState;
  2849. internal Grid LayoutGrid;
  2850. private bool _contentLoaded;
  2851.  
  2852. public bool CloseToTray { get; set; }
  2853.  
  2854. public MainWindowVM ViewModel { get; private set; }
  2855.  
  2856. public MainWindow()
  2857. {
  2858. this.InitializeComponent();
  2859. ((FrameworkElement) this).DataContext = (object) (this.ViewModel = new MainWindowVM(this));
  2860. this.CloseToTray = true;
  2861. this.LayoutGrid.Children.Add(Map.Get<IAppTray>().Tray);
  2862. }
  2863.  
  2864. public void Open()
  2865. {
  2866. if (((WindowBase) this).get_WindowState() == WindowState.Minimized)
  2867. {
  2868. Logger.WriteInfo(typeof (MainWindow), "Open()", "???????? ?????????? ?? ????");
  2869. this.ShowInTaskbar = true;
  2870. ((UIElement) this).Visibility = Visibility.Visible;
  2871. ((WindowBase) this).set_WindowState(this._lastWindowState != WindowState.Minimized ? this._lastWindowState : WindowState.Normal);
  2872. }
  2873. ((WindowBase) this).BringToFront();
  2874. }
  2875.  
  2876. protected virtual void OnPreviewClosed(WindowPreviewClosedEventArgs e)
  2877. {
  2878. if (!this.CloseToTray)
  2879. return;
  2880. Logger.WriteInfo(typeof (MainWindow), "OnPreviewClosed()", "???????????? ?????????? ? ????");
  2881. e.set_Cancel(new bool?(true));
  2882. this._lastWindowState = ((WindowBase) this).get_WindowState();
  2883. ((WindowBase) this).set_WindowState(WindowState.Minimized);
  2884. ((UIElement) this).Visibility = Visibility.Collapsed;
  2885. this.ShowInTaskbar = false;
  2886. }
  2887.  
  2888. private void Window_Loaded(object sender, RoutedEventArgs e)
  2889. {
  2890. ((MainWindowVM) ((FrameworkElement) this).DataContext).MainWindowLoaded();
  2891. }
  2892.  
  2893. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2894. [DebuggerNonUserCode]
  2895. public void InitializeComponent()
  2896. {
  2897. if (this._contentLoaded)
  2898. return;
  2899. this._contentLoaded = true;
  2900. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/mainwindow.xaml", UriKind.Relative));
  2901. }
  2902.  
  2903. [DebuggerNonUserCode]
  2904. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2905. internal Delegate _CreateDelegate(Type delegateType, string handler)
  2906. {
  2907. return Delegate.CreateDelegate(delegateType, (object) this, handler);
  2908. }
  2909.  
  2910. [DebuggerNonUserCode]
  2911. [EditorBrowsable(EditorBrowsableState.Never)]
  2912. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2913. void IComponentConnector.Connect(int connectionId, object target)
  2914. {
  2915. if (connectionId == 1)
  2916. this.LayoutGrid = (Grid) target;
  2917. else
  2918. this._contentLoaded = true;
  2919. }
  2920.  
  2921. void IMainWindow.Show()
  2922. {
  2923. this.Show();
  2924. }
  2925. }
  2926. }
  2927. ?// Decompiled with JetBrains decompiler
  2928. // Type: WinApp.View.VersionUC
  2929. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  2930. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  2931. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  2932.  
  2933. using System;
  2934. using System.CodeDom.Compiler;
  2935. using System.ComponentModel;
  2936. using System.Diagnostics;
  2937. using System.Windows;
  2938. using System.Windows.Controls;
  2939. using System.Windows.Markup;
  2940. using WinApp.ViewModel.Controls;
  2941.  
  2942. namespace WinApp.View
  2943. {
  2944. public class VersionUC : UserControl, IComponentConnector
  2945. {
  2946. private VersionControlVM _viewModel;
  2947. private bool _contentLoaded;
  2948.  
  2949. public double WindowHeight
  2950. {
  2951. get
  2952. {
  2953. return 400.0;
  2954. }
  2955. }
  2956.  
  2957. public double WindowWidth
  2958. {
  2959. get
  2960. {
  2961. return 400.0;
  2962. }
  2963. }
  2964.  
  2965. public ResizeMode ResizeMode
  2966. {
  2967. get
  2968. {
  2969. return ResizeMode.CanMinimize;
  2970. }
  2971. }
  2972.  
  2973. public VersionUC(Version appVersionOnSite, Version appVersionCurrent)
  2974. {
  2975. this.InitializeComponent();
  2976. this._viewModel = new VersionControlVM(appVersionOnSite, appVersionCurrent);
  2977. this.DataContext = (object) this._viewModel;
  2978. }
  2979.  
  2980. private void Button_Click(object sender, RoutedEventArgs e)
  2981. {
  2982. this._viewModel.ButtonOkClick();
  2983. }
  2984.  
  2985. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2986. [DebuggerNonUserCode]
  2987. public void InitializeComponent()
  2988. {
  2989. if (this._contentLoaded)
  2990. return;
  2991. this._contentLoaded = true;
  2992. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/versionuc.xaml", UriKind.Relative));
  2993. }
  2994.  
  2995. [EditorBrowsable(EditorBrowsableState.Never)]
  2996. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  2997. [DebuggerNonUserCode]
  2998. void IComponentConnector.Connect(int connectionId, object target)
  2999. {
  3000. this._contentLoaded = true;
  3001. }
  3002. }
  3003. }
  3004. ?// Decompiled with JetBrains decompiler
  3005. // Type: WinApp.View.SessionStatisticsUC
  3006. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  3007. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  3008. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  3009.  
  3010. using System;
  3011. using System.CodeDom.Compiler;
  3012. using System.ComponentModel;
  3013. using System.Diagnostics;
  3014. using System.Windows;
  3015. using System.Windows.Controls;
  3016. using System.Windows.Markup;
  3017. using WinApp.ViewModel.Controls;
  3018.  
  3019. namespace WinApp.View
  3020. {
  3021. internal class SessionStatisticsUC : UserControl, IComponentConnector
  3022. {
  3023. private bool _contentLoaded;
  3024.  
  3025. public SessionStatisticsVM ViewModel { get; private set; }
  3026.  
  3027. public SessionStatisticsUC()
  3028. {
  3029. this.InitializeComponent();
  3030. this.DataContext = (object) (this.ViewModel = new SessionStatisticsVM());
  3031. }
  3032.  
  3033. [DebuggerNonUserCode]
  3034. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  3035. public void InitializeComponent()
  3036. {
  3037. if (this._contentLoaded)
  3038. return;
  3039. this._contentLoaded = true;
  3040. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/view/sessionstatisticsuc.xaml", UriKind.Relative));
  3041. }
  3042.  
  3043. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  3044. [EditorBrowsable(EditorBrowsableState.Never)]
  3045. [DebuggerNonUserCode]
  3046. void IComponentConnector.Connect(int connectionId, object target)
  3047. {
  3048. this._contentLoaded = true;
  3049. }
  3050. }
  3051. }
  3052. ?// Decompiled with JetBrains decompiler
  3053. // Type: WinApp.Tray.RichNotifyIcon.RoutedEventHelper
  3054. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  3055. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  3056. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  3057.  
  3058. using System;
  3059. using System.Windows;
  3060.  
  3061. namespace WinApp.Tray.RichNotifyIcon
  3062. {
  3063. internal static class RoutedEventHelper
  3064. {
  3065. internal static void RaiseEvent(DependencyObject target, RoutedEventArgs args)
  3066. {
  3067. if (target is UIElement)
  3068. {
  3069. (target as UIElement).RaiseEvent(args);
  3070. }
  3071. else
  3072. {
  3073. if (!(target is ContentElement))
  3074. return;
  3075. (target as ContentElement).RaiseEvent(args);
  3076. }
  3077. }
  3078.  
  3079. internal static void AddHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
  3080. {
  3081. UIElement uiElement = element as UIElement;
  3082. if (uiElement != null)
  3083. {
  3084. uiElement.AddHandler(routedEvent, handler);
  3085. }
  3086. else
  3087. {
  3088. ContentElement contentElement = element as ContentElement;
  3089. if (contentElement == null)
  3090. return;
  3091. contentElement.AddHandler(routedEvent, handler);
  3092. }
  3093. }
  3094.  
  3095. internal static void RemoveHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
  3096. {
  3097. UIElement uiElement = element as UIElement;
  3098. if (uiElement != null)
  3099. {
  3100. uiElement.RemoveHandler(routedEvent, handler);
  3101. }
  3102. else
  3103. {
  3104. ContentElement contentElement = element as ContentElement;
  3105. if (contentElement == null)
  3106. return;
  3107. contentElement.RemoveHandler(routedEvent, handler);
  3108. }
  3109. }
  3110. }
  3111. }
  3112. ?// Decompiled with JetBrains decompiler
  3113. // Type: WinApp.Tray.RichNotifyIcon.PopupActivationMode
  3114. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  3115. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  3116. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  3117.  
  3118. namespace WinApp.Tray.RichNotifyIcon
  3119. {
  3120. public enum PopupActivationMode
  3121. {
  3122. LeftClick,
  3123. RightClick,
  3124. DoubleClick,
  3125. LeftOrRightClick,
  3126. LeftOrDoubleClick,
  3127. MiddleClick,
  3128. All,
  3129. }
  3130. }
  3131. ?// Decompiled with JetBrains decompiler
  3132. // Type: WinApp.Tray.RichNotifyIcon.TaskbarIcon
  3133. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  3134. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  3135. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  3136.  
  3137. using System;
  3138. using System.ComponentModel;
  3139. using System.Drawing;
  3140. using System.Threading;
  3141. using System.Windows;
  3142. using System.Windows.Controls;
  3143. using System.Windows.Controls.Primitives;
  3144. using System.Windows.Input;
  3145. using System.Windows.Interop;
  3146. using System.Windows.Media;
  3147. using System.Windows.Threading;
  3148. using WinApp.Tray.RichNotifyIcon.Interop;
  3149.  
  3150. namespace WinApp.Tray.RichNotifyIcon
  3151. {
  3152. public class TaskbarIcon : FrameworkElement, IDisposable
  3153. {
  3154. private static readonly DependencyPropertyKey TrayPopupResolvedPropertyKey = DependencyProperty.RegisterReadOnly("TrayPopupResolved", typeof (Popup), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((PropertyChangedCallback) null));
  3155. public static readonly DependencyProperty TrayPopupResolvedProperty = TaskbarIcon.TrayPopupResolvedPropertyKey.DependencyProperty;
  3156. private static readonly DependencyPropertyKey TrayToolTipResolvedPropertyKey = DependencyProperty.RegisterReadOnly("TrayToolTipResolved", typeof (ToolTip), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((PropertyChangedCallback) null));
  3157. public static readonly DependencyProperty TrayToolTipResolvedProperty = TaskbarIcon.TrayToolTipResolvedPropertyKey.DependencyProperty;
  3158. private static readonly DependencyPropertyKey CustomBalloonPropertyKey = DependencyProperty.RegisterReadOnly("CustomBalloon", typeof (Popup), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((PropertyChangedCallback) null));
  3159. public static readonly DependencyProperty CustomBalloonProperty = TaskbarIcon.CustomBalloonPropertyKey.DependencyProperty;
  3160. public static readonly DependencyProperty IconSourceProperty = DependencyProperty.Register("IconSource", typeof (ImageSource), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((object) null, new PropertyChangedCallback(TaskbarIcon.IconSourcePropertyChanged)));
  3161. public static readonly DependencyProperty ToolTipTextProperty = DependencyProperty.Register("ToolTipText", typeof (string), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((object) string.Empty, new PropertyChangedCallback(TaskbarIcon.ToolTipTextPropertyChanged)));
  3162. public static readonly DependencyProperty TrayToolTipProperty = DependencyProperty.Register("TrayToolTip", typeof (UIElement), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((object) null, new PropertyChangedCallback(TaskbarIcon.TrayToolTipPropertyChanged)));
  3163. public static readonly DependencyProperty TrayPopupProperty = DependencyProperty.Register("TrayPopup", typeof (UIElement), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((object) null, new PropertyChangedCallback(TaskbarIcon.TrayPopupPropertyChanged)));
  3164. public static readonly DependencyProperty MenuActivationProperty = DependencyProperty.Register("MenuActivation", typeof (PopupActivationMode), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((object) PopupActivationMode.RightClick));
  3165. public static readonly DependencyProperty PopupActivationProperty = DependencyProperty.Register("PopupActivation", typeof (PopupActivationMode), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((object) PopupActivationMode.LeftClick));
  3166. public static readonly DependencyProperty DoubleClickCommandProperty = DependencyProperty.Register("DoubleClickCommand", typeof (ICommand), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((PropertyChangedCallback) null));
  3167. public static readonly DependencyProperty DoubleClickCommandParameterProperty = DependencyProperty.Register("DoubleClickCommandParameter", typeof (object), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((PropertyChangedCallback) null));
  3168. public static readonly DependencyProperty DoubleClickCommandTargetProperty = DependencyProperty.Register("DoubleClickCommandTarget", typeof (IInputElement), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((PropertyChangedCallback) null));
  3169. public static readonly DependencyProperty LeftClickCommandProperty = DependencyProperty.Register("LeftClickCommand", typeof (ICommand), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((PropertyChangedCallback) null));
  3170. public static readonly DependencyProperty LeftClickCommandParameterProperty = DependencyProperty.Register("LeftClickCommandParameter", typeof (object), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((PropertyChangedCallback) null));
  3171. public static readonly DependencyProperty LeftClickCommandTargetProperty = DependencyProperty.Register("LeftClickCommandTarget", typeof (IInputElement), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((PropertyChangedCallback) null));
  3172. public static readonly RoutedEvent TrayLeftMouseDownEvent = EventManager.RegisterRoutedEvent("TrayLeftMouseDown", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3173. public static readonly RoutedEvent TrayRightMouseDownEvent = EventManager.RegisterRoutedEvent("TrayRightMouseDown", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3174. public static readonly RoutedEvent TrayMiddleMouseDownEvent = EventManager.RegisterRoutedEvent("TrayMiddleMouseDown", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3175. public static readonly RoutedEvent TrayLeftMouseUpEvent = EventManager.RegisterRoutedEvent("TrayLeftMouseUp", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3176. public static readonly RoutedEvent TrayRightMouseUpEvent = EventManager.RegisterRoutedEvent("TrayRightMouseUp", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3177. public static readonly RoutedEvent TrayMiddleMouseUpEvent = EventManager.RegisterRoutedEvent("TrayMiddleMouseUp", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3178. public static readonly RoutedEvent TrayMouseDoubleClickEvent = EventManager.RegisterRoutedEvent("TrayMouseDoubleClick", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3179. public static readonly RoutedEvent TrayMouseMoveEvent = EventManager.RegisterRoutedEvent("TrayMouseMove", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3180. public static readonly RoutedEvent TrayBalloonTipShownEvent = EventManager.RegisterRoutedEvent("TrayBalloonTipShown", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3181. public static readonly RoutedEvent TrayBalloonTipClosedEvent = EventManager.RegisterRoutedEvent("TrayBalloonTipClosed", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3182. public static readonly RoutedEvent TrayBalloonTipClickedEvent = EventManager.RegisterRoutedEvent("TrayBalloonTipClicked", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3183. public static readonly RoutedEvent TrayContextMenuOpenEvent = EventManager.RegisterRoutedEvent("TrayContextMenuOpen", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3184. public static readonly RoutedEvent PreviewTrayContextMenuOpenEvent = EventManager.RegisterRoutedEvent("PreviewTrayContextMenuOpen", RoutingStrategy.Tunnel, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3185. public static readonly RoutedEvent TrayPopupOpenEvent = EventManager.RegisterRoutedEvent("TrayPopupOpen", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3186. public static readonly RoutedEvent PreviewTrayPopupOpenEvent = EventManager.RegisterRoutedEvent("PreviewTrayPopupOpen", RoutingStrategy.Tunnel, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3187. public static readonly RoutedEvent TrayToolTipOpenEvent = EventManager.RegisterRoutedEvent("TrayToolTipOpen", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3188. public static readonly RoutedEvent PreviewTrayToolTipOpenEvent = EventManager.RegisterRoutedEvent("PreviewTrayToolTipOpen", RoutingStrategy.Tunnel, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3189. public static readonly RoutedEvent TrayToolTipCloseEvent = EventManager.RegisterRoutedEvent("TrayToolTipClose", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3190. public static readonly RoutedEvent PreviewTrayToolTipCloseEvent = EventManager.RegisterRoutedEvent("PreviewTrayToolTipClose", RoutingStrategy.Tunnel, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3191. public static readonly RoutedEvent PopupOpenedEvent = EventManager.RegisterRoutedEvent("PopupOpened", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3192. public static readonly RoutedEvent ToolTipOpenedEvent = EventManager.RegisterRoutedEvent("ToolTipOpened", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3193. public static readonly RoutedEvent ToolTipCloseEvent = EventManager.RegisterRoutedEvent("ToolTipClose", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3194. public static readonly RoutedEvent BalloonShowingEvent = EventManager.RegisterRoutedEvent("BalloonShowing", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3195. public static readonly RoutedEvent BalloonClosingEvent = EventManager.RegisterRoutedEvent("BalloonClosing", RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (TaskbarIcon));
  3196. public static readonly DependencyProperty ParentTaskbarIconProperty = DependencyProperty.RegisterAttached("ParentTaskbarIcon", typeof (TaskbarIcon), typeof (TaskbarIcon), (PropertyMetadata) new FrameworkPropertyMetadata((object) null, FrameworkPropertyMetadataOptions.Inherits));
  3197. private double scalingFactor = double.NaN;
  3198. public const string CategoryName = "NotifyIcon";
  3199. private NotifyIconData iconData;
  3200. private readonly WindowMessageSink messageSink;
  3201. private Action singleClickTimerAction;
  3202. private readonly Timer singleClickTimer;
  3203. private readonly Timer balloonCloseTimer;
  3204. private Icon icon;
  3205.  
  3206. public bool IsTaskbarIconCreated { get; private set; }
  3207.  
  3208. public bool SupportsCustomToolTips
  3209. {
  3210. get
  3211. {
  3212. return this.messageSink.Version == NotifyIconVersion.Vista;
  3213. }
  3214. }
  3215.  
  3216. private bool IsPopupOpen
  3217. {
  3218. get
  3219. {
  3220. Popup trayPopupResolved = this.TrayPopupResolved;
  3221. ContextMenu contextMenu = this.ContextMenu;
  3222. Popup customBalloon = this.CustomBalloon;
  3223. if (trayPopupResolved != null && trayPopupResolved.IsOpen || contextMenu != null && contextMenu.IsOpen)
  3224. return true;
  3225. if (customBalloon != null)
  3226. return customBalloon.IsOpen;
  3227. return false;
  3228. }
  3229. }
  3230.  
  3231. public bool IsDisposed { get; private set; }
  3232.  
  3233. [Category("NotifyIcon")]
  3234. public Popup TrayPopupResolved
  3235. {
  3236. get
  3237. {
  3238. return (Popup) this.GetValue(TaskbarIcon.TrayPopupResolvedProperty);
  3239. }
  3240. }
  3241.  
  3242. [Browsable(true)]
  3243. [Bindable(true)]
  3244. [Category("NotifyIcon")]
  3245. public ToolTip TrayToolTipResolved
  3246. {
  3247. get
  3248. {
  3249. return (ToolTip) this.GetValue(TaskbarIcon.TrayToolTipResolvedProperty);
  3250. }
  3251. }
  3252.  
  3253. public Popup CustomBalloon
  3254. {
  3255. get
  3256. {
  3257. return (Popup) this.GetValue(TaskbarIcon.CustomBalloonProperty);
  3258. }
  3259. }
  3260.  
  3261. [Browsable(false)]
  3262. public Icon Icon
  3263. {
  3264. get
  3265. {
  3266. return this.icon;
  3267. }
  3268. set
  3269. {
  3270. this.icon = value;
  3271. this.iconData.IconHandle = value == null ? IntPtr.Zero : this.icon.Handle;
  3272. Util.WriteIconData(ref this.iconData, NotifyCommand.Modify, IconDataMembers.Icon);
  3273. }
  3274. }
  3275.  
  3276. [Description("Sets the displayed taskbar icon.")]
  3277. [Category("NotifyIcon")]
  3278. public ImageSource IconSource
  3279. {
  3280. get
  3281. {
  3282. return (ImageSource) this.GetValue(TaskbarIcon.IconSourceProperty);
  3283. }
  3284. set
  3285. {
  3286. this.SetValue(TaskbarIcon.IconSourceProperty, (object) value);
  3287. }
  3288. }
  3289.  
  3290. [Category("NotifyIcon")]
  3291. [Description("Alternative to a fully blown ToolTip, which is only displayed on Vista and above.")]
  3292. public string ToolTipText
  3293. {
  3294. get
  3295. {
  3296. return (string) this.GetValue(TaskbarIcon.ToolTipTextProperty);
  3297. }
  3298. set
  3299. {
  3300. this.SetValue(TaskbarIcon.ToolTipTextProperty, (object) value);
  3301. }
  3302. }
  3303.  
  3304. [Category("NotifyIcon")]
  3305. [Description("Custom UI element that is displayed as a tooltip. Only on Vista and above")]
  3306. public UIElement TrayToolTip
  3307. {
  3308. get
  3309. {
  3310. return (UIElement) this.GetValue(TaskbarIcon.TrayToolTipProperty);
  3311. }
  3312. set
  3313. {
  3314. this.SetValue(TaskbarIcon.TrayToolTipProperty, (object) value);
  3315. }
  3316. }
  3317.  
  3318. [Category("NotifyIcon")]
  3319. [Description("Displayed as a Popup if the user clicks on the taskbar icon.")]
  3320. public UIElement TrayPopup
  3321. {
  3322. get
  3323. {
  3324. return (UIElement) this.GetValue(TaskbarIcon.TrayPopupProperty);
  3325. }
  3326. set
  3327. {
  3328. this.SetValue(TaskbarIcon.TrayPopupProperty, (object) value);
  3329. }
  3330. }
  3331.  
  3332. [Category("NotifyIcon")]
  3333. [Description("Defines what mouse events display the context menu.")]
  3334. public PopupActivationMode MenuActivation
  3335. {
  3336. get
  3337. {
  3338. return (PopupActivationMode) this.GetValue(TaskbarIcon.MenuActivationProperty);
  3339. }
  3340. set
  3341. {
  3342. this.SetValue(TaskbarIcon.MenuActivationProperty, (object) value);
  3343. }
  3344. }
  3345.  
  3346. [Category("NotifyIcon")]
  3347. [Description("Defines what mouse events display the TaskbarIconPopup.")]
  3348. public PopupActivationMode PopupActivation
  3349. {
  3350. get
  3351. {
  3352. return (PopupActivationMode) this.GetValue(TaskbarIcon.PopupActivationProperty);
  3353. }
  3354. set
  3355. {
  3356. this.SetValue(TaskbarIcon.PopupActivationProperty, (object) value);
  3357. }
  3358. }
  3359.  
  3360. [Category("NotifyIcon")]
  3361. [Description("A command that is being executed if the tray icon is being double-clicked.")]
  3362. public ICommand DoubleClickCommand
  3363. {
  3364. get
  3365. {
  3366. return (ICommand) this.GetValue(TaskbarIcon.DoubleClickCommandProperty);
  3367. }
  3368. set
  3369. {
  3370. this.SetValue(TaskbarIcon.DoubleClickCommandProperty, (object) value);
  3371. }
  3372. }
  3373.  
  3374. [Category("NotifyIcon")]
  3375. [Description("Parameter to submit to the DoubleClickCommand when the user double clicks on the NotifyIcon.")]
  3376. public object DoubleClickCommandParameter
  3377. {
  3378. get
  3379. {
  3380. return this.GetValue(TaskbarIcon.DoubleClickCommandParameterProperty);
  3381. }
  3382. set
  3383. {
  3384. this.SetValue(TaskbarIcon.DoubleClickCommandParameterProperty, value);
  3385. }
  3386. }
  3387.  
  3388. [Category("NotifyIcon")]
  3389. [Description("The target of the command that is fired if the notify icon is double clicked.")]
  3390. public IInputElement DoubleClickCommandTarget
  3391. {
  3392. get
  3393. {
  3394. return (IInputElement) this.GetValue(TaskbarIcon.DoubleClickCommandTargetProperty);
  3395. }
  3396. set
  3397. {
  3398. this.SetValue(TaskbarIcon.DoubleClickCommandTargetProperty, (object) value);
  3399. }
  3400. }
  3401.  
  3402. [Category("NotifyIcon")]
  3403. [Description("A command that is being executed if the tray icon is being left-clicked.")]
  3404. public ICommand LeftClickCommand
  3405. {
  3406. get
  3407. {
  3408. return (ICommand) this.GetValue(TaskbarIcon.LeftClickCommandProperty);
  3409. }
  3410. set
  3411. {
  3412. this.SetValue(TaskbarIcon.LeftClickCommandProperty, (object) value);
  3413. }
  3414. }
  3415.  
  3416. [Description("The target of the command that is fired if the notify icon is clicked with the left mouse button.")]
  3417. [Category("NotifyIcon")]
  3418. public object LeftClickCommandParameter
  3419. {
  3420. get
  3421. {
  3422. return this.GetValue(TaskbarIcon.LeftClickCommandParameterProperty);
  3423. }
  3424. set
  3425. {
  3426. this.SetValue(TaskbarIcon.LeftClickCommandParameterProperty, value);
  3427. }
  3428. }
  3429.  
  3430. [Category("NotifyIcon")]
  3431. [Description("The target of the command that is fired if the notify icon is clicked with the left mouse button.")]
  3432. public IInputElement LeftClickCommandTarget
  3433. {
  3434. get
  3435. {
  3436. return (IInputElement) this.GetValue(TaskbarIcon.LeftClickCommandTargetProperty);
  3437. }
  3438. set
  3439. {
  3440. this.SetValue(TaskbarIcon.LeftClickCommandTargetProperty, (object) value);
  3441. }
  3442. }
  3443.  
  3444. [Category("NotifyIcon")]
  3445. public event RoutedEventHandler TrayLeftMouseDown
  3446. {
  3447. add
  3448. {
  3449. this.AddHandler(TaskbarIcon.TrayLeftMouseDownEvent, (Delegate) value);
  3450. }
  3451. remove
  3452. {
  3453. this.RemoveHandler(TaskbarIcon.TrayLeftMouseDownEvent, (Delegate) value);
  3454. }
  3455. }
  3456.  
  3457. public event RoutedEventHandler TrayRightMouseDown
  3458. {
  3459. add
  3460. {
  3461. this.AddHandler(TaskbarIcon.TrayRightMouseDownEvent, (Delegate) value);
  3462. }
  3463. remove
  3464. {
  3465. this.RemoveHandler(TaskbarIcon.TrayRightMouseDownEvent, (Delegate) value);
  3466. }
  3467. }
  3468.  
  3469. public event RoutedEventHandler TrayMiddleMouseDown
  3470. {
  3471. add
  3472. {
  3473. this.AddHandler(TaskbarIcon.TrayMiddleMouseDownEvent, (Delegate) value);
  3474. }
  3475. remove
  3476. {
  3477. this.RemoveHandler(TaskbarIcon.TrayMiddleMouseDownEvent, (Delegate) value);
  3478. }
  3479. }
  3480.  
  3481. public event RoutedEventHandler TrayLeftMouseUp
  3482. {
  3483. add
  3484. {
  3485. this.AddHandler(TaskbarIcon.TrayLeftMouseUpEvent, (Delegate) value);
  3486. }
  3487. remove
  3488. {
  3489. this.RemoveHandler(TaskbarIcon.TrayLeftMouseUpEvent, (Delegate) value);
  3490. }
  3491. }
  3492.  
  3493. public event RoutedEventHandler TrayRightMouseUp
  3494. {
  3495. add
  3496. {
  3497. this.AddHandler(TaskbarIcon.TrayRightMouseUpEvent, (Delegate) value);
  3498. }
  3499. remove
  3500. {
  3501. this.RemoveHandler(TaskbarIcon.TrayRightMouseUpEvent, (Delegate) value);
  3502. }
  3503. }
  3504.  
  3505. public event RoutedEventHandler TrayMiddleMouseUp
  3506. {
  3507. add
  3508. {
  3509. this.AddHandler(TaskbarIcon.TrayMiddleMouseUpEvent, (Delegate) value);
  3510. }
  3511. remove
  3512. {
  3513. this.RemoveHandler(TaskbarIcon.TrayMiddleMouseUpEvent, (Delegate) value);
  3514. }
  3515. }
  3516.  
  3517. public event RoutedEventHandler TrayMouseDoubleClick
  3518. {
  3519. add
  3520. {
  3521. this.AddHandler(TaskbarIcon.TrayMouseDoubleClickEvent, (Delegate) value);
  3522. }
  3523. remove
  3524. {
  3525. this.RemoveHandler(TaskbarIcon.TrayMouseDoubleClickEvent, (Delegate) value);
  3526. }
  3527. }
  3528.  
  3529. public event RoutedEventHandler TrayMouseMove
  3530. {
  3531. add
  3532. {
  3533. this.AddHandler(TaskbarIcon.TrayMouseMoveEvent, (Delegate) value);
  3534. }
  3535. remove
  3536. {
  3537. this.RemoveHandler(TaskbarIcon.TrayMouseMoveEvent, (Delegate) value);
  3538. }
  3539. }
  3540.  
  3541. public event RoutedEventHandler TrayBalloonTipShown
  3542. {
  3543. add
  3544. {
  3545. this.AddHandler(TaskbarIcon.TrayBalloonTipShownEvent, (Delegate) value);
  3546. }
  3547. remove
  3548. {
  3549. this.RemoveHandler(TaskbarIcon.TrayBalloonTipShownEvent, (Delegate) value);
  3550. }
  3551. }
  3552.  
  3553. public event RoutedEventHandler TrayBalloonTipClosed
  3554. {
  3555. add
  3556. {
  3557. this.AddHandler(TaskbarIcon.TrayBalloonTipClosedEvent, (Delegate) value);
  3558. }
  3559. remove
  3560. {
  3561. this.RemoveHandler(TaskbarIcon.TrayBalloonTipClosedEvent, (Delegate) value);
  3562. }
  3563. }
  3564.  
  3565. public event RoutedEventHandler TrayBalloonTipClicked
  3566. {
  3567. add
  3568. {
  3569. this.AddHandler(TaskbarIcon.TrayBalloonTipClickedEvent, (Delegate) value);
  3570. }
  3571. remove
  3572. {
  3573. this.RemoveHandler(TaskbarIcon.TrayBalloonTipClickedEvent, (Delegate) value);
  3574. }
  3575. }
  3576.  
  3577. public event RoutedEventHandler TrayContextMenuOpen
  3578. {
  3579. add
  3580. {
  3581. this.AddHandler(TaskbarIcon.TrayContextMenuOpenEvent, (Delegate) value);
  3582. }
  3583. remove
  3584. {
  3585. this.RemoveHandler(TaskbarIcon.TrayContextMenuOpenEvent, (Delegate) value);
  3586. }
  3587. }
  3588.  
  3589. public event RoutedEventHandler PreviewTrayContextMenuOpen
  3590. {
  3591. add
  3592. {
  3593. this.AddHandler(TaskbarIcon.PreviewTrayContextMenuOpenEvent, (Delegate) value);
  3594. }
  3595. remove
  3596. {
  3597. this.RemoveHandler(TaskbarIcon.PreviewTrayContextMenuOpenEvent, (Delegate) value);
  3598. }
  3599. }
  3600.  
  3601. public event RoutedEventHandler TrayPopupOpen
  3602. {
  3603. add
  3604. {
  3605. this.AddHandler(TaskbarIcon.TrayPopupOpenEvent, (Delegate) value);
  3606. }
  3607. remove
  3608. {
  3609. this.RemoveHandler(TaskbarIcon.TrayPopupOpenEvent, (Delegate) value);
  3610. }
  3611. }
  3612.  
  3613. public event RoutedEventHandler PreviewTrayPopupOpen
  3614. {
  3615. add
  3616. {
  3617. this.AddHandler(TaskbarIcon.PreviewTrayPopupOpenEvent, (Delegate) value);
  3618. }
  3619. remove
  3620. {
  3621. this.RemoveHandler(TaskbarIcon.PreviewTrayPopupOpenEvent, (Delegate) value);
  3622. }
  3623. }
  3624.  
  3625. public event RoutedEventHandler TrayToolTipOpen
  3626. {
  3627. add
  3628. {
  3629. this.AddHandler(TaskbarIcon.TrayToolTipOpenEvent, (Delegate) value);
  3630. }
  3631. remove
  3632. {
  3633. this.RemoveHandler(TaskbarIcon.TrayToolTipOpenEvent, (Delegate) value);
  3634. }
  3635. }
  3636.  
  3637. public event RoutedEventHandler PreviewTrayToolTipOpen
  3638. {
  3639. add
  3640. {
  3641. this.AddHandler(TaskbarIcon.PreviewTrayToolTipOpenEvent, (Delegate) value);
  3642. }
  3643. remove
  3644. {
  3645. this.RemoveHandler(TaskbarIcon.PreviewTrayToolTipOpenEvent, (Delegate) value);
  3646. }
  3647. }
  3648.  
  3649. public event RoutedEventHandler TrayToolTipClose
  3650. {
  3651. add
  3652. {
  3653. this.AddHandler(TaskbarIcon.TrayToolTipCloseEvent, (Delegate) value);
  3654. }
  3655. remove
  3656. {
  3657. this.RemoveHandler(TaskbarIcon.TrayToolTipCloseEvent, (Delegate) value);
  3658. }
  3659. }
  3660.  
  3661. public event RoutedEventHandler PreviewTrayToolTipClose
  3662. {
  3663. add
  3664. {
  3665. this.AddHandler(TaskbarIcon.PreviewTrayToolTipCloseEvent, (Delegate) value);
  3666. }
  3667. remove
  3668. {
  3669. this.RemoveHandler(TaskbarIcon.PreviewTrayToolTipCloseEvent, (Delegate) value);
  3670. }
  3671. }
  3672.  
  3673. static TaskbarIcon()
  3674. {
  3675. PropertyMetadata typeMetadata1 = new PropertyMetadata((object) Visibility.Visible, new PropertyChangedCallback(TaskbarIcon.VisibilityPropertyChanged));
  3676. UIElement.VisibilityProperty.OverrideMetadata(typeof (TaskbarIcon), typeMetadata1);
  3677. PropertyMetadata typeMetadata2 = (PropertyMetadata) new FrameworkPropertyMetadata(new PropertyChangedCallback(TaskbarIcon.DataContextPropertyChanged));
  3678. FrameworkElement.DataContextProperty.OverrideMetadata(typeof (TaskbarIcon), typeMetadata2);
  3679. PropertyMetadata typeMetadata3 = (PropertyMetadata) new FrameworkPropertyMetadata(new PropertyChangedCallback(TaskbarIcon.ContextMenuPropertyChanged));
  3680. FrameworkElement.ContextMenuProperty.OverrideMetadata(typeof (TaskbarIcon), typeMetadata3);
  3681. }
  3682.  
  3683. public TaskbarIcon()
  3684. {
  3685. this.messageSink = Util.IsDesignMode ? WindowMessageSink.CreateEmpty() : new WindowMessageSink(NotifyIconVersion.Win95);
  3686. this.iconData = NotifyIconData.CreateDefault(this.messageSink.MessageWindowHandle);
  3687. this.CreateTaskbarIcon();
  3688. this.messageSink.MouseEventReceived += new Action<MouseEvent>(this.OnMouseEvent);
  3689. this.messageSink.TaskbarCreated += new Action(this.OnTaskbarCreated);
  3690. this.messageSink.ChangeToolTipStateRequest += new Action<bool>(this.OnToolTipChange);
  3691. this.messageSink.BalloonToolTipChanged += new Action<bool>(this.OnBalloonToolTipChanged);
  3692. this.singleClickTimer = new Timer(new TimerCallback(this.DoSingleClickAction));
  3693. this.balloonCloseTimer = new Timer(new TimerCallback(this.CloseBalloonCallback));
  3694. if (Application.Current == null)
  3695. return;
  3696. Application.Current.Exit += new ExitEventHandler(this.OnExit);
  3697. }
  3698.  
  3699. ~TaskbarIcon()
  3700. {
  3701. this.Dispose(false);
  3702. }
  3703.  
  3704. public void ShowCustomBalloon(UIElement balloon, PopupAnimation animation, int? timeout)
  3705. {
  3706. Dispatcher dispatcher = Util.GetDispatcher((DispatcherObject) this);
  3707. if (!dispatcher.CheckAccess())
  3708. {
  3709. Action action = (Action) (() => this.ShowCustomBalloon(balloon, animation, timeout));
  3710. dispatcher.Invoke(DispatcherPriority.Normal, (Delegate) action);
  3711. }
  3712. else
  3713. {
  3714. if (balloon == null)
  3715. throw new ArgumentNullException("balloon");
  3716. if (timeout.HasValue)
  3717. {
  3718. int? nullable = timeout;
  3719. if ((nullable.GetValueOrDefault() >= 500 ? 0 : (nullable.HasValue ? 1 : 0)) != 0)
  3720. throw new ArgumentOutOfRangeException("timeout", string.Format("Invalid timeout of {0} milliseconds. Timeout must be at least 500 ms", (object) timeout));
  3721. }
  3722. this.EnsureNotDisposed();
  3723. lock (this)
  3724. this.CloseBalloon();
  3725. Popup popup1 = new Popup();
  3726. popup1.AllowsTransparency = true;
  3727. this.UpdateDataContext((FrameworkElement) popup1, (object) null, this.DataContext);
  3728. popup1.PopupAnimation = animation;
  3729. Popup popup2 = LogicalTreeHelper.GetParent((DependencyObject) balloon) as Popup;
  3730. if (popup2 != null)
  3731. popup2.Child = (UIElement) null;
  3732. if (popup2 != null)
  3733. throw new InvalidOperationException(string.Format("Cannot display control [{0}] in a new balloon popup - that control already has a parent. You may consider creating new balloons every time you want to show one.", (object) balloon));
  3734. popup1.Child = balloon;
  3735. popup1.Placement = PlacementMode.AbsolutePoint;
  3736. popup1.StaysOpen = true;
  3737. WinApp.Tray.RichNotifyIcon.Interop.Point deviceCoordinates = this.GetDeviceCoordinates(TrayInfo.GetTrayLocation());
  3738. popup1.HorizontalOffset = (double) (deviceCoordinates.X - 1);
  3739. popup1.VerticalOffset = (double) (deviceCoordinates.Y - 1);
  3740. lock (this)
  3741. this.SetCustomBalloon(popup1);
  3742. TaskbarIcon.SetParentTaskbarIcon((DependencyObject) balloon, this);
  3743. TaskbarIcon.RaiseBalloonShowingEvent((DependencyObject) balloon, this);
  3744. popup1.IsOpen = true;
  3745. if (!timeout.HasValue)
  3746. return;
  3747. this.balloonCloseTimer.Change(timeout.Value, -1);
  3748. }
  3749. }
  3750.  
  3751. public void ResetBalloonCloseTimer()
  3752. {
  3753. if (this.IsDisposed)
  3754. return;
  3755. lock (this)
  3756. this.balloonCloseTimer.Change(-1, -1);
  3757. }
  3758.  
  3759. public void CloseBalloon()
  3760. {
  3761. if (this.IsDisposed)
  3762. return;
  3763. Dispatcher dispatcher = Util.GetDispatcher((DispatcherObject) this);
  3764. if (!dispatcher.CheckAccess())
  3765. {
  3766. Action action = new Action(this.CloseBalloon);
  3767. dispatcher.Invoke(DispatcherPriority.Normal, (Delegate) action);
  3768. }
  3769. else
  3770. {
  3771. lock (this)
  3772. {
  3773. this.balloonCloseTimer.Change(-1, -1);
  3774. Popup local_2 = this.CustomBalloon;
  3775. if (local_2 == null)
  3776. return;
  3777. UIElement local_3 = local_2.Child;
  3778. if (!TaskbarIcon.RaiseBalloonClosingEvent((DependencyObject) local_3, this).Handled)
  3779. {
  3780. local_2.IsOpen = false;
  3781. local_2.Child = (UIElement) null;
  3782. if (local_3 != null)
  3783. TaskbarIcon.SetParentTaskbarIcon((DependencyObject) local_3, (TaskbarIcon) null);
  3784. }
  3785. this.SetCustomBalloon((Popup) null);
  3786. }
  3787. }
  3788. }
  3789.  
  3790. private void CloseBalloonCallback(object state)
  3791. {
  3792. if (this.IsDisposed)
  3793. return;
  3794. Util.GetDispatcher((DispatcherObject) this).Invoke((Delegate) new Action(this.CloseBalloon));
  3795. }
  3796.  
  3797. private void OnMouseEvent(MouseEvent me)
  3798. {
  3799. if (this.IsDisposed)
  3800. return;
  3801. switch (me)
  3802. {
  3803. case MouseEvent.MouseMove:
  3804. this.RaiseTrayMouseMoveEvent();
  3805. return;
  3806. case MouseEvent.IconRightMouseDown:
  3807. this.RaiseTrayRightMouseDownEvent();
  3808. break;
  3809. case MouseEvent.IconLeftMouseDown:
  3810. this.RaiseTrayLeftMouseDownEvent();
  3811. break;
  3812. case MouseEvent.IconRightMouseUp:
  3813. this.RaiseTrayRightMouseUpEvent();
  3814. break;
  3815. case MouseEvent.IconLeftMouseUp:
  3816. this.RaiseTrayLeftMouseUpEvent();
  3817. break;
  3818. case MouseEvent.IconMiddleMouseDown:
  3819. this.RaiseTrayMiddleMouseDownEvent();
  3820. break;
  3821. case MouseEvent.IconMiddleMouseUp:
  3822. this.RaiseTrayMiddleMouseUpEvent();
  3823. break;
  3824. case MouseEvent.IconDoubleClick:
  3825. this.singleClickTimer.Change(-1, -1);
  3826. this.RaiseTrayMouseDoubleClickEvent();
  3827. break;
  3828. case MouseEvent.BalloonToolTipClicked:
  3829. this.RaiseTrayBalloonTipClickedEvent();
  3830. break;
  3831. default:
  3832. throw new ArgumentOutOfRangeException("me", "Missing handler for mouse event flag: " + (object) me);
  3833. }
  3834. WinApp.Tray.RichNotifyIcon.Interop.Point cursorPosition = new WinApp.Tray.RichNotifyIcon.Interop.Point();
  3835. if (this.messageSink.Version == NotifyIconVersion.Vista)
  3836. WinApi.GetPhysicalCursorPos(ref cursorPosition);
  3837. else
  3838. WinApi.GetCursorPos(ref cursorPosition);
  3839. cursorPosition = this.GetDeviceCoordinates(cursorPosition);
  3840. bool flag = false;
  3841. if (Util.IsMatch(me, this.PopupActivation))
  3842. {
  3843. if (me == MouseEvent.IconLeftMouseUp)
  3844. {
  3845. this.singleClickTimerAction = (Action) (() =>
  3846. {
  3847. Util.ExecuteIfEnabled(this.LeftClickCommand, this.LeftClickCommandParameter, this.LeftClickCommandTarget ?? (IInputElement) this);
  3848. this.ShowTrayPopup(cursorPosition);
  3849. });
  3850. this.singleClickTimer.Change(WinApi.GetDoubleClickTime(), -1);
  3851. flag = true;
  3852. }
  3853. else
  3854. this.ShowTrayPopup(cursorPosition);
  3855. }
  3856. if (Util.IsMatch(me, this.MenuActivation))
  3857. {
  3858. if (me == MouseEvent.IconLeftMouseUp)
  3859. {
  3860. this.singleClickTimerAction = (Action) (() =>
  3861. {
  3862. Util.ExecuteIfEnabled(this.LeftClickCommand, this.LeftClickCommandParameter, this.LeftClickCommandTarget ?? (IInputElement) this);
  3863. this.ShowContextMenu(cursorPosition);
  3864. });
  3865. this.singleClickTimer.Change(WinApi.GetDoubleClickTime(), -1);
  3866. flag = true;
  3867. }
  3868. else
  3869. this.ShowContextMenu(cursorPosition);
  3870. }
  3871. if (me != MouseEvent.IconLeftMouseUp || flag)
  3872. return;
  3873. this.singleClickTimerAction = (Action) (() => Util.ExecuteIfEnabled(this.LeftClickCommand, this.LeftClickCommandParameter, this.LeftClickCommandTarget ?? (IInputElement) this));
  3874. this.singleClickTimer.Change(WinApi.GetDoubleClickTime(), -1);
  3875. }
  3876.  
  3877. private void OnToolTipChange(bool visible)
  3878. {
  3879. if (this.TrayToolTipResolved == null)
  3880. return;
  3881. if (visible)
  3882. {
  3883. if (this.IsPopupOpen || this.RaisePreviewTrayToolTipOpenEvent().Handled)
  3884. return;
  3885. this.TrayToolTipResolved.IsOpen = true;
  3886. if (this.TrayToolTip != null)
  3887. TaskbarIcon.RaiseToolTipOpenedEvent((DependencyObject) this.TrayToolTip);
  3888. this.RaiseTrayToolTipOpenEvent();
  3889. }
  3890. else
  3891. {
  3892. if (this.RaisePreviewTrayToolTipCloseEvent().Handled)
  3893. return;
  3894. if (this.TrayToolTip != null)
  3895. TaskbarIcon.RaiseToolTipCloseEvent((DependencyObject) this.TrayToolTip);
  3896. this.TrayToolTipResolved.IsOpen = false;
  3897. this.RaiseTrayToolTipCloseEvent();
  3898. }
  3899. }
  3900.  
  3901. private void CreateCustomToolTip()
  3902. {
  3903. ToolTip toolTip = this.TrayToolTip as ToolTip;
  3904. if (toolTip == null && this.TrayToolTip != null)
  3905. {
  3906. toolTip = new ToolTip();
  3907. toolTip.Placement = PlacementMode.Mouse;
  3908. toolTip.HasDropShadow = false;
  3909. toolTip.BorderThickness = new Thickness(0.0);
  3910. toolTip.Background = (System.Windows.Media.Brush) System.Windows.Media.Brushes.Transparent;
  3911. toolTip.StaysOpen = true;
  3912. toolTip.Content = (object) this.TrayToolTip;
  3913. }
  3914. else if (toolTip == null && !string.IsNullOrEmpty(this.ToolTipText))
  3915. {
  3916. toolTip = new ToolTip();
  3917. toolTip.Content = (object) this.ToolTipText;
  3918. }
  3919. if (toolTip != null)
  3920. this.UpdateDataContext((FrameworkElement) toolTip, (object) null, this.DataContext);
  3921. this.SetTrayToolTipResolved(toolTip);
  3922. }
  3923.  
  3924. private void WriteToolTipSettings()
  3925. {
  3926. this.iconData.ToolTipText = this.ToolTipText;
  3927. if (this.messageSink.Version == NotifyIconVersion.Vista && string.IsNullOrEmpty(this.iconData.ToolTipText) && this.TrayToolTipResolved != null)
  3928. this.iconData.ToolTipText = "ToolTip";
  3929. Util.WriteIconData(ref this.iconData, NotifyCommand.Modify, IconDataMembers.Tip);
  3930. }
  3931.  
  3932. private void CreatePopup()
  3933. {
  3934. Popup popup = this.TrayPopup as Popup;
  3935. if (popup == null && this.TrayPopup != null)
  3936. {
  3937. popup = new Popup();
  3938. popup.AllowsTransparency = true;
  3939. popup.PopupAnimation = PopupAnimation.None;
  3940. popup.Child = this.TrayPopup;
  3941. popup.Placement = PlacementMode.AbsolutePoint;
  3942. popup.StaysOpen = false;
  3943. }
  3944. if (popup != null)
  3945. this.UpdateDataContext((FrameworkElement) popup, (object) null, this.DataContext);
  3946. this.SetTrayPopupResolved(popup);
  3947. }
  3948.  
  3949. private void ShowTrayPopup(WinApp.Tray.RichNotifyIcon.Interop.Point cursorPosition)
  3950. {
  3951. if (this.IsDisposed || this.RaisePreviewTrayPopupOpenEvent().Handled || this.TrayPopup == null)
  3952. return;
  3953. this.TrayPopupResolved.Placement = PlacementMode.AbsolutePoint;
  3954. this.TrayPopupResolved.HorizontalOffset = (double) cursorPosition.X;
  3955. this.TrayPopupResolved.VerticalOffset = (double) cursorPosition.Y;
  3956. this.TrayPopupResolved.IsOpen = true;
  3957. IntPtr hWnd = IntPtr.Zero;
  3958. if (this.TrayPopupResolved.Child != null)
  3959. {
  3960. HwndSource hwndSource = (HwndSource) PresentationSource.FromVisual((Visual) this.TrayPopupResolved.Child);
  3961. if (hwndSource != null)
  3962. hWnd = hwndSource.Handle;
  3963. }
  3964. if (hWnd == IntPtr.Zero)
  3965. hWnd = this.messageSink.MessageWindowHandle;
  3966. WinApi.SetForegroundWindow(hWnd);
  3967. if (this.TrayPopup != null)
  3968. TaskbarIcon.RaisePopupOpenedEvent((DependencyObject) this.TrayPopup);
  3969. this.RaiseTrayPopupOpenEvent();
  3970. }
  3971.  
  3972. private void ShowContextMenu(WinApp.Tray.RichNotifyIcon.Interop.Point cursorPosition)
  3973. {
  3974. if (this.IsDisposed || this.RaisePreviewTrayContextMenuOpenEvent().Handled || this.ContextMenu == null)
  3975. return;
  3976. this.ContextMenu.Placement = PlacementMode.AbsolutePoint;
  3977. this.ContextMenu.HorizontalOffset = (double) cursorPosition.X;
  3978. this.ContextMenu.VerticalOffset = (double) cursorPosition.Y;
  3979. this.ContextMenu.IsOpen = true;
  3980. IntPtr hWnd = IntPtr.Zero;
  3981. HwndSource hwndSource = (HwndSource) PresentationSource.FromVisual((Visual) this.ContextMenu);
  3982. if (hwndSource != null)
  3983. hWnd = hwndSource.Handle;
  3984. if (hWnd == IntPtr.Zero)
  3985. hWnd = this.messageSink.MessageWindowHandle;
  3986. WinApi.SetForegroundWindow(hWnd);
  3987. this.RaiseTrayContextMenuOpenEvent();
  3988. }
  3989.  
  3990. private void OnBalloonToolTipChanged(bool visible)
  3991. {
  3992. if (visible)
  3993. this.RaiseTrayBalloonTipShownEvent();
  3994. else
  3995. this.RaiseTrayBalloonTipClosedEvent();
  3996. }
  3997.  
  3998. public void ShowBalloonTip(string title, string message, BalloonIcon symbol)
  3999. {
  4000. lock (this)
  4001. this.ShowBalloonTip(title, message, Util.GetBalloonFlag(symbol), IntPtr.Zero);
  4002. }
  4003.  
  4004. public void ShowBalloonTip(string title, string message, Icon customIcon)
  4005. {
  4006. if (customIcon == null)
  4007. throw new ArgumentNullException("customIcon");
  4008. lock (this)
  4009. this.ShowBalloonTip(title, message, BalloonFlags.User, customIcon.Handle);
  4010. }
  4011.  
  4012. private void ShowBalloonTip(string title, string message, BalloonFlags flags, IntPtr balloonIconHandle)
  4013. {
  4014. this.EnsureNotDisposed();
  4015. this.iconData.BalloonText = message ?? string.Empty;
  4016. this.iconData.BalloonTitle = title ?? string.Empty;
  4017. this.iconData.BalloonFlags = flags;
  4018. this.iconData.CustomBalloonIconHandle = balloonIconHandle;
  4019. Util.WriteIconData(ref this.iconData, NotifyCommand.Modify, IconDataMembers.Icon | IconDataMembers.Info);
  4020. }
  4021.  
  4022. public void HideBalloonTip()
  4023. {
  4024. this.EnsureNotDisposed();
  4025. this.iconData.BalloonText = this.iconData.BalloonTitle = string.Empty;
  4026. Util.WriteIconData(ref this.iconData, NotifyCommand.Modify, IconDataMembers.Info);
  4027. }
  4028.  
  4029. private void DoSingleClickAction(object state)
  4030. {
  4031. if (this.IsDisposed)
  4032. return;
  4033. Action action = this.singleClickTimerAction;
  4034. if (action == null)
  4035. return;
  4036. this.singleClickTimerAction = (Action) null;
  4037. Util.GetDispatcher((DispatcherObject) this).Invoke((Delegate) action);
  4038. }
  4039.  
  4040. private void SetVersion()
  4041. {
  4042. this.iconData.VersionOrTimeout = 4U;
  4043. bool flag = WinApi.Shell_NotifyIcon(NotifyCommand.SetVersion, ref this.iconData);
  4044. if (!flag)
  4045. {
  4046. this.iconData.VersionOrTimeout = 3U;
  4047. flag = Util.WriteIconData(ref this.iconData, NotifyCommand.SetVersion);
  4048. }
  4049. if (!flag)
  4050. {
  4051. this.iconData.VersionOrTimeout = 0U;
  4052. flag = Util.WriteIconData(ref this.iconData, NotifyCommand.SetVersion);
  4053. }
  4054. int num = flag ? 1 : 0;
  4055. }
  4056.  
  4057. private void OnTaskbarCreated()
  4058. {
  4059. this.IsTaskbarIconCreated = false;
  4060. this.CreateTaskbarIcon();
  4061. }
  4062.  
  4063. private void CreateTaskbarIcon()
  4064. {
  4065. lock (this)
  4066. {
  4067. if (this.IsTaskbarIconCreated || !Util.WriteIconData(ref this.iconData, NotifyCommand.Add, IconDataMembers.Message | IconDataMembers.Icon | IconDataMembers.Tip))
  4068. return;
  4069. this.SetVersion();
  4070. this.messageSink.Version = (NotifyIconVersion) this.iconData.VersionOrTimeout;
  4071. this.IsTaskbarIconCreated = true;
  4072. }
  4073. }
  4074.  
  4075. private void RemoveTaskbarIcon()
  4076. {
  4077. lock (this)
  4078. {
  4079. if (!this.IsTaskbarIconCreated)
  4080. return;
  4081. Util.WriteIconData(ref this.iconData, NotifyCommand.Delete, IconDataMembers.Message);
  4082. this.IsTaskbarIconCreated = false;
  4083. }
  4084. }
  4085.  
  4086. private WinApp.Tray.RichNotifyIcon.Interop.Point GetDeviceCoordinates(WinApp.Tray.RichNotifyIcon.Interop.Point point)
  4087. {
  4088. if (double.IsNaN(this.scalingFactor))
  4089. {
  4090. PresentationSource presentationSource = PresentationSource.FromVisual((Visual) this);
  4091. this.scalingFactor = presentationSource != null ? 1.0 / presentationSource.CompositionTarget.TransformToDevice.M11 : 1.0;
  4092. }
  4093. if (this.scalingFactor == 1.0)
  4094. return point;
  4095. return new WinApp.Tray.RichNotifyIcon.Interop.Point()
  4096. {
  4097. X = (int) ((double) point.X * this.scalingFactor),
  4098. Y = (int) ((double) point.Y * this.scalingFactor)
  4099. };
  4100. }
  4101.  
  4102. private void EnsureNotDisposed()
  4103. {
  4104. if (this.IsDisposed)
  4105. throw new ObjectDisposedException(this.Name ?? this.GetType().FullName);
  4106. }
  4107.  
  4108. private void OnExit(object sender, EventArgs e)
  4109. {
  4110. this.Dispose();
  4111. }
  4112.  
  4113. public void Dispose()
  4114. {
  4115. this.Dispose(true);
  4116. GC.SuppressFinalize((object) this);
  4117. }
  4118.  
  4119. private void Dispose(bool disposing)
  4120. {
  4121. if (this.IsDisposed || !disposing)
  4122. return;
  4123. lock (this)
  4124. {
  4125. this.IsDisposed = true;
  4126. if (Application.Current != null)
  4127. Application.Current.Exit -= new ExitEventHandler(this.OnExit);
  4128. this.singleClickTimer.Dispose();
  4129. this.balloonCloseTimer.Dispose();
  4130. this.messageSink.Dispose();
  4131. this.RemoveTaskbarIcon();
  4132. }
  4133. }
  4134.  
  4135. protected void SetTrayPopupResolved(Popup value)
  4136. {
  4137. this.SetValue(TaskbarIcon.TrayPopupResolvedPropertyKey, (object) value);
  4138. }
  4139.  
  4140. protected void SetTrayToolTipResolved(ToolTip value)
  4141. {
  4142. this.SetValue(TaskbarIcon.TrayToolTipResolvedPropertyKey, (object) value);
  4143. }
  4144.  
  4145. protected void SetCustomBalloon(Popup value)
  4146. {
  4147. this.SetValue(TaskbarIcon.CustomBalloonPropertyKey, (object) value);
  4148. }
  4149.  
  4150. private static void IconSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  4151. {
  4152. ((TaskbarIcon) d).OnIconSourcePropertyChanged(e);
  4153. }
  4154.  
  4155. private void OnIconSourcePropertyChanged(DependencyPropertyChangedEventArgs e)
  4156. {
  4157. ImageSource imageSource = (ImageSource) e.NewValue;
  4158. if (Util.IsDesignMode)
  4159. return;
  4160. this.Icon = Util.ToIcon(imageSource);
  4161. }
  4162.  
  4163. private static void ToolTipTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  4164. {
  4165. ((TaskbarIcon) d).OnToolTipTextPropertyChanged(e);
  4166. }
  4167.  
  4168. private void OnToolTipTextPropertyChanged(DependencyPropertyChangedEventArgs e)
  4169. {
  4170. if (this.TrayToolTip == null)
  4171. {
  4172. ToolTip trayToolTipResolved = this.TrayToolTipResolved;
  4173. if (trayToolTipResolved == null)
  4174. this.CreateCustomToolTip();
  4175. else
  4176. trayToolTipResolved.Content = e.NewValue;
  4177. }
  4178. this.WriteToolTipSettings();
  4179. }
  4180.  
  4181. private static void TrayToolTipPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  4182. {
  4183. ((TaskbarIcon) d).OnTrayToolTipPropertyChanged(e);
  4184. }
  4185.  
  4186. private void OnTrayToolTipPropertyChanged(DependencyPropertyChangedEventArgs e)
  4187. {
  4188. this.CreateCustomToolTip();
  4189. if (e.OldValue != null)
  4190. TaskbarIcon.SetParentTaskbarIcon((DependencyObject) e.OldValue, (TaskbarIcon) null);
  4191. if (e.NewValue != null)
  4192. TaskbarIcon.SetParentTaskbarIcon((DependencyObject) e.NewValue, this);
  4193. this.WriteToolTipSettings();
  4194. }
  4195.  
  4196. private static void TrayPopupPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  4197. {
  4198. ((TaskbarIcon) d).OnTrayPopupPropertyChanged(e);
  4199. }
  4200.  
  4201. private void OnTrayPopupPropertyChanged(DependencyPropertyChangedEventArgs e)
  4202. {
  4203. if (e.OldValue != null)
  4204. TaskbarIcon.SetParentTaskbarIcon((DependencyObject) e.OldValue, (TaskbarIcon) null);
  4205. if (e.NewValue != null)
  4206. TaskbarIcon.SetParentTaskbarIcon((DependencyObject) e.NewValue, this);
  4207. this.CreatePopup();
  4208. }
  4209.  
  4210. private static void VisibilityPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  4211. {
  4212. ((TaskbarIcon) d).OnVisibilityPropertyChanged(e);
  4213. }
  4214.  
  4215. private void OnVisibilityPropertyChanged(DependencyPropertyChangedEventArgs e)
  4216. {
  4217. if ((Visibility) e.NewValue == Visibility.Visible)
  4218. this.CreateTaskbarIcon();
  4219. else
  4220. this.RemoveTaskbarIcon();
  4221. }
  4222.  
  4223. private void UpdateDataContext(FrameworkElement target, object oldDataContextValue, object newDataContextValue)
  4224. {
  4225. if (target == null || Util.IsDataContextDataBound(target) || !object.ReferenceEquals((object) this, target.DataContext) && !object.Equals(oldDataContextValue, target.DataContext))
  4226. return;
  4227. target.DataContext = newDataContextValue ?? (object) this;
  4228. }
  4229.  
  4230. private static void DataContextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  4231. {
  4232. ((TaskbarIcon) d).OnDataContextPropertyChanged(e);
  4233. }
  4234.  
  4235. private void OnDataContextPropertyChanged(DependencyPropertyChangedEventArgs e)
  4236. {
  4237. object newValue = e.NewValue;
  4238. object oldValue = e.OldValue;
  4239. this.UpdateDataContext((FrameworkElement) this.TrayPopupResolved, oldValue, newValue);
  4240. this.UpdateDataContext((FrameworkElement) this.TrayToolTipResolved, oldValue, newValue);
  4241. this.UpdateDataContext((FrameworkElement) this.ContextMenu, oldValue, newValue);
  4242. }
  4243.  
  4244. private static void ContextMenuPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  4245. {
  4246. ((TaskbarIcon) d).OnContextMenuPropertyChanged(e);
  4247. }
  4248.  
  4249. private void OnContextMenuPropertyChanged(DependencyPropertyChangedEventArgs e)
  4250. {
  4251. if (e.OldValue != null)
  4252. TaskbarIcon.SetParentTaskbarIcon((DependencyObject) e.OldValue, (TaskbarIcon) null);
  4253. if (e.NewValue != null)
  4254. TaskbarIcon.SetParentTaskbarIcon((DependencyObject) e.NewValue, this);
  4255. this.UpdateDataContext((FrameworkElement) e.NewValue, (object) null, this.DataContext);
  4256. }
  4257.  
  4258. protected RoutedEventArgs RaiseTrayLeftMouseDownEvent()
  4259. {
  4260. return TaskbarIcon.RaiseTrayLeftMouseDownEvent((DependencyObject) this);
  4261. }
  4262.  
  4263. internal static RoutedEventArgs RaiseTrayLeftMouseDownEvent(DependencyObject target)
  4264. {
  4265. if (target == null)
  4266. return (RoutedEventArgs) null;
  4267. RoutedEventArgs args = new RoutedEventArgs();
  4268. args.RoutedEvent = TaskbarIcon.TrayLeftMouseDownEvent;
  4269. RoutedEventHelper.RaiseEvent(target, args);
  4270. return args;
  4271. }
  4272.  
  4273. protected RoutedEventArgs RaiseTrayRightMouseDownEvent()
  4274. {
  4275. return TaskbarIcon.RaiseTrayRightMouseDownEvent((DependencyObject) this);
  4276. }
  4277.  
  4278. internal static RoutedEventArgs RaiseTrayRightMouseDownEvent(DependencyObject target)
  4279. {
  4280. if (target == null)
  4281. return (RoutedEventArgs) null;
  4282. RoutedEventArgs args = new RoutedEventArgs();
  4283. args.RoutedEvent = TaskbarIcon.TrayRightMouseDownEvent;
  4284. RoutedEventHelper.RaiseEvent(target, args);
  4285. return args;
  4286. }
  4287.  
  4288. protected RoutedEventArgs RaiseTrayMiddleMouseDownEvent()
  4289. {
  4290. return TaskbarIcon.RaiseTrayMiddleMouseDownEvent((DependencyObject) this);
  4291. }
  4292.  
  4293. internal static RoutedEventArgs RaiseTrayMiddleMouseDownEvent(DependencyObject target)
  4294. {
  4295. if (target == null)
  4296. return (RoutedEventArgs) null;
  4297. RoutedEventArgs args = new RoutedEventArgs();
  4298. args.RoutedEvent = TaskbarIcon.TrayMiddleMouseDownEvent;
  4299. RoutedEventHelper.RaiseEvent(target, args);
  4300. return args;
  4301. }
  4302.  
  4303. protected RoutedEventArgs RaiseTrayLeftMouseUpEvent()
  4304. {
  4305. return TaskbarIcon.RaiseTrayLeftMouseUpEvent((DependencyObject) this);
  4306. }
  4307.  
  4308. internal static RoutedEventArgs RaiseTrayLeftMouseUpEvent(DependencyObject target)
  4309. {
  4310. if (target == null)
  4311. return (RoutedEventArgs) null;
  4312. RoutedEventArgs args = new RoutedEventArgs();
  4313. args.RoutedEvent = TaskbarIcon.TrayLeftMouseUpEvent;
  4314. RoutedEventHelper.RaiseEvent(target, args);
  4315. return args;
  4316. }
  4317.  
  4318. protected RoutedEventArgs RaiseTrayRightMouseUpEvent()
  4319. {
  4320. return TaskbarIcon.RaiseTrayRightMouseUpEvent((DependencyObject) this);
  4321. }
  4322.  
  4323. internal static RoutedEventArgs RaiseTrayRightMouseUpEvent(DependencyObject target)
  4324. {
  4325. if (target == null)
  4326. return (RoutedEventArgs) null;
  4327. RoutedEventArgs args = new RoutedEventArgs();
  4328. args.RoutedEvent = TaskbarIcon.TrayRightMouseUpEvent;
  4329. RoutedEventHelper.RaiseEvent(target, args);
  4330. return args;
  4331. }
  4332.  
  4333. protected RoutedEventArgs RaiseTrayMiddleMouseUpEvent()
  4334. {
  4335. return TaskbarIcon.RaiseTrayMiddleMouseUpEvent((DependencyObject) this);
  4336. }
  4337.  
  4338. internal static RoutedEventArgs RaiseTrayMiddleMouseUpEvent(DependencyObject target)
  4339. {
  4340. if (target == null)
  4341. return (RoutedEventArgs) null;
  4342. RoutedEventArgs args = new RoutedEventArgs();
  4343. args.RoutedEvent = TaskbarIcon.TrayMiddleMouseUpEvent;
  4344. RoutedEventHelper.RaiseEvent(target, args);
  4345. return args;
  4346. }
  4347.  
  4348. protected RoutedEventArgs RaiseTrayMouseDoubleClickEvent()
  4349. {
  4350. RoutedEventArgs routedEventArgs = TaskbarIcon.RaiseTrayMouseDoubleClickEvent((DependencyObject) this);
  4351. Util.ExecuteIfEnabled(this.DoubleClickCommand, this.DoubleClickCommandParameter, this.DoubleClickCommandTarget ?? (IInputElement) this);
  4352. return routedEventArgs;
  4353. }
  4354.  
  4355. internal static RoutedEventArgs RaiseTrayMouseDoubleClickEvent(DependencyObject target)
  4356. {
  4357. if (target == null)
  4358. return (RoutedEventArgs) null;
  4359. RoutedEventArgs args = new RoutedEventArgs();
  4360. args.RoutedEvent = TaskbarIcon.TrayMouseDoubleClickEvent;
  4361. RoutedEventHelper.RaiseEvent(target, args);
  4362. return args;
  4363. }
  4364.  
  4365. protected RoutedEventArgs RaiseTrayMouseMoveEvent()
  4366. {
  4367. return TaskbarIcon.RaiseTrayMouseMoveEvent((DependencyObject) this);
  4368. }
  4369.  
  4370. internal static RoutedEventArgs RaiseTrayMouseMoveEvent(DependencyObject target)
  4371. {
  4372. if (target == null)
  4373. return (RoutedEventArgs) null;
  4374. RoutedEventArgs args = new RoutedEventArgs();
  4375. args.RoutedEvent = TaskbarIcon.TrayMouseMoveEvent;
  4376. RoutedEventHelper.RaiseEvent(target, args);
  4377. return args;
  4378. }
  4379.  
  4380. protected RoutedEventArgs RaiseTrayBalloonTipShownEvent()
  4381. {
  4382. return TaskbarIcon.RaiseTrayBalloonTipShownEvent((DependencyObject) this);
  4383. }
  4384.  
  4385. internal static RoutedEventArgs RaiseTrayBalloonTipShownEvent(DependencyObject target)
  4386. {
  4387. if (target == null)
  4388. return (RoutedEventArgs) null;
  4389. RoutedEventArgs args = new RoutedEventArgs();
  4390. args.RoutedEvent = TaskbarIcon.TrayBalloonTipShownEvent;
  4391. RoutedEventHelper.RaiseEvent(target, args);
  4392. return args;
  4393. }
  4394.  
  4395. protected RoutedEventArgs RaiseTrayBalloonTipClosedEvent()
  4396. {
  4397. return TaskbarIcon.RaiseTrayBalloonTipClosedEvent((DependencyObject) this);
  4398. }
  4399.  
  4400. internal static RoutedEventArgs RaiseTrayBalloonTipClosedEvent(DependencyObject target)
  4401. {
  4402. if (target == null)
  4403. return (RoutedEventArgs) null;
  4404. RoutedEventArgs args = new RoutedEventArgs();
  4405. args.RoutedEvent = TaskbarIcon.TrayBalloonTipClosedEvent;
  4406. RoutedEventHelper.RaiseEvent(target, args);
  4407. return args;
  4408. }
  4409.  
  4410. protected RoutedEventArgs RaiseTrayBalloonTipClickedEvent()
  4411. {
  4412. return TaskbarIcon.RaiseTrayBalloonTipClickedEvent((DependencyObject) this);
  4413. }
  4414.  
  4415. internal static RoutedEventArgs RaiseTrayBalloonTipClickedEvent(DependencyObject target)
  4416. {
  4417. if (target == null)
  4418. return (RoutedEventArgs) null;
  4419. RoutedEventArgs args = new RoutedEventArgs();
  4420. args.RoutedEvent = TaskbarIcon.TrayBalloonTipClickedEvent;
  4421. RoutedEventHelper.RaiseEvent(target, args);
  4422. return args;
  4423. }
  4424.  
  4425. protected RoutedEventArgs RaiseTrayContextMenuOpenEvent()
  4426. {
  4427. return TaskbarIcon.RaiseTrayContextMenuOpenEvent((DependencyObject) this);
  4428. }
  4429.  
  4430. internal static RoutedEventArgs RaiseTrayContextMenuOpenEvent(DependencyObject target)
  4431. {
  4432. if (target == null)
  4433. return (RoutedEventArgs) null;
  4434. RoutedEventArgs args = new RoutedEventArgs();
  4435. args.RoutedEvent = TaskbarIcon.TrayContextMenuOpenEvent;
  4436. RoutedEventHelper.RaiseEvent(target, args);
  4437. return args;
  4438. }
  4439.  
  4440. protected RoutedEventArgs RaisePreviewTrayContextMenuOpenEvent()
  4441. {
  4442. return TaskbarIcon.RaisePreviewTrayContextMenuOpenEvent((DependencyObject) this);
  4443. }
  4444.  
  4445. internal static RoutedEventArgs RaisePreviewTrayContextMenuOpenEvent(DependencyObject target)
  4446. {
  4447. if (target == null)
  4448. return (RoutedEventArgs) null;
  4449. RoutedEventArgs args = new RoutedEventArgs();
  4450. args.RoutedEvent = TaskbarIcon.PreviewTrayContextMenuOpenEvent;
  4451. RoutedEventHelper.RaiseEvent(target, args);
  4452. return args;
  4453. }
  4454.  
  4455. protected RoutedEventArgs RaiseTrayPopupOpenEvent()
  4456. {
  4457. return TaskbarIcon.RaiseTrayPopupOpenEvent((DependencyObject) this);
  4458. }
  4459.  
  4460. internal static RoutedEventArgs RaiseTrayPopupOpenEvent(DependencyObject target)
  4461. {
  4462. if (target == null)
  4463. return (RoutedEventArgs) null;
  4464. RoutedEventArgs args = new RoutedEventArgs();
  4465. args.RoutedEvent = TaskbarIcon.TrayPopupOpenEvent;
  4466. RoutedEventHelper.RaiseEvent(target, args);
  4467. return args;
  4468. }
  4469.  
  4470. protected RoutedEventArgs RaisePreviewTrayPopupOpenEvent()
  4471. {
  4472. return TaskbarIcon.RaisePreviewTrayPopupOpenEvent((DependencyObject) this);
  4473. }
  4474.  
  4475. internal static RoutedEventArgs RaisePreviewTrayPopupOpenEvent(DependencyObject target)
  4476. {
  4477. if (target == null)
  4478. return (RoutedEventArgs) null;
  4479. RoutedEventArgs args = new RoutedEventArgs();
  4480. args.RoutedEvent = TaskbarIcon.PreviewTrayPopupOpenEvent;
  4481. RoutedEventHelper.RaiseEvent(target, args);
  4482. return args;
  4483. }
  4484.  
  4485. protected RoutedEventArgs RaiseTrayToolTipOpenEvent()
  4486. {
  4487. return TaskbarIcon.RaiseTrayToolTipOpenEvent((DependencyObject) this);
  4488. }
  4489.  
  4490. internal static RoutedEventArgs RaiseTrayToolTipOpenEvent(DependencyObject target)
  4491. {
  4492. if (target == null)
  4493. return (RoutedEventArgs) null;
  4494. RoutedEventArgs args = new RoutedEventArgs();
  4495. args.RoutedEvent = TaskbarIcon.TrayToolTipOpenEvent;
  4496. RoutedEventHelper.RaiseEvent(target, args);
  4497. return args;
  4498. }
  4499.  
  4500. protected RoutedEventArgs RaisePreviewTrayToolTipOpenEvent()
  4501. {
  4502. return TaskbarIcon.RaisePreviewTrayToolTipOpenEvent((DependencyObject) this);
  4503. }
  4504.  
  4505. internal static RoutedEventArgs RaisePreviewTrayToolTipOpenEvent(DependencyObject target)
  4506. {
  4507. if (target == null)
  4508. return (RoutedEventArgs) null;
  4509. RoutedEventArgs args = new RoutedEventArgs();
  4510. args.RoutedEvent = TaskbarIcon.PreviewTrayToolTipOpenEvent;
  4511. RoutedEventHelper.RaiseEvent(target, args);
  4512. return args;
  4513. }
  4514.  
  4515. protected RoutedEventArgs RaiseTrayToolTipCloseEvent()
  4516. {
  4517. return TaskbarIcon.RaiseTrayToolTipCloseEvent((DependencyObject) this);
  4518. }
  4519.  
  4520. internal static RoutedEventArgs RaiseTrayToolTipCloseEvent(DependencyObject target)
  4521. {
  4522. if (target == null)
  4523. return (RoutedEventArgs) null;
  4524. RoutedEventArgs args = new RoutedEventArgs();
  4525. args.RoutedEvent = TaskbarIcon.TrayToolTipCloseEvent;
  4526. RoutedEventHelper.RaiseEvent(target, args);
  4527. return args;
  4528. }
  4529.  
  4530. protected RoutedEventArgs RaisePreviewTrayToolTipCloseEvent()
  4531. {
  4532. return TaskbarIcon.RaisePreviewTrayToolTipCloseEvent((DependencyObject) this);
  4533. }
  4534.  
  4535. internal static RoutedEventArgs RaisePreviewTrayToolTipCloseEvent(DependencyObject target)
  4536. {
  4537. if (target == null)
  4538. return (RoutedEventArgs) null;
  4539. RoutedEventArgs args = new RoutedEventArgs();
  4540. args.RoutedEvent = TaskbarIcon.PreviewTrayToolTipCloseEvent;
  4541. RoutedEventHelper.RaiseEvent(target, args);
  4542. return args;
  4543. }
  4544.  
  4545. public static void AddPopupOpenedHandler(DependencyObject element, RoutedEventHandler handler)
  4546. {
  4547. RoutedEventHelper.AddHandler(element, TaskbarIcon.PopupOpenedEvent, (Delegate) handler);
  4548. }
  4549.  
  4550. public static void RemovePopupOpenedHandler(DependencyObject element, RoutedEventHandler handler)
  4551. {
  4552. RoutedEventHelper.RemoveHandler(element, TaskbarIcon.PopupOpenedEvent, (Delegate) handler);
  4553. }
  4554.  
  4555. internal static RoutedEventArgs RaisePopupOpenedEvent(DependencyObject target)
  4556. {
  4557. if (target == null)
  4558. return (RoutedEventArgs) null;
  4559. RoutedEventArgs args = new RoutedEventArgs();
  4560. args.RoutedEvent = TaskbarIcon.PopupOpenedEvent;
  4561. RoutedEventHelper.RaiseEvent(target, args);
  4562. return args;
  4563. }
  4564.  
  4565. public static void AddToolTipOpenedHandler(DependencyObject element, RoutedEventHandler handler)
  4566. {
  4567. RoutedEventHelper.AddHandler(element, TaskbarIcon.ToolTipOpenedEvent, (Delegate) handler);
  4568. }
  4569.  
  4570. public static void RemoveToolTipOpenedHandler(DependencyObject element, RoutedEventHandler handler)
  4571. {
  4572. RoutedEventHelper.RemoveHandler(element, TaskbarIcon.ToolTipOpenedEvent, (Delegate) handler);
  4573. }
  4574.  
  4575. internal static RoutedEventArgs RaiseToolTipOpenedEvent(DependencyObject target)
  4576. {
  4577. if (target == null)
  4578. return (RoutedEventArgs) null;
  4579. RoutedEventArgs args = new RoutedEventArgs();
  4580. args.RoutedEvent = TaskbarIcon.ToolTipOpenedEvent;
  4581. RoutedEventHelper.RaiseEvent(target, args);
  4582. return args;
  4583. }
  4584.  
  4585. public static void AddToolTipCloseHandler(DependencyObject element, RoutedEventHandler handler)
  4586. {
  4587. RoutedEventHelper.AddHandler(element, TaskbarIcon.ToolTipCloseEvent, (Delegate) handler);
  4588. }
  4589.  
  4590. public static void RemoveToolTipCloseHandler(DependencyObject element, RoutedEventHandler handler)
  4591. {
  4592. RoutedEventHelper.RemoveHandler(element, TaskbarIcon.ToolTipCloseEvent, (Delegate) handler);
  4593. }
  4594.  
  4595. internal static RoutedEventArgs RaiseToolTipCloseEvent(DependencyObject target)
  4596. {
  4597. if (target == null)
  4598. return (RoutedEventArgs) null;
  4599. RoutedEventArgs args = new RoutedEventArgs();
  4600. args.RoutedEvent = TaskbarIcon.ToolTipCloseEvent;
  4601. RoutedEventHelper.RaiseEvent(target, args);
  4602. return args;
  4603. }
  4604.  
  4605. public static void AddBalloonShowingHandler(DependencyObject element, RoutedEventHandler handler)
  4606. {
  4607. RoutedEventHelper.AddHandler(element, TaskbarIcon.BalloonShowingEvent, (Delegate) handler);
  4608. }
  4609.  
  4610. public static void RemoveBalloonShowingHandler(DependencyObject element, RoutedEventHandler handler)
  4611. {
  4612. RoutedEventHelper.RemoveHandler(element, TaskbarIcon.BalloonShowingEvent, (Delegate) handler);
  4613. }
  4614.  
  4615. internal static RoutedEventArgs RaiseBalloonShowingEvent(DependencyObject target, TaskbarIcon source)
  4616. {
  4617. if (target == null)
  4618. return (RoutedEventArgs) null;
  4619. RoutedEventArgs args = new RoutedEventArgs(TaskbarIcon.BalloonShowingEvent, (object) source);
  4620. RoutedEventHelper.RaiseEvent(target, args);
  4621. return args;
  4622. }
  4623.  
  4624. public static void AddBalloonClosingHandler(DependencyObject element, RoutedEventHandler handler)
  4625. {
  4626. RoutedEventHelper.AddHandler(element, TaskbarIcon.BalloonClosingEvent, (Delegate) handler);
  4627. }
  4628.  
  4629. public static void RemoveBalloonClosingHandler(DependencyObject element, RoutedEventHandler handler)
  4630. {
  4631. RoutedEventHelper.RemoveHandler(element, TaskbarIcon.BalloonClosingEvent, (Delegate) handler);
  4632. }
  4633.  
  4634. internal static RoutedEventArgs RaiseBalloonClosingEvent(DependencyObject target, TaskbarIcon source)
  4635. {
  4636. if (target == null)
  4637. return (RoutedEventArgs) null;
  4638. RoutedEventArgs args = new RoutedEventArgs(TaskbarIcon.BalloonClosingEvent, (object) source);
  4639. RoutedEventHelper.RaiseEvent(target, args);
  4640. return args;
  4641. }
  4642.  
  4643. public static TaskbarIcon GetParentTaskbarIcon(DependencyObject d)
  4644. {
  4645. return (TaskbarIcon) d.GetValue(TaskbarIcon.ParentTaskbarIconProperty);
  4646. }
  4647.  
  4648. public static void SetParentTaskbarIcon(DependencyObject d, TaskbarIcon value)
  4649. {
  4650. d.SetValue(TaskbarIcon.ParentTaskbarIconProperty, (object) value);
  4651. }
  4652. }
  4653. }
  4654. ?// Decompiled with JetBrains decompiler
  4655. // Type: WinApp.Tray.RichNotifyIcon.BalloonIcon
  4656. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  4657. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  4658. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  4659.  
  4660. namespace WinApp.Tray.RichNotifyIcon
  4661. {
  4662. public enum BalloonIcon
  4663. {
  4664. None,
  4665. Info,
  4666. Warning,
  4667. Error,
  4668. }
  4669. }
  4670. ?// Decompiled with JetBrains decompiler
  4671. // Type: WinApp.Tray.RichNotifyIcon.Util
  4672. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  4673. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  4674. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  4675.  
  4676. using System;
  4677. using System.ComponentModel;
  4678. using System.Drawing;
  4679. using System.Windows;
  4680. using System.Windows.Input;
  4681. using System.Windows.Media;
  4682. using System.Windows.Resources;
  4683. using System.Windows.Threading;
  4684. using WinApp.Tray.RichNotifyIcon.Interop;
  4685.  
  4686. namespace WinApp.Tray.RichNotifyIcon
  4687. {
  4688. internal static class Util
  4689. {
  4690. public static readonly object SyncRoot = new object();
  4691. private static readonly bool isDesignMode = (bool) DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof (FrameworkElement)).Metadata.DefaultValue;
  4692.  
  4693. public static bool IsDesignMode
  4694. {
  4695. get
  4696. {
  4697. return Util.isDesignMode;
  4698. }
  4699. }
  4700.  
  4701. public static Window CreateHelperWindow()
  4702. {
  4703. Window window = new Window();
  4704. window.Width = 0.0;
  4705. window.Height = 0.0;
  4706. window.ShowInTaskbar = false;
  4707. window.WindowStyle = WindowStyle.None;
  4708. window.AllowsTransparency = true;
  4709. window.Opacity = 0.0;
  4710. return window;
  4711. }
  4712.  
  4713. public static bool WriteIconData(ref NotifyIconData data, NotifyCommand command)
  4714. {
  4715. return Util.WriteIconData(ref data, command, data.ValidMembers);
  4716. }
  4717.  
  4718. public static bool WriteIconData(ref NotifyIconData data, NotifyCommand command, IconDataMembers flags)
  4719. {
  4720. if (Util.IsDesignMode)
  4721. return true;
  4722. data.ValidMembers = flags;
  4723. lock (Util.SyncRoot)
  4724. return WinApi.Shell_NotifyIcon(command, ref data);
  4725. }
  4726.  
  4727. public static BalloonFlags GetBalloonFlag(this BalloonIcon icon)
  4728. {
  4729. switch (icon)
  4730. {
  4731. case BalloonIcon.None:
  4732. return BalloonFlags.None;
  4733. case BalloonIcon.Info:
  4734. return BalloonFlags.Info;
  4735. case BalloonIcon.Warning:
  4736. return BalloonFlags.Warning;
  4737. case BalloonIcon.Error:
  4738. return BalloonFlags.Error;
  4739. default:
  4740. throw new ArgumentOutOfRangeException("icon");
  4741. }
  4742. }
  4743.  
  4744. public static Icon ToIcon(this ImageSource imageSource)
  4745. {
  4746. if (imageSource == null)
  4747. return (Icon) null;
  4748. StreamResourceInfo resourceStream = Application.GetResourceStream(new Uri(imageSource.ToString()));
  4749. if (resourceStream == null)
  4750. throw new ArgumentException(string.Format("The supplied image source '{0}' could not be resolved.", (object) imageSource));
  4751. return new Icon(resourceStream.Stream);
  4752. }
  4753.  
  4754. public static bool Is<T>(this T value, params T[] candidates)
  4755. {
  4756. if (candidates == null)
  4757. return false;
  4758. foreach (T obj in candidates)
  4759. {
  4760. if (value.Equals((object) obj))
  4761. return true;
  4762. }
  4763. return false;
  4764. }
  4765.  
  4766. public static bool IsMatch(this MouseEvent me, PopupActivationMode activationMode)
  4767. {
  4768. switch (activationMode)
  4769. {
  4770. case PopupActivationMode.LeftClick:
  4771. return me == MouseEvent.IconLeftMouseUp;
  4772. case PopupActivationMode.RightClick:
  4773. return me == MouseEvent.IconRightMouseUp;
  4774. case PopupActivationMode.DoubleClick:
  4775. return Util.Is<MouseEvent>(me, MouseEvent.IconDoubleClick);
  4776. case PopupActivationMode.LeftOrRightClick:
  4777. return Util.Is<MouseEvent>(me, MouseEvent.IconLeftMouseUp, MouseEvent.IconRightMouseUp);
  4778. case PopupActivationMode.LeftOrDoubleClick:
  4779. return Util.Is<MouseEvent>(me, MouseEvent.IconLeftMouseUp, MouseEvent.IconDoubleClick);
  4780. case PopupActivationMode.MiddleClick:
  4781. return me == MouseEvent.IconMiddleMouseUp;
  4782. case PopupActivationMode.All:
  4783. return me != MouseEvent.MouseMove;
  4784. default:
  4785. throw new ArgumentOutOfRangeException("activationMode");
  4786. }
  4787. }
  4788.  
  4789. public static void ExecuteIfEnabled(this ICommand command, object commandParameter, IInputElement target)
  4790. {
  4791. if (command == null)
  4792. return;
  4793. RoutedCommand routedCommand = command as RoutedCommand;
  4794. if (routedCommand != null)
  4795. {
  4796. if (!routedCommand.CanExecute(commandParameter, target))
  4797. return;
  4798. routedCommand.Execute(commandParameter, target);
  4799. }
  4800. else
  4801. {
  4802. if (!command.CanExecute(commandParameter))
  4803. return;
  4804. command.Execute(commandParameter);
  4805. }
  4806. }
  4807.  
  4808. internal static Dispatcher GetDispatcher(this DispatcherObject source)
  4809. {
  4810. if (Application.Current != null)
  4811. return Application.Current.Dispatcher;
  4812. if (source.Dispatcher != null)
  4813. return source.Dispatcher;
  4814. return Dispatcher.CurrentDispatcher;
  4815. }
  4816.  
  4817. public static bool IsDataContextDataBound(this FrameworkElement element)
  4818. {
  4819. if (element == null)
  4820. throw new ArgumentNullException("element");
  4821. return element.GetBindingExpression(FrameworkElement.DataContextProperty) != null;
  4822. }
  4823. }
  4824. }
  4825. ?// Decompiled with JetBrains decompiler
  4826. // Type: WinApp.Tray.RichNotifyIcon.Interop.NotifyIconData
  4827. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  4828. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  4829. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  4830.  
  4831. using System;
  4832. using System.Runtime.InteropServices;
  4833.  
  4834. namespace WinApp.Tray.RichNotifyIcon.Interop
  4835. {
  4836. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  4837. public struct NotifyIconData
  4838. {
  4839. public uint cbSize;
  4840. public IntPtr WindowHandle;
  4841. public uint TaskbarIconId;
  4842. public IconDataMembers ValidMembers;
  4843. public uint CallbackMessageId;
  4844. public IntPtr IconHandle;
  4845. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
  4846. public string ToolTipText;
  4847. public IconState IconState;
  4848. public IconState StateMask;
  4849. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
  4850. public string BalloonText;
  4851. public uint VersionOrTimeout;
  4852. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
  4853. public string BalloonTitle;
  4854. public BalloonFlags BalloonFlags;
  4855. public Guid TaskbarIconGuid;
  4856. public IntPtr CustomBalloonIconHandle;
  4857.  
  4858. public static NotifyIconData CreateDefault(IntPtr handle)
  4859. {
  4860. NotifyIconData notifyIconData = new NotifyIconData();
  4861. if (Environment.OSVersion.Version.Major >= 6)
  4862. {
  4863. notifyIconData.cbSize = (uint) Marshal.SizeOf((object) notifyIconData);
  4864. }
  4865. else
  4866. {
  4867. notifyIconData.cbSize = 952U;
  4868. notifyIconData.VersionOrTimeout = 10U;
  4869. }
  4870. notifyIconData.WindowHandle = handle;
  4871. notifyIconData.TaskbarIconId = 0U;
  4872. notifyIconData.CallbackMessageId = 1024U;
  4873. notifyIconData.VersionOrTimeout = 0U;
  4874. notifyIconData.IconHandle = IntPtr.Zero;
  4875. notifyIconData.IconState = IconState.Hidden;
  4876. notifyIconData.StateMask = IconState.Hidden;
  4877. notifyIconData.ValidMembers = IconDataMembers.Message | IconDataMembers.Icon | IconDataMembers.Tip;
  4878. notifyIconData.ToolTipText = notifyIconData.BalloonText = notifyIconData.BalloonTitle = string.Empty;
  4879. return notifyIconData;
  4880. }
  4881. }
  4882. }
  4883. ?// Decompiled with JetBrains decompiler
  4884. // Type: WinApp.Tray.RichNotifyIcon.Interop.Point
  4885. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  4886. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  4887. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  4888.  
  4889. namespace WinApp.Tray.RichNotifyIcon.Interop
  4890. {
  4891. public struct Point
  4892. {
  4893. public int X;
  4894. public int Y;
  4895. }
  4896. }
  4897. ?// Decompiled with JetBrains decompiler
  4898. // Type: WinApp.Tray.RichNotifyIcon.Interop.WindowProcedureHandler
  4899. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  4900. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  4901. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  4902.  
  4903. using System;
  4904.  
  4905. namespace WinApp.Tray.RichNotifyIcon.Interop
  4906. {
  4907. public delegate IntPtr WindowProcedureHandler(IntPtr hwnd, uint uMsg, IntPtr wparam, IntPtr lparam);
  4908. }
  4909. ?// Decompiled with JetBrains decompiler
  4910. // Type: WinApp.Tray.RichNotifyIcon.Interop.WinApi
  4911. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  4912. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  4913. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  4914.  
  4915. using System;
  4916. using System.Runtime.InteropServices;
  4917.  
  4918. namespace WinApp.Tray.RichNotifyIcon.Interop
  4919. {
  4920. internal static class WinApi
  4921. {
  4922. [DllImport("shell32.Dll", CharSet = CharSet.Unicode)]
  4923. public static extern bool Shell_NotifyIcon(NotifyCommand cmd, [In] ref NotifyIconData data);
  4924.  
  4925. [DllImport("USER32.DLL", EntryPoint = "CreateWindowExW", SetLastError = true)]
  4926. public static extern IntPtr CreateWindowEx(int dwExStyle, [MarshalAs(UnmanagedType.LPWStr)] string lpClassName, [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
  4927.  
  4928. [DllImport("USER32.DLL")]
  4929. public static extern IntPtr DefWindowProc(IntPtr hWnd, uint msg, IntPtr wparam, IntPtr lparam);
  4930.  
  4931. [DllImport("USER32.DLL", EntryPoint = "RegisterClassW", SetLastError = true)]
  4932. public static extern short RegisterClass(ref WindowClass lpWndClass);
  4933.  
  4934. [DllImport("User32.Dll", EntryPoint = "RegisterWindowMessageW")]
  4935. public static extern uint RegisterWindowMessage([MarshalAs(UnmanagedType.LPWStr)] string lpString);
  4936.  
  4937. [DllImport("USER32.DLL", SetLastError = true)]
  4938. public static extern bool DestroyWindow(IntPtr hWnd);
  4939.  
  4940. [DllImport("USER32.DLL")]
  4941. public static extern bool SetForegroundWindow(IntPtr hWnd);
  4942.  
  4943. [DllImport("user32.dll", CharSet = CharSet.Auto)]
  4944. public static extern int GetDoubleClickTime();
  4945.  
  4946. [DllImport("USER32.DLL", SetLastError = true)]
  4947. public static extern bool GetPhysicalCursorPos(ref Point lpPoint);
  4948.  
  4949. [DllImport("USER32.DLL", SetLastError = true)]
  4950. public static extern bool GetCursorPos(ref Point lpPoint);
  4951. }
  4952. }
  4953. ?// Decompiled with JetBrains decompiler
  4954. // Type: WinApp.Tray.RichNotifyIcon.Interop.MouseEvent
  4955. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  4956. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  4957. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  4958.  
  4959. namespace WinApp.Tray.RichNotifyIcon.Interop
  4960. {
  4961. public enum MouseEvent
  4962. {
  4963. MouseMove,
  4964. IconRightMouseDown,
  4965. IconLeftMouseDown,
  4966. IconRightMouseUp,
  4967. IconLeftMouseUp,
  4968. IconMiddleMouseDown,
  4969. IconMiddleMouseUp,
  4970. IconDoubleClick,
  4971. BalloonToolTipClicked,
  4972. }
  4973. }
  4974. ?// Decompiled with JetBrains decompiler
  4975. // Type: WinApp.Tray.RichNotifyIcon.Interop.AppBarInfo
  4976. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  4977. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  4978. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  4979.  
  4980. using System;
  4981. using System.Drawing;
  4982. using System.Runtime.InteropServices;
  4983.  
  4984. namespace WinApp.Tray.RichNotifyIcon.Interop
  4985. {
  4986. internal class AppBarInfo
  4987. {
  4988. private const int ABE_BOTTOM = 3;
  4989. private const int ABE_LEFT = 0;
  4990. private const int ABE_RIGHT = 2;
  4991. private const int ABE_TOP = 1;
  4992. private const int ABM_GETTASKBARPOS = 5;
  4993. private const uint SPI_GETWORKAREA = 48;
  4994. private AppBarInfo.APPBARDATA m_data;
  4995.  
  4996. public AppBarInfo.ScreenEdge Edge
  4997. {
  4998. get
  4999. {
  5000. return (AppBarInfo.ScreenEdge) this.m_data.uEdge;
  5001. }
  5002. }
  5003.  
  5004. public Rectangle WorkArea
  5005. {
  5006. get
  5007. {
  5008. AppBarInfo.RECT rect1 = new AppBarInfo.RECT();
  5009. IntPtr num1 = Marshal.AllocHGlobal(Marshal.SizeOf((object) rect1));
  5010. int num2 = AppBarInfo.SystemParametersInfo(48U, 0U, num1, 0U);
  5011. AppBarInfo.RECT rect2 = (AppBarInfo.RECT) Marshal.PtrToStructure(num1, rect1.GetType());
  5012. if (num2 != 1)
  5013. return new Rectangle(0, 0, 0, 0);
  5014. Marshal.FreeHGlobal(num1);
  5015. return new Rectangle(rect2.left, rect2.top, rect2.right - rect2.left, rect2.bottom - rect2.top);
  5016. }
  5017. }
  5018.  
  5019. [DllImport("user32.dll")]
  5020. private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
  5021.  
  5022. [DllImport("shell32.dll")]
  5023. private static extern uint SHAppBarMessage(uint dwMessage, ref AppBarInfo.APPBARDATA data);
  5024.  
  5025. [DllImport("user32.dll")]
  5026. private static extern int SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni);
  5027.  
  5028. public void GetPosition(string strClassName, string strWindowName)
  5029. {
  5030. this.m_data = new AppBarInfo.APPBARDATA();
  5031. this.m_data.cbSize = (uint) Marshal.SizeOf(this.m_data.GetType());
  5032. if (!(AppBarInfo.FindWindow(strClassName, strWindowName) != IntPtr.Zero))
  5033. throw new Exception("Failed to find an AppBar that matched the given criteria");
  5034. if ((int) AppBarInfo.SHAppBarMessage(5U, ref this.m_data) != 1)
  5035. throw new Exception("Failed to communicate with the given AppBar");
  5036. }
  5037.  
  5038. public void GetSystemTaskBarPosition()
  5039. {
  5040. this.GetPosition("Shell_TrayWnd", (string) null);
  5041. }
  5042.  
  5043. public enum ScreenEdge
  5044. {
  5045. Undefined = -1,
  5046. Left = 0,
  5047. Top = 1,
  5048. Right = 2,
  5049. Bottom = 3,
  5050. }
  5051.  
  5052. private struct APPBARDATA
  5053. {
  5054. public uint cbSize;
  5055. public IntPtr hWnd;
  5056. public uint uCallbackMessage;
  5057. public uint uEdge;
  5058. public AppBarInfo.RECT rc;
  5059. public int lParam;
  5060. }
  5061.  
  5062. private struct RECT
  5063. {
  5064. public int left;
  5065. public int top;
  5066. public int right;
  5067. public int bottom;
  5068. }
  5069. }
  5070. }
  5071. ?// Decompiled with JetBrains decompiler
  5072. // Type: WinApp.Tray.RichNotifyIcon.Interop.NotifyIconVersion
  5073. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5074. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5075. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5076.  
  5077. namespace WinApp.Tray.RichNotifyIcon.Interop
  5078. {
  5079. public enum NotifyIconVersion
  5080. {
  5081. Win95 = 0,
  5082. Win2000 = 3,
  5083. Vista = 4,
  5084. }
  5085. }
  5086. ?// Decompiled with JetBrains decompiler
  5087. // Type: WinApp.Tray.RichNotifyIcon.Interop.BalloonFlags
  5088. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5089. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5090. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5091.  
  5092. namespace WinApp.Tray.RichNotifyIcon.Interop
  5093. {
  5094. public enum BalloonFlags
  5095. {
  5096. None = 0,
  5097. Info = 1,
  5098. Warning = 2,
  5099. Error = 3,
  5100. User = 4,
  5101. NoSound = 16,
  5102. LargeIcon = 32,
  5103. RespectQuietTime = 128,
  5104. }
  5105. }
  5106. ?// Decompiled with JetBrains decompiler
  5107. // Type: WinApp.Tray.RichNotifyIcon.Interop.IconState
  5108. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5109. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5110. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5111.  
  5112. namespace WinApp.Tray.RichNotifyIcon.Interop
  5113. {
  5114. public enum IconState
  5115. {
  5116. Visible,
  5117. Hidden,
  5118. }
  5119. }
  5120. ?// Decompiled with JetBrains decompiler
  5121. // Type: WinApp.Tray.RichNotifyIcon.Interop.WindowClass
  5122. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5123. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5124. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5125.  
  5126. using System;
  5127. using System.Runtime.InteropServices;
  5128.  
  5129. namespace WinApp.Tray.RichNotifyIcon.Interop
  5130. {
  5131. public struct WindowClass
  5132. {
  5133. public uint style;
  5134. public WindowProcedureHandler lpfnWndProc;
  5135. public int cbClsExtra;
  5136. public int cbWndExtra;
  5137. public IntPtr hInstance;
  5138. public IntPtr hIcon;
  5139. public IntPtr hCursor;
  5140. public IntPtr hbrBackground;
  5141. [MarshalAs(UnmanagedType.LPWStr)]
  5142. public string lpszMenuName;
  5143. [MarshalAs(UnmanagedType.LPWStr)]
  5144. public string lpszClassName;
  5145. }
  5146. }
  5147. ?// Decompiled with JetBrains decompiler
  5148. // Type: WinApp.Tray.RichNotifyIcon.Interop.WindowMessageSink
  5149. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5150. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5151. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5152.  
  5153. using System;
  5154. using System.ComponentModel;
  5155.  
  5156. namespace WinApp.Tray.RichNotifyIcon.Interop
  5157. {
  5158. public class WindowMessageSink : IDisposable
  5159. {
  5160. public const int CallbackMessageId = 1024;
  5161. private uint taskbarRestartMessageId;
  5162. private bool isDoubleClick;
  5163. private WindowProcedureHandler messageHandler;
  5164.  
  5165. internal string WindowId { get; private set; }
  5166.  
  5167. internal IntPtr MessageWindowHandle { get; private set; }
  5168.  
  5169. public NotifyIconVersion Version { get; set; }
  5170.  
  5171. public bool IsDisposed { get; private set; }
  5172.  
  5173. public event Action<bool> ChangeToolTipStateRequest;
  5174.  
  5175. public event Action<MouseEvent> MouseEventReceived;
  5176.  
  5177. public event Action<bool> BalloonToolTipChanged;
  5178.  
  5179. public event Action TaskbarCreated;
  5180.  
  5181. public WindowMessageSink(NotifyIconVersion version)
  5182. {
  5183. this.Version = version;
  5184. this.CreateMessageWindow();
  5185. }
  5186.  
  5187. private WindowMessageSink()
  5188. {
  5189. }
  5190.  
  5191. ~WindowMessageSink()
  5192. {
  5193. this.Dispose(false);
  5194. }
  5195.  
  5196. internal static WindowMessageSink CreateEmpty()
  5197. {
  5198. return new WindowMessageSink()
  5199. {
  5200. MessageWindowHandle = IntPtr.Zero,
  5201. Version = NotifyIconVersion.Vista
  5202. };
  5203. }
  5204.  
  5205. private void CreateMessageWindow()
  5206. {
  5207. this.WindowId = "WPFTaskbarIcon_" + (object) DateTime.Now.Ticks;
  5208. this.messageHandler = new WindowProcedureHandler(this.OnWindowMessageReceived);
  5209. WindowClass lpWndClass;
  5210. lpWndClass.style = 0U;
  5211. lpWndClass.lpfnWndProc = this.messageHandler;
  5212. lpWndClass.cbClsExtra = 0;
  5213. lpWndClass.cbWndExtra = 0;
  5214. lpWndClass.hInstance = IntPtr.Zero;
  5215. lpWndClass.hIcon = IntPtr.Zero;
  5216. lpWndClass.hCursor = IntPtr.Zero;
  5217. lpWndClass.hbrBackground = IntPtr.Zero;
  5218. lpWndClass.lpszMenuName = "";
  5219. lpWndClass.lpszClassName = this.WindowId;
  5220. int num = (int) WinApi.RegisterClass(ref lpWndClass);
  5221. this.taskbarRestartMessageId = WinApi.RegisterWindowMessage("TaskbarCreated");
  5222. this.MessageWindowHandle = WinApi.CreateWindowEx(0, this.WindowId, "", 0, 0, 0, 1, 1, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
  5223. if (this.MessageWindowHandle == IntPtr.Zero)
  5224. throw new Win32Exception("Message window handle was not a valid pointer");
  5225. }
  5226.  
  5227. private IntPtr OnWindowMessageReceived(IntPtr hwnd, uint messageId, IntPtr wparam, IntPtr lparam)
  5228. {
  5229. if ((int) messageId == (int) this.taskbarRestartMessageId)
  5230. this.TaskbarCreated();
  5231. this.ProcessWindowMessage(messageId, wparam, lparam);
  5232. return WinApi.DefWindowProc(hwnd, messageId, wparam, lparam);
  5233. }
  5234.  
  5235. private void ProcessWindowMessage(uint msg, IntPtr wParam, IntPtr lParam)
  5236. {
  5237. if ((int) msg != 1024)
  5238. return;
  5239. switch (lParam.ToInt32())
  5240. {
  5241. case 512:
  5242. this.MouseEventReceived(MouseEvent.MouseMove);
  5243. break;
  5244. case 513:
  5245. this.MouseEventReceived(MouseEvent.IconLeftMouseDown);
  5246. break;
  5247. case 514:
  5248. if (!this.isDoubleClick)
  5249. this.MouseEventReceived(MouseEvent.IconLeftMouseUp);
  5250. this.isDoubleClick = false;
  5251. break;
  5252. case 515:
  5253. this.isDoubleClick = true;
  5254. this.MouseEventReceived(MouseEvent.IconDoubleClick);
  5255. break;
  5256. case 516:
  5257. this.MouseEventReceived(MouseEvent.IconRightMouseDown);
  5258. break;
  5259. case 517:
  5260. this.MouseEventReceived(MouseEvent.IconRightMouseUp);
  5261. break;
  5262. case 519:
  5263. this.MouseEventReceived(MouseEvent.IconMiddleMouseDown);
  5264. break;
  5265. case 520:
  5266. this.MouseEventReceived(MouseEvent.IconMiddleMouseUp);
  5267. break;
  5268. case 1026:
  5269. this.BalloonToolTipChanged(true);
  5270. break;
  5271. case 1027:
  5272. case 1028:
  5273. this.BalloonToolTipChanged(false);
  5274. break;
  5275. case 1029:
  5276. this.MouseEventReceived(MouseEvent.BalloonToolTipClicked);
  5277. break;
  5278. case 1030:
  5279. this.ChangeToolTipStateRequest(true);
  5280. break;
  5281. case 1031:
  5282. this.ChangeToolTipStateRequest(false);
  5283. break;
  5284. }
  5285. }
  5286.  
  5287. public void Dispose()
  5288. {
  5289. this.Dispose(true);
  5290. GC.SuppressFinalize((object) this);
  5291. }
  5292.  
  5293. private void Dispose(bool disposing)
  5294. {
  5295. if (this.IsDisposed)
  5296. return;
  5297. this.IsDisposed = true;
  5298. WinApi.DestroyWindow(this.MessageWindowHandle);
  5299. this.messageHandler = (WindowProcedureHandler) null;
  5300. }
  5301. }
  5302. }
  5303. ?// Decompiled with JetBrains decompiler
  5304. // Type: WinApp.Tray.RichNotifyIcon.Interop.TrayInfo
  5305. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5306. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5307. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5308.  
  5309. using System.Drawing;
  5310.  
  5311. namespace WinApp.Tray.RichNotifyIcon.Interop
  5312. {
  5313. public static class TrayInfo
  5314. {
  5315. public static Point GetTrayLocation()
  5316. {
  5317. AppBarInfo appBarInfo = new AppBarInfo();
  5318. appBarInfo.GetSystemTaskBarPosition();
  5319. Rectangle workArea = appBarInfo.WorkArea;
  5320. int num1 = 0;
  5321. int num2 = 0;
  5322. if (appBarInfo.Edge == AppBarInfo.ScreenEdge.Left)
  5323. {
  5324. num1 = workArea.Left + 2;
  5325. num2 = workArea.Bottom;
  5326. }
  5327. else if (appBarInfo.Edge == AppBarInfo.ScreenEdge.Bottom)
  5328. {
  5329. num1 = workArea.Right;
  5330. num2 = workArea.Bottom;
  5331. }
  5332. else if (appBarInfo.Edge == AppBarInfo.ScreenEdge.Top)
  5333. {
  5334. num1 = workArea.Right;
  5335. num2 = workArea.Top;
  5336. }
  5337. else if (appBarInfo.Edge == AppBarInfo.ScreenEdge.Right)
  5338. {
  5339. num1 = workArea.Right;
  5340. num2 = workArea.Bottom;
  5341. }
  5342. return new Point()
  5343. {
  5344. X = num1,
  5345. Y = num2
  5346. };
  5347. }
  5348. }
  5349. }
  5350. ?// Decompiled with JetBrains decompiler
  5351. // Type: WinApp.Tray.RichNotifyIcon.Interop.IconDataMembers
  5352. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5353. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5354. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5355.  
  5356. using System;
  5357.  
  5358. namespace WinApp.Tray.RichNotifyIcon.Interop
  5359. {
  5360. [Flags]
  5361. public enum IconDataMembers
  5362. {
  5363. Message = 1,
  5364. Icon = 2,
  5365. Tip = 4,
  5366. State = 8,
  5367. Info = 16,
  5368. Realtime = 64,
  5369. UseLegacyToolTips = 128,
  5370. }
  5371. }
  5372. ?// Decompiled with JetBrains decompiler
  5373. // Type: WinApp.Tray.RichNotifyIcon.Interop.NotifyCommand
  5374. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5375. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5376. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5377.  
  5378. namespace WinApp.Tray.RichNotifyIcon.Interop
  5379. {
  5380. public enum NotifyCommand
  5381. {
  5382. Add,
  5383. Modify,
  5384. Delete,
  5385. SetFocus,
  5386. SetVersion,
  5387. }
  5388. }
  5389. ?// Decompiled with JetBrains decompiler
  5390. // Type: WinApp.LoginState
  5391. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5392. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5393. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5394.  
  5395. namespace WinApp
  5396. {
  5397. internal enum LoginState
  5398. {
  5399. NoLogin,
  5400. Done,
  5401. }
  5402. }
  5403. ?// Decompiled with JetBrains decompiler
  5404. // Type: WinApp.App
  5405. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5406. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5407. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5408.  
  5409. using Inc.Logging;
  5410. using System;
  5411. using System.CodeDom.Compiler;
  5412. using System.Configuration;
  5413. using System.Diagnostics;
  5414. using System.IO;
  5415. using System.Runtime.InteropServices;
  5416. using System.Threading;
  5417. using System.Windows;
  5418. using System.Windows.Threading;
  5419. using WinApp.ViewModel;
  5420.  
  5421. namespace WinApp
  5422. {
  5423. internal class App : Application
  5424. {
  5425. private const string _appName = "KairosPlanet";
  5426. private static Mutex _instanceMutex;
  5427. private bool _contentLoaded;
  5428.  
  5429. public App()
  5430. {
  5431. Application.Current.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(this.Application_DispatcherUnhandledException);
  5432. WinApp.Managers.Configuration.ConfigurationManager.Analyze();
  5433. AppVM.Initialize();
  5434. }
  5435.  
  5436. protected override void OnStartup(StartupEventArgs e)
  5437. {
  5438. try
  5439. {
  5440. bool createdNew;
  5441. App._instanceMutex = new Mutex(true, "KairosPlanet", out createdNew);
  5442. if (!createdNew)
  5443. {
  5444. App.SendMessage();
  5445. this.Shutdown();
  5446. }
  5447. else
  5448. {
  5449. this.SetOverrideLogFile();
  5450. Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
  5451. AppVM.Instance.OnStartUp();
  5452. base.OnStartup(e);
  5453. }
  5454. }
  5455. catch (FileLoadException ex)
  5456. {
  5457. Logger.WriteError((object) this, "FileLoadException", "?????? ??? ????????? ???????? , ??????: " + ex.Message, (Exception) ex);
  5458. int num = (int) MessageBox.Show("?????? ??? ????????? ????????, ?????????? ?? ????? ????????? ????????, ??? ????? ???????");
  5459. this.Shutdown();
  5460. }
  5461. catch (Exception ex)
  5462. {
  5463. Logger.WriteError((object) this, "UnhandledException", "???????????? ??????????, ????????? ??????: " + (object) e, ex);
  5464. }
  5465. }
  5466.  
  5467. [DllImport("user32.dll", CharSet = CharSet.Auto)]
  5468. private static extern int SendNotifyMessage(IntPtr hwnd, IntPtr wMsg, IntPtr wParam, IntPtr lParam);
  5469.  
  5470. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  5471. private static extern uint RegisterWindowMessage(string lpString);
  5472.  
  5473. private static void SendMessage()
  5474. {
  5475. App.SendNotifyMessage((IntPtr) ((int) ushort.MaxValue), (IntPtr) ((long) App.RegisterWindowMessage("KairosPlanetMessage")), Marshal.StringToHGlobalAuto("ShowMainWindow"), Marshal.StringToHGlobalAuto("another message"));
  5476. }
  5477.  
  5478. private static void SaveParametrToAppConfig(string strSettingsName, string value)
  5479. {
  5480. Configuration configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  5481. KeyValueConfigurationElement configurationElement = configuration.AppSettings.Settings[strSettingsName];
  5482. if (configurationElement != null)
  5483. {
  5484. if (configurationElement.Value == value)
  5485. return;
  5486. configurationElement.Value = value;
  5487. }
  5488. else
  5489. configuration.AppSettings.Settings.Add(strSettingsName, value);
  5490. configuration.Save(ConfigurationSaveMode.Modified);
  5491. }
  5492.  
  5493. private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
  5494. {
  5495. Logger.WriteError((object) this, "UnhandledException", "?????????? ?? ?????? ??????????. C???????? ??????: " + (object) e.Exception, e.Exception);
  5496. e.Handled = true;
  5497. }
  5498.  
  5499. private void SetOverrideLogFile()
  5500. {
  5501. App.SaveParametrToAppConfig("OverrideLogFile", "True");
  5502. }
  5503.  
  5504. [DebuggerNonUserCode]
  5505. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  5506. public void InitializeComponent()
  5507. {
  5508. if (this._contentLoaded)
  5509. return;
  5510. this._contentLoaded = true;
  5511. Application.LoadComponent((object) this, new Uri("/KairosPlanet;component/app.xaml", UriKind.Relative));
  5512. }
  5513.  
  5514. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  5515. [DebuggerNonUserCode]
  5516. [STAThread]
  5517. public static void Main()
  5518. {
  5519. App app = new App();
  5520. app.InitializeComponent();
  5521. app.Run();
  5522. }
  5523. }
  5524. }
  5525. ?// Decompiled with JetBrains decompiler
  5526. // Type: WinApp.Managers.Credentials
  5527. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5528. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5529. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5530.  
  5531. namespace WinApp.Managers
  5532. {
  5533. public class Credentials
  5534. {
  5535. public string Login { get; private set; }
  5536.  
  5537. public string Password { get; private set; }
  5538.  
  5539. public Credentials(string login, string password)
  5540. {
  5541. this.Login = login;
  5542. this.Password = password;
  5543. }
  5544. }
  5545. }
  5546. ?// Decompiled with JetBrains decompiler
  5547. // Type: WinApp.Managers.Interfaces.IMainWindow
  5548. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5549. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5550. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5551.  
  5552. using WinApp.ViewModel;
  5553.  
  5554. namespace WinApp.Managers.Interfaces
  5555. {
  5556. internal interface IMainWindow
  5557. {
  5558. MainWindowVM ViewModel { get; }
  5559.  
  5560. bool CloseToTray { get; set; }
  5561.  
  5562. void Open();
  5563.  
  5564. void Show();
  5565. }
  5566. }
  5567. ?// Decompiled with JetBrains decompiler
  5568. // Type: WinApp.Managers.Interfaces.IModuleResolver
  5569. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5570. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5571. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5572.  
  5573. using WinApp.Data.Model;
  5574. using WinApp.Module;
  5575.  
  5576. namespace WinApp.Managers.Interfaces
  5577. {
  5578. public interface IModuleResolver : IModuleCallback
  5579. {
  5580. IModuleManager GetModuleManager(ModuleInfo moduleInfo);
  5581.  
  5582. ModuleInfo GetModuleInfo(long productId);
  5583.  
  5584. bool DownloadModule(ModuleInfo moduleInfo);
  5585.  
  5586. string GetActiveModuleSecureKey();
  5587. }
  5588. }
  5589. ?// Decompiled with JetBrains decompiler
  5590. // Type: WinApp.Managers.Interfaces.IAppTray
  5591. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5592. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5593. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5594.  
  5595. using System.Windows;
  5596.  
  5597. namespace WinApp.Managers.Interfaces
  5598. {
  5599. internal interface IAppTray
  5600. {
  5601. UIElement Tray { get; }
  5602.  
  5603. void Refresh();
  5604. }
  5605. }
  5606. ?// Decompiled with JetBrains decompiler
  5607. // Type: WinApp.Managers.Interfaces.ISessionManager
  5608. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5609. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5610. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5611.  
  5612. using System;
  5613. using WinApp.Api.Data;
  5614. using WinApp.Api.Interfaces;
  5615. using WinApp.Data.Helpers;
  5616. using WinApp.Data.Model;
  5617.  
  5618. namespace WinApp.Managers.Interfaces
  5619. {
  5620. public interface ISessionManager
  5621. {
  5622. Man CurrentUser { get; }
  5623.  
  5624. IApi Api { get; }
  5625.  
  5626. LoginResponce Login(string user, string password);
  5627.  
  5628. PingResponse PingSession(string activeModuleSecureKey);
  5629.  
  5630. void CloseSession();
  5631.  
  5632. Statistic[] GetStatistics();
  5633.  
  5634. Statistic[] GetStatistics(DateTime periodStart, DateTime periodEnd);
  5635.  
  5636. Purchase[] GetPurchases();
  5637.  
  5638. string GetAppVersion();
  5639.  
  5640. ModuleInfo GetModuleInfo(long productId);
  5641.  
  5642. byte[] GetModuleContent(long productId);
  5643.  
  5644. string Activation(long purchaseId);
  5645.  
  5646. void UpdateUserAgentString();
  5647. }
  5648. }
  5649. ?// Decompiled with JetBrains decompiler
  5650. // Type: WinApp.Managers.Interfaces.IApplicationSettings
  5651. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5652. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5653. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5654.  
  5655. using WinApp.Managers.Localization;
  5656.  
  5657. namespace WinApp.Managers.Interfaces
  5658. {
  5659. internal interface IApplicationSettings
  5660. {
  5661. string Email { get; set; }
  5662.  
  5663. string Password { get; set; }
  5664.  
  5665. string ProtectedEmail { get; set; }
  5666.  
  5667. string ProtectedPassword { get; set; }
  5668.  
  5669. bool IsRemeberMe { get; set; }
  5670.  
  5671. bool RunAtStartup { get; set; }
  5672.  
  5673. bool IsAutoLogin { get; set; }
  5674.  
  5675. bool IsHttpUsed { get; set; }
  5676.  
  5677. string LocalizationKey { get; set; }
  5678.  
  5679. long ActiveProductId { get; set; }
  5680.  
  5681. void Save();
  5682.  
  5683. void SetLocalization(LocalizationObject localizationObject);
  5684.  
  5685. void SetRunAtStartup(bool isRunAtStartup);
  5686.  
  5687. void SetIsAutoLogin(bool isAutoLogin);
  5688.  
  5689. void SetHttpPingUsed(bool isHttpPingUsed);
  5690.  
  5691. LocalizationObject GetLocalizationObject();
  5692.  
  5693. void RemeberMe(string email, string passwordHash);
  5694.  
  5695. void ForgetMe();
  5696. }
  5697. }
  5698. ?// Decompiled with JetBrains decompiler
  5699. // Type: WinApp.Managers.Interfaces.ICountriesManager
  5700. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5701. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5702. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5703.  
  5704. using System.Collections.Generic;
  5705.  
  5706. namespace WinApp.Managers.Interfaces
  5707. {
  5708. internal interface ICountriesManager
  5709. {
  5710. List<string> GetAllCountries();
  5711. }
  5712. }
  5713. ?// Decompiled with JetBrains decompiler
  5714. // Type: WinApp.Managers.Interfaces.IScreenManager
  5715. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5716. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5717. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5718.  
  5719. using System;
  5720. using WinApp.Module;
  5721. using WinApp.View;
  5722. using WinApp.ViewModel.Services;
  5723.  
  5724. namespace WinApp.Managers.Interfaces
  5725. {
  5726. internal interface IScreenManager
  5727. {
  5728. MainViewUC MainView { get; }
  5729.  
  5730. void DoVisualSafe(Action action);
  5731.  
  5732. void ShowAlert(string message, string title);
  5733.  
  5734. void SwitchToMain();
  5735.  
  5736. void SwitchToLogin();
  5737.  
  5738. void SwitchToInstall(InstallModuleUC installModuleUc, ServiceVM serviceVm, Action<bool> onInstalledAction);
  5739.  
  5740. void SwitchToNewVersionAvailableWindow(Version appVersionOnSite, Version appVersionCurrent);
  5741.  
  5742. Action ShowStatusMessage(string message, int timeInSeconds, bool isInProgress = false);
  5743. }
  5744. }
  5745. ?// Decompiled with JetBrains decompiler
  5746. // Type: WinApp.Managers.Network.NetworkStateEventArgs
  5747. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5748. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5749. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5750.  
  5751. using System;
  5752. using WinApp;
  5753.  
  5754. namespace WinApp.Managers.Network
  5755. {
  5756. internal class NetworkStateEventArgs : EventArgs
  5757. {
  5758. public NetworkState State { get; private set; }
  5759.  
  5760. public NetworkStateEventArgs(NetworkState state)
  5761. {
  5762. this.State = state;
  5763. }
  5764. }
  5765. }
  5766. ?// Decompiled with JetBrains decompiler
  5767. // Type: WinApp.Managers.Network.NetworkMonitor
  5768. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5769. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5770. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5771.  
  5772. using Inc.Logging;
  5773. using IncMap;
  5774. using System;
  5775. using System.Net;
  5776. using System.Net.NetworkInformation;
  5777. using System.Timers;
  5778. using WinApp;
  5779. using WinApp.Managers;
  5780. using WinApp.Managers.Interfaces;
  5781.  
  5782. namespace WinApp.Managers.Network
  5783. {
  5784. internal static class NetworkMonitor
  5785. {
  5786. private static NetworkState _networkState = NetworkState.None;
  5787. private static bool _checkServerRecursion = true;
  5788. private static bool _isHttpUsed = Map.Get<IApplicationSettings>().IsHttpUsed;
  5789. private static int _failedPingAttemptsCount;
  5790. private static System.Timers.Timer _networkMonitorTimer;
  5791.  
  5792. public static NetworkState NetworkState
  5793. {
  5794. get
  5795. {
  5796. return NetworkMonitor._networkState;
  5797. }
  5798. private set
  5799. {
  5800. if (NetworkMonitor._networkState == value)
  5801. return;
  5802. NetworkMonitor._networkState = value;
  5803. Logger.WriteInfo(typeof (NetworkMonitor), "NetworkState", "NetworkState changed status on '" + NetworkMonitor._networkState.ToString() + "'");
  5804. if (NetworkMonitor.NetworkStateChanged == null)
  5805. return;
  5806. NetworkMonitor.NetworkStateChanged((object) typeof (NetworkMonitor), new NetworkStateEventArgs(value));
  5807. }
  5808. }
  5809.  
  5810. public static event EventHandler<NetworkStateEventArgs> NetworkStateChanged;
  5811.  
  5812. public static event EventHandler<EventArgs> ConnectionAttemptFailed;
  5813.  
  5814. public static void StartNetworkMonitoring()
  5815. {
  5816. NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkMonitor.InternalNetworkAvailabilityChanged);
  5817. NetworkMonitor.TransitNetworkStateChange(NetworkInterface.GetIsNetworkAvailable());
  5818. }
  5819.  
  5820. internal static void SetPingThrough(bool useHttpFlag)
  5821. {
  5822. NetworkMonitor._isHttpUsed = useHttpFlag;
  5823. }
  5824.  
  5825. internal static void CheckServerOff()
  5826. {
  5827. NetworkMonitor._checkServerRecursion = false;
  5828. }
  5829.  
  5830. internal static void CheckServerOn(bool immediately = false)
  5831. {
  5832. NetworkMonitor._checkServerRecursion = true;
  5833. NetworkMonitor.StartNetworkMonitorTimer(immediately, true);
  5834. }
  5835.  
  5836. private static void InternalNetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
  5837. {
  5838. NetworkMonitor.TransitNetworkStateChange(e.IsAvailable);
  5839. }
  5840.  
  5841. private static void OnConnectionAttemptFailed()
  5842. {
  5843. if (NetworkMonitor.ConnectionAttemptFailed == null)
  5844. return;
  5845. NetworkMonitor.ConnectionAttemptFailed((object) null, new EventArgs());
  5846. }
  5847.  
  5848. private static void TransitNetworkStateChange(bool isNetworkAvailable)
  5849. {
  5850. NetworkMonitor._checkServerRecursion = true;
  5851. if (isNetworkAvailable)
  5852. {
  5853. Logger.WriteInfo(typeof (NetworkMonitor), "TransitNetworkStateChange()", "???? ????????. ??????? ? ?????? ???????");
  5854. NetworkMonitor.CheckServer();
  5855. }
  5856. else
  5857. {
  5858. NetworkMonitor.NetworkState = NetworkState.NetworkNotFound;
  5859. Logger.WriteInfo(typeof (NetworkMonitor), "TransitNetworkStateChange()", "???? ?? ????????. ??????? ? ????? NetworkNotFound");
  5860. }
  5861. }
  5862.  
  5863. private static void CheckServer()
  5864. {
  5865. bool flag = NetworkMonitor._isHttpUsed ? NetworkMonitor.HttpPingServer() : NetworkMonitor.PingServer();
  5866. if (NetworkMonitor._failedPingAttemptsCount == 2)
  5867. {
  5868. NetworkMonitor.OnConnectionAttemptFailed();
  5869. ++NetworkMonitor._failedPingAttemptsCount;
  5870. }
  5871. else if (!flag && NetworkMonitor._failedPingAttemptsCount < 2)
  5872. ++NetworkMonitor._failedPingAttemptsCount;
  5873. if (flag)
  5874. {
  5875. NetworkMonitor._failedPingAttemptsCount = 0;
  5876. NetworkMonitor.NetworkState = NetworkState.ServerOnline;
  5877. NetworkMonitor.StartNetworkMonitorTimer(false, false);
  5878. }
  5879. else
  5880. {
  5881. Logger.WriteInfo(typeof (NetworkMonitor), "CheckServer()", "?????? ?? ????????.");
  5882. if (!NetworkInterface.GetIsNetworkAvailable())
  5883. {
  5884. Logger.WriteInfo(typeof (NetworkMonitor), "CheckServer()", "?????????, ??? ??????? ????.");
  5885. NetworkMonitor.TransitNetworkStateChange(false);
  5886. }
  5887. else
  5888. {
  5889. NetworkMonitor.NetworkState = NetworkState.ServerNotFound;
  5890. NetworkMonitor.CheckServerOn(false);
  5891. }
  5892. }
  5893. }
  5894.  
  5895. private static void StartNetworkMonitorTimer(bool immediatelyTick = false, bool isShortInterval = false)
  5896. {
  5897. if (!NetworkMonitor._checkServerRecursion)
  5898. return;
  5899. if (NetworkMonitor._networkMonitorTimer == null)
  5900. {
  5901. NetworkMonitor._networkMonitorTimer = new System.Timers.Timer(10000.0);
  5902. NetworkMonitor._networkMonitorTimer.Elapsed += new ElapsedEventHandler(NetworkMonitor.OnNetworkMonitorTimerTick);
  5903. Logger.WriteInfo(typeof (NetworkMonitor), "StartNetworkMonitorTimer()", "??????? ?????? ????? ???????");
  5904. }
  5905. NetworkMonitor._networkMonitorTimer.Interval = isShortInterval ? 1000.0 : 10000.0;
  5906. if (!immediatelyTick)
  5907. {
  5908. NetworkMonitor._networkMonitorTimer.Start();
  5909. }
  5910. else
  5911. {
  5912. NetworkMonitor._networkMonitorTimer.Stop();
  5913. NetworkMonitor.OnNetworkMonitorTimerTick();
  5914. }
  5915. }
  5916.  
  5917. private static void OnNetworkMonitorTimerTick(object sender, ElapsedEventArgs e)
  5918. {
  5919. NetworkMonitor.OnNetworkMonitorTimerTick();
  5920. }
  5921.  
  5922. private static void OnNetworkMonitorTimerTick()
  5923. {
  5924. NetworkMonitor._networkMonitorTimer.Stop();
  5925. NetworkMonitor.CheckServer();
  5926. }
  5927.  
  5928. private static bool PingServer()
  5929. {
  5930. Ping ping = new Ping();
  5931. Uri uri = new Uri(ApplicationSettings.ServiceUri);
  5932. try
  5933. {
  5934. PingReply pingReply = ping.Send(uri.Host, 2000);
  5935. return pingReply != null && pingReply.Status == IPStatus.Success;
  5936. }
  5937. catch (PingException ex)
  5938. {
  5939. Logger.WriteError((object) typeof (NetworkMonitor), "PingServer", "PingException when pinging the host " + uri.Host + ": " + ex.Message);
  5940. return false;
  5941. }
  5942. catch (Exception ex)
  5943. {
  5944. Logger.WriteError((object) typeof (NetworkMonitor), "PingServer", "Exception when pinging the host " + uri.Host + ": " + ex.Message);
  5945. return false;
  5946. }
  5947. }
  5948.  
  5949. private static bool HttpPingServer()
  5950. {
  5951. Uri requestUri = new Uri(ApplicationSettings.ServiceUri);
  5952. try
  5953. {
  5954. HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(requestUri);
  5955. httpWebRequest.Timeout = 2000;
  5956. httpWebRequest.AllowAutoRedirect = false;
  5957. HttpWebResponse httpWebResponse = (HttpWebResponse) httpWebRequest.GetResponse();
  5958. return true;
  5959. }
  5960. catch (PingException ex)
  5961. {
  5962. Logger.WriteError((object) typeof (NetworkMonitor), "PingServer", "PingException when pinging the host " + requestUri.Host + ": " + ex.Message);
  5963. return false;
  5964. }
  5965. catch (WebException ex)
  5966. {
  5967. if (ex.Status == WebExceptionStatus.TrustFailure)
  5968. return true;
  5969. Logger.WriteError((object) typeof (NetworkMonitor), "PingServer", "Exception when pinging the host " + requestUri.Host + ": " + ex.Message);
  5970. return false;
  5971. }
  5972. }
  5973. }
  5974. }
  5975. ?// Decompiled with JetBrains decompiler
  5976. // Type: WinApp.Managers.Configuration.ConfigurationManager
  5977. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  5978. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  5979. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  5980.  
  5981. using Inc.Logging;
  5982. using Microsoft.Win32;
  5983. using System;
  5984. using System.Collections.Generic;
  5985. using System.Drawing;
  5986. using System.IO;
  5987. using System.Linq;
  5988. using System.Reflection;
  5989. using System.Runtime.InteropServices;
  5990. using System.Text;
  5991. using System.Windows;
  5992. using WinApp.ViewModel;
  5993.  
  5994. namespace WinApp.Managers.Configuration
  5995. {
  5996. public static class ConfigurationManager
  5997. {
  5998. private const int VER_NT_WORKSTATION = 1;
  5999. private const int VER_NT_DOMAIN_CONTROLLER = 2;
  6000. private const int VER_NT_SERVER = 3;
  6001. private const int VER_SUITE_SMALLBUSINESS = 1;
  6002. private const int VER_SUITE_ENTERPRISE = 2;
  6003. private const int VER_SUITE_TERMINAL = 16;
  6004. private const int VER_SUITE_DATACENTER = 128;
  6005. private const int VER_SUITE_SINGLEUSERTS = 256;
  6006. private const int VER_SUITE_PERSONAL = 512;
  6007. private const int VER_SUITE_BLADE = 1024;
  6008. private static string _userAgentCache;
  6009.  
  6010. public static void Analyze()
  6011. {
  6012. Logger.WriteInfo((object) typeof (ConfigurationManager), "Analyze()", "???????????? ???????", string.Format("\n\t\t\t\t\t?????????? ????: {0}\n\t\t\t\t\t???????????? ???????: {1}\n\t\t\t\t\t?????? .Net Framework: {2}", (object) Environment.ProcessorCount, (object) ConfigurationManager.GetOsInfo(), (object) ConfigurationManager.GetFrameworkVersion()));
  6013. Logger.WriteInfo((object) typeof (ConfigurationManager), "Analyze()", "???????????? ????????????", string.Format("\n\t\t\t\t\t??? ??????: {0}\n\t\t\t\t\t?????: {1}\n\t\t\t\t\t??? ????????????: {2}", (object) Environment.MachineName, (object) Environment.UserDomainName, (object) Environment.UserName));
  6014. Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
  6015. Logger.WriteInfo((object) typeof (ConfigurationManager), "Analyze()", "???????????? ??????", string.Format("\n\t\t\t\t\t?????????? ??????: {0}x{1}\n\t\t\t\t\tDpi X: {2}\n\t\t\t\t\tDpi Y: {3}", (object) (SystemParameters.PrimaryScreenWidth / 96.0 * (double) graphics.DpiX), (object) (SystemParameters.PrimaryScreenHeight / 96.0 * (double) graphics.DpiY), (object) graphics.DpiX, (object) graphics.DpiY));
  6016. }
  6017.  
  6018. public static void UpdateUserAgent()
  6019. {
  6020. ConfigurationManager._userAgentCache = string.Empty;
  6021. }
  6022.  
  6023. public static string GetUserAgent()
  6024. {
  6025. if (!string.IsNullOrEmpty(ConfigurationManager._userAgentCache))
  6026. return ConfigurationManager._userAgentCache;
  6027. Version currentAppVersion = AppVM.Instance.GetCurrentAppVersion();
  6028. string str = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Modules\\Rent module\\RentModule.dll");
  6029. Version version = (Version) null;
  6030. if (File.Exists(str))
  6031. version = AssemblyName.GetAssemblyName(str).Version;
  6032. string format = "KairosPlanet/{0} ({1}; .Net Framework {2}) {3}";
  6033. object[] objArray = new object[4]
  6034. {
  6035. (object) currentAppVersion,
  6036. (object) ConfigurationManager.GetOsInfo(),
  6037. (object) ConfigurationManager.GetFrameworkVersion(),
  6038. version == (Version) null ? (object) string.Empty : (object) ("RentModule/" + (object) version)
  6039. };
  6040. return ConfigurationManager._userAgentCache = string.Format(format, objArray);
  6041. }
  6042.  
  6043. private static string GetFrameworkVersion()
  6044. {
  6045. try
  6046. {
  6047. using (RegistryKey registryKey1 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, string.Empty).OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\"))
  6048. {
  6049. if (registryKey1 == null)
  6050. return "?? ????????";
  6051. List<string> list = new List<string>();
  6052. foreach (string name1 in registryKey1.GetSubKeyNames())
  6053. {
  6054. if (name1.StartsWith("v"))
  6055. {
  6056. RegistryKey registryKey2 = registryKey1.OpenSubKey(name1);
  6057. if (registryKey2 != null)
  6058. {
  6059. string str1 = (string) registryKey2.GetValue("Version", (object) string.Empty);
  6060. string str2 = registryKey2.GetValue("SP", (object) string.Empty).ToString();
  6061. string str3 = registryKey2.GetValue("Install", (object) string.Empty).ToString();
  6062. if (!string.IsNullOrEmpty(str3) && !string.IsNullOrEmpty(str2) && str3 == "1")
  6063. list.Add(string.Format("{0} {1} SP{2}", (object) name1, (object) str1, (object) str2));
  6064. if (string.IsNullOrEmpty(str1))
  6065. {
  6066. foreach (string name2 in registryKey2.GetSubKeyNames())
  6067. {
  6068. RegistryKey registryKey3 = registryKey2.OpenSubKey(name2);
  6069. if (registryKey3 != null)
  6070. {
  6071. string str4 = (string) registryKey3.GetValue("Version", (object) string.Empty);
  6072. if (!string.IsNullOrEmpty(str4))
  6073. str2 = registryKey3.GetValue("SP", (object) string.Empty).ToString();
  6074. string str5 = registryKey3.GetValue("Install", (object) string.Empty).ToString();
  6075. if (string.IsNullOrEmpty(str5))
  6076. list.Add(string.Format("{0} {1}", (object) name1, (object) str4));
  6077. else if (!string.IsNullOrEmpty(str2) && str5 == "1")
  6078. list.Add(string.Format("{0} {1} SP{2}", (object) name1, (object) str4, (object) str2));
  6079. else if (str5 == "1")
  6080. list.Add(string.Format("v{0} {1}", (object) str4, (object) name2));
  6081. }
  6082. }
  6083. }
  6084. }
  6085. }
  6086. }
  6087. return Enumerable.FirstOrDefault<string>((IEnumerable<string>) Enumerable.OrderByDescending<string, string>((IEnumerable<string>) list, (Func<string, string>) (x => x)));
  6088. }
  6089. }
  6090. catch (Exception ex)
  6091. {
  6092. Logger.WriteError(typeof (ConfigurationManager), "GetFrameworkVersion()", "?? ??????? ???????? ?????? framework", ex);
  6093. return "?? ????????";
  6094. }
  6095. }
  6096.  
  6097. private static string GetOsInfo()
  6098. {
  6099. StringBuilder stringBuilder = new StringBuilder(string.Format("{0} ({1}) - version: {2}", (object) ConfigurationManager.GetOsName(), (object) ConfigurationManager.GetProcessorArchitecture(), (object) Environment.OSVersion.Version));
  6100. string osServicePack = ConfigurationManager.GetOsServicePack();
  6101. if (!string.IsNullOrEmpty(osServicePack))
  6102. stringBuilder.AppendFormat(" {0}", (object) osServicePack);
  6103. string osProductType = ConfigurationManager.GetOsProductType();
  6104. if (!string.IsNullOrEmpty(osProductType))
  6105. stringBuilder.AppendFormat(" - {0}", (object) osProductType);
  6106. return stringBuilder.ToString();
  6107. }
  6108.  
  6109. private static string GetProcessorArchitecture()
  6110. {
  6111. string environmentVariable = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
  6112. if (string.IsNullOrEmpty(environmentVariable))
  6113. return "?? ????????";
  6114. return environmentVariable == "AMD64" ? "x64" : "x86";
  6115. }
  6116.  
  6117. private static string GetOsName()
  6118. {
  6119. try
  6120. {
  6121. OperatingSystem osVersion = Environment.OSVersion;
  6122. switch (osVersion.Platform)
  6123. {
  6124. case PlatformID.Win32Windows:
  6125. switch (osVersion.Version.Minor)
  6126. {
  6127. case 0:
  6128. return "Windows 95";
  6129. case 10:
  6130. return osVersion.Version.Revision.ToString() == "2222A" ? "Windows 98 Second Edition" : "Windows 98";
  6131. case 90:
  6132. return "Windows Me";
  6133. }
  6134. case PlatformID.Win32NT:
  6135. switch (osVersion.Version.Major)
  6136. {
  6137. case 3:
  6138. return "Windows NT 3.51";
  6139. case 4:
  6140. return "Windows NT 4.0";
  6141. case 5:
  6142. switch (osVersion.Version.Minor)
  6143. {
  6144. case 0:
  6145. return "Windows 2000";
  6146. case 1:
  6147. return "Windows XP";
  6148. case 2:
  6149. return "Windows Server 2003";
  6150. }
  6151. case 6:
  6152. OSVERSIONINFOEX? osVersionInfo = ConfigurationManager.GetOsVersionInfo();
  6153. switch (osVersion.Version.Minor)
  6154. {
  6155. case 0:
  6156. if (!osVersionInfo.HasValue)
  6157. return "Windows Vista/Windows Server 2008";
  6158. return (int) osVersionInfo.Value.wProductType == 1 ? "Windows Vista" : "Windows Server 2008";
  6159. case 1:
  6160. if (!osVersionInfo.HasValue)
  6161. return "Windows 7/Windows Server 2008 R2";
  6162. return (int) osVersionInfo.Value.wProductType == 1 ? "Windows 7" : "Windows Server 2008 R2";
  6163. case 2:
  6164. if (!osVersionInfo.HasValue)
  6165. return "Windows 8/Windows Server 2012";
  6166. return (int) osVersionInfo.Value.wProductType == 1 ? "Windows 8" : "Windows Server 2012";
  6167. case 3:
  6168. if (!osVersionInfo.HasValue)
  6169. return "Windows 8.1/Windows Server 2012 R2";
  6170. return (int) osVersionInfo.Value.wProductType == 1 ? "Windows 8.1" : "Windows Server 2012 R2";
  6171. }
  6172. case 10:
  6173. return "Windows 10";
  6174. }
  6175. }
  6176. }
  6177. catch (Exception ex)
  6178. {
  6179. Logger.WriteError(typeof (ConfigurationManager), "GetOsName()", "?? ??????? ???????? ???????? ??", ex);
  6180. }
  6181. return "?? ????????";
  6182. }
  6183.  
  6184. private static string GetOsServicePack()
  6185. {
  6186. try
  6187. {
  6188. OSVERSIONINFOEX? osVersionInfo = ConfigurationManager.GetOsVersionInfo();
  6189. if (!osVersionInfo.HasValue)
  6190. return string.Empty;
  6191. return osVersionInfo.Value.szCSDVersion;
  6192. }
  6193. catch (Exception ex)
  6194. {
  6195. Logger.WriteError(typeof (ConfigurationManager), "GetOsServicePack()", "?? ??????? ???????? ????????? ????? ??", ex);
  6196. }
  6197. return "?? ????????";
  6198. }
  6199.  
  6200. private static string GetOsProductType()
  6201. {
  6202. try
  6203. {
  6204. OSVERSIONINFOEX? osVersionInfo = ConfigurationManager.GetOsVersionInfo();
  6205. if (!osVersionInfo.HasValue)
  6206. return string.Empty;
  6207. OperatingSystem osVersion = Environment.OSVersion;
  6208. if (osVersion.Version.Major == 4)
  6209. {
  6210. if ((int) osVersionInfo.Value.wProductType == 1)
  6211. return "Workstation";
  6212. if ((int) osVersionInfo.Value.wProductType == 3)
  6213. return "Server";
  6214. return string.Empty;
  6215. }
  6216. if (osVersion.Version.Major == 5)
  6217. {
  6218. if ((int) osVersionInfo.Value.wProductType == 1)
  6219. return ((int) osVersionInfo.Value.wSuiteMask & 512) == 512 ? "Home Edition" : "Professional";
  6220. if ((int) osVersionInfo.Value.wProductType == 3)
  6221. {
  6222. if (osVersion.Version.Minor == 0)
  6223. {
  6224. if (((int) osVersionInfo.Value.wSuiteMask & 128) == 128)
  6225. return "Datacenter Server";
  6226. return ((int) osVersionInfo.Value.wSuiteMask & 2) == 2 ? "Advanced Server" : "Server";
  6227. }
  6228. }
  6229. else
  6230. {
  6231. if (((int) osVersionInfo.Value.wSuiteMask & 128) == 128)
  6232. return "Datacenter Edition";
  6233. if (((int) osVersionInfo.Value.wSuiteMask & 2) == 2)
  6234. return "Enterprise Edition";
  6235. return ((int) osVersionInfo.Value.wSuiteMask & 1024) == 1024 ? "Web Edition" : "Standard Edition";
  6236. }
  6237. }
  6238. }
  6239. catch (Exception ex)
  6240. {
  6241. Logger.WriteError(typeof (ConfigurationManager), "GetOsProductType()", "?? ??????? ???????? ??? ???????? ??", ex);
  6242. }
  6243. return string.Empty;
  6244. }
  6245.  
  6246. private static OSVERSIONINFOEX? GetOsVersionInfo()
  6247. {
  6248. OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX()
  6249. {
  6250. dwOSVersionInfoSize = Marshal.SizeOf(typeof (OSVERSIONINFOEX))
  6251. };
  6252. if (!ConfigurationManager.GetVersionEx(ref osVersionInfo))
  6253. return new OSVERSIONINFOEX?();
  6254. return new OSVERSIONINFOEX?(osVersionInfo);
  6255. }
  6256.  
  6257. [DllImport("kernel32.dll")]
  6258. private static extern bool GetVersionEx(ref OSVERSIONINFOEX osVersionInfo);
  6259. }
  6260. }
  6261. ?// Decompiled with JetBrains decompiler
  6262. // Type: WinApp.Managers.Configuration.OSVERSIONINFOEX
  6263. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  6264. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  6265. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  6266.  
  6267. using System.Runtime.InteropServices;
  6268.  
  6269. namespace WinApp.Managers.Configuration
  6270. {
  6271. public struct OSVERSIONINFOEX
  6272. {
  6273. public int dwOSVersionInfoSize;
  6274. public int dwMajorVersion;
  6275. public int dwMinorVersion;
  6276. public int dwBuildNumber;
  6277. public int dwPlatformId;
  6278. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
  6279. public string szCSDVersion;
  6280. public short wServicePackMajor;
  6281. public short wServicePackMinor;
  6282. public short wSuiteMask;
  6283. public byte wProductType;
  6284. public byte wReserved;
  6285. }
  6286. }
  6287. ?// Decompiled with JetBrains decompiler
  6288. // Type: WinApp.Managers.Localization.ILocalizationManager
  6289. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  6290. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  6291. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  6292.  
  6293. using System.Collections.ObjectModel;
  6294.  
  6295. namespace WinApp.Managers.Localization
  6296. {
  6297. public interface ILocalizationManager
  6298. {
  6299. ObservableCollection<LocalizationObject> LanguagesCollection { get; }
  6300.  
  6301. void ApplyLocalization();
  6302. }
  6303. }
  6304. ?// Decompiled with JetBrains decompiler
  6305. // Type: WinApp.Managers.Localization.LocalizationObject
  6306. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  6307. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  6308. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  6309.  
  6310. namespace WinApp.Managers.Localization
  6311. {
  6312. public class LocalizationObject
  6313. {
  6314. public string LocalizationKey { get; set; }
  6315.  
  6316. public string LanguageName { get; set; }
  6317.  
  6318. public string CountryName { get; set; }
  6319. }
  6320. }
  6321. ?// Decompiled with JetBrains decompiler
  6322. // Type: WinApp.Managers.Localization.LocalizationManager
  6323. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  6324. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  6325. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  6326.  
  6327. using Inc.Logging;
  6328. using IncMap;
  6329. using KairosPlanet.Managers.Localization;
  6330. using System;
  6331. using System.Collections.ObjectModel;
  6332. using System.Globalization;
  6333. using System.Threading;
  6334. using WinApp.Managers.Interfaces;
  6335.  
  6336. namespace WinApp.Managers.Localization
  6337. {
  6338. public class LocalizationManager : ILocalizationManager
  6339. {
  6340. public ObservableCollection<LocalizationObject> LanguagesCollection { get; private set; }
  6341.  
  6342. public LocalizationManager()
  6343. {
  6344. this.Initialize();
  6345. }
  6346.  
  6347. public void ApplyLocalization()
  6348. {
  6349. string localizationKey1 = Map.Get<IApplicationSettings>().LocalizationKey;
  6350. Logger.WriteInfo(typeof (LocalizationManager), "ApplyLocalization()", "?????????? ??????????? ?? ????? ApplicationSettings...");
  6351. try
  6352. {
  6353. Thread.CurrentThread.CurrentCulture = (CultureInfo) new UnifyCultureInfo(localizationKey1);
  6354. Thread.CurrentThread.CurrentUICulture = (CultureInfo) new UnifyCultureInfo(localizationKey1);
  6355. Logger.WriteInfo(typeof (LocalizationManager), "ApplyLocalization()", string.Format("??????????? '{0}' ??????? ?????????", (object) localizationKey1));
  6356. }
  6357. catch (Exception ex1)
  6358. {
  6359. Logger.WriteWarning(typeof (LocalizationManager), "ApplyLocalization()", string.Format("?????? ??? ?????????? ??????????? '{0}'. ????? ????????? ??????????? ???????????", (object) localizationKey1));
  6360. try
  6361. {
  6362. string localizationKey2 = this.LanguagesCollection[0].LocalizationKey;
  6363. Map.Get<IApplicationSettings>().LocalizationKey = localizationKey2;
  6364. Thread.CurrentThread.CurrentCulture = (CultureInfo) new UnifyCultureInfo(localizationKey2);
  6365. Thread.CurrentThread.CurrentUICulture = (CultureInfo) new UnifyCultureInfo(localizationKey2);
  6366. Logger.WriteInfo(typeof (LocalizationManager), "ApplyLocalization()", string.Format("??????????? '{0}' ??????? ?????????", (object) localizationKey2));
  6367. }
  6368. catch (Exception ex2)
  6369. {
  6370. Logger.WriteError(typeof (LocalizationManager), "ApplyLocalization()", string.Format("?????? ??? ?????????? ???????????"), ex2);
  6371. }
  6372. }
  6373. }
  6374.  
  6375. private void Initialize()
  6376. {
  6377. Logger.WriteInfo(typeof (LocalizationManager), "Initialize()", "????????????? ?????? ???????????...");
  6378. this.LanguagesCollection = new ObservableCollection<LocalizationObject>();
  6379. this.LanguagesCollection.Add(new LocalizationObject()
  6380. {
  6381. LanguageName = "English",
  6382. LocalizationKey = "en-US",
  6383. CountryName = "USA"
  6384. });
  6385. this.LanguagesCollection.Add(new LocalizationObject()
  6386. {
  6387. LanguageName = "???????",
  6388. LocalizationKey = "ru-RU",
  6389. CountryName = "??????"
  6390. });
  6391. Logger.WriteInfo(typeof (LocalizationManager), "Initialize()", "?????? ??????????? ??????? ???????????????");
  6392. }
  6393. }
  6394. }
  6395. ?// Decompiled with JetBrains decompiler
  6396. // Type: WinApp.Managers.PingEventArgs
  6397. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  6398. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  6399. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  6400.  
  6401. namespace WinApp.Managers
  6402. {
  6403. public class PingEventArgs
  6404. {
  6405. public long LifeTime { get; private set; }
  6406.  
  6407. public PingEventArgs(long lifeTime)
  6408. {
  6409. this.LifeTime = lifeTime;
  6410. }
  6411. }
  6412. }
  6413. ?// Decompiled with JetBrains decompiler
  6414. // Type: WinApp.Managers.ModuleResolver
  6415. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  6416. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  6417. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  6418.  
  6419. using Inc.Logging;
  6420. using IncMap;
  6421. using Ionic.Zip;
  6422. using System;
  6423. using System.Collections.Generic;
  6424. using System.IO;
  6425. using System.Linq;
  6426. using System.Reflection;
  6427. using System.Runtime.Serialization;
  6428. using WinApp.Data.Model;
  6429. using WinApp.Managers.Interfaces;
  6430. using WinApp.Module;
  6431.  
  6432. namespace WinApp.Managers
  6433. {
  6434. public class ModuleResolver : IModuleResolver, IModuleCallback
  6435. {
  6436. private static Dictionary<string, IModuleManager> _moduleManagerDictionary = new Dictionary<string, IModuleManager>();
  6437. private Dictionary<long, ModuleInfo> _moduleInfoDictionary = new Dictionary<long, ModuleInfo>();
  6438.  
  6439. public IModuleManager GetModuleManager(ModuleInfo moduleInfo)
  6440. {
  6441. if (moduleInfo == null)
  6442. throw new ArgumentException("Module info is null", "moduleInfo");
  6443. Logger.WriteInfo((object) this, "GetModuleManager()", string.Format("?????? ????????? ?????? - {0}", (object) moduleInfo.Title));
  6444. string str = Path.Combine(ModuleResolver.GetModulesFolderPath(), ModuleResolver.GetModuleInfoFileName(moduleInfo));
  6445. bool flag = true;
  6446. if (File.Exists(str))
  6447. {
  6448. Logger.WriteInfo((object) this, "GetModuleManager()", "Module already exist");
  6449. Version version1 = new Version(ModuleResolver.ReadModuleInfo(str).Version);
  6450. Version version2 = new Version(moduleInfo.Version);
  6451. flag = version2 != version1;
  6452. Logger.WriteInfo((object) this, "GetModuleManager()", string.Format("Module version on site: '{0}' and version local: '{1}'", (object) version2, (object) version1));
  6453. }
  6454. if (flag)
  6455. {
  6456. Logger.WriteInfo((object) this, "GetModuleManager()", "Module need update");
  6457. if (!this.DownloadModule(moduleInfo))
  6458. {
  6459. Logger.WriteError((object) this, "GetModuleManager", "Module is not downloaded");
  6460. return (IModuleManager) null;
  6461. }
  6462. if (!ModuleResolver.DeployedModule(moduleInfo))
  6463. {
  6464. Logger.WriteError((object) this, "GetModuleManager", "Module is not deployed");
  6465. return (IModuleManager) null;
  6466. }
  6467. Map.Get<ISessionManager>().UpdateUserAgentString();
  6468. }
  6469. return ModuleResolver.GetInstanceModuleManager(moduleInfo);
  6470. }
  6471.  
  6472. public ModuleInfo GetModuleInfoFromSite(long productId)
  6473. {
  6474. Logger.WriteInfo((object) this, "GetModuleInfoFromSite", "Get module info for productId = " + (object) productId);
  6475. ModuleInfo moduleInfo = Map.Get<ISessionManager>().GetModuleInfo(productId);
  6476. if (moduleInfo == null)
  6477. {
  6478. Logger.WriteError((object) this, "GetModuleInfoFromSite", "Module info from site is not received");
  6479. return (ModuleInfo) null;
  6480. }
  6481. if (this._moduleInfoDictionary.ContainsKey(productId))
  6482. this._moduleInfoDictionary[productId] = moduleInfo;
  6483. else
  6484. this._moduleInfoDictionary.Add(productId, moduleInfo);
  6485. return moduleInfo;
  6486. }
  6487.  
  6488. public ModuleInfo GetModuleInfo(long productId)
  6489. {
  6490. if (this._moduleInfoDictionary.ContainsKey(productId))
  6491. return this._moduleInfoDictionary[productId];
  6492. return this.GetModuleInfoFromSite(productId);
  6493. }
  6494.  
  6495. public bool DownloadModule(ModuleInfo moduleInfo)
  6496. {
  6497. try
  6498. {
  6499. Logger.WriteInfo((object) this, "DownloadModule", "Start download module " + moduleInfo.Title);
  6500. long productId = moduleInfo.ProductId;
  6501. ModuleInfo moduleInfo1 = Map.Get<ISessionManager>().GetModuleInfo(productId);
  6502. byte[] moduleContent = Map.Get<ISessionManager>().GetModuleContent(productId);
  6503. Logger.WriteInfo((object) this, "DownloadModule", "Content for module " + moduleInfo.Title + " downloaded");
  6504. ModuleResolver.SaveModuleFile(moduleContent, moduleInfo);
  6505. Logger.WriteInfo((object) this, "DownloadModule", "Content for module " + moduleInfo.Title + " saved");
  6506. string filePath = Path.Combine(ModuleResolver.GetDownloadsModuleFolderPath(moduleInfo), ModuleResolver.GetModuleInfoFileName(moduleInfo));
  6507. ModuleResolver.SaveModuleInfo(moduleInfo1, filePath);
  6508. Logger.WriteInfo((object) this, "DownloadModule", "ModuleInfo for module " + moduleInfo.Title + " saved");
  6509. Logger.WriteInfo((object) this, "DownloadModule", "Module " + moduleInfo.Title + " downloaded successful");
  6510. return true;
  6511. }
  6512. catch (Exception ex)
  6513. {
  6514. Logger.WriteError((object) this, "DownloadModule", "Error throw download module", ex);
  6515. return false;
  6516. }
  6517. }
  6518.  
  6519. public string GetActiveModuleSecureKey()
  6520. {
  6521. try
  6522. {
  6523. long activeProductId = Map.Get<IApplicationSettings>().ActiveProductId;
  6524. if (activeProductId == 0L)
  6525. return string.Empty;
  6526. ModuleInfo moduleInfo = this.GetModuleInfo(activeProductId);
  6527. if (moduleInfo == null)
  6528. return string.Empty;
  6529. IModuleManager moduleManager = this.GetModuleManager(moduleInfo);
  6530. if (moduleManager == null)
  6531. return string.Empty;
  6532. return moduleManager.GetSecurityKey((IModuleCallback) this);
  6533. }
  6534. catch (Exception ex)
  6535. {
  6536. Logger.WriteError((object) this, "GetActiveModuleSecureKey()", "Error by GetActiveModuleSecureKey", ex);
  6537. return string.Empty;
  6538. }
  6539. }
  6540.  
  6541. public ModuleSettings GetModuleSettings(string moduleId)
  6542. {
  6543. return SettingsForAllModules.GetModuleSettings(moduleId);
  6544. }
  6545.  
  6546. public void SaveModuleSettings(ModuleSettings moduleSettings)
  6547. {
  6548. SettingsForAllModules.SaveModuleSettings(moduleSettings);
  6549. }
  6550.  
  6551. private static bool DeployedModule(ModuleInfo moduleInfo)
  6552. {
  6553. try
  6554. {
  6555. Logger.WriteInfo(typeof (ModuleResolver), "DeployedModule", "Start deploy for module " + moduleInfo.Title);
  6556. string moduleFolderPath1 = ModuleResolver.GetDownloadsModuleFolderPath(moduleInfo);
  6557. string moduleFolderPath2 = ModuleResolver.GetModuleFolderPath(moduleInfo);
  6558. string moduleFolderPath3 = ModuleResolver.GetBackupModuleFolderPath(moduleInfo);
  6559. if (Directory.Exists(moduleFolderPath2))
  6560. {
  6561. string[] files = Directory.GetFiles(moduleFolderPath2);
  6562. if (files != null && files.Length > 0)
  6563. {
  6564. if (Directory.Exists(moduleFolderPath3))
  6565. Directory.Delete(moduleFolderPath3, true);
  6566. DirectoryInfo directoryInfo = new DirectoryInfo(moduleFolderPath3);
  6567. if (!directoryInfo.Parent.Exists)
  6568. directoryInfo.Parent.Create();
  6569. Directory.Move(moduleFolderPath2, moduleFolderPath3);
  6570. }
  6571. Logger.WriteInfo(typeof (ModuleResolver), "DeployedModule", "Backup module " + moduleInfo.Title + " execute successful");
  6572. }
  6573. if (!Directory.Exists(moduleFolderPath2))
  6574. Directory.CreateDirectory(moduleFolderPath2);
  6575. new ZipFile(ModuleResolver.GetDownloadsModuleFilePath(moduleInfo)).ExtractAll(moduleFolderPath2);
  6576. Logger.WriteInfo(typeof (ModuleResolver), "DeployedModule", "Module " + moduleInfo.Title + " unziped to folder " + moduleFolderPath2);
  6577. File.Copy(Path.Combine(moduleFolderPath1, ModuleResolver.GetModuleInfoFileName(moduleInfo)), Path.Combine(ModuleResolver.GetModulesFolderPath(), ModuleResolver.GetModuleInfoFileName(moduleInfo)), true);
  6578. Logger.WriteInfo(typeof (ModuleResolver), "DeployedModule", "ModuleInfo for module " + moduleInfo.Title + " moved to work folder");
  6579. Logger.WriteInfo(typeof (ModuleResolver), "DeployedModule", "Module " + moduleInfo.Title + " deployed successful");
  6580. return true;
  6581. }
  6582. catch (Exception ex)
  6583. {
  6584. Logger.WriteError(typeof (ModuleResolver), "DeployedModule", "Deploy module error", ex);
  6585. return false;
  6586. }
  6587. }
  6588.  
  6589. private static void SaveModuleFile(byte[] content, ModuleInfo moduleInfo)
  6590. {
  6591. string downloadsModuleFilePath = ModuleResolver.GetDownloadsModuleFilePath(moduleInfo);
  6592. FileInfo fileInfo = new FileInfo(downloadsModuleFilePath);
  6593. if (!fileInfo.Directory.Exists)
  6594. fileInfo.Directory.Create();
  6595. using (FileStream fileStream = File.Open(downloadsModuleFilePath, FileMode.Create))
  6596. fileStream.Write(content, 0, content.Length);
  6597. }
  6598.  
  6599. private static IModuleManager GetInstanceModuleManager(ModuleInfo moduleInfo)
  6600. {
  6601. try
  6602. {
  6603. if (ModuleResolver._moduleManagerDictionary.ContainsKey(moduleInfo.Title))
  6604. return ModuleResolver._moduleManagerDictionary[moduleInfo.Title];
  6605. string moduleFolderPath = ModuleResolver.GetModuleFolderPath(moduleInfo);
  6606. string title = moduleInfo.Title;
  6607. if (!Directory.Exists(moduleFolderPath))
  6608. return (IModuleManager) null;
  6609. foreach (string path in Directory.GetFiles(moduleFolderPath, "*.dll"))
  6610. {
  6611. IModuleManager imoduleManager = (IModuleManager) null;
  6612. Assembly assembly = Assembly.LoadFile(path);
  6613. Type type1 = (Type) null;
  6614. try
  6615. {
  6616. foreach (Type type2 in assembly.GetTypes())
  6617. {
  6618. if (Enumerable.Contains<Type>((IEnumerable<Type>) type2.GetInterfaces(), typeof (IModuleManager)))
  6619. {
  6620. type1 = type2;
  6621. break;
  6622. }
  6623. }
  6624. if (type1 == null)
  6625. continue;
  6626. }
  6627. catch (ReflectionTypeLoadException ex)
  6628. {
  6629. Logger.WriteError(typeof (ModuleResolver), "GetModuleManager()", string.Format("?? ??????? ???????? ???? ?????????? '{0}'", (object) title), (Exception) ex);
  6630. continue;
  6631. }
  6632. try
  6633. {
  6634. imoduleManager = (IModuleManager) Activator.CreateInstance(type1);
  6635. if (!ModuleResolver._moduleManagerDictionary.ContainsKey(moduleInfo.Title))
  6636. ModuleResolver._moduleManagerDictionary.Add(moduleInfo.Title, imoduleManager);
  6637. return imoduleManager;
  6638. }
  6639. catch (InvalidCastException ex)
  6640. {
  6641. Logger.WriteError(typeof (ModuleResolver), "GetModuleManager()", "?? ??????? ???????? ?????? ? ???? 'IModuleManager'", (Exception) ex);
  6642. }
  6643. if (imoduleManager != null)
  6644. Logger.WriteInfo(typeof (ModuleResolver), "GetModuleManager()", string.Format("?????? ??????? ???????? - {0}", (object) title));
  6645. }
  6646. }
  6647. catch (Exception ex)
  6648. {
  6649. Logger.WriteError(typeof (ModuleResolver), "GetInstanceModuleManager", "Instance of module manager not loaded", ex);
  6650. }
  6651. return (IModuleManager) null;
  6652. }
  6653.  
  6654. private static string GetDownloadsModuleFilePath(ModuleInfo moduleInfo)
  6655. {
  6656. return Path.Combine(ModuleResolver.GetDownloadsModuleFolderPath(moduleInfo), moduleInfo.Filename);
  6657. }
  6658.  
  6659. private static string GetModuleInfoFileName(ModuleInfo moduleInfo)
  6660. {
  6661. return string.Format("{0}.ModuleInfo.xml", (object) moduleInfo.Title);
  6662. }
  6663.  
  6664. private static void SaveModuleInfo(ModuleInfo moduleInfo, string filePath)
  6665. {
  6666. using (FileStream fileStream = File.Open(filePath, FileMode.Create))
  6667. new DataContractSerializer(typeof (ModuleInfo)).WriteObject((Stream) fileStream, (object) moduleInfo);
  6668. }
  6669.  
  6670. private static ModuleInfo ReadModuleInfo(string filePath)
  6671. {
  6672. if (!File.Exists(filePath))
  6673. return (ModuleInfo) null;
  6674. try
  6675. {
  6676. using (FileStream fileStream = File.Open(filePath, FileMode.Open))
  6677. return (ModuleInfo) new DataContractSerializer(typeof (ModuleInfo)).ReadObject((Stream) fileStream);
  6678. }
  6679. catch (Exception ex)
  6680. {
  6681. Logger.WriteError(typeof (ModuleResolver), "ReadModuleInfo()", "Error: ", ex);
  6682. return (ModuleInfo) null;
  6683. }
  6684. }
  6685.  
  6686. private static string GetDownloadsModuleFolderPath(ModuleInfo moduleInfo)
  6687. {
  6688. return Path.Combine(Environment.CurrentDirectory, string.Format("DownloadedModules\\{0}", (object) moduleInfo.Title));
  6689. }
  6690.  
  6691. private static string GetBackupModuleFolderPath(ModuleInfo moduleInfo)
  6692. {
  6693. return Path.Combine(Environment.CurrentDirectory, string.Format("BackupModules\\{0}", (object) moduleInfo.Title));
  6694. }
  6695.  
  6696. private static string GetModuleFolderPath(ModuleInfo moduleInfo)
  6697. {
  6698. return Path.Combine(ModuleResolver.GetModulesFolderPath(), moduleInfo.Title);
  6699. }
  6700.  
  6701. private static string GetModulesFolderPath()
  6702. {
  6703. return Path.Combine(Environment.CurrentDirectory, "Modules");
  6704. }
  6705. }
  6706. }
  6707. ?// Decompiled with JetBrains decompiler
  6708. // Type: WinApp.Managers.CountriesManager
  6709. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  6710. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  6711. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  6712.  
  6713. using Inc.Logging;
  6714. using IncMap;
  6715. using System;
  6716. using System.Collections.Generic;
  6717. using System.IO;
  6718. using System.Linq;
  6719. using System.Xml.Serialization;
  6720. using WinApp.Managers.Interfaces;
  6721. using WinApp.Managers.Localization;
  6722.  
  6723. namespace WinApp.Managers
  6724. {
  6725. internal class CountriesManager : ICountriesManager
  6726. {
  6727. private List<string> _deserializedCountries = new List<string>();
  6728.  
  6729. protected string FilePath
  6730. {
  6731. get
  6732. {
  6733. return Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WinApp"), string.Format("countries.xml"));
  6734. }
  6735. }
  6736.  
  6737. public CountriesManager()
  6738. {
  6739. this.DeserializeCountries();
  6740. this._deserializedCountries = new List<string>(Enumerable.Select<LocalizationObject, string>((IEnumerable<LocalizationObject>) Map.Get<ILocalizationManager>().LanguagesCollection, (Func<LocalizationObject, string>) (x => x.CountryName)));
  6741. }
  6742.  
  6743. public List<string> GetAllCountries()
  6744. {
  6745. return this._deserializedCountries;
  6746. }
  6747.  
  6748. private List<string> DeserializeCountries()
  6749. {
  6750. Logger.WriteError((object) typeof (CountriesManager), "DeserializeCountries()", "????????? ?????? ????? ?? ?????");
  6751. if (!File.Exists(this.FilePath))
  6752. {
  6753. Logger.WriteWarning(typeof (CountriesManager), "DeserializeCountries()", "???? ?? ??????? ????? ?? ??????");
  6754. return (List<string>) null;
  6755. }
  6756. List<string> list;
  6757. try
  6758. {
  6759. XmlSerializer xmlSerializer = new XmlSerializer(typeof (List<string>));
  6760. TextReader textReader = (TextReader) new StreamReader(this.FilePath);
  6761. list = (List<string>) xmlSerializer.Deserialize(textReader);
  6762. textReader.Close();
  6763. Logger.WriteWarning(typeof (CountriesManager), "DeserializeCountries()", "?????? ????? ??????? ???????");
  6764. }
  6765. catch (Exception ex)
  6766. {
  6767. list = (List<string>) null;
  6768. Logger.WriteError(typeof (CountriesManager), "DeserializeCountries()", "?????? ??? ????????? ????? ?? ?????", ex);
  6769. }
  6770. return list;
  6771. }
  6772. }
  6773. }
  6774. ?// Decompiled with JetBrains decompiler
  6775. // Type: WinApp.Managers.SessionManager
  6776. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  6777. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  6778. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  6779.  
  6780. using Inc.Logging;
  6781. using IncMap;
  6782. using KairosPlanet.Managers.Network;
  6783. using KairosPlanet.Properties;
  6784. using System;
  6785. using System.Net;
  6786. using System.ServiceModel;
  6787. using System.Windows;
  6788. using WinApp.Api;
  6789. using WinApp.Api.Data;
  6790. using WinApp.Api.Interfaces;
  6791. using WinApp.Data.Helpers;
  6792. using WinApp.Data.Model;
  6793. using WinApp.Managers.Configuration;
  6794. using WinApp.Managers.Interfaces;
  6795.  
  6796. namespace WinApp.Managers
  6797. {
  6798. public class SessionManager : ISessionManager
  6799. {
  6800. private IAuthApi _api;
  6801. private Man _currentUser;
  6802.  
  6803. public Man CurrentUser
  6804. {
  6805. get
  6806. {
  6807. return this._currentUser;
  6808. }
  6809. }
  6810.  
  6811. public IApi Api
  6812. {
  6813. get
  6814. {
  6815. return (IApi) this._api;
  6816. }
  6817. }
  6818.  
  6819. public LoginResponce Login(string user, string password)
  6820. {
  6821. CheckPoint checkPoint = Logger.CheckPointStart("Login(user, password)");
  6822. Logger.WriteInfo((object) this, "Login()", "Connect to service " + ApplicationSettings.ServiceUri);
  6823. this._api = Map.Get<IClientFactory>().CreateChannel(user, password, ApplicationSettings.ServiceUri, ConfigurationManager.GetUserAgent());
  6824. this._api.SetUserData(user, password);
  6825. try
  6826. {
  6827. UserResponse user1 = this._api.GetUser();
  6828. if (user1.User == null)
  6829. return LoginResponce.NoResponce;
  6830. if (user1.User.Email != user)
  6831. {
  6832. Logger.WriteError((object) this, "Login()", "?????? ?????? ????? ??????? ????????????.");
  6833. user1 = this._api.GetUser();
  6834. if (string.Equals(user1.User.Name, user, StringComparison.InvariantCultureIgnoreCase))
  6835. {
  6836. Logger.WriteError((object) this, "Login()", "?????? ?????? ?????? ????? ??????? ????????????.");
  6837. SessionMonitor.Instance.SetSessionStateToSuspended();
  6838. int num = (int) MessageBox.Show(Resources.Error_ServerReturnIncorrectData, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
  6839. throw new ApiException("?????? ?????? ????? ??????? ????????????.", HttpStatusCode.InternalServerError, "");
  6840. }
  6841. }
  6842. this._currentUser = user1.User;
  6843. SessionMonitor.Instance.SetSessionStateToLogon();
  6844. return LoginResponce.Pass(this.CurrentUser);
  6845. }
  6846. catch (ApiException ex)
  6847. {
  6848. if (ex.ErrorCode == HttpStatusCode.Unauthorized)
  6849. return LoginResponce.WrongInput;
  6850. }
  6851. finally
  6852. {
  6853. checkPoint.Close();
  6854. }
  6855. return LoginResponce.NoResponce;
  6856. }
  6857.  
  6858. public PingResponse PingSession(string activeModuleSecureKey)
  6859. {
  6860. try
  6861. {
  6862. Logger.WriteInfo((object) this, "PingSession()", "???????? Ping");
  6863. bool flag;
  6864. try
  6865. {
  6866. return this._api.Ping(activeModuleSecureKey);
  6867. }
  6868. catch (ApiException ex)
  6869. {
  6870. if (ex.ErrorCode == HttpStatusCode.NotFound || ex.ErrorCode == HttpStatusCode.Unauthorized)
  6871. {
  6872. if (string.Equals(ex.StatusDescription, "Secret key not found"))
  6873. throw;
  6874. else
  6875. flag = true;
  6876. }
  6877. else
  6878. throw;
  6879. }
  6880. if (flag)
  6881. {
  6882. Logger.WriteInfo((object) this, "PingSession()", "????????? ??????? ????????? ????????????(api.GetUser())");
  6883. if (this._api.GetUser().User.Id != this.CurrentUser.Id)
  6884. {
  6885. Logger.WriteError((object) this, "PingSession()", "?????? ?????? ????? ??????? ????????????.");
  6886. SessionMonitor.Instance.SetSessionStateToSuspended();
  6887. int num = (int) MessageBox.Show(Resources.Error_ServerReturnIncorrectData, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
  6888. throw new ApiException("?????? ?????? ????? ??????? ????????????.", HttpStatusCode.InternalServerError, "");
  6889. }
  6890. return this._api.Ping(activeModuleSecureKey);
  6891. }
  6892. }
  6893. catch (ApiException ex)
  6894. {
  6895. if (string.Equals(ex.StatusDescription, "Secret key not found"))
  6896. throw;
  6897. else
  6898. Logger.WriteError((object) this, "PingSession()", "Error during operation Ping", (Exception) ex);
  6899. }
  6900. catch (Exception ex)
  6901. {
  6902. Logger.WriteError((object) this, "PingSession()", "Error during operation Ping", ex);
  6903. }
  6904. return (PingResponse) null;
  6905. }
  6906.  
  6907. public void CloseSession()
  6908. {
  6909. if (this._api != null)
  6910. this._api.Close();
  6911. this._api = (IAuthApi) null;
  6912. this._currentUser = (Man) null;
  6913. }
  6914.  
  6915. public Statistic[] GetStatistics()
  6916. {
  6917. Logger.WriteInfo((object) this, "GetStatistics()", "Get Statistics from server");
  6918. try
  6919. {
  6920. return this._api.GetStatistics().Statistics;
  6921. }
  6922. catch (ApiException ex)
  6923. {
  6924. return new Statistic[0];
  6925. }
  6926. catch (EndpointNotFoundException ex)
  6927. {
  6928. return (Statistic[]) null;
  6929. }
  6930. catch (Exception ex)
  6931. {
  6932. Logger.WriteError((object) this, "GetStatistics()", "?????? ??? ????????? ??????????: " + ex.Message, ex);
  6933. return (Statistic[]) null;
  6934. }
  6935. }
  6936.  
  6937. public Statistic[] GetStatistics(DateTime periodStart, DateTime periodEnd)
  6938. {
  6939. Logger.WriteInfo((object) this, "GetStatistics(periodStart, periodEnd)", "Get Statistics from server for period");
  6940. try
  6941. {
  6942. StatisticsResponse statistics = this._api.GetStatistics(periodStart, periodEnd);
  6943. return statistics == null ? new Statistic[0] : statistics.Statistics;
  6944. }
  6945. catch (ApiException ex)
  6946. {
  6947. return new Statistic[0];
  6948. }
  6949. }
  6950.  
  6951. public Purchase[] GetPurchases()
  6952. {
  6953. PurchaseResponse purchases;
  6954. try
  6955. {
  6956. purchases = this._api.GetPurchases();
  6957. }
  6958. catch (ApiException ex)
  6959. {
  6960. return (Purchase[]) null;
  6961. }
  6962. catch (EndpointNotFoundException ex)
  6963. {
  6964. return (Purchase[]) null;
  6965. }
  6966. catch (Exception ex)
  6967. {
  6968. Logger.WriteError((object) this, "GetStatistics()", "?????? ??? ????????? ???????: " + ex.Message, ex);
  6969. return (Purchase[]) null;
  6970. }
  6971. return purchases.Purchases;
  6972. }
  6973.  
  6974. public string Activation(long purchaseId)
  6975. {
  6976. try
  6977. {
  6978. return this._api.Activation(new ActivationRequest()
  6979. {
  6980. PurchaseId = purchaseId
  6981. }).PackageSecureKey;
  6982. }
  6983. catch (Exception ex)
  6984. {
  6985. Logger.WriteError((object) this, "Activation()", "Error by activation", ex);
  6986. throw;
  6987. }
  6988. }
  6989.  
  6990. public string GetAppVersion()
  6991. {
  6992. try
  6993. {
  6994. return this._api.GetAppVersion().Version;
  6995. }
  6996. catch (ApiException ex)
  6997. {
  6998. Logger.WriteError((object) this, "GetAppVersion()", "Error: ", (Exception) ex);
  6999. return string.Empty;
  7000. }
  7001. }
  7002.  
  7003. public ModuleInfo GetModuleInfo(long productId)
  7004. {
  7005. ModuleInfo moduleInfo1 = new ModuleInfo();
  7006. try
  7007. {
  7008. ModuleInfoResponse moduleInfo2 = this._api.GetModuleInfo(productId);
  7009. moduleInfo1.Id = moduleInfo2.Id;
  7010. moduleInfo1.ProductId = moduleInfo2.ProductId;
  7011. moduleInfo1.Title = moduleInfo2.Title;
  7012. moduleInfo1.Version = moduleInfo2.Version;
  7013. moduleInfo1.Description = moduleInfo2.Description;
  7014. moduleInfo1.Filename = moduleInfo2.Filename;
  7015. moduleInfo1.Url = moduleInfo2.Url;
  7016. }
  7017. catch (ApiException ex)
  7018. {
  7019. Logger.WriteError((object) this, "GetModuleInfo(productId)", "Error: ", (Exception) ex);
  7020. return (ModuleInfo) null;
  7021. }
  7022. return moduleInfo1;
  7023. }
  7024.  
  7025. public byte[] GetModuleContent(long productId)
  7026. {
  7027. CheckPoint checkPoint = Logger.CheckPointStart("GetModuleContent");
  7028. try
  7029. {
  7030. ModuleContentResponse moduleContent = this._api.GetModuleContent(productId);
  7031. if (moduleContent != null && !string.IsNullOrEmpty(moduleContent.Source))
  7032. return Convert.FromBase64String(moduleContent.Source);
  7033. Logger.WriteWarning((object) this, "GetModuleContent()", "the module contents is not received");
  7034. return (byte[]) null;
  7035. }
  7036. catch (Exception ex)
  7037. {
  7038. Logger.WriteError((object) this, "GetModuleContent(productId)", "Error: ", ex);
  7039. return (byte[]) null;
  7040. }
  7041. finally
  7042. {
  7043. checkPoint.Close();
  7044. }
  7045. }
  7046.  
  7047. public void UpdateUserAgentString()
  7048. {
  7049. ConfigurationManager.UpdateUserAgent();
  7050. string userAgent = ConfigurationManager.GetUserAgent();
  7051. ApiAccess apiAccess = this._api as ApiAccess;
  7052. if (apiAccess == null)
  7053. return;
  7054. string login = string.Empty;
  7055. string password = string.Empty;
  7056. if (apiAccess.ClientCredentials != null)
  7057. {
  7058. login = apiAccess.ClientCredentials.UserName.UserName;
  7059. password = apiAccess.ClientCredentials.UserName.Password;
  7060. }
  7061. this._api = Map.Get<IClientFactory>().CreateChannel(login, password, ApplicationSettings.ServiceUri, userAgent);
  7062. }
  7063. }
  7064. }
  7065. ?// Decompiled with JetBrains decompiler
  7066. // Type: WinApp.Managers.ApplicationSettings
  7067. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  7068. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  7069. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  7070.  
  7071. using Inc.Logging;
  7072. using IncMap;
  7073. using Microsoft.Win32;
  7074. using System;
  7075. using System.Collections.Generic;
  7076. using System.Configuration;
  7077. using System.Globalization;
  7078. using System.IO;
  7079. using System.Linq;
  7080. using System.Reflection;
  7081. using System.Threading;
  7082. using System.Xml.Serialization;
  7083. using WinApp.Data.Security;
  7084. using WinApp.Managers.Interfaces;
  7085. using WinApp.Managers.Localization;
  7086.  
  7087. namespace WinApp.Managers
  7088. {
  7089. public class ApplicationSettings : IApplicationSettings
  7090. {
  7091. private static readonly string _configFileName = "\\ApplicationSettings.cfg";
  7092. private static readonly string _configPath = Environment.CurrentDirectory;
  7093. private static object _lockObject = new object();
  7094. private static string _serviceUri;
  7095.  
  7096. public static string ServiceUri
  7097. {
  7098. get
  7099. {
  7100. if (string.IsNullOrEmpty(ApplicationSettings._serviceUri))
  7101. {
  7102. string str = ConfigurationManager.AppSettings["ServiceUri"];
  7103. if (string.IsNullOrEmpty(str))
  7104. {
  7105. Logger.WriteError((object) typeof (ApplicationSettings), "ServiceUri", "ServiceUri not specified in settings app.config");
  7106. str = "https://cabinet.kairosplanet.com";
  7107. }
  7108. ApplicationSettings._serviceUri = str;
  7109. }
  7110. return ApplicationSettings._serviceUri;
  7111. }
  7112. }
  7113.  
  7114. public bool IsHttpUsed { get; set; }
  7115.  
  7116. public string LocalizationKey { get; set; }
  7117.  
  7118. [XmlIgnore]
  7119. public string Email
  7120. {
  7121. get
  7122. {
  7123. return Cryptography.UnprotectUserData(this.ProtectedEmail);
  7124. }
  7125. set
  7126. {
  7127. this.ProtectedEmail = Cryptography.ProtectedUserData(value);
  7128. }
  7129. }
  7130.  
  7131. [XmlIgnore]
  7132. public string Password
  7133. {
  7134. get
  7135. {
  7136. return Cryptography.UnprotectUserData(this.ProtectedPassword);
  7137. }
  7138. set
  7139. {
  7140. this.ProtectedPassword = Cryptography.ProtectedUserData(value);
  7141. }
  7142. }
  7143.  
  7144. public string ProtectedEmail { get; set; }
  7145.  
  7146. public string ProtectedPassword { get; set; }
  7147.  
  7148. public bool IsAutoLogin { get; set; }
  7149.  
  7150. public long ActiveProductId { get; set; }
  7151.  
  7152. public bool UseHttpPing { get; set; }
  7153.  
  7154. [XmlIgnore]
  7155. public bool RunAtStartup
  7156. {
  7157. get
  7158. {
  7159. return this.GetRunAtStartup();
  7160. }
  7161. set
  7162. {
  7163. this.SetRunAtStartup(value);
  7164. }
  7165. }
  7166.  
  7167. public bool IsRemeberMe { get; set; }
  7168.  
  7169. private static string ConfigFileFullName
  7170. {
  7171. get
  7172. {
  7173. return ApplicationSettings._configPath + ApplicationSettings._configFileName;
  7174. }
  7175. }
  7176.  
  7177. public ApplicationSettings()
  7178. {
  7179. Logger.WriteInfo(typeof (ApplicationSettings), "ApplicationSettings()", "????????????? ????? ????????...");
  7180. this.LocalizationKey = CultureInfo.CurrentUICulture.Name;
  7181. Logger.WriteInfo(typeof (ApplicationSettings), "ApplicationSettings()", "????? ????????? ????????????????");
  7182. }
  7183.  
  7184. public static ApplicationSettings GetClientSettings()
  7185. {
  7186. return ApplicationSettings.ReadConfigSettingFromFile(true);
  7187. }
  7188.  
  7189. public void SetLocalization(LocalizationObject localizationObject)
  7190. {
  7191. this.LocalizationKey = localizationObject.LocalizationKey;
  7192. Logger.WriteInfo(typeof (ApplicationSettings), "SetLocalization()", string.Format("??????????? ???????? ?? {0}", (object) this.LocalizationKey));
  7193. this.Save();
  7194. }
  7195.  
  7196. public void SetRunAtStartup(bool isRunAtStartup)
  7197. {
  7198. Logger.WriteInfo(typeof (ApplicationSettings), "SetRunAtStartup()", "????? ???????? ??????? ??? ??????...");
  7199. RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
  7200. if (registryKey == null)
  7201. {
  7202. Logger.WriteWarning(typeof (ApplicationSettings), "SetRunAtStartup()", "??????????? ???? null");
  7203. }
  7204. else
  7205. {
  7206. Assembly executingAssembly = Assembly.GetExecutingAssembly();
  7207. try
  7208. {
  7209. if (isRunAtStartup)
  7210. {
  7211. registryKey.SetValue(executingAssembly.GetName().Name, (object) executingAssembly.Location);
  7212. Logger.WriteInfo(typeof (ApplicationSettings), "SetRunAtStartup()", "?????? ?????????? ??? ?????? ???????");
  7213. }
  7214. else
  7215. {
  7216. registryKey.DeleteValue(executingAssembly.GetName().Name, false);
  7217. Logger.WriteInfo(typeof (ApplicationSettings), "SetRunAtStartup()", "?????? ?????????? ??? ?????? ????????");
  7218. }
  7219. }
  7220. catch (Exception ex)
  7221. {
  7222. Logger.WriteError(typeof (ApplicationSettings), "SetRunAtStartup()", "?????? ??? ????? ????????? ??????? ?????????? ??? ??????", ex);
  7223. }
  7224. }
  7225. }
  7226.  
  7227. public bool GetRunAtStartup()
  7228. {
  7229. Logger.WriteInfo(typeof (ApplicationSettings), "GetRunAtStartup()", "????????? ???????? ??????? ??? ??????...");
  7230. RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
  7231. if (registryKey == null)
  7232. {
  7233. Logger.WriteWarning(typeof (ApplicationSettings), "GetRunAtStartup()", "??????????? ???? null");
  7234. return false;
  7235. }
  7236. Assembly executingAssembly = Assembly.GetExecutingAssembly();
  7237. try
  7238. {
  7239. return registryKey.GetValue(executingAssembly.GetName().Name) != null;
  7240. }
  7241. catch (Exception ex)
  7242. {
  7243. Logger.WriteError(typeof (ApplicationSettings), "GetRunAtStartup()", "?????? ??? ????????? ????????? ??????? ?????????? ??? ??????", ex);
  7244. return false;
  7245. }
  7246. }
  7247.  
  7248. public void SetIsAutoLogin(bool isAutoLogin)
  7249. {
  7250. this.IsAutoLogin = isAutoLogin;
  7251. Logger.WriteInfo(typeof (ApplicationSettings), "SetIsAutoLogin()", string.Format("???????? ?????????? ???????? ?? {0}", (object) (bool) (isAutoLogin ? 1 : 0)));
  7252. this.Save();
  7253. }
  7254.  
  7255. public void SetHttpPingUsed(bool isHttpPingUsed)
  7256. {
  7257. this.IsHttpUsed = isHttpPingUsed;
  7258. Logger.WriteInfo(typeof (ApplicationSettings), "SetHttpPingUsed()", string.Format("???????? ????????????? http ping'a ?? {0}", (object) (bool) (isHttpPingUsed ? 1 : 0)));
  7259. this.Save();
  7260. }
  7261.  
  7262. public LocalizationObject GetLocalizationObject()
  7263. {
  7264. return Enumerable.SingleOrDefault<LocalizationObject>((IEnumerable<LocalizationObject>) Map.Get<ILocalizationManager>().LanguagesCollection, (Func<LocalizationObject, bool>) (lco => lco.LocalizationKey.Contains(this.LocalizationKey))) ?? Map.Get<ILocalizationManager>().LanguagesCollection[0];
  7265. }
  7266.  
  7267. public void RemeberMe(string email, string password)
  7268. {
  7269. this.Email = email;
  7270. this.Password = password;
  7271. this.IsRemeberMe = true;
  7272. Logger.WriteInfo(typeof (ApplicationSettings), "RememberMe()", "????????? ?????? ??? ?????");
  7273. this.Save();
  7274. }
  7275.  
  7276. public void ForgetMe()
  7277. {
  7278. this.IsAutoLogin = false;
  7279. this.IsRemeberMe = false;
  7280. this.Password = string.Empty;
  7281. Logger.WriteInfo(typeof (ApplicationSettings), "ForgetMe()", "???????? ?????????, ?????? ??????");
  7282. this.Save();
  7283. }
  7284.  
  7285. public void Save()
  7286. {
  7287. Logger.WriteInfo(typeof (ApplicationSettings), "SaveCredential()", "?????????? ????? ????????...");
  7288. string configFileFullName = ApplicationSettings.ConfigFileFullName;
  7289. try
  7290. {
  7291. lock (ApplicationSettings._lockObject)
  7292. {
  7293. using (FileStream resource_0 = new FileStream(configFileFullName, FileMode.Create))
  7294. {
  7295. new XmlSerializer(typeof (ApplicationSettings)).Serialize((Stream) resource_0, (object) this);
  7296. Logger.WriteInfo(typeof (ApplicationSettings), "SaveCredential()", "????????? ??????? ?????????");
  7297. }
  7298. }
  7299. }
  7300. catch (Exception ex)
  7301. {
  7302. Logger.WriteError(typeof (ApplicationSettings), "SaveCredential()", "?????? ??? ?????????? ????? ???????? ??????????", ex);
  7303. }
  7304. }
  7305.  
  7306. private static ApplicationSettings CreateNewSettings()
  7307. {
  7308. Logger.WriteInfo(typeof (ApplicationSettings), "CreateNewSettings()", "???????? ?????? ????? ????????...");
  7309. ApplicationSettings applicationSettings = new ApplicationSettings();
  7310. applicationSettings.Save();
  7311. Logger.WriteInfo(typeof (ApplicationSettings), "CreateNewSettings()", "????? ???? ???????? ??????");
  7312. return applicationSettings;
  7313. }
  7314.  
  7315. private static ApplicationSettings ReadConfigSettingFromFile(bool isEnableTryRead)
  7316. {
  7317. try
  7318. {
  7319. string configFileFullName = ApplicationSettings.ConfigFileFullName;
  7320. if (!File.Exists(configFileFullName))
  7321. return ApplicationSettings.CreateNewSettings();
  7322. lock (ApplicationSettings._lockObject)
  7323. {
  7324. using (FileStream resource_0 = File.OpenRead(configFileFullName))
  7325. {
  7326. Logger.WriteError((object) typeof (ApplicationSettings), "ReadConfigSettingFromFile()", "file opened. Start XmlSerializer.");
  7327. return (ApplicationSettings) new XmlSerializer(typeof (ApplicationSettings)).Deserialize((Stream) resource_0);
  7328. }
  7329. }
  7330. }
  7331. catch (Exception ex)
  7332. {
  7333. Logger.WriteError(typeof (ApplicationSettings), "ReadConfigSettingFromFile()", "?????? ??? ????????? ???????? , ??????: " + ex.Message, ex);
  7334. if (!isEnableTryRead)
  7335. throw new FileLoadException("?????? ??? ????????? ????????");
  7336. Thread.Sleep(1000);
  7337. return ApplicationSettings.ReadConfigSettingFromFile(false);
  7338. }
  7339. }
  7340. }
  7341. }
  7342. ?// Decompiled with JetBrains decompiler
  7343. // Type: WinApp.Managers.ScreenManager
  7344. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  7345. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  7346. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  7347.  
  7348. using Inc.Logging;
  7349. using IncMap;
  7350. using System;
  7351. using System.Collections.Generic;
  7352. using System.Drawing;
  7353. using System.Threading;
  7354. using System.Windows;
  7355. using System.Windows.Controls;
  7356. using System.Windows.Forms;
  7357. using System.Windows.Interop;
  7358. using Telerik.Windows.Controls;
  7359. using WinApp.Data.Model;
  7360. using WinApp.Managers.Interfaces;
  7361. using WinApp.Module;
  7362. using WinApp.Service.Repository.Interface;
  7363. using WinApp.View;
  7364. using WinApp.View.Base;
  7365. using WinApp.ViewModel;
  7366. using WinApp.ViewModel.Services;
  7367.  
  7368. namespace WinApp.Managers
  7369. {
  7370. internal class ScreenManager : IScreenManager
  7371. {
  7372. private readonly Stack<System.Windows.Controls.UserControl> _controlsHistory = new Stack<System.Windows.Controls.UserControl>();
  7373. private Thread _statusEndThread;
  7374.  
  7375. public MainViewUC MainView { get; private set; }
  7376.  
  7377. public void DoVisualSafe(Action action)
  7378. {
  7379. System.Windows.Application.Current.Dispatcher.BeginInvoke((Delegate) action);
  7380. }
  7381.  
  7382. public void SwitchBack()
  7383. {
  7384. Logger.WriteInfo(typeof (ScreenManager), "SwitchBack()", "??????????? ??????? ?? ?????????? ????????...");
  7385. if (!this.CanSwitchBack())
  7386. {
  7387. Logger.WriteWarning(typeof (ScreenManager), "SwitchBack()", "??? ??????????? ????????? ?? ?????????? ????????");
  7388. }
  7389. else
  7390. {
  7391. this._controlsHistory.Pop();
  7392. MainWindowVM viewModel = Map.Get<IMainWindow>().ViewModel;
  7393. if (viewModel == null)
  7394. {
  7395. Logger.WriteWarning(typeof (ScreenManager), "SwitchBack()", "???????? ?????? ???? ???????????");
  7396. }
  7397. else
  7398. {
  7399. viewModel.Content = this._controlsHistory.Peek();
  7400. Logger.WriteInfo(typeof (ScreenManager), "SwitchBack()", "??????? ?? ?????????? ???????? ???????? ???????");
  7401. }
  7402. }
  7403. }
  7404.  
  7405. public bool CanSwitchBack()
  7406. {
  7407. return this._controlsHistory.Count > 1;
  7408. }
  7409.  
  7410. public void SwitchToLogin()
  7411. {
  7412. try
  7413. {
  7414. Logger.WriteInfo(typeof (ScreenManager), "SwitchToLogin()", "?????????? ???????? ?? ???????? ??????...");
  7415. this.MainView = (MainViewUC) null;
  7416. this._controlsHistory.Clear();
  7417. this.SwitchTo((System.Windows.Controls.UserControl) new LoginUC(), false);
  7418. Logger.WriteInfo(typeof (ScreenManager), "SwitchToLogin()", "??????? ?? ???????? ?????? ??????? ????????");
  7419. }
  7420. catch (Exception ex)
  7421. {
  7422. Logger.WriteError((object) this, "SwitchToLogin()", "?????? ??? ???????? ?? ????? ??????: " + ex.Message);
  7423. }
  7424. }
  7425.  
  7426. public void SwitchToNewVersionAvailableWindow(Version appVersionOnSite, Version appVersionCurrent)
  7427. {
  7428. Logger.WriteInfo(typeof (ScreenManager), "SwitchToNewVersionAvailableWindow()", "?????????? ???????? ?? ???? ??????????? ??????????? ????? ??????");
  7429. this.MainView = (MainViewUC) null;
  7430. this._controlsHistory.Clear();
  7431. this.SwitchTo((System.Windows.Controls.UserControl) new VersionUC(appVersionOnSite, appVersionCurrent), false);
  7432. Logger.WriteInfo(typeof (ScreenManager), "SwitchToNewVersionAvailableWindow()", "??????? ?? ???? ??????????? ??????????? ????? ?????? ??????? ????????");
  7433. }
  7434.  
  7435. public void SwitchToMain()
  7436. {
  7437. Logger.WriteInfo(typeof (ScreenManager), "SwitchToMain()", "?????????? ???????? ?? ??????? ????????...");
  7438. this.MainView = new MainViewUC();
  7439. this.SwitchTo((System.Windows.Controls.UserControl) this.MainView, true);
  7440. Logger.WriteInfo(typeof (ScreenManager), "SwitchToMain()", "??????? ?? ??????? ???????? ??????? ????????");
  7441. }
  7442.  
  7443. public void SwitchToInstall(InstallModuleUC installModuleUc, ServiceVM serviceVm, Action<bool> onInstalledAction)
  7444. {
  7445. Logger.WriteInfo((object) this, "SwitchToInstall", "Action to install started");
  7446. System.Windows.Controls.Control oldControl = this.MainView.ViewModel.Content;
  7447. this.MainView.ViewModel.Content = (System.Windows.Controls.Control) installModuleUc;
  7448. installModuleUc.get_ViewModel().set_CloseAction((Action) (() =>
  7449. {
  7450. if (!installModuleUc.get_ViewModel().get_IsInstalled())
  7451. {
  7452. Logger.WriteInfo((object) this, "Install", "Action to install closed without installed");
  7453. }
  7454. else
  7455. {
  7456. Logger.WriteInfo((object) this, "Install", "Action to install closed with successful");
  7457. this.MainView.ViewModel.Content = oldControl;
  7458. Module moduleByProductId = Map.Get<IModuleRepository>().GetModuleByProductId(serviceVm.ProductId);
  7459. moduleByProductId.StateEnum = ModuleState.Installed;
  7460. Map.Get<IModuleRepository>().Save(moduleByProductId);
  7461. serviceVm.RefreshButtonContent();
  7462. onInstalledAction(installModuleUc.get_ViewModel().get_IsInstalled());
  7463. }
  7464. }));
  7465. }
  7466.  
  7467. public void ShowAlert(string message, string title)
  7468. {
  7469. TextBlock textBlock1 = new TextBlock();
  7470. textBlock1.Text = message;
  7471. textBlock1.TextWrapping = TextWrapping.Wrap;
  7472. textBlock1.Width = 400.0;
  7473. TextBlock textBlock2 = textBlock1;
  7474. DialogParameters dialogParameters = new DialogParameters();
  7475. dialogParameters.set_Content((object) textBlock2);
  7476. dialogParameters.set_Header((object) title);
  7477. dialogParameters.set_DialogStartupLocation(WindowStartupLocation.CenterOwner);
  7478. dialogParameters.set_OkButtonContent((object) "OK");
  7479. RadWindow.Alert(dialogParameters);
  7480. }
  7481.  
  7482. public Action ShowStatusMessage(string message, int timeInSeconds, bool isInProgress)
  7483. {
  7484. if (this.MainView == null)
  7485. return (Action) (() => {});
  7486. this.MainView.ViewModel.StatusMessage = message;
  7487. if (this._statusEndThread != null && this._statusEndThread.IsAlive)
  7488. this._statusEndThread.Abort();
  7489. if (isInProgress)
  7490. {
  7491. this.DoVisualSafe((Action) (() => this.MainView.ViewModel.IsStatusInProgress = Visibility.Visible));
  7492. return (Action) (() => this.DoVisualSafe((Action) (() =>
  7493. {
  7494. this.MainView.ViewModel.IsStatusInProgress = Visibility.Collapsed;
  7495. this.MainView.ViewModel.StatusMessage = string.Empty;
  7496. })));
  7497. }
  7498. this._statusEndThread = new Thread((ThreadStart) (() =>
  7499. {
  7500. Thread.Sleep(1000 * timeInSeconds);
  7501. if (this.MainView == null)
  7502. return;
  7503. this.DoVisualSafe((Action) (() => this.MainView.ViewModel.StatusMessage = string.Empty));
  7504. }));
  7505. this._statusEndThread.Start();
  7506. this.DoVisualSafe((Action) (() => this.MainView.ViewModel.IsStatusInProgress = Visibility.Collapsed));
  7507. return (Action) (() => {});
  7508. }
  7509.  
  7510. private void SwitchTo(System.Windows.Controls.UserControl control, bool pushToHistory = true)
  7511. {
  7512. CheckPoint checkPoint = Logger.CheckPointStart("SwithTo " + control.Name);
  7513. try
  7514. {
  7515. MainWindowVM viewModel = Map.Get<IMainWindow>().ViewModel;
  7516. if (viewModel == null)
  7517. return;
  7518. IWindowArrangeView windowArrangeView = control as IWindowArrangeView;
  7519. if (windowArrangeView != null)
  7520. {
  7521. WindowCommon windowCommon = Map.Get<IMainWindow>() as WindowCommon;
  7522. if (windowCommon != null)
  7523. {
  7524. ((UIElement) windowCommon).Visibility = Visibility.Hidden;
  7525. ((UIElement) windowCommon).UpdateLayout();
  7526. ((FrameworkElement) windowCommon).Width = windowArrangeView.WindowWidth;
  7527. ((FrameworkElement) windowCommon).Height = windowArrangeView.WindowHeight;
  7528. ((WindowBase) windowCommon).set_ResizeMode(windowArrangeView.ResizeMode);
  7529. ((UIElement) windowCommon).UpdateLayout();
  7530. Screen screen = Screen.FromHandle(new WindowInteropHelper(windowCommon.ParentWindow).Handle);
  7531. Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
  7532. double num1 = 96.0 / (double) graphics.DpiX;
  7533. double num2 = 96.0 / (double) graphics.DpiY;
  7534. ((WindowBase) windowCommon).set_Left(Math.Round(((double) screen.Bounds.X + ((double) screen.WorkingArea.Width - ((FrameworkElement) windowCommon).ActualWidth / num1) / 2.0) * num1));
  7535. ((WindowBase) windowCommon).set_Top(Math.Round(((double) screen.Bounds.Y + ((double) screen.WorkingArea.Height - ((FrameworkElement) windowCommon).ActualHeight / num2) / 2.0) * num2));
  7536. ((UIElement) windowCommon).Visibility = Visibility.Visible;
  7537. }
  7538. }
  7539. viewModel.Content = control;
  7540. if (!pushToHistory)
  7541. return;
  7542. this._controlsHistory.Push(control);
  7543. }
  7544. finally
  7545. {
  7546. checkPoint.Close();
  7547. }
  7548. }
  7549. }
  7550. }
  7551. ?// Decompiled with JetBrains decompiler
  7552. // Type: WinApp.Bootstrapper
  7553. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  7554. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  7555. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  7556.  
  7557. using Inc.Logging;
  7558. using IncMap;
  7559. using KairosPlanet.Managers.Data;
  7560. using KairosPlanet.Managers.Interfaces;
  7561. using System;
  7562. using WinApp.Api;
  7563. using WinApp.Managers;
  7564. using WinApp.Managers.Interfaces;
  7565. using WinApp.Managers.Localization;
  7566. using WinApp.Service;
  7567. using WinApp.View;
  7568.  
  7569. namespace WinApp
  7570. {
  7571. internal class Bootstrapper
  7572. {
  7573. public static void Bootstrap()
  7574. {
  7575. Logger.WriteInfo(typeof (Bootstrapper), "Bootstrap()", "????????????? ??????????? Bootstrapper...");
  7576. Map.Inject<IApplicationSettings>((IApplicationSettings) ApplicationSettings.GetClientSettings());
  7577. Map.Inject<IScreenManager>((IScreenManager) new ScreenManager());
  7578. Map.InjectLazy<IAppTray>((Func<object>) (() => (object) new AppTray()));
  7579. Map.InjectLazy<IMainWindow>((Func<object>) (() => (object) new MainWindow()));
  7580. Map.Inject<ILocalizationManager>((ILocalizationManager) new LocalizationManager());
  7581. Map.Inject<ICountriesManager>((ICountriesManager) new CountriesManager());
  7582. Map.Inject<IModuleResolver>((IModuleResolver) new ModuleResolver());
  7583. Map.Inject<ISessionManager>((ISessionManager) new SessionManager());
  7584. Map.Inject<IPurchaseManager>((IPurchaseManager) new PurchaseManager());
  7585. Logger.WriteInfo(typeof (Bootstrapper), "Bootstrap()", "?????????? Bootstrapper ??????? ???????????????");
  7586. ServiceBootstrapper.Bootstrap();
  7587. ApiBootstrapper.Bootstrap();
  7588. }
  7589. }
  7590. }
  7591. ?// Decompiled with JetBrains decompiler
  7592. // Type: WinApp.ViewModel.Tray.TrayStateVM
  7593. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  7594. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  7595. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  7596.  
  7597. using KairosPlanet.Properties;
  7598. using WinApp.ViewModel.Base;
  7599.  
  7600. namespace WinApp.ViewModel.Tray
  7601. {
  7602. public class TrayStateVM : ViewModelBase
  7603. {
  7604. public static TrayStateVM None = new TrayStateVM(Resources.NetworkState_None, "/Assets/Images/None.ico");
  7605. public static TrayStateVM Offline = new TrayStateVM(Resources.NetworkState_Offline, "/Assets/Images/Offline.ico");
  7606. public static TrayStateVM Online = new TrayStateVM(Resources.NetworkState_Online, "/Assets/Images/Online.ico");
  7607.  
  7608. public string ToolTipText { get; private set; }
  7609.  
  7610. public string IconPath { get; private set; }
  7611.  
  7612. private TrayStateVM(string toolTipText, string iconPath)
  7613. {
  7614. this.ToolTipText = toolTipText;
  7615. this.IconPath = iconPath;
  7616. }
  7617. }
  7618. }
  7619. ?// Decompiled with JetBrains decompiler
  7620. // Type: WinApp.ViewModel.Tray.AppTrayVM
  7621. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  7622. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  7623. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  7624.  
  7625. using IncMap;
  7626. using System;
  7627. using System.Linq.Expressions;
  7628. using System.Windows.Controls;
  7629. using System.Windows.Input;
  7630. using WinApp;
  7631. using WinApp.Managers.Interfaces;
  7632. using WinApp.View;
  7633. using WinApp.ViewModel;
  7634. using WinApp.ViewModel.Base;
  7635. using WinApp.ViewModel.MainMenu;
  7636.  
  7637. namespace WinApp.ViewModel.Tray
  7638. {
  7639. public class AppTrayVM : ViewModelBase
  7640. {
  7641. public TrayStateVM TrayState
  7642. {
  7643. get
  7644. {
  7645. switch (AppVM.Instance.NetworkState)
  7646. {
  7647. case NetworkState.None:
  7648. return TrayStateVM.None;
  7649. case NetworkState.NetworkNotFound:
  7650. case NetworkState.ServerNotFound:
  7651. return TrayStateVM.Offline;
  7652. case NetworkState.ServerOnline:
  7653. return TrayStateVM.Online;
  7654. default:
  7655. return (TrayStateVM) null;
  7656. }
  7657. }
  7658. }
  7659.  
  7660. public ICommand ShowWindowCommand
  7661. {
  7662. get
  7663. {
  7664. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.ShowWindowCommand), new Action(Map.Get<IMainWindow>().Open));
  7665. }
  7666. }
  7667.  
  7668. public ICommand ServicesCommand
  7669. {
  7670. get
  7671. {
  7672. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.ServicesCommand), (Action) (() => this.SwitchToMenuItem((Func<MainMenuCollection, MainMenuItem>) (x => (MainMenuItem) x.Services))));
  7673. }
  7674. }
  7675.  
  7676. public ICommand StatisticsCommand
  7677. {
  7678. get
  7679. {
  7680. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.StatisticsCommand), (Action) (() => this.SwitchToMenuItem((Func<MainMenuCollection, MainMenuItem>) (x => (MainMenuItem) x.Statistics))));
  7681. }
  7682. }
  7683.  
  7684. public ICommand ProfileCommand
  7685. {
  7686. get
  7687. {
  7688. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.ProfileCommand), (Action) (() => this.SwitchToMenuItem((Func<MainMenuCollection, MainMenuItem>) (x => (MainMenuItem) x.Profile))));
  7689. }
  7690. }
  7691.  
  7692. public ICommand SettingsCommand
  7693. {
  7694. get
  7695. {
  7696. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.SettingsCommand), (Action) (() => this.SwitchToMenuItem((Func<MainMenuCollection, MainMenuItem>) (x => (MainMenuItem) x.Settings))));
  7697. }
  7698. }
  7699.  
  7700. public ICommand LogInCommand
  7701. {
  7702. get
  7703. {
  7704. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.LogInCommand), new Action(Map.Get<IMainWindow>().Open));
  7705. }
  7706. }
  7707.  
  7708. public ICommand LogOutCommand
  7709. {
  7710. get
  7711. {
  7712. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.LogOutCommand), new Action(this.LogOutAction));
  7713. }
  7714. }
  7715.  
  7716. public ICommand ExitCommand
  7717. {
  7718. get
  7719. {
  7720. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.ExitCommand), new Action(Map.Get<IMainWindow>().ViewModel.Exit));
  7721. }
  7722. }
  7723.  
  7724. public ContextMenu ContextMenu
  7725. {
  7726. get
  7727. {
  7728. switch (AppVM.Instance.LoginState)
  7729. {
  7730. case LoginState.NoLogin:
  7731. return this.NoLoginContextMenu;
  7732. case LoginState.Done:
  7733. return this.FullContextMenu;
  7734. default:
  7735. return (ContextMenu) null;
  7736. }
  7737. }
  7738. }
  7739.  
  7740. public ContextMenu NoLoginContextMenu { get; set; }
  7741.  
  7742. public ContextMenu FullContextMenu { get; set; }
  7743.  
  7744. public void Refresh()
  7745. {
  7746. this.OnPropertyChanged("TrayState");
  7747. this.OnPropertyChanged("ContextMenu");
  7748. }
  7749.  
  7750. private void SwitchToMenuItem(Func<MainMenuCollection, MainMenuItem> selector)
  7751. {
  7752. MainViewUC mainView = Map.Get<IScreenManager>().MainView;
  7753. mainView.ViewModel.SwithToMenuItem(selector(mainView.ViewModel.MenuItems));
  7754. Map.Get<IMainWindow>().Open();
  7755. }
  7756.  
  7757. private void LogOutAction()
  7758. {
  7759. Map.Get<IApplicationSettings>().ForgetMe();
  7760. AppVM.Instance.ProcedeLogOut();
  7761. Map.Get<IMainWindow>().Open();
  7762. }
  7763. }
  7764. }
  7765. ?// Decompiled with JetBrains decompiler
  7766. // Type: WinApp.ViewModel.Base.EntityVM`1
  7767. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  7768. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  7769. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  7770.  
  7771. using System.Collections.Generic;
  7772. using WinApp.Data.Model;
  7773.  
  7774. namespace WinApp.ViewModel.Base
  7775. {
  7776. public abstract class EntityVM<T> : ViewModelBase where T : Entity, new()
  7777. {
  7778. private T _model;
  7779.  
  7780. public long Id
  7781. {
  7782. get
  7783. {
  7784. return this.Model.Id;
  7785. }
  7786. }
  7787.  
  7788. public T Model
  7789. {
  7790. get
  7791. {
  7792. return this._model;
  7793. }
  7794. set
  7795. {
  7796. this._model = value;
  7797. this.OnPropertyChanged("Model");
  7798. foreach (string propertyName in this.GetFieldNames())
  7799. this.OnPropertyChanged(propertyName);
  7800. }
  7801. }
  7802.  
  7803. protected EntityVM(T model)
  7804. {
  7805. this.Model = model;
  7806. }
  7807.  
  7808. protected abstract IEnumerable<string> GetFieldNames();
  7809. }
  7810. }
  7811. ?// Decompiled with JetBrains decompiler
  7812. // Type: WinApp.ViewModel.Base.SymbolHelpers
  7813. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  7814. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  7815. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  7816.  
  7817. using System;
  7818. using System.Linq.Expressions;
  7819.  
  7820. namespace WinApp.ViewModel.Base
  7821. {
  7822. public static class SymbolHelpers
  7823. {
  7824. public static string GetPropertyName<T>(Expression<Func<T>> propertyExpression)
  7825. {
  7826. if (propertyExpression == null || propertyExpression.Body == null)
  7827. return string.Empty;
  7828. return (propertyExpression.Body as MemberExpression).Member.Name;
  7829. }
  7830. }
  7831. }
  7832. ?// Decompiled with JetBrains decompiler
  7833. // Type: WinApp.ViewModel.Base.CommandHolder
  7834. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  7835. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  7836. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  7837.  
  7838. using System;
  7839. using System.Collections.Generic;
  7840. using System.Linq.Expressions;
  7841. using System.Windows.Input;
  7842.  
  7843. namespace WinApp.ViewModel.Base
  7844. {
  7845. public class CommandHolder
  7846. {
  7847. private readonly Dictionary<string, ICommand> _commands = new Dictionary<string, ICommand>();
  7848.  
  7849. public ICommand GetOrCreateCommand<T>(Expression<Func<T>> commandNameExpression, Action executeCommandAction)
  7850. {
  7851. return this.GetOrCreateCommand<T>(commandNameExpression, executeCommandAction, (Func<bool>) (() => true));
  7852. }
  7853.  
  7854. public ICommand GetOrCreateCommand<T>(Expression<Func<T>> commandNameExpression, Action<object> executeCommandAction)
  7855. {
  7856. string propertyName = SymbolHelpers.GetPropertyName<T>(commandNameExpression);
  7857. if (!this._commands.ContainsKey(propertyName))
  7858. {
  7859. RelayCommand relayCommand = new RelayCommand(executeCommandAction);
  7860. this._commands.Add(propertyName, (ICommand) relayCommand);
  7861. }
  7862. return this._commands[propertyName];
  7863. }
  7864.  
  7865. public ICommand GetOrCreateCommand<T>(Expression<Func<T>> commandNameExpression, Action executeCommandAction, Func<bool> canExecutePredicate)
  7866. {
  7867. return this.GetOrCreateCommand<T>(commandNameExpression, (Action<object>) (parameter => executeCommandAction()), (Func<object, bool>) (parameter => canExecutePredicate()));
  7868. }
  7869.  
  7870. public ICommand GetOrCreateCommand<T>(Expression<Func<T>> commandNameExpression, Action<object> executeCommandAction, Func<object, bool> canExecutePredicate)
  7871. {
  7872. string propertyName = SymbolHelpers.GetPropertyName<T>(commandNameExpression);
  7873. if (!this._commands.ContainsKey(propertyName))
  7874. {
  7875. RelayCommand relayCommand = new RelayCommand(executeCommandAction, canExecutePredicate);
  7876. this._commands.Add(propertyName, (ICommand) relayCommand);
  7877. }
  7878. return this._commands[propertyName];
  7879. }
  7880. }
  7881. }
  7882. ?// Decompiled with JetBrains decompiler
  7883. // Type: WinApp.ViewModel.Base.ViewModelBase
  7884. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  7885. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  7886. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  7887.  
  7888. using System;
  7889. using System.ComponentModel;
  7890.  
  7891. namespace WinApp.ViewModel.Base
  7892. {
  7893. public class ViewModelBase : INotifyPropertyChanged, IDataErrorInfo
  7894. {
  7895. private CommandHolder _commands;
  7896.  
  7897. public CommandHolder Commands
  7898. {
  7899. get
  7900. {
  7901. return this._commands ?? (this._commands = new CommandHolder());
  7902. }
  7903. }
  7904.  
  7905. public virtual string Error
  7906. {
  7907. get
  7908. {
  7909. return string.Empty;
  7910. }
  7911. }
  7912.  
  7913. public virtual string this[string columnName]
  7914. {
  7915. get
  7916. {
  7917. return string.Empty;
  7918. }
  7919. }
  7920.  
  7921. public event PropertyChangedEventHandler PropertyChanged;
  7922.  
  7923. protected void OnPropertyChanged(string propertyName)
  7924. {
  7925. if (this.PropertyChanged == null)
  7926. return;
  7927. try
  7928. {
  7929. this.PropertyChanged((object) this, new PropertyChangedEventArgs(propertyName));
  7930. }
  7931. catch (Exception ex)
  7932. {
  7933. }
  7934. }
  7935. }
  7936. }
  7937. ?// Decompiled with JetBrains decompiler
  7938. // Type: WinApp.ViewModel.Base.RelayCommand
  7939. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  7940. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  7941. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  7942.  
  7943. using System;
  7944. using System.Windows;
  7945. using System.Windows.Input;
  7946. using System.Windows.Threading;
  7947.  
  7948. namespace WinApp.ViewModel.Base
  7949. {
  7950. public class RelayCommand : ICommand
  7951. {
  7952. private readonly Action<object> _execute;
  7953. private readonly Func<object, bool> _canExecute;
  7954. private EventHandler _internalCanExecuteChanged;
  7955.  
  7956. public event EventHandler CanExecuteChanged
  7957. {
  7958. add
  7959. {
  7960. this._internalCanExecuteChanged += value;
  7961. CommandManager.RequerySuggested += value;
  7962. }
  7963. remove
  7964. {
  7965. this._internalCanExecuteChanged += value;
  7966. CommandManager.RequerySuggested -= value;
  7967. }
  7968. }
  7969.  
  7970. public RelayCommand(Action<object> execute)
  7971. : this(execute, (Func<object, bool>) null)
  7972. {
  7973. }
  7974.  
  7975. public RelayCommand(Action<object> execute, Func<object, bool> canExecute)
  7976. {
  7977. if (execute == null)
  7978. throw new ArgumentNullException("execute");
  7979. this._execute = execute;
  7980. this._canExecute = canExecute;
  7981. }
  7982.  
  7983. public bool CanExecute(object parameter)
  7984. {
  7985. if (this._canExecute != null)
  7986. return this._canExecute(parameter);
  7987. return true;
  7988. }
  7989.  
  7990. public void Execute(object parameter)
  7991. {
  7992. this._execute(parameter);
  7993. }
  7994.  
  7995. public void RaiseCanExecuteChanged()
  7996. {
  7997. if (this._canExecute == null)
  7998. return;
  7999. Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Delegate) (() => this.OnCanExecuteChanged()));
  8000. }
  8001.  
  8002. protected virtual void OnCanExecuteChanged()
  8003. {
  8004. EventHandler eventHandler = this._internalCanExecuteChanged;
  8005. if (eventHandler == null)
  8006. return;
  8007. eventHandler((object) this, EventArgs.Empty);
  8008. }
  8009. }
  8010. }
  8011. ?// Decompiled with JetBrains decompiler
  8012. // Type: WinApp.ViewModel.Services.ServiceVM
  8013. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  8014. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  8015. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  8016.  
  8017. using Inc.Logging;
  8018. using IncMap;
  8019. using KairosPlanet;
  8020. using KairosPlanet.Managers.Interfaces;
  8021. using KairosPlanet.Properties;
  8022. using KairosPlanet.ViewModel.Services;
  8023. using System;
  8024. using System.Collections.Generic;
  8025. using System.Diagnostics;
  8026. using System.Globalization;
  8027. using System.IO;
  8028. using System.Threading;
  8029. using System.Windows;
  8030. using System.Windows.Documents;
  8031. using System.Windows.Input;
  8032. using System.Windows.Markup;
  8033. using System.Windows.Media;
  8034. using System.Windows.Media.Imaging;
  8035. using System.Windows.Threading;
  8036. using Telerik.Windows.Controls;
  8037. using WinApp.Data.Model;
  8038. using WinApp.Managers;
  8039. using WinApp.Managers.Interfaces;
  8040. using WinApp.Module;
  8041. using WinApp.Service.Repository.Interface;
  8042. using WinApp.View.Helpers;
  8043. using WinApp.ViewModel;
  8044. using WinApp.ViewModel.Base;
  8045.  
  8046. namespace WinApp.ViewModel.Services
  8047. {
  8048. internal class ServiceVM : ViewModelBase
  8049. {
  8050. private static object _lockObject = new object();
  8051. private readonly Product _product;
  8052. private Purchase _purchase;
  8053. private Module _module;
  8054. private bool _isDisabledProduct;
  8055. private TileViewItemState _state;
  8056. private FlowDocument _richDescription;
  8057. private ImageSource _image;
  8058. private IModuleManager _manager;
  8059. private IModuleResolver _moduleResolver;
  8060.  
  8061. public long ProductId
  8062. {
  8063. get
  8064. {
  8065. return this._product.Id;
  8066. }
  8067. }
  8068.  
  8069. public Purchase Purchase
  8070. {
  8071. get
  8072. {
  8073. return this._purchase;
  8074. }
  8075. }
  8076.  
  8077. public string ServiceButtonContent
  8078. {
  8079. get
  8080. {
  8081. if (!this._isDisabledProduct)
  8082. {
  8083. switch (this._module.StateEnum)
  8084. {
  8085. case ModuleState.Buy:
  8086. return Resources.ServiceVM_Buy;
  8087. case ModuleState.Install:
  8088. return Resources.ServiceVM_Install;
  8089. case ModuleState.Installed:
  8090. return Resources.ServiceVM_Activate;
  8091. case ModuleState.InstalledAndActivated:
  8092. case ModuleState.ValidityCompleted:
  8093. case ModuleState.Blocked:
  8094. return Resources.ServiceVM_Details;
  8095. case ModuleState.Order:
  8096. return Resources.ServiceVM_Order;
  8097. }
  8098. }
  8099. return Resources.ServiceVM_Details;
  8100. }
  8101. }
  8102.  
  8103. public TileViewItemState State
  8104. {
  8105. get
  8106. {
  8107. return this._state;
  8108. }
  8109. set
  8110. {
  8111. this._state = value;
  8112. this.OnPropertyChanged("State");
  8113. this.OnPropertyChanged("RichDescription");
  8114. }
  8115. }
  8116.  
  8117. public string Title
  8118. {
  8119. get
  8120. {
  8121. return this._product.Title;
  8122. }
  8123. set
  8124. {
  8125. this._product.Title = value;
  8126. this.OnPropertyChanged("Title");
  8127. }
  8128. }
  8129.  
  8130. public double Price
  8131. {
  8132. get
  8133. {
  8134. return this._product.Price;
  8135. }
  8136. set
  8137. {
  8138. this._product.Price = value;
  8139. this.OnPropertyChanged("Price");
  8140. }
  8141. }
  8142.  
  8143. public ImageSource Image
  8144. {
  8145. get
  8146. {
  8147. return this._image;
  8148. }
  8149. private set
  8150. {
  8151. this._image = value;
  8152. this.OnPropertyChanged("Image");
  8153. }
  8154. }
  8155.  
  8156. public DateTime? PurchaseDate
  8157. {
  8158. get
  8159. {
  8160. if (this._purchase == null)
  8161. return new DateTime?();
  8162. return this._purchase.Date;
  8163. }
  8164. }
  8165.  
  8166. public string BackgroundColor
  8167. {
  8168. get
  8169. {
  8170. if (this._module.StateEnum == ModuleState.ValidityCompleted || this._isDisabledProduct)
  8171. return "#253A516B";
  8172. if (this._module.StateEnum == ModuleState.Order)
  8173. return "#55A3AD1D";
  8174. return this._module.StateEnum != ModuleState.Buy ? "#553A516B" : "Transparent";
  8175. }
  8176. }
  8177.  
  8178. public double EnableOpacity
  8179. {
  8180. get
  8181. {
  8182. return this._module.StateEnum != ModuleState.ValidityCompleted && !this._isDisabledProduct ? 1.0 : 0.65;
  8183. }
  8184. }
  8185.  
  8186. public bool IsEnableMainButton
  8187. {
  8188. get
  8189. {
  8190. if (this._module.StateEnum != ModuleState.ValidityCompleted)
  8191. return !this._isDisabledProduct;
  8192. return false;
  8193. }
  8194. }
  8195.  
  8196. public ICommand RestoreStateCommand
  8197. {
  8198. get
  8199. {
  8200. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.RestoreStateCommand), (Action) (() => this.State = (TileViewItemState) 0));
  8201. }
  8202. }
  8203.  
  8204. public FlowDocument RichDescription
  8205. {
  8206. get
  8207. {
  8208. if (this._richDescription == null && this._state == 1)
  8209. new Thread(new ThreadStart(this.GetDetailedDescription))
  8210. {
  8211. CurrentCulture = Thread.CurrentThread.CurrentCulture,
  8212. CurrentUICulture = Thread.CurrentThread.CurrentUICulture,
  8213. IsBackground = true
  8214. }.Start();
  8215. return this._richDescription;
  8216. }
  8217. }
  8218.  
  8219. public ICommand MainCommand
  8220. {
  8221. get
  8222. {
  8223. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.MainCommand), new Action(this.MainAction));
  8224. }
  8225. }
  8226.  
  8227. public ServiceVM(Product product, Purchase purchase)
  8228. {
  8229. this._product = product;
  8230. this._purchase = purchase;
  8231. this._module = this.GetModule();
  8232. this.UpdateByInnerPurchase();
  8233. new Thread(new ThreadStart(this.GetImageFromUrl))
  8234. {
  8235. IsBackground = true
  8236. }.Start();
  8237. }
  8238.  
  8239. public void RefreshButtonContent()
  8240. {
  8241. this.OnPropertyChanged("ServiceButtonContent");
  8242. this.OnPropertyChanged("IsEnableMainButton");
  8243. this.OnPropertyChanged("EnableOpacity");
  8244. this.OnPropertyChanged("BackgroundColor");
  8245. }
  8246.  
  8247. public void DisableProduct()
  8248. {
  8249. this._isDisabledProduct = true;
  8250. }
  8251.  
  8252. public void Update(Purchase purchase)
  8253. {
  8254. if (purchase.ProductId != this.ProductId)
  8255. return;
  8256. lock (ServiceVM._lockObject)
  8257. {
  8258. if (this._module == null)
  8259. return;
  8260. this._purchase = purchase;
  8261. this.UpdateByInnerPurchase();
  8262. }
  8263. }
  8264.  
  8265. internal void UpdateByInnerPurchase()
  8266. {
  8267. if (this._module == null)
  8268. return;
  8269. lock (ServiceVM._lockObject)
  8270. {
  8271. ModuleState local_0 = this._module.StateEnum;
  8272. bool local_1 = true;
  8273. if (this._purchase == null)
  8274. this._module.StateEnum = this._product.Price <= AppVM.Instance.ActivePackagePrice ? ModuleState.Blocked : ModuleState.Buy;
  8275. else if ((this._purchase.PackageStatus == 1 || this._purchase.PackageStatus == 3) && this._purchase.Status == 1)
  8276. {
  8277. if (AppVM.Instance.ModuleErrorState == ModuleErrorState.CrashOrNotFoundMainFile || AppVM.Instance.ModuleErrorState == ModuleErrorState.ModuleNotInstalledMessage)
  8278. {
  8279. this._module.StateEnum = ModuleState.Install;
  8280. Logger.WriteInfo((object) this, "UpdateByInnerPurchase", string.Concat(new object[4]
  8281. {
  8282. (object) "Update product '",
  8283. (object) this._product.Title,
  8284. (object) "': ModuleErrorState = ",
  8285. (object) AppVM.Instance.ModuleErrorState
  8286. }));
  8287. local_1 = false;
  8288. }
  8289. else
  8290. this._module.StateEnum = this.ProductIsInstalledAndActivated() ? ModuleState.InstalledAndActivated : ModuleState.Install;
  8291. }
  8292. else if ((this._purchase.PackageStatus == 1 || this._purchase.PackageStatus == 3) && this._purchase.Status == 3)
  8293. this._module.StateEnum = ModuleState.Order;
  8294. else if (this._purchase.PackageStatus == 4)
  8295. this._module.StateEnum = ModuleState.ValidityCompleted;
  8296. else if (this._purchase.PackageStatus == 5)
  8297. this._module.StateEnum = ModuleState.Blocked;
  8298. if (local_1 && this._module.StateEnum != local_0)
  8299. {
  8300. Map.Get<IModuleRepository>().Save(this._module);
  8301. Logger.WriteInfo((object) this, "UpdateByInnerPurchase", "Module status changed and saved from '" + (object) local_0 + "' to '" + (string) (object) this._module.StateEnum + "'");
  8302. }
  8303. this.RefreshButtonContent();
  8304. }
  8305. }
  8306.  
  8307. private bool ProductIsInstalledAndActivated()
  8308. {
  8309. lock (ServiceVM._lockObject)
  8310. {
  8311. try
  8312. {
  8313. return Map.Get<IModuleRepository>().IsInstalledAndActivated(this._product.Id);
  8314. }
  8315. catch (Exception exception_0)
  8316. {
  8317. Logger.WriteError((object) this, "ProductIsInstalledAndActivated", "Error by read module info from DB for product '" + this._product.Title + "'", exception_0);
  8318. return false;
  8319. }
  8320. }
  8321. }
  8322.  
  8323. private Module GetModule()
  8324. {
  8325. Module moduleByProductId = Map.Get<IModuleRepository>().GetModuleByProductId(this.ProductId);
  8326. if (moduleByProductId != null)
  8327. return moduleByProductId;
  8328. Module entity = new Module()
  8329. {
  8330. ProductId = this.ProductId,
  8331. StateEnum = ModuleState.Buy
  8332. };
  8333. Map.Get<IModuleRepository>().Save(entity);
  8334. return entity;
  8335. }
  8336.  
  8337. private void GetImageFromUrl()
  8338. {
  8339. Uri uri;
  8340. try
  8341. {
  8342. Logger.WriteInfo((object) this, "GetImageFromUrl()", "Product " + this._product.Title + " ImageUrl = " + this._product.ImageUrl);
  8343. uri = new Uri(string.IsNullOrEmpty(this._product.ImageUrl) ? string.Format("{0}/main/img/{1}.png", (object) ApplicationSettings.ServiceUri, (object) this._product.Title.ToLowerInvariant()) : this._product.ImageUrl);
  8344. }
  8345. catch (Exception ex)
  8346. {
  8347. Logger.WriteError((object) this, "GetImageFromUrl()", "Error get uri for product '" + this._product.Title + "'. product.ImageUrl = '" + this._product.ImageUrl + "'", ex);
  8348. uri = new Uri(string.Format("{0}/main/img/{1}.png", (object) ApplicationSettings.ServiceUri, (object) this._product.Title.ToLowerInvariant()));
  8349. }
  8350. try
  8351. {
  8352. BitmapImage image = new BitmapImage();
  8353. image.BeginInit();
  8354. image.StreamSource = WebHelper.DownloadImage(uri, Environment.ExpandEnvironmentVariables(string.Format("%TEMP%\\Kairos\\{0}_img.png", (object) this._product.Title.ToLowerInvariant())));
  8355. image.EndInit();
  8356. image.Freeze();
  8357. Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Delegate) (() => this.Image = (ImageSource) image));
  8358. }
  8359. catch (Exception ex)
  8360. {
  8361. Logger.WriteError((object) this, "GetImageFromUrl()", "Error get uri for product '" + this._product.Title + "'. url = '" + uri.AbsolutePath + "'", ex);
  8362. }
  8363. }
  8364.  
  8365. private void GetDetailedDescription()
  8366. {
  8367. lock (ServiceVM._lockObject)
  8368. {
  8369. Stream local_0 = this.GetRtfTextDescription(this._product);
  8370. FlowDocument local_1 = new FlowDocument();
  8371. new TextRange(local_1.ContentStart, local_1.ContentEnd).Load(local_0, DataFormats.Rtf);
  8372. MemoryStream stream = new MemoryStream();
  8373. XamlWriter.Save((object) local_1, (Stream) stream);
  8374. stream.Position = 0L;
  8375. Application.Current.Dispatcher.BeginInvoke((Delegate) (() =>
  8376. {
  8377. this._richDescription = (FlowDocument) XamlReader.Load((Stream) stream);
  8378. this.OnPropertyChanged("RichDescription");
  8379. }));
  8380. }
  8381. }
  8382.  
  8383. private Stream GetRtfTextDescription(Product product)
  8384. {
  8385. lock (ServiceVM._lockObject)
  8386. {
  8387. string local_4 = RtfReplaseser.Replase(new StreamReader(Application.GetResourceStream(new Uri(Resources.ServicesVM_ProductDescriptionFileName, UriKind.Relative)).Stream).ReadToEnd(), new Dictionary<string, string>()
  8388. {
  8389. {
  8390. "<%ProductTitle%>",
  8391. product.Title
  8392. },
  8393. {
  8394. "<%ProductPrice%>",
  8395. product.Price.ToString((IFormatProvider) CultureInfo.CurrentCulture)
  8396. },
  8397. {
  8398. "<%Available%>",
  8399. product.Attributes.Available
  8400. },
  8401. {
  8402. "<%BasicIncome%>",
  8403. product.Attributes.BasicIncome
  8404. },
  8405. {
  8406. "<%BasicIncomePeriod%>",
  8407. product.Attributes.BasicIncomePeriod
  8408. },
  8409. {
  8410. "<%DiscSpace%>",
  8411. product.Attributes.DiscSpace.ToString()
  8412. },
  8413. {
  8414. "<%InvestmentPeriod%>",
  8415. product.Attributes.InvestmentPeriod
  8416. },
  8417. {
  8418. "<%Profit%>",
  8419. product.Attributes.Profit
  8420. },
  8421. {
  8422. "<%Start%>",
  8423. product.Attributes.Start
  8424. },
  8425. {
  8426. "<%TimeOnline%>",
  8427. product.Attributes.TimeOnline
  8428. }
  8429. });
  8430. MemoryStream local_5 = new MemoryStream();
  8431. new StreamWriter((Stream) local_5).Write(local_4);
  8432. local_5.Position = 0L;
  8433. return (Stream) local_5;
  8434. }
  8435. }
  8436.  
  8437. private void MainAction()
  8438. {
  8439. lock (ServiceVM._lockObject)
  8440. {
  8441. if (this._module == null)
  8442. return;
  8443. switch (this._module.StateEnum)
  8444. {
  8445. case ModuleState.Buy:
  8446. Process.Start(this._product.ProductUrl);
  8447. break;
  8448. case ModuleState.Install:
  8449. this.InstallModule();
  8450. break;
  8451. case ModuleState.Installed:
  8452. this.ActivateInstalledModule(true);
  8453. break;
  8454. case ModuleState.InstalledAndActivated:
  8455. case ModuleState.ValidityCompleted:
  8456. case ModuleState.Blocked:
  8457. case ModuleState.Order:
  8458. this.State = (TileViewItemState) 1;
  8459. break;
  8460. }
  8461. }
  8462. }
  8463.  
  8464. private void InstallModule()
  8465. {
  8466. lock (ServiceVM._lockObject)
  8467. {
  8468. try
  8469. {
  8470. WinApp.Data.Model.ModuleInfo local_0 = Map.Get<IModuleResolver>().GetModuleInfo(this._product.Id);
  8471. if (local_0 == null)
  8472. {
  8473. Logger.WriteError((object) this, "InstallModule", "Module Info not found. exit from install");
  8474. }
  8475. else
  8476. {
  8477. if (this._moduleResolver == null)
  8478. this._moduleResolver = Map.Get<IModuleResolver>();
  8479. if (this._manager == null)
  8480. {
  8481. Logger.WriteWarning((object) this, "InstallModule", "Module not found. Start get it");
  8482. this._manager = this._moduleResolver.GetModuleManager(local_0);
  8483. }
  8484. if (this._manager == null)
  8485. return;
  8486. Map.Get<IScreenManager>().SwitchToInstall(this._manager.Install((InvestmentType) 3, this._product.Attributes.DiscSpace, (IModuleCallback) this._moduleResolver), this, new Action<bool>(this.ActivateInstalledModule));
  8487. }
  8488. }
  8489. catch (Exception exception_0)
  8490. {
  8491. Logger.WriteError((object) this, "InstallModule", "Install module for product '" + this._product.Title + "' error:" + exception_0.Message);
  8492. int temp_27 = (int) MessageBox.Show("Product not installed", "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
  8493. }
  8494. }
  8495. }
  8496.  
  8497. private void ActivateInstalledModule(bool isInstalled)
  8498. {
  8499. lock (ServiceVM._lockObject)
  8500. {
  8501. try
  8502. {
  8503. if (isInstalled)
  8504. {
  8505. this._module.StateEnum = ModuleState.Installed;
  8506. this.RefreshButtonContent();
  8507. }
  8508. Logger.WriteInfo((object) this, "ActivateInstalledModule", "Start action of activation");
  8509. if (Map.Get<IPurchaseManager>().ActivateModule(this._purchase))
  8510. {
  8511. this._module.StateEnum = ModuleState.InstalledAndActivated;
  8512. AppVM.Instance.SetActivePackage(this._purchase.ProductId);
  8513. Logger.WriteInfo((object) this, "ActivateInstalledModule", string.Format(Resources.ScreenManager_ModuleInstalled, (object) this._product.Title));
  8514. IScreenManager local_1 = Map.Get<IScreenManager>();
  8515. local_1.DoVisualSafe(local_1.ShowStatusMessage(string.Format(Resources.ScreenManager_ModuleInstalled, (object) this._product.Title), 15, false));
  8516. }
  8517. else
  8518. {
  8519. this._module.StateEnum = ModuleState.Install;
  8520. Map.Get<IScreenManager>().ShowStatusMessage(Resources.ActivationError_TryReinstallModule, 5, false);
  8521. }
  8522. }
  8523. catch (Exception exception_0)
  8524. {
  8525. Logger.WriteError((object) this, "ModuleInstalled", "Activate module after install for product '" + this._product.Title + "' error:", exception_0);
  8526. int temp_32 = (int) MessageBox.Show("Activate installed product problem", "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
  8527. }
  8528. }
  8529. this.RefreshButtonContent();
  8530. }
  8531. }
  8532. }
  8533. ?// Decompiled with JetBrains decompiler
  8534. // Type: WinApp.ViewModel.LoginVM
  8535. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  8536. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  8537. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  8538.  
  8539. using Inc.Logging;
  8540. using IncMap;
  8541. using System;
  8542. using System.Diagnostics;
  8543. using System.Windows;
  8544. using System.Windows.Input;
  8545. using WinApp;
  8546. using WinApp.Data.Helpers;
  8547. using WinApp.Managers;
  8548. using WinApp.Managers.Interfaces;
  8549. using WinApp.Managers.Network;
  8550.  
  8551. namespace WinApp.ViewModel
  8552. {
  8553. internal class LoginVM : LoginBaseVM
  8554. {
  8555. private Visibility _visibleCheckBoxChangePing = Visibility.Hidden;
  8556. private Visibility _visibleHttpWarning = Visibility.Hidden;
  8557. private bool _remeberMeEnabled;
  8558. private byte _countPing;
  8559. private bool _isCheckHttpPing;
  8560.  
  8561. public bool RemeberMeEnabled
  8562. {
  8563. get
  8564. {
  8565. return this._remeberMeEnabled;
  8566. }
  8567. set
  8568. {
  8569. this._remeberMeEnabled = value;
  8570. if (this._remeberMeEnabled)
  8571. Map.Get<IApplicationSettings>().IsAutoLogin = true;
  8572. this.OnPropertyChanged("RemeberMeEnabled");
  8573. }
  8574. }
  8575.  
  8576. public bool IsConnectionAvailable
  8577. {
  8578. get
  8579. {
  8580. bool flag = NetworkMonitor.NetworkState == NetworkState.ServerOnline;
  8581. if (flag)
  8582. this.VisibleCheckBoxChangePing = Visibility.Hidden;
  8583. return flag;
  8584. }
  8585. }
  8586.  
  8587. public bool IsCheckHttpPing
  8588. {
  8589. get
  8590. {
  8591. this._isCheckHttpPing = Map.Get<IApplicationSettings>().IsHttpUsed;
  8592. return this._isCheckHttpPing;
  8593. }
  8594. set
  8595. {
  8596. this._isCheckHttpPing = value;
  8597. NetworkMonitor.SetPingThrough(this._isCheckHttpPing);
  8598. Map.Get<IApplicationSettings>().SetHttpPingUsed(this._isCheckHttpPing);
  8599. this.OnPropertyChanged("IsCheckHttpPing");
  8600. this.OnPropertyChanged("IsCheckIcmpPing");
  8601. this.OnPropertyChanged("VisibleHttpWarning");
  8602. }
  8603. }
  8604.  
  8605. public bool IsCheckIcmpPing
  8606. {
  8607. get
  8608. {
  8609. return !this.IsCheckHttpPing;
  8610. }
  8611. set
  8612. {
  8613. this.IsCheckHttpPing = false;
  8614. }
  8615. }
  8616.  
  8617. public Visibility VisibleCheckBoxChangePing
  8618. {
  8619. get
  8620. {
  8621. if (Map.Get<IApplicationSettings>().IsHttpUsed)
  8622. this._visibleCheckBoxChangePing = Visibility.Visible;
  8623. return this._visibleCheckBoxChangePing;
  8624. }
  8625. set
  8626. {
  8627. this._visibleCheckBoxChangePing = value;
  8628. this.OnPropertyChanged("VisibleCheckBoxChangePing");
  8629. }
  8630. }
  8631.  
  8632. public Visibility VisibleHttpWarning
  8633. {
  8634. get
  8635. {
  8636. return !this.IsCheckHttpPing ? Visibility.Hidden : Visibility.Visible;
  8637. }
  8638. set
  8639. {
  8640. this.OnPropertyChanged("VisibleHttpWarning");
  8641. }
  8642. }
  8643.  
  8644. public ICommand DoRegister
  8645. {
  8646. get
  8647. {
  8648. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.DoRegister), (Action) (() => Process.Start(ApplicationSettings.ServiceUri + "/register/")));
  8649. }
  8650. }
  8651.  
  8652. public ICommand DoRestorePassword
  8653. {
  8654. get
  8655. {
  8656. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.DoRestorePassword), (Action) (() => Process.Start(ApplicationSettings.ServiceUri + "/resetting/request")));
  8657. }
  8658. }
  8659.  
  8660. public LoginVM()
  8661. {
  8662. NetworkMonitor.NetworkStateChanged += new EventHandler<NetworkStateEventArgs>(this.NetworkMonitor_NetworkStateChanged);
  8663. NetworkMonitor.ConnectionAttemptFailed += new EventHandler<EventArgs>(this.NetworkMonitorOnConnectionAttemptFailed);
  8664. if (NetworkMonitor.NetworkState != NetworkState.ServerOnline)
  8665. return;
  8666. this.TryAutoLogin();
  8667. }
  8668.  
  8669. public LoginVM(string email, string password)
  8670. : base(email, password)
  8671. {
  8672. NetworkMonitor.NetworkStateChanged += new EventHandler<NetworkStateEventArgs>(this.NetworkMonitor_NetworkStateChanged);
  8673. NetworkMonitor.ConnectionAttemptFailed += new EventHandler<EventArgs>(this.NetworkMonitorOnConnectionAttemptFailed);
  8674. if (NetworkMonitor.NetworkState != NetworkState.ServerOnline)
  8675. return;
  8676. this.TryAutoLogin();
  8677. }
  8678.  
  8679. public void Initialize()
  8680. {
  8681. try
  8682. {
  8683. this._remeberMeEnabled = Map.Get<IApplicationSettings>().IsRemeberMe;
  8684. this.OnPropertyChanged("RemeberMeEnabled");
  8685. string email = Map.Get<IApplicationSettings>().Email;
  8686. this.EmailEditable = string.IsNullOrEmpty(email) || !AppVM.Instance.ActivePackageId.HasValue || AppVM.Instance.ActivePackageId.Value < 1L;
  8687. this.Email = email;
  8688. if (string.IsNullOrEmpty(this.Email) || !this.RemeberMeEnabled)
  8689. return;
  8690. this.Password = Map.Get<IApplicationSettings>().Password;
  8691. }
  8692. catch (Exception ex)
  8693. {
  8694. Logger.WriteError((object) this, "Initialize()", "??????: " + ex.Message);
  8695. }
  8696. }
  8697.  
  8698. protected override void PassAction(bool isAutoLogin)
  8699. {
  8700. if (!isAutoLogin)
  8701. {
  8702. if (this.RemeberMeEnabled)
  8703. {
  8704. Map.Get<IApplicationSettings>().RemeberMe(this.Email, this.Password);
  8705. }
  8706. else
  8707. {
  8708. Map.Get<IApplicationSettings>().ForgetMe();
  8709. Map.Get<IApplicationSettings>().Email = this.Email;
  8710. Map.Get<IApplicationSettings>().Save();
  8711. }
  8712. }
  8713. AppVM.Instance.LogIn();
  8714. }
  8715.  
  8716. protected override LoginResponce RequestLogin(string email, string password)
  8717. {
  8718. Logger.WriteInfo(typeof (LoginVM), "RequestLogin()", "?????? ?? ???? ? ???????");
  8719. LoginResponce loginResponce = Map.Get<ISessionManager>().Login(email.ToLower(), password);
  8720. Logger.WriteInfo(typeof (LoginVM), "RequestLogin()", string.Format("????? ?? ??????: '{0}'", (object) loginResponce.Result));
  8721. return loginResponce;
  8722. }
  8723.  
  8724. private void NetworkMonitor_NetworkStateChanged(object sender, NetworkStateEventArgs e)
  8725. {
  8726. this.OnPropertyChanged("IsConnectionAvailable");
  8727. if (!this.IsConnectionAvailable)
  8728. return;
  8729. this.TryAutoLogin();
  8730. }
  8731.  
  8732. private void TryAutoLogin()
  8733. {
  8734. try
  8735. {
  8736. if (!Map.Get<IApplicationSettings>().IsAutoLogin)
  8737. return;
  8738. Logger.WriteInfo((object) this, "TryAutoLogin()", "??????? ?????????. ????? ??????? ????? ? ???????");
  8739. Application.Current.Dispatcher.BeginInvoke((Delegate) (() => this.ExecuteLogin(true)));
  8740. }
  8741. catch (Exception ex)
  8742. {
  8743. Logger.WriteError((object) this, "TryAutoLogin()", "?????? ??? ??????? ?????????? ??????" + ex.ToString(), ex);
  8744. }
  8745. }
  8746.  
  8747. private void NetworkMonitorOnConnectionAttemptFailed(object sender, EventArgs eventArgs)
  8748. {
  8749. this.VisibleCheckBoxChangePing = Visibility.Visible;
  8750. }
  8751. }
  8752. }
  8753. ?// Decompiled with JetBrains decompiler
  8754. // Type: WinApp.ViewModel.SessionChartItemVM
  8755. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  8756. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  8757. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  8758.  
  8759. using System;
  8760. using WinApp.ViewModel.Base;
  8761.  
  8762. namespace WinApp.ViewModel
  8763. {
  8764. public class SessionChartItemVM : ViewModelBase
  8765. {
  8766. private DateTime _date;
  8767. private double _duration;
  8768.  
  8769. public DateTime Date
  8770. {
  8771. get
  8772. {
  8773. return this._date;
  8774. }
  8775. set
  8776. {
  8777. this._date = value;
  8778. this.OnPropertyChanged("EndTime");
  8779. }
  8780. }
  8781.  
  8782. public double Duration
  8783. {
  8784. get
  8785. {
  8786. return this._duration;
  8787. }
  8788. set
  8789. {
  8790. this._duration = value;
  8791. this.OnPropertyChanged("Duration");
  8792. }
  8793. }
  8794.  
  8795. public SessionChartItemVM(DateTime date, double minutes)
  8796. {
  8797. this._date = date;
  8798. this._duration = minutes;
  8799. }
  8800. }
  8801. }
  8802. ?// Decompiled with JetBrains decompiler
  8803. // Type: WinApp.ViewModel.Controls.SessionStatisticsVM
  8804. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  8805. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  8806. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  8807.  
  8808. using Inc.Logging;
  8809. using IncMap;
  8810. using KairosPlanet.Managers;
  8811. using KairosPlanet.Managers.Network;
  8812. using KairosPlanet.Properties;
  8813. using System;
  8814. using System.Collections.Generic;
  8815. using System.Linq;
  8816. using System.Threading;
  8817. using System.Timers;
  8818. using System.Windows;
  8819. using System.Windows.Input;
  8820. using WinApp;
  8821. using WinApp.Api.Data;
  8822. using WinApp.Data.Helpers;
  8823. using WinApp.Managers;
  8824. using WinApp.Managers.Interfaces;
  8825. using WinApp.Managers.Network;
  8826. using WinApp.ViewModel;
  8827. using WinApp.ViewModel.Base;
  8828.  
  8829. namespace WinApp.ViewModel.Controls
  8830. {
  8831. internal class SessionStatisticsVM : ViewModelBase
  8832. {
  8833. private static object _lockObject = new object();
  8834. private TimeSpan _sessionTime = new TimeSpan();
  8835. private object _sessionTimeLock = new object();
  8836. private System.Timers.Timer _timer;
  8837. private TimeSpan _allSessionTime;
  8838. private TimeSpan _today;
  8839. private TimeSpan _yesterday;
  8840. private TimeSpan _currentMonth;
  8841. private TimeSpan _lastMonth;
  8842. private TimeSpan _total;
  8843. private bool _isStartPing;
  8844. private DateTime _lastDateTimeUpdateSessionTime;
  8845. private DateTime _currentDate;
  8846. private Thread _loadThread;
  8847.  
  8848. public string CurrentSession
  8849. {
  8850. get
  8851. {
  8852. return TimeSpanExtention.TotalTimeString(this.SessionTime, "{0:00}:{1:00}:{2:00}");
  8853. }
  8854. }
  8855.  
  8856. public string Today
  8857. {
  8858. get
  8859. {
  8860. return TimeSpanExtention.TotalTimeString(this._today.Add(this.SessionTime), "{0:00}:{1:00}");
  8861. }
  8862. }
  8863.  
  8864. public string Yesterday
  8865. {
  8866. get
  8867. {
  8868. return TimeSpanExtention.TotalTimeString(this._yesterday, "{0:00}:{1:00}");
  8869. }
  8870. }
  8871.  
  8872. public string CurrentMonth
  8873. {
  8874. get
  8875. {
  8876. return TimeSpanExtention.TotalTimeString(this._currentMonth.Add(this.SessionTime), "{0:00}:{1:00}");
  8877. }
  8878. }
  8879.  
  8880. public string LastMonth
  8881. {
  8882. get
  8883. {
  8884. return TimeSpanExtention.TotalTimeString(this._lastMonth, "{0:00}:{1:00}");
  8885. }
  8886. }
  8887.  
  8888. public string Total
  8889. {
  8890. get
  8891. {
  8892. return TimeSpanExtention.TotalTimeString(this._total.Add(this.SessionTime), "{0:00}:{1:00}");
  8893. }
  8894. }
  8895.  
  8896. public string TimeLeftToEarnMoney
  8897. {
  8898. get
  8899. {
  8900. return TimeSpanExtention.TotalTimeString(TimeSpan.FromHours(500.0).Subtract(this._currentMonth.Add(this.SessionTime)), "{0:00}:{1:00}");
  8901. }
  8902. }
  8903.  
  8904. public Visibility NotPingVisibility
  8905. {
  8906. get
  8907. {
  8908. return !this._isStartPing && !AppVM.Instance.ActivePackageId.HasValue ? Visibility.Visible : Visibility.Collapsed;
  8909. }
  8910. }
  8911.  
  8912. public Visibility NotPingAndRetrievingDataVisibility
  8913. {
  8914. get
  8915. {
  8916. return this._isStartPing || !AppVM.Instance.ActivePackageId.HasValue ? Visibility.Collapsed : Visibility.Visible;
  8917. }
  8918. }
  8919.  
  8920. public Visibility PingVisibility
  8921. {
  8922. get
  8923. {
  8924. return !this._isStartPing ? Visibility.Collapsed : Visibility.Visible;
  8925. }
  8926. }
  8927.  
  8928. public ICommand RefreshCommand
  8929. {
  8930. get
  8931. {
  8932. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.RefreshCommand), new Action(this.DoRefresh), new Func<bool>(this.CanRefresh));
  8933. }
  8934. }
  8935.  
  8936. private TimeSpan SessionTime
  8937. {
  8938. get
  8939. {
  8940. return this._sessionTime;
  8941. }
  8942. set
  8943. {
  8944. if (this._sessionTime == value)
  8945. return;
  8946. TimeSpan timeSpan = this._sessionTime;
  8947. this._sessionTime = value;
  8948. this.OnPropertyChanged("CurrentSession");
  8949. if (timeSpan.Minutes == this._sessionTime.Minutes)
  8950. return;
  8951. this.OnPropertyChanged("Today");
  8952. this.OnPropertyChanged("CurrentMonth");
  8953. this.OnPropertyChanged("Total");
  8954. }
  8955. }
  8956.  
  8957. public SessionStatisticsVM()
  8958. {
  8959. NetworkMonitor.NetworkStateChanged += new EventHandler<NetworkStateEventArgs>(this.OnNetworkStateChanged);
  8960. this.InitializeTimer();
  8961. this.OnNetworkStateChanged((object) this, new NetworkStateEventArgs(AppVM.Instance.NetworkState));
  8962. Map.Get<ISessionManager>();
  8963. SessionMonitor.Instance.PingEvent += new SessionMonitor.PingEventHandler(this.OnPingEvent);
  8964. SessionMonitor.Instance.SessionStateChanged += new EventHandler<SessionStateEventArgs>(this.OnSessionStateChanged);
  8965. if (SessionMonitor.Instance.FirstSessionPing == null)
  8966. return;
  8967. SessionMonitor.Instance.InvokePingEvent(SessionMonitor.Instance.FirstSessionPing.Lifetime);
  8968. }
  8969.  
  8970. private bool CanRefresh()
  8971. {
  8972. if (NetworkMonitor.NetworkState != NetworkState.ServerOnline)
  8973. return false;
  8974. if (this._loadThread != null)
  8975. return !this._loadThread.IsAlive;
  8976. return true;
  8977. }
  8978.  
  8979. private void DoRefresh()
  8980. {
  8981. if (NetworkMonitor.NetworkState != NetworkState.ServerOnline)
  8982. return;
  8983. Logger.WriteInfo((object) this, "DoRefresh", "?????? ?????? ???????? ??????????");
  8984. this.UpdateStatisticsAndStatisticCashe();
  8985. }
  8986.  
  8987. private void UpdateStatisticsAndStatisticCashe()
  8988. {
  8989. if (this._loadThread != null && this._loadThread.IsAlive)
  8990. return;
  8991. Logger.WriteInfo((object) this, "UpdateStatisticsAndStatisticCashe", "????? ???? ? ?????????? ?????????? ? ???????");
  8992. this._loadThread = new Thread((ThreadStart) (() =>
  8993. {
  8994. Action action = Map.Get<IScreenManager>().ShowStatusMessage(Resources.StatusMessage_IsRefreshing, 5, true);
  8995. Thread.Sleep(1000);
  8996. StatisticManager.Instance.SetNeedRefreshStatistics();
  8997. this.UpdateStatistics(true);
  8998. action();
  8999. }))
  9000. {
  9001. CurrentUICulture = Thread.CurrentThread.CurrentUICulture,
  9002. IsBackground = true
  9003. };
  9004. this._loadThread.Start();
  9005. }
  9006.  
  9007. private void OnPingEvent(object sender, PingEventArgs e)
  9008. {
  9009. lock (this._sessionTimeLock)
  9010. {
  9011. if (!this._isStartPing)
  9012. {
  9013. this._isStartPing = true;
  9014. this._timer.Start();
  9015. this.OnPropertyChanged("NotPingVisibility");
  9016. this.OnPropertyChanged("PingVisibility");
  9017. this.OnPropertyChanged("NotPingAndRetrievingDataVisibility");
  9018. }
  9019. this._lastDateTimeUpdateSessionTime = DateTime.Now;
  9020. this.SessionTime = new TimeSpan(0, 0, (int) e.LifeTime);
  9021. }
  9022. this.InitializeTimer();
  9023. }
  9024.  
  9025. private void UpdateStatistics(bool isRefreshCommand = false)
  9026. {
  9027. Logger.WriteInfo(typeof (SessionStatisticsVM), "UpdateStatistics()", "????????? ? ?????????? ?????? ??????????...");
  9028. if (!isRefreshCommand)
  9029. this._currentDate = DateTime.Today;
  9030. DateTime dateTime = this._currentDate;
  9031. Statistic[] totalStatistics = StatisticManager.Instance.GetStatistics();
  9032. if (isRefreshCommand && totalStatistics == null)
  9033. {
  9034. Logger.WriteError((object) typeof (SessionStatisticsVM), "UpdateStatistics()", "??? ?????????? ??????? ?????????? ?????? ?? ?????????? ?? ???????? ??-?? ?????? ?????????? ? ????????. ??????????? ????????? ????????? ????????? ???????????");
  9035. SessionMonitor.Instance.SetSessionStateToSuspended();
  9036. }
  9037. else
  9038. {
  9039. if (totalStatistics == null)
  9040. totalStatistics = new Statistic[0];
  9041. this._today = this.GetTotalTimeByPeriod(new DateTime?(dateTime.Date), new DateTime?(dateTime.Date.AddDays(1.0)), totalStatistics);
  9042. this._yesterday = this.GetTotalTimeByPeriod(new DateTime?(dateTime.Date.AddDays(-1.0)), new DateTime?(dateTime.Date), totalStatistics);
  9043. this._currentMonth = this.GetTotalTimeByPeriod(new DateTime?(dateTime.Date.AddDays((double) (1 - dateTime.Day))), new DateTime?(dateTime.Date.AddDays((double) (1 - dateTime.Day)).AddMonths(1)), totalStatistics);
  9044. this._lastMonth = this.GetTotalTimeByPeriod(new DateTime?(dateTime.Date.AddDays((double) (1 - dateTime.Day)).AddMonths(-1)), new DateTime?(dateTime.Date.AddDays((double) (1 - dateTime.Day))), totalStatistics);
  9045. this._total = this.GetTotalTimeByPeriod(new DateTime?(), new DateTime?(), totalStatistics);
  9046. Logger.WriteInfo(typeof (SessionStatisticsVM), "UpdateStatistics()", "??? ?????? ???????? ? ?????????");
  9047. this.RefreshProperties();
  9048. }
  9049. }
  9050.  
  9051. private void RefreshProperties()
  9052. {
  9053. this.OnPropertyChanged("CurrentSession");
  9054. this.OnPropertyChanged("Today");
  9055. this.OnPropertyChanged("Yesterday");
  9056. this.OnPropertyChanged("CurrentMonth");
  9057. this.OnPropertyChanged("LastMonth");
  9058. this.OnPropertyChanged("Total");
  9059. this.OnPropertyChanged("TimeLeftToEarnMoney");
  9060. this.OnPropertyChanged("NotPingVisibility");
  9061. this.OnPropertyChanged("NotPingAndRetrievingDataVisibility");
  9062. this.OnPropertyChanged("PingVisibility");
  9063. this.RefreshButtonCanExecuteUpdate();
  9064. }
  9065.  
  9066. private void RefreshButtonCanExecuteUpdate()
  9067. {
  9068. RelayCommand relayCommand = this.RefreshCommand as RelayCommand;
  9069. if (relayCommand == null)
  9070. return;
  9071. relayCommand.RaiseCanExecuteChanged();
  9072. }
  9073.  
  9074. private TimeSpan GetTotalTimeByPeriod(DateTime? timeFrom, DateTime? timeTo, Statistic[] totalStatistics)
  9075. {
  9076. try
  9077. {
  9078. Statistic[] statisticArray = !timeTo.HasValue || !timeFrom.HasValue ? totalStatistics : Enumerable.ToArray<Statistic>(Enumerable.Where<Statistic>((IEnumerable<Statistic>) totalStatistics, (Func<Statistic, bool>) (ts =>
  9079. {
  9080. if (ts.CreatedDate >= timeFrom.Value)
  9081. return ts.CreatedDate.AddSeconds((double) ts.Lifetime) <= timeTo.Value;
  9082. return false;
  9083. })));
  9084. if (statisticArray == null || statisticArray.Length == 0)
  9085. return new TimeSpan(0L);
  9086. long num = 0;
  9087. foreach (Statistic statistic in statisticArray)
  9088. {
  9089. if (!statistic.Actual)
  9090. num += statistic.Lifetime;
  9091. }
  9092. return new TimeSpan(0, 0, (int) num);
  9093. }
  9094. catch (Exception ex)
  9095. {
  9096. Logger.WriteError((object) this, "InitializeTotalSessionTime", "?????? ??? ????????? ? ???????? ??????? ?? ???? ???????", ex);
  9097. return new TimeSpan(0L);
  9098. }
  9099. }
  9100.  
  9101. private void OnNetworkStateChanged(object sender, NetworkStateEventArgs e)
  9102. {
  9103. switch (e.State)
  9104. {
  9105. case NetworkState.None:
  9106. case NetworkState.NetworkNotFound:
  9107. case NetworkState.ServerNotFound:
  9108. Logger.WriteInfo(typeof (SessionStatisticsVM), "OnNetworkStateChanged()", "???? ??????? ? ????????? Offline");
  9109. this.StopTimer();
  9110. this.RefreshProperties();
  9111. break;
  9112. case NetworkState.ServerOnline:
  9113. Logger.WriteInfo(typeof (SessionStatisticsVM), "OnNetworkStateChanged()", "???? ??????? ? ????????? Online");
  9114. lock (this._sessionTimeLock)
  9115. {
  9116. this.UpdateStatistics(false);
  9117. if (!this._isStartPing)
  9118. break;
  9119. this._timer.Start();
  9120. break;
  9121. }
  9122. }
  9123. }
  9124.  
  9125. private void OnSessionStateChanged(object sender, SessionStateEventArgs e)
  9126. {
  9127. if (e.State == SessionState.Suspended && this._isStartPing)
  9128. {
  9129. Logger.WriteInfo(typeof (SessionStatisticsVM), "OnSessionStateChanged()", "?????? ??????? ? ????????? Suspended");
  9130. this.StopTimer();
  9131. }
  9132. else
  9133. {
  9134. if (e.State != SessionState.InAccrual || !this._isStartPing)
  9135. return;
  9136. Logger.WriteInfo(typeof (SessionStatisticsVM), "OnSessionStateChanged()", "?????? ??????? ? ????????? Accrual");
  9137. this._timer.Start();
  9138. }
  9139. }
  9140.  
  9141. private void StopTimer()
  9142. {
  9143. if (this._timer == null)
  9144. return;
  9145. this._timer.Enabled = false;
  9146. }
  9147.  
  9148. private void InitializeTimer()
  9149. {
  9150. Logger.WriteInfo(typeof (SessionStatisticsVM), "InitializeTimer()", "????????????? ??????? ?????????? ??????????...");
  9151. this._timer = new System.Timers.Timer(40.0);
  9152. this._timer.Elapsed += new ElapsedEventHandler(this.TimeTick);
  9153. this._timer.AutoReset = false;
  9154. Logger.WriteInfo(typeof (SessionStatisticsVM), "InitializeTimer()", "?????? ?????????? ?????????? ???????????????");
  9155. }
  9156.  
  9157. private void TimeTick(object source, ElapsedEventArgs e)
  9158. {
  9159. lock (this._sessionTimeLock)
  9160. {
  9161. DateTime local_0 = DateTime.Now;
  9162. if (this._currentDate.Date < local_0.Date)
  9163. this.UpdateStatistics(false);
  9164. this.SessionTime += local_0.Subtract(this._lastDateTimeUpdateSessionTime);
  9165. this._lastDateTimeUpdateSessionTime = local_0;
  9166. this._timer.Enabled = true;
  9167. }
  9168. }
  9169. }
  9170. }
  9171. ?// Decompiled with JetBrains decompiler
  9172. // Type: WinApp.ViewModel.Controls.VersionControlVM
  9173. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  9174. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  9175. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  9176.  
  9177. using System;
  9178. using System.Diagnostics;
  9179. using System.Linq.Expressions;
  9180. using System.Windows.Input;
  9181. using WinApp.Managers;
  9182. using WinApp.ViewModel;
  9183. using WinApp.ViewModel.Base;
  9184.  
  9185. namespace WinApp.ViewModel.Controls
  9186. {
  9187. internal class VersionControlVM : ViewModelBase
  9188. {
  9189. private Version _appVersionOnSite;
  9190. private Version _appVersionCurrent;
  9191.  
  9192. public string AppVersionOnSiteText
  9193. {
  9194. get
  9195. {
  9196. return this._appVersionOnSite.ToString();
  9197. }
  9198. }
  9199.  
  9200. public string AppVersionCurrentText
  9201. {
  9202. get
  9203. {
  9204. return this._appVersionCurrent.ToString();
  9205. }
  9206. }
  9207.  
  9208. public ICommand OpenAppDownloadPageCommand
  9209. {
  9210. get
  9211. {
  9212. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.OpenAppDownloadPageCommand), new Action(this.OpenAppDownloadPage));
  9213. }
  9214. }
  9215.  
  9216. public ICommand DownloadNewAppVersionCommand
  9217. {
  9218. get
  9219. {
  9220. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.DownloadNewAppVersionCommand), new Action(this.DownloadNewAppVersion));
  9221. }
  9222. }
  9223.  
  9224. public ICommand CloseCommand
  9225. {
  9226. get
  9227. {
  9228. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.CloseCommand), new Action(this.CloseWindow));
  9229. }
  9230. }
  9231.  
  9232. public VersionControlVM(Version appVersionOnSite, Version appVersionCurrent)
  9233. {
  9234. this._appVersionOnSite = appVersionOnSite;
  9235. this._appVersionCurrent = appVersionCurrent;
  9236. }
  9237.  
  9238. public void ButtonOkClick()
  9239. {
  9240. this.CloseWindow();
  9241. }
  9242.  
  9243. private void OpenAppDownloadPage()
  9244. {
  9245. Process.Start(ApplicationSettings.ServiceUri + "/products/my-purchases/");
  9246. }
  9247.  
  9248. private void DownloadNewAppVersion()
  9249. {
  9250. Process.Start(ApplicationSettings.ServiceUri + "/products/installer/main/downloader/");
  9251. }
  9252.  
  9253. private void CloseWindow()
  9254. {
  9255. AppVM.Instance.ShowMainWindow();
  9256. }
  9257. }
  9258. }
  9259. ?// Decompiled with JetBrains decompiler
  9260. // Type: WinApp.ViewModel.Controls.PersonalInformationVM
  9261. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  9262. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  9263. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  9264.  
  9265. using Inc.Logging;
  9266. using IncMap;
  9267. using KairosPlanet.Properties;
  9268. using System;
  9269. using System.Collections.Generic;
  9270. using System.Linq.Expressions;
  9271. using System.Windows.Input;
  9272. using WinApp.Data.Model;
  9273. using WinApp.Managers.Interfaces;
  9274. using WinApp.ViewModel.Base;
  9275.  
  9276. namespace WinApp.ViewModel.Controls
  9277. {
  9278. internal class PersonalInformationVM : ViewModelBase
  9279. {
  9280. private bool _hasErrors;
  9281. private bool _isInEdit;
  9282. private string _email;
  9283. private string _name;
  9284. private int _genderId;
  9285. private string _phoneNumber;
  9286. private DateTime _birthDate;
  9287.  
  9288. public bool IsInEdit
  9289. {
  9290. get
  9291. {
  9292. return this._isInEdit;
  9293. }
  9294. set
  9295. {
  9296. this._isInEdit = value;
  9297. this.OnPropertyChanged("IsInEdit");
  9298. this.OnPropertyChanged("SaveEditButtonText");
  9299. }
  9300. }
  9301.  
  9302. public List<string> CountriesCollection { get; private set; }
  9303.  
  9304. public string Name
  9305. {
  9306. get
  9307. {
  9308. return this._name;
  9309. }
  9310. set
  9311. {
  9312. this._name = value;
  9313. this.OnPropertyChanged("Name");
  9314. }
  9315. }
  9316.  
  9317. public string Country { get; set; }
  9318.  
  9319. public int GenderId
  9320. {
  9321. get
  9322. {
  9323. return this._genderId;
  9324. }
  9325. set
  9326. {
  9327. this._genderId = value;
  9328. this.OnPropertyChanged("Gender");
  9329. this.OnPropertyChanged("GenderName");
  9330. }
  9331. }
  9332.  
  9333. public string GenderName
  9334. {
  9335. get
  9336. {
  9337. if (this.GenderId != 1)
  9338. return Resources.MaleGender;
  9339. return Resources.FemaleGender;
  9340. }
  9341. }
  9342.  
  9343. public DateTime CreatedDate { get; set; }
  9344.  
  9345. public int UserStatusId { get; set; }
  9346.  
  9347. public DateTime BirthDate
  9348. {
  9349. get
  9350. {
  9351. return this._birthDate;
  9352. }
  9353. set
  9354. {
  9355. this._birthDate = value;
  9356. this.OnPropertyChanged("BirthDate");
  9357. }
  9358. }
  9359.  
  9360. public string Email
  9361. {
  9362. get
  9363. {
  9364. return this._email;
  9365. }
  9366. set
  9367. {
  9368. this._email = value;
  9369. this.OnPropertyChanged("Email");
  9370. }
  9371. }
  9372.  
  9373. public string PhoneNumber
  9374. {
  9375. get
  9376. {
  9377. return this._phoneNumber;
  9378. }
  9379. set
  9380. {
  9381. this._phoneNumber = value;
  9382. this.OnPropertyChanged("PhoneNumber");
  9383. }
  9384. }
  9385.  
  9386. public string SaveEditButtonText
  9387. {
  9388. get
  9389. {
  9390. if (!this.IsInEdit)
  9391. return Resources.SaveEditButton_Edit;
  9392. return Resources.SaveEditButton_Save;
  9393. }
  9394. }
  9395.  
  9396. public ICommand SaveEditButtonCommand
  9397. {
  9398. get
  9399. {
  9400. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.SaveEditButtonCommand), new Action(this.SaveEditButtonAction));
  9401. }
  9402. }
  9403.  
  9404. public PersonalInformationVM(Man man)
  9405. {
  9406. this.Name = man.Name;
  9407. this.Email = man.Email;
  9408. this.CreatedDate = DateTime.Parse(man.CreatedDate);
  9409. this.BirthDate = DateTime.Parse(man.BirthDate);
  9410. this.GenderId = man.Gender;
  9411. this.PhoneNumber = man.PhoneNumber;
  9412. this.UserStatusId = man.UserStatus;
  9413. this.InitializeCountries();
  9414. this.Country = man.Country;
  9415. }
  9416.  
  9417. private void SaveEditButtonAction()
  9418. {
  9419. if (this.IsInEdit)
  9420. {
  9421. Logger.WriteInfo(typeof (ContactInformationVM), "SaveEditButtonAction()", "??????? ?????????? ? ?????? ?????????????? ???????????? ??????????");
  9422. this.HideErrors();
  9423. this.CheckFields();
  9424. if (this._hasErrors)
  9425. {
  9426. Logger.WriteWarning(typeof (ContactInformationVM), "SaveEditButtonAction()", "?????? ??? ????? ?????? ? ?????? ?????????????? ???????????? ??????????");
  9427. }
  9428. else
  9429. {
  9430. this.Save();
  9431. Logger.WriteInfo(typeof (ContactInformationVM), "SaveEditButtonAction()", "??????? ? ????? ????????? ???????????? ??????????");
  9432. this.IsInEdit = false;
  9433. }
  9434. }
  9435. else
  9436. {
  9437. Logger.WriteInfo(typeof (ContactInformationVM), "SaveEditButtonAction()", "??????? ? ????? ?????????????? ???????????? ??????????");
  9438. this.IsInEdit = true;
  9439. }
  9440. }
  9441.  
  9442. private void Save()
  9443. {
  9444. Logger.WriteInfo(typeof (ContactInformationVM), "SaveCredential()", "?????????? ????????? ???????????? ??????????...");
  9445. Logger.WriteInfo(typeof (ContactInformationVM), "SaveCredential()", "????????? ???????????? ?????????? ??????? ?????????");
  9446. }
  9447.  
  9448. private void CheckFields()
  9449. {
  9450. }
  9451.  
  9452. private void HideErrors()
  9453. {
  9454. }
  9455.  
  9456. private void InitializeCountries()
  9457. {
  9458. this.CountriesCollection = Map.Get<ICountriesManager>().GetAllCountries();
  9459. }
  9460. }
  9461. }
  9462. ?// Decompiled with JetBrains decompiler
  9463. // Type: WinApp.ViewModel.Controls.ChangePasswordVM
  9464. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  9465. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  9466. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  9467.  
  9468. using Inc.Logging;
  9469. using KairosPlanet.Properties;
  9470. using System;
  9471. using System.Windows;
  9472. using System.Windows.Input;
  9473. using WinApp.Data.Helpers;
  9474. using WinApp.ViewModel.Base;
  9475.  
  9476. namespace WinApp.ViewModel.Controls
  9477. {
  9478. internal class ChangePasswordVM : ViewModelBase
  9479. {
  9480. private Visibility _currentPasswordErrorVisibility = Visibility.Hidden;
  9481. private Visibility _newPasswordErrorVisibility = Visibility.Hidden;
  9482. private Visibility _confirmNewPasswordErrorVisibility = Visibility.Hidden;
  9483. private string _currentPassword;
  9484. private string _newPassword;
  9485. private string _confirmNewPassword;
  9486. private string _currentPasswordError;
  9487. private string _newPasswordError;
  9488. private string _confirmNewPasswordError;
  9489.  
  9490. public string CurrentPassword
  9491. {
  9492. get
  9493. {
  9494. return this._currentPassword;
  9495. }
  9496. set
  9497. {
  9498. this._currentPassword = value;
  9499. this.OnPropertyChanged("CurrentPassword");
  9500. }
  9501. }
  9502.  
  9503. public string NewPassword
  9504. {
  9505. get
  9506. {
  9507. return this._newPassword;
  9508. }
  9509. set
  9510. {
  9511. this._newPassword = value;
  9512. this.OnPropertyChanged("NewPassword");
  9513. }
  9514. }
  9515.  
  9516. public string ConfirmNewPassword
  9517. {
  9518. get
  9519. {
  9520. return this._confirmNewPassword;
  9521. }
  9522. set
  9523. {
  9524. this._confirmNewPassword = value;
  9525. this.OnPropertyChanged("ConfirmNewPassword");
  9526. }
  9527. }
  9528.  
  9529. public string CurrentPasswordError
  9530. {
  9531. get
  9532. {
  9533. return this._currentPasswordError;
  9534. }
  9535. set
  9536. {
  9537. this._currentPasswordError = value;
  9538. this.OnPropertyChanged("CurrentPasswordError");
  9539. }
  9540. }
  9541.  
  9542. public string NewPasswordError
  9543. {
  9544. get
  9545. {
  9546. return this._newPasswordError;
  9547. }
  9548. set
  9549. {
  9550. this._newPasswordError = value;
  9551. this.OnPropertyChanged("NewPasswordError");
  9552. }
  9553. }
  9554.  
  9555. public string ConfirmNewPasswordError
  9556. {
  9557. get
  9558. {
  9559. return this._confirmNewPasswordError;
  9560. }
  9561. set
  9562. {
  9563. this._confirmNewPasswordError = value;
  9564. this.OnPropertyChanged("ConfirmNewPasswordError");
  9565. }
  9566. }
  9567.  
  9568. public Visibility CurrentPasswordErrorVisibility
  9569. {
  9570. get
  9571. {
  9572. return this._currentPasswordErrorVisibility;
  9573. }
  9574. set
  9575. {
  9576. this._currentPasswordErrorVisibility = value;
  9577. this.OnPropertyChanged("CurrentPasswordErrorVisibility");
  9578. }
  9579. }
  9580.  
  9581. public Visibility NewPasswordErrorVisibility
  9582. {
  9583. get
  9584. {
  9585. return this._newPasswordErrorVisibility;
  9586. }
  9587. set
  9588. {
  9589. this._newPasswordErrorVisibility = value;
  9590. this.OnPropertyChanged("NewPasswordErrorVisibility");
  9591. }
  9592. }
  9593.  
  9594. public Visibility ConfirmNewPasswordErrorVisibility
  9595. {
  9596. get
  9597. {
  9598. return this._confirmNewPasswordErrorVisibility;
  9599. }
  9600. set
  9601. {
  9602. this._confirmNewPasswordErrorVisibility = value;
  9603. this.OnPropertyChanged("ConfirmNewPasswordErrorVisibility");
  9604. }
  9605. }
  9606.  
  9607. public ICommand ChangePasswordCommand
  9608. {
  9609. get
  9610. {
  9611. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.ChangePasswordCommand), (Action) (() => this.ExecuteChangePassword()));
  9612. }
  9613. }
  9614.  
  9615. public bool ExecuteChangePassword()
  9616. {
  9617. Logger.WriteInfo(typeof (ChangePasswordVM), "ExecuteChangePassword()", "??????? ????????? ??????...");
  9618. this.HideAllErrors();
  9619. if (!this.CheckPasswords())
  9620. {
  9621. Logger.WriteWarning(typeof (ChangePasswordVM), "ExecuteChangePassword()", "?????? ??? ????? ?????? ??? ????? ??????");
  9622. return false;
  9623. }
  9624. if (!true)
  9625. {
  9626. Logger.WriteWarning(typeof (ChangePasswordVM), "ExecuteChangePassword()", "?????? ??? ????????? ??????");
  9627. this.ShowCurrentPasswordError(Resources.Error_UserPasswordIncorrect);
  9628. return false;
  9629. }
  9630. Logger.WriteInfo(typeof (ChangePasswordVM), "ExecuteChangePassword()", "?????? ??? ??????? ???????");
  9631. return true;
  9632. }
  9633.  
  9634. public bool Cancel()
  9635. {
  9636. return true;
  9637. }
  9638.  
  9639. internal bool CheckPasswords()
  9640. {
  9641. bool flag = false;
  9642. if (StringUtil.IsNullOrWhiteSpace(this.CurrentPassword))
  9643. {
  9644. this.ShowCurrentPasswordError(Resources.Error_EnterCurrentPasswordToChange);
  9645. flag = true;
  9646. }
  9647. if (StringUtil.IsNullOrWhiteSpace(this.NewPassword))
  9648. {
  9649. this.ShowNewPasswordError(Resources.Error_NewPasswordIsEmpty);
  9650. flag = true;
  9651. }
  9652. if (StringUtil.IsNullOrWhiteSpace(this.ConfirmNewPassword))
  9653. {
  9654. this.ShowConfirmNewPasswordError(Resources.Error_ConfirmNewPasswordIsEmpty);
  9655. flag = true;
  9656. }
  9657. if (flag)
  9658. return false;
  9659. if (this.NewPassword.Equals(this.ConfirmNewPassword))
  9660. return true;
  9661. this.ShowConfirmNewPasswordError(Resources.Error_PasswordsNotIdentical);
  9662. return false;
  9663. }
  9664.  
  9665. private void HideAllErrors()
  9666. {
  9667. this.CurrentPasswordErrorVisibility = Visibility.Hidden;
  9668. this.NewPasswordErrorVisibility = Visibility.Hidden;
  9669. this.ConfirmNewPasswordErrorVisibility = Visibility.Hidden;
  9670. }
  9671.  
  9672. private void ShowCurrentPasswordError(string errorText)
  9673. {
  9674. this.CurrentPasswordErrorVisibility = Visibility.Visible;
  9675. this.CurrentPasswordError = errorText;
  9676. }
  9677.  
  9678. private void ShowNewPasswordError(string errorText)
  9679. {
  9680. this.NewPasswordErrorVisibility = Visibility.Visible;
  9681. this.NewPasswordError = errorText;
  9682. }
  9683.  
  9684. private void ShowConfirmNewPasswordError(string errorText)
  9685. {
  9686. this.ConfirmNewPasswordErrorVisibility = Visibility.Visible;
  9687. this.ConfirmNewPasswordError = errorText;
  9688. }
  9689. }
  9690. }
  9691. ?// Decompiled with JetBrains decompiler
  9692. // Type: WinApp.ViewModel.Controls.ContactInformationVM
  9693. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  9694. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  9695. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  9696.  
  9697. using Inc.Logging;
  9698. using KairosPlanet.Properties;
  9699. using System;
  9700. using System.Linq.Expressions;
  9701. using System.Windows.Input;
  9702. using WinApp.Data.Model;
  9703. using WinApp.ViewModel.Base;
  9704.  
  9705. namespace WinApp.ViewModel.Controls
  9706. {
  9707. internal class ContactInformationVM : ViewModelBase
  9708. {
  9709. private bool _hasErrors;
  9710. private bool _isInEdit;
  9711. private string _email1;
  9712. private string _email2;
  9713. private string _telephone1;
  9714. private string _telephone2;
  9715. private string _city;
  9716. private string _zipcode;
  9717. private string _address;
  9718.  
  9719. public bool IsInEdit
  9720. {
  9721. get
  9722. {
  9723. return this._isInEdit;
  9724. }
  9725. set
  9726. {
  9727. this._isInEdit = value;
  9728. this.OnPropertyChanged("IsInEdit");
  9729. this.OnPropertyChanged("SaveEditButtonText");
  9730. }
  9731. }
  9732.  
  9733. public string Email1
  9734. {
  9735. get
  9736. {
  9737. return this._email1;
  9738. }
  9739. set
  9740. {
  9741. this._email1 = value;
  9742. this.OnPropertyChanged("Email1");
  9743. }
  9744. }
  9745.  
  9746. public string Email2
  9747. {
  9748. get
  9749. {
  9750. return this._email2;
  9751. }
  9752. set
  9753. {
  9754. this._email2 = value;
  9755. this.OnPropertyChanged("Email2");
  9756. }
  9757. }
  9758.  
  9759. public string Telephone1
  9760. {
  9761. get
  9762. {
  9763. return this._telephone1;
  9764. }
  9765. set
  9766. {
  9767. this._telephone1 = value;
  9768. this.OnPropertyChanged("Telephone1");
  9769. }
  9770. }
  9771.  
  9772. public string Telephone2
  9773. {
  9774. get
  9775. {
  9776. return this._telephone2;
  9777. }
  9778. set
  9779. {
  9780. this._telephone2 = value;
  9781. this.OnPropertyChanged("Telephone2");
  9782. }
  9783. }
  9784.  
  9785. public string City
  9786. {
  9787. get
  9788. {
  9789. return this._city;
  9790. }
  9791. set
  9792. {
  9793. this._city = value;
  9794. this.OnPropertyChanged("City");
  9795. }
  9796. }
  9797.  
  9798. public string Zipcode
  9799. {
  9800. get
  9801. {
  9802. return this._zipcode;
  9803. }
  9804. set
  9805. {
  9806. this._zipcode = value;
  9807. this.OnPropertyChanged("Zipcode");
  9808. }
  9809. }
  9810.  
  9811. public string Address
  9812. {
  9813. get
  9814. {
  9815. return this._address;
  9816. }
  9817. set
  9818. {
  9819. this._address = value;
  9820. this.OnPropertyChanged("Address");
  9821. }
  9822. }
  9823.  
  9824. public string SaveEditButtonText
  9825. {
  9826. get
  9827. {
  9828. if (!this.IsInEdit)
  9829. return Resources.SaveEditButton_Edit;
  9830. return Resources.SaveEditButton_Save;
  9831. }
  9832. }
  9833.  
  9834. public ICommand SaveEditButtonCommand
  9835. {
  9836. get
  9837. {
  9838. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.SaveEditButtonCommand), new Action(this.SaveEditButtonAction));
  9839. }
  9840. }
  9841.  
  9842. public ContactInformationVM(Man man)
  9843. {
  9844. this.Email1 = man.Email;
  9845. this.Telephone1 = man.PhoneNumber;
  9846. }
  9847.  
  9848. private void SaveEditButtonAction()
  9849. {
  9850. if (this.IsInEdit)
  9851. {
  9852. Logger.WriteInfo(typeof (ContactInformationVM), "SaveEditButtonAction()", "??????? ?????????? ? ?????? ?????????????? ?????????? ??????????");
  9853. this.HideErrors();
  9854. this.CheckFields();
  9855. if (this._hasErrors)
  9856. {
  9857. Logger.WriteWarning(typeof (ContactInformationVM), "SaveEditButtonAction()", "?????? ??? ????? ?????? ? ?????? ?????????????? ?????????? ??????????");
  9858. }
  9859. else
  9860. {
  9861. this.Save();
  9862. Logger.WriteInfo(typeof (ContactInformationVM), "SaveEditButtonAction()", "??????? ? ????? ????????? ?????????? ??????????");
  9863. this.IsInEdit = false;
  9864. }
  9865. }
  9866. else
  9867. {
  9868. Logger.WriteInfo(typeof (ContactInformationVM), "SaveEditButtonAction()", "??????? ? ????? ?????????????? ?????????? ??????????");
  9869. this.IsInEdit = true;
  9870. }
  9871. }
  9872.  
  9873. private void Save()
  9874. {
  9875. Logger.WriteInfo(typeof (ContactInformationVM), "SaveCredential()", "?????????? ????????? ?????????? ??????????...");
  9876. Logger.WriteInfo(typeof (ContactInformationVM), "SaveCredential()", "????????? ?????????? ?????????? ??????? ?????????");
  9877. }
  9878.  
  9879. private void CheckFields()
  9880. {
  9881. }
  9882.  
  9883. private void HideErrors()
  9884. {
  9885. }
  9886. }
  9887. }
  9888. ?// Decompiled with JetBrains decompiler
  9889. // Type: WinApp.ViewModel.Controls.ServicesControlVM
  9890. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  9891. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  9892. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  9893.  
  9894. using Inc.Logging;
  9895. using IncMap;
  9896. using KairosPlanet.Managers.Interfaces;
  9897. using KairosPlanet.Properties;
  9898. using System;
  9899. using System.Collections;
  9900. using System.Collections.Generic;
  9901. using System.Collections.ObjectModel;
  9902. using System.Collections.Specialized;
  9903. using System.Linq;
  9904. using System.Threading;
  9905. using System.Windows;
  9906. using System.Windows.Input;
  9907. using System.Windows.Threading;
  9908. using WinApp;
  9909. using WinApp.Api;
  9910. using WinApp.Data.Model;
  9911. using WinApp.Managers.Interfaces;
  9912. using WinApp.Managers.Network;
  9913. using WinApp.ViewModel;
  9914. using WinApp.ViewModel.Base;
  9915. using WinApp.ViewModel.Services;
  9916.  
  9917. namespace WinApp.ViewModel.Controls
  9918. {
  9919. internal class ServicesControlVM : ViewModelBase
  9920. {
  9921. private static object _lockObject = new object();
  9922. private Thread _loadThread;
  9923.  
  9924. public ObservableCollection<ServiceVM> Services { get; private set; }
  9925.  
  9926. public ICommand RefreshCommand
  9927. {
  9928. get
  9929. {
  9930. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.RefreshCommand), new Action(this.DoRefresh), new Func<bool>(this.CanRefresh));
  9931. }
  9932. }
  9933.  
  9934. public ServicesControlVM()
  9935. {
  9936. NetworkMonitor.NetworkStateChanged += new EventHandler<NetworkStateEventArgs>(this.OnNetworkStateChanged);
  9937. this.Services = new ObservableCollection<ServiceVM>();
  9938. Map.Get<IPurchaseManager>().Purchases.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnPurchasesChanged);
  9939. AppVM.Instance.ErrorStateChanged += new EventHandler(this.AppVmInstance_ErrorStateChanged);
  9940. this.DoRefresh();
  9941. }
  9942.  
  9943. private bool CanRefresh()
  9944. {
  9945. if (NetworkMonitor.NetworkState != NetworkState.ServerOnline)
  9946. return false;
  9947. return !this._loadThread.IsAlive;
  9948. }
  9949.  
  9950. private void OnNetworkStateChanged(object sender, NetworkStateEventArgs e)
  9951. {
  9952. this.RefreshProperties();
  9953. }
  9954.  
  9955. private void RefreshProperties()
  9956. {
  9957. this.RefreshButtonCanExecuteUpdate();
  9958. }
  9959.  
  9960. private void RefreshButtonCanExecuteUpdate()
  9961. {
  9962. RelayCommand relayCommand = this.RefreshCommand as RelayCommand;
  9963. if (relayCommand == null)
  9964. return;
  9965. relayCommand.RaiseCanExecuteChanged();
  9966. }
  9967.  
  9968. private void LoadServices()
  9969. {
  9970. lock (ServicesControlVM._lockObject)
  9971. {
  9972. Action local_0 = Map.Get<IScreenManager>().ShowStatusMessage(Resources.StatusMessage_ServicesLoading, 5, true);
  9973. try
  9974. {
  9975. Product[] local_1 = Map.Get<ISessionManager>().Api.GetProducts();
  9976. Purchase[] local_2 = Enumerable.ToArray<Purchase>((IEnumerable<Purchase>) Map.Get<IPurchaseManager>().Purchases);
  9977. List<ServiceVM> serviceVms = new List<ServiceVM>();
  9978. if (local_1 == null)
  9979. {
  9980. Logger.WriteWarning((object) this, "LoadServices()", "Products is not loaded");
  9981. Map.Get<IScreenManager>().ShowStatusMessage(Resources.StatusMessage_CanNotLoadServices, 5, false);
  9982. return;
  9983. }
  9984. Logger.WriteInfo((object) this, "LoadServices()", "Loaded products count: " + (object) local_1.Length);
  9985. this.SetActivePackagePrice(local_1);
  9986. int local_3 = -1;
  9987. foreach (Product item_0 in local_1)
  9988. {
  9989. Product product = item_0;
  9990. Purchase local_4 = Enumerable.FirstOrDefault<Purchase>((IEnumerable<Purchase>) local_2, (Func<Purchase, bool>) (p => p.ProductId == product.Id));
  9991. serviceVms.Add(new ServiceVM(product, local_4));
  9992. if (local_4 == null)
  9993. {
  9994. Logger.WriteInfo((object) this, "LoadServices()", string.Format("Product : {0} (product.Status={1}) purchase is not founded", (object) product.Title, (object) product.Status));
  9995. }
  9996. else
  9997. {
  9998. if (local_4.PackageStatus == 3)
  9999. local_3 = (int) local_4.Price;
  10000. Logger.WriteInfo((object) this, "LoadServices()", string.Format("Product : {0} (product.Status={1}) purchase: purchase.PackageStatus={2}, purchase.Status={3}", (object) product.Title, (object) product.Status, (object) local_4.PackageStatus, (object) local_4.Status));
  10001. }
  10002. }
  10003. if (local_3 != -1)
  10004. {
  10005. foreach (ServiceVM item_1 in serviceVms)
  10006. {
  10007. if ((double) local_3 > item_1.Price && item_1.Purchase == null)
  10008. item_1.DisableProduct();
  10009. }
  10010. }
  10011. Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Delegate) (() => Enumerable.ToList<ServiceVM>((IEnumerable<ServiceVM>) Enumerable.OrderBy<ServiceVM, double>((IEnumerable<ServiceVM>) serviceVms, (Func<ServiceVM, double>) (s => s.Price))).ForEach((Action<ServiceVM>) (x => this.Services.Add(x)))));
  10012. }
  10013. catch (ApiException exception_0)
  10014. {
  10015. Logger.WriteError((object) this, "LoadServices()", "Error: ", (Exception) exception_0);
  10016. }
  10017. local_0();
  10018. }
  10019. }
  10020.  
  10021. private void SetActivePackagePrice(Product[] products)
  10022. {
  10023. lock (ServicesControlVM._lockObject)
  10024. {
  10025. if (!AppVM.Instance.ActivePackageId.HasValue)
  10026. {
  10027. AppVM.Instance.ActivePackagePrice = 0.0;
  10028. }
  10029. else
  10030. {
  10031. Product local_0 = (Product) null;
  10032. if (products != null)
  10033. local_0 = Enumerable.FirstOrDefault<Product>((IEnumerable<Product>) products, (Func<Product, bool>) (p => p.Id == AppVM.Instance.ActivePackageId.Value));
  10034. AppVM.Instance.ActivePackagePrice = local_0 == null ? 0.0 : local_0.Price;
  10035. }
  10036. }
  10037. }
  10038.  
  10039. private void DoRefresh()
  10040. {
  10041. if (NetworkMonitor.NetworkState != NetworkState.ServerOnline || this._loadThread != null && this._loadThread.IsAlive)
  10042. return;
  10043. if (this.Services.Count == 0)
  10044. {
  10045. this._loadThread = new Thread(new ThreadStart(this.LoadServices))
  10046. {
  10047. CurrentUICulture = Thread.CurrentThread.CurrentUICulture,
  10048. IsBackground = true
  10049. };
  10050. this._loadThread.Start();
  10051. }
  10052. else
  10053. {
  10054. this._loadThread = new Thread((ThreadStart) (() =>
  10055. {
  10056. Action action = Map.Get<IScreenManager>().ShowStatusMessage(Resources.StatusMessage_IsRefreshing, 5, true);
  10057. Map.Get<IPurchaseManager>().UpdatePurchases();
  10058. this.RefreshServicesState();
  10059. action();
  10060. this.RefreshProperties();
  10061. }))
  10062. {
  10063. CurrentUICulture = Thread.CurrentThread.CurrentUICulture,
  10064. IsBackground = true
  10065. };
  10066. this._loadThread.Start();
  10067. }
  10068. }
  10069.  
  10070. private void RefreshServicesState()
  10071. {
  10072. lock (ServicesControlVM._lockObject)
  10073. {
  10074. Logger.WriteInfo((object) this, "RefreshServicesState", "Execute refresh state for services");
  10075. Enumerable.ToList<ServiceVM>((IEnumerable<ServiceVM>) this.Services).ForEach((Action<ServiceVM>) (s => s.UpdateByInnerPurchase()));
  10076. }
  10077. }
  10078.  
  10079. private void AppVmInstance_ErrorStateChanged(object sender, EventArgs e)
  10080. {
  10081. this.RefreshServicesState();
  10082. }
  10083.  
  10084. private void ShowUpdateMessage(string productTitle)
  10085. {
  10086. IScreenManager manager = Map.Get<IScreenManager>();
  10087. manager.DoVisualSafe((Action) (() => manager.ShowAlert(string.Format(Resources.Message_NewPackageIsAvailable + productTitle), Resources.Refresh_NewPackage)));
  10088. }
  10089.  
  10090. private void OnPurchasesChanged(object sender, NotifyCollectionChangedEventArgs e)
  10091. {
  10092. if (e.Action != NotifyCollectionChangedAction.Add && e.Action != NotifyCollectionChangedAction.Replace)
  10093. return;
  10094. lock (ServicesControlVM._lockObject)
  10095. {
  10096. Action local_0 = Map.Get<IScreenManager>().ShowStatusMessage(Resources.StatusMessage_IsRefreshing, 5, true);
  10097. try
  10098. {
  10099. if (e.NewItems.Count > 0)
  10100. {
  10101. foreach (Purchase item_0 in (IEnumerable) e.NewItems)
  10102. {
  10103. Purchase purchase = item_0;
  10104. ServiceVM local_1 = Enumerable.Single<ServiceVM>((IEnumerable<ServiceVM>) this.Services, (Func<ServiceVM, bool>) (x => x.ProductId == purchase.ProductId));
  10105. local_1.Update(purchase);
  10106. if (purchase.PackageStatus == 1)
  10107. this.ShowUpdateMessage(local_1.Title);
  10108. }
  10109. }
  10110. else
  10111. local_0 = Map.Get<IScreenManager>().ShowStatusMessage(Resources.StatusMessage_NoNewPurchases, 5, false);
  10112. }
  10113. catch (ApiException exception_0)
  10114. {
  10115. Logger.WriteError((object) this, "OnPurchasesChanged()", "Error: ", (Exception) exception_0);
  10116. }
  10117. local_0();
  10118. }
  10119. }
  10120. }
  10121. }
  10122. ?// Decompiled with JetBrains decompiler
  10123. // Type: WinApp.ViewModel.Controls.SessionHistoryVM
  10124. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  10125. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  10126. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  10127.  
  10128. using Inc.Logging;
  10129. using KairosPlanet.Managers;
  10130. using KairosPlanet.Properties;
  10131. using System;
  10132. using System.Collections.Generic;
  10133. using System.Collections.ObjectModel;
  10134. using System.Linq;
  10135. using System.Linq.Expressions;
  10136. using System.Windows.Input;
  10137. using WinApp.Api.Data;
  10138. using WinApp.Data.Helpers;
  10139. using WinApp.ViewModel;
  10140. using WinApp.ViewModel.Base;
  10141.  
  10142. namespace WinApp.ViewModel.Controls
  10143. {
  10144. public class SessionHistoryVM : ViewModelBase
  10145. {
  10146. private DateTime _periodStart;
  10147. private DateTime _periodEnd;
  10148. private string _periodTotalString;
  10149. private ObservableCollection<SessionRecordVM> _items;
  10150. private ObservableCollection<SessionChartItemVM> _chartItems;
  10151.  
  10152. public DateTime PeriodStart
  10153. {
  10154. get
  10155. {
  10156. return this._periodStart;
  10157. }
  10158. set
  10159. {
  10160. this._periodStart = value;
  10161. this.OnPropertyChanged("PeriodStart");
  10162. }
  10163. }
  10164.  
  10165. public DateTime PeriodEnd
  10166. {
  10167. get
  10168. {
  10169. return this._periodEnd;
  10170. }
  10171. set
  10172. {
  10173. this._periodEnd = value.AddDays(1.0).AddSeconds(-1.0);
  10174. this.OnPropertyChanged("PeriodEnd");
  10175. }
  10176. }
  10177.  
  10178. public string PeriodTotalString
  10179. {
  10180. get
  10181. {
  10182. return this._periodTotalString;
  10183. }
  10184. private set
  10185. {
  10186. this._periodTotalString = value;
  10187. this.OnPropertyChanged("PeriodTotalString");
  10188. }
  10189. }
  10190.  
  10191. public ObservableCollection<SessionRecordVM> Items
  10192. {
  10193. get
  10194. {
  10195. return this._items;
  10196. }
  10197. private set
  10198. {
  10199. this._items = value;
  10200. this.OnPropertyChanged("Items");
  10201. }
  10202. }
  10203.  
  10204. public ObservableCollection<SessionChartItemVM> ChartItems
  10205. {
  10206. get
  10207. {
  10208. return this._chartItems;
  10209. }
  10210. private set
  10211. {
  10212. this._chartItems = value;
  10213. this.OnPropertyChanged("Items");
  10214. }
  10215. }
  10216.  
  10217. public ICommand ShowPeriodCommand
  10218. {
  10219. get
  10220. {
  10221. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.ShowPeriodCommand), new Action(this.ExecuteShowPeriodCommand));
  10222. }
  10223. }
  10224.  
  10225. public SessionHistoryVM()
  10226. {
  10227. this.PeriodStart = DateTime.Now.Date.AddDays(-7.0);
  10228. this.PeriodEnd = DateTime.Now.Date;
  10229. this.ExecuteShowPeriodCommand();
  10230. }
  10231.  
  10232. private void ExecuteShowPeriodCommand()
  10233. {
  10234. Logger.WriteInfo(typeof (SessionHistoryVM), "ExecuteShowPeriodCommand()", "??????? ???????? ?????? ?? ????????? ??????");
  10235. Statistic[] statisticArray = Enumerable.ToArray<Statistic>(Enumerable.Where<Statistic>((IEnumerable<Statistic>) (StatisticManager.Instance.GetStatistics() ?? new Statistic[0]), (Func<Statistic, bool>) (x => x.Lifetime != 0L)));
  10236. this.Items = new ObservableCollection<SessionRecordVM>(Enumerable.Where<SessionRecordVM>(Enumerable.Select<Statistic, SessionRecordVM>((IEnumerable<Statistic>) Enumerable.OrderByDescending<Statistic, DateTime>((IEnumerable<Statistic>) statisticArray, (Func<Statistic, DateTime>) (r => r.CreatedDate)), (Func<Statistic, SessionRecordVM>) (x => new SessionRecordVM(x))), (Func<SessionRecordVM, bool>) (y =>
  10237. {
  10238. DateTime? endTime = y.EndTime;
  10239. DateTime periodEnd = this.PeriodEnd;
  10240. if ((endTime.HasValue ? (endTime.GetValueOrDefault() < periodEnd ? 1 : 0) : 0) != 0)
  10241. return y.StartTime > this.PeriodStart;
  10242. return false;
  10243. })));
  10244. this.ChartItems = new ObservableCollection<SessionChartItemVM>(Enumerable.Select<IGrouping<DateTime, Statistic>, SessionChartItemVM>(Enumerable.GroupBy<Statistic, DateTime>((IEnumerable<Statistic>) statisticArray, (Func<Statistic, DateTime>) (x => x.CreatedDate.Date)), (Func<IGrouping<DateTime, Statistic>, SessionChartItemVM>) (x => new SessionChartItemVM(x.Key, Enumerable.Sum<Statistic>((IEnumerable<Statistic>) x, (Func<Statistic, double>) (y => (double) y.Lifetime / 60.0))))));
  10245. Logger.WriteInfo(typeof (SessionHistoryVM), "ExecuteShowPeriodCommand()", "????????? ?????? ??????? ?? ??????...");
  10246. string str = TimeSpanExtention.TotalTimeString(TimeSpan.FromMinutes(Enumerable.Sum<SessionChartItemVM>((IEnumerable<SessionChartItemVM>) this.ChartItems, (Func<SessionChartItemVM, double>) (x => x.Duration))), "{0:00}:{1:00}:{2:00}");
  10247. Logger.WriteInfo(typeof (SessionHistoryVM), "ExecuteShowPeriodCommand()", "??????? ???????? ????? ????? ?? ????????? ??????");
  10248. this.PeriodTotalString = string.Format("{0} {1}", (object) Resources.SessionHistoryUC_Total, (object) str);
  10249. }
  10250. }
  10251. }
  10252. ?// Decompiled with JetBrains decompiler
  10253. // Type: WinApp.ViewModel.Controls.SettingsVM
  10254. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  10255. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  10256. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  10257.  
  10258. using Inc.Logging;
  10259. using IncMap;
  10260. using System;
  10261. using System.Collections.ObjectModel;
  10262. using System.Diagnostics;
  10263. using System.Windows;
  10264. using System.Windows.Input;
  10265. using WinApp.Managers.Interfaces;
  10266. using WinApp.Managers.Localization;
  10267. using WinApp.Managers.Network;
  10268. using WinApp.ViewModel.Base;
  10269.  
  10270. namespace WinApp.ViewModel.Controls
  10271. {
  10272. internal class SettingsVM : ViewModelBase
  10273. {
  10274. private bool _isRunAtStartup = Map.Get<IApplicationSettings>().RunAtStartup;
  10275. private bool _isAutoLogin = Map.Get<IApplicationSettings>().IsAutoLogin;
  10276. private bool _isHttpUsed = Map.Get<IApplicationSettings>().IsHttpUsed;
  10277. private Visibility _languageSelectedVisibility = Visibility.Hidden;
  10278. private Visibility _visibleHttpWarning = Visibility.Hidden;
  10279. private LocalizationObject _selectedLanguage;
  10280. private bool _isCheckHttpPing;
  10281.  
  10282. public bool IsRunAtStartup
  10283. {
  10284. get
  10285. {
  10286. return this._isRunAtStartup;
  10287. }
  10288. set
  10289. {
  10290. this._isRunAtStartup = value;
  10291. Map.Get<IApplicationSettings>().SetRunAtStartup(this._isRunAtStartup);
  10292. this.OnPropertyChanged("IsRunAtStartup");
  10293. }
  10294. }
  10295.  
  10296. public bool IsAutoLogin
  10297. {
  10298. get
  10299. {
  10300. return this._isAutoLogin;
  10301. }
  10302. set
  10303. {
  10304. this._isAutoLogin = value;
  10305. Map.Get<IApplicationSettings>().SetIsAutoLogin(this._isAutoLogin);
  10306. this.OnPropertyChanged("IsAutoLogin");
  10307. }
  10308. }
  10309.  
  10310. public bool IsCheckHttpPing
  10311. {
  10312. get
  10313. {
  10314. this._isCheckHttpPing = Map.Get<IApplicationSettings>().IsHttpUsed;
  10315. return this._isCheckHttpPing;
  10316. }
  10317. set
  10318. {
  10319. this._isCheckHttpPing = value;
  10320. NetworkMonitor.SetPingThrough(this._isCheckHttpPing);
  10321. Map.Get<IApplicationSettings>().SetHttpPingUsed(this._isCheckHttpPing);
  10322. this.OnPropertyChanged("IsCheckHttpPing");
  10323. this.OnPropertyChanged("IsCheckIcmpPing");
  10324. this.OnPropertyChanged("VisibleHttpWarning");
  10325. }
  10326. }
  10327.  
  10328. public bool IsCheckIcmpPing
  10329. {
  10330. get
  10331. {
  10332. return !this.IsCheckHttpPing;
  10333. }
  10334. set
  10335. {
  10336. this.IsCheckHttpPing = false;
  10337. }
  10338. }
  10339.  
  10340. public Visibility VisibleHttpWarning
  10341. {
  10342. get
  10343. {
  10344. return !this.IsCheckHttpPing ? Visibility.Hidden : Visibility.Visible;
  10345. }
  10346. set
  10347. {
  10348. this.OnPropertyChanged("VisibleHttpWarning");
  10349. }
  10350. }
  10351.  
  10352. public bool IsAutoLoginEnabled
  10353. {
  10354. get
  10355. {
  10356. return Map.Get<IApplicationSettings>().IsRemeberMe;
  10357. }
  10358. }
  10359.  
  10360. public ObservableCollection<LocalizationObject> LanguagesCollection
  10361. {
  10362. get
  10363. {
  10364. return Map.Get<ILocalizationManager>().LanguagesCollection;
  10365. }
  10366. }
  10367.  
  10368. public LocalizationObject SelectedLanguage
  10369. {
  10370. get
  10371. {
  10372. return this._selectedLanguage;
  10373. }
  10374. set
  10375. {
  10376. this._selectedLanguage = value;
  10377. if (this._selectedLanguage == null)
  10378. return;
  10379. Map.Get<IApplicationSettings>().SetLocalization(this._selectedLanguage);
  10380. this.LanguageSelectedVisibility = Visibility.Visible;
  10381. this.OnPropertyChanged("SelectedLanguage");
  10382. }
  10383. }
  10384.  
  10385. public Visibility LanguageSelectedVisibility
  10386. {
  10387. get
  10388. {
  10389. return this._languageSelectedVisibility;
  10390. }
  10391. set
  10392. {
  10393. this._languageSelectedVisibility = value;
  10394. this.OnPropertyChanged("LanguageSelectedVisibility");
  10395. }
  10396. }
  10397.  
  10398. public ICommand RestartCommand
  10399. {
  10400. get
  10401. {
  10402. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.RestartCommand), new Action(this.Restart));
  10403. }
  10404. }
  10405.  
  10406. internal SettingsVM()
  10407. {
  10408. this.IsRunAtStartup = Map.Get<IApplicationSettings>().RunAtStartup;
  10409. this._selectedLanguage = Map.Get<IApplicationSettings>().GetLocalizationObject();
  10410. }
  10411.  
  10412. private void Restart()
  10413. {
  10414. Logger.WriteInfo(typeof (SettingsVM), "Restart()", "???????????? ??????????...");
  10415. Process.Start(Application.ResourceAssembly.Location);
  10416. Application.Current.Shutdown();
  10417. }
  10418. }
  10419. }
  10420. ?// Decompiled with JetBrains decompiler
  10421. // Type: WinApp.ViewModel.Controls.CaptionListVM
  10422. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  10423. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  10424. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  10425.  
  10426. using Inc.Logging;
  10427. using IncMap;
  10428. using System;
  10429. using System.Linq.Expressions;
  10430. using System.Windows.Input;
  10431. using WinApp.Managers.Interfaces;
  10432. using WinApp.ViewModel.Base;
  10433. using WinApp.ViewModel.MainMenu;
  10434.  
  10435. namespace WinApp.ViewModel.Controls
  10436. {
  10437. internal class CaptionListVM : ViewModelBase
  10438. {
  10439. public CaptionMenuItem MenuItem { get; set; }
  10440.  
  10441. public ICommand OpenCommand
  10442. {
  10443. get
  10444. {
  10445. return this.Commands.GetOrCreateCommand<ICommand>((Expression<Func<ICommand>>) (() => this.OpenCommand), new Action<object>(this.OpenTab));
  10446. }
  10447. }
  10448.  
  10449. public CaptionListVM(CaptionMenuItem menuItem)
  10450. {
  10451. this.MenuItem = menuItem;
  10452. }
  10453.  
  10454. private void OpenTab(object obj)
  10455. {
  10456. MainMenuItem menuItem = obj as MainMenuItem;
  10457. if (menuItem == null)
  10458. return;
  10459. Logger.WriteInfo(typeof (CaptionListVM), "OpenTab()", string.Format("??????????? ??????? ?? ???????? '{0}'...", (object) menuItem.Name));
  10460. Map.Get<IScreenManager>().MainView.ViewModel.SwithToMenuItem(menuItem);
  10461. Logger.WriteInfo(typeof (CaptionListVM), "OpenTab()", string.Format("??????? ?? ???????? '{0}' ???????? ???????", (object) menuItem.Name));
  10462. }
  10463. }
  10464. }
  10465. ?// Decompiled with JetBrains decompiler
  10466. // Type: WinApp.ViewModel.MainViewVM
  10467. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  10468. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  10469. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  10470.  
  10471. using Inc.Logging;
  10472. using IncMap;
  10473. using KairosPlanet;
  10474. using KairosPlanet.Properties;
  10475. using System;
  10476. using System.Collections.Generic;
  10477. using System.Linq;
  10478. using System.Windows;
  10479. using System.Windows.Controls;
  10480. using System.Windows.Documents;
  10481. using System.Windows.Media;
  10482. using System.Windows.Media.Imaging;
  10483. using WinApp.Managers.Interfaces;
  10484. using WinApp.View;
  10485. using WinApp.ViewModel.Base;
  10486. using WinApp.ViewModel.MainMenu;
  10487.  
  10488. namespace WinApp.ViewModel
  10489. {
  10490. internal class MainViewVM : ViewModelBase
  10491. {
  10492. private readonly Stack<Control> _controlsHistory = new Stack<Control>();
  10493. private readonly MainMenuCollection _menu = new MainMenuCollection();
  10494. private Visibility _visiblityErrorBlock = Visibility.Collapsed;
  10495. private Visibility _visibilityStatusBlock = Visibility.Collapsed;
  10496. private Visibility _isStatusInProgress = Visibility.Collapsed;
  10497. private FlowDocument _errorDocument = new FlowDocument();
  10498. private MainMenuItem _selectedMenuItem;
  10499. private Control _content;
  10500. private string _messageErrorBlock;
  10501. private string _statusMessage;
  10502. private MainViewUC _mainView;
  10503.  
  10504. public MainMenuCollection MenuItems
  10505. {
  10506. get
  10507. {
  10508. return this._menu;
  10509. }
  10510. }
  10511.  
  10512. public MainMenuItem SelectedMenuItem
  10513. {
  10514. get
  10515. {
  10516. return this._selectedMenuItem;
  10517. }
  10518. set
  10519. {
  10520. this._selectedMenuItem = value;
  10521. if (!object.Equals((object) this.Content, (object) this._selectedMenuItem.Control))
  10522. this.SwithToMenuItem(this._selectedMenuItem);
  10523. this.OnPropertyChanged("SelectedMenuItem");
  10524. }
  10525. }
  10526.  
  10527. public Control Content
  10528. {
  10529. get
  10530. {
  10531. return this._content;
  10532. }
  10533. set
  10534. {
  10535. this._content = value;
  10536. this.OnPropertyChanged("Content");
  10537. }
  10538. }
  10539.  
  10540. public Visibility VisiblityErrorBlock
  10541. {
  10542. get
  10543. {
  10544. return this._visiblityErrorBlock;
  10545. }
  10546. set
  10547. {
  10548. this._visiblityErrorBlock = value;
  10549. this.OnPropertyChanged("VisiblityErrorBlock");
  10550. }
  10551. }
  10552.  
  10553. public FlowDocument ErrorDocument
  10554. {
  10555. get
  10556. {
  10557. return this._errorDocument;
  10558. }
  10559. set
  10560. {
  10561. this._errorDocument = value;
  10562. this.OnPropertyChanged("ErrorDocument");
  10563. }
  10564. }
  10565.  
  10566. public string MessageErrorBlock
  10567. {
  10568. get
  10569. {
  10570. return this._messageErrorBlock;
  10571. }
  10572. set
  10573. {
  10574. this._messageErrorBlock = value;
  10575. this.OnPropertyChanged("MessageErrorBlock");
  10576. }
  10577. }
  10578.  
  10579. public string StatusMessage
  10580. {
  10581. get
  10582. {
  10583. return this._statusMessage;
  10584. }
  10585. set
  10586. {
  10587. this._statusMessage = value;
  10588. this.VisibilityStatusBlock = !string.IsNullOrEmpty(this.StatusMessage) || this._isStatusInProgress == Visibility.Visible ? Visibility.Visible : Visibility.Collapsed;
  10589. this.OnPropertyChanged("StatusMessage");
  10590. }
  10591. }
  10592.  
  10593. public Visibility VisibilityStatusBlock
  10594. {
  10595. get
  10596. {
  10597. return this._visibilityStatusBlock;
  10598. }
  10599. set
  10600. {
  10601. this._visibilityStatusBlock = value;
  10602. this.OnPropertyChanged("VisibilityStatusBlock");
  10603. }
  10604. }
  10605.  
  10606. public Visibility IsStatusInProgress
  10607. {
  10608. get
  10609. {
  10610. return this._isStatusInProgress;
  10611. }
  10612. set
  10613. {
  10614. this._isStatusInProgress = value;
  10615. this.VisibilityStatusBlock = !string.IsNullOrEmpty(this.StatusMessage) || this._isStatusInProgress == Visibility.Visible ? Visibility.Visible : Visibility.Collapsed;
  10616. this.OnPropertyChanged("IsStatusInProgress");
  10617. }
  10618. }
  10619.  
  10620. public MainViewVM(MainViewUC mainViewUc)
  10621. {
  10622. this._mainView = mainViewUc;
  10623. this._menu.Services.IsSelected = true;
  10624. AppVM.Instance.ErrorStateChanged += new EventHandler(this.OnErrorStateChanged);
  10625. this.ErorStateRefresh();
  10626. }
  10627.  
  10628. ~MainViewVM()
  10629. {
  10630. AppVM.Instance.ErrorStateChanged -= new EventHandler(this.OnErrorStateChanged);
  10631. }
  10632.  
  10633. public void SwithToMenuItem(MainMenuItem menuItem)
  10634. {
  10635. Logger.WriteInfo(typeof (MainViewVM), "SwithToMenuItem()", string.Format("??????? ?? ???????? '{0}'", (object) menuItem.Name));
  10636. this._controlsHistory.Clear();
  10637. this.SwithTo(menuItem.Control, true);
  10638. MainMenuItem mainMenuItem1;
  10639. if (menuItem is CaptionMenuItem)
  10640. {
  10641. menuItem.IsExpanded = true;
  10642. mainMenuItem1 = menuItem;
  10643. }
  10644. else
  10645. mainMenuItem1 = menuItem.Parent;
  10646. foreach (MainMenuItem mainMenuItem2 in Enumerable.Except<MainMenuItem>((IEnumerable<MainMenuItem>) this.MenuItems, (IEnumerable<MainMenuItem>) new MainMenuItem[1]
  10647. {
  10648. mainMenuItem1
  10649. }))
  10650. mainMenuItem2.IsExpanded = false;
  10651. if (menuItem.IsSelected)
  10652. return;
  10653. menuItem.IsSelected = true;
  10654. }
  10655.  
  10656. public void SwitchBack()
  10657. {
  10658. if (!this.CanSwitchBack())
  10659. return;
  10660. this._controlsHistory.Pop();
  10661. this.Content = this._controlsHistory.Peek();
  10662. }
  10663.  
  10664. public bool CanSwitchBack()
  10665. {
  10666. return this._controlsHistory.Count > 1;
  10667. }
  10668.  
  10669. private void OnErrorStateChanged(object sender, EventArgs eventArgs)
  10670. {
  10671. this.ErorStateRefresh();
  10672. }
  10673.  
  10674. private void ErorStateRefresh()
  10675. {
  10676. switch (AppVM.Instance.ModuleErrorState)
  10677. {
  10678. case ModuleErrorState.NoError:
  10679. this._visiblityErrorBlock = Visibility.Collapsed;
  10680. this._messageErrorBlock = string.Empty;
  10681. break;
  10682. case ModuleErrorState.CrashOrNotFoundMainFile:
  10683. this.ShowError(Resources.Tray_ModuleCrashOrNotFoundMainFiledMessage);
  10684. break;
  10685. case ModuleErrorState.ModuleNotInstalledMessage:
  10686. this.ShowError(Resources.Tray_ModuleNotInstalledMessage);
  10687. break;
  10688. }
  10689. this.OnPropertyChanged("VisiblityErrorBlock");
  10690. this.OnPropertyChanged("MessageErrorBlock");
  10691. this.OnPropertyChanged("ErrorDocument");
  10692. }
  10693.  
  10694. private void SwithTo(Control control, bool pushToHistory = true)
  10695. {
  10696. this.Content = control;
  10697. if (!pushToHistory)
  10698. return;
  10699. this._controlsHistory.Push(control);
  10700. }
  10701.  
  10702. private void ShowError(string message)
  10703. {
  10704. this._messageErrorBlock = message;
  10705. this._visiblityErrorBlock = Visibility.Visible;
  10706. Map.Get<IScreenManager>().DoVisualSafe((Action) (() => this.ErrorDocument = this.CreateFlowDocument(message)));
  10707. }
  10708.  
  10709. private FlowDocument CreateFlowDocument(string message)
  10710. {
  10711. FlowDocument flowDocument = new FlowDocument()
  10712. {
  10713. PagePadding = new Thickness(0.0)
  10714. };
  10715. Paragraph paragraph = new Paragraph();
  10716. BitmapImage bitmapImage = new BitmapImage();
  10717. bitmapImage.BeginInit();
  10718. bitmapImage.UriSource = new Uri("pack://application:,,,/KairosPlanet;component/Assets/Images/Offline.ico", UriKind.Absolute);
  10719. bitmapImage.EndInit();
  10720. Image image = new Image();
  10721. image.Source = (ImageSource) bitmapImage;
  10722. image.Height = 40.0;
  10723. image.Width = 40.0;
  10724. BlockUIContainer blockUiContainer = new BlockUIContainer((UIElement) image);
  10725. blockUiContainer.Margin = new Thickness(0.0);
  10726. Figure figure1 = new Figure((Block) blockUiContainer);
  10727. figure1.HorizontalAnchor = FigureHorizontalAnchor.PageLeft;
  10728. figure1.Width = new FigureLength(40.0);
  10729. figure1.Margin = new Thickness(0.0, 0.0, 10.0, 0.0);
  10730. figure1.Padding = new Thickness(0.0);
  10731. Figure figure2 = figure1;
  10732. paragraph.Inlines.Add((Inline) figure2);
  10733. paragraph.Margin = new Thickness(0.0);
  10734. paragraph.Padding = new Thickness(0.0);
  10735. paragraph.LineHeight = 0.6;
  10736. paragraph.TextAlignment = TextAlignment.Justify;
  10737. paragraph.Foreground = (Brush) new SolidColorBrush(Color.FromRgb((byte) 102, (byte) 102, (byte) 102));
  10738. paragraph.FontFamily = (FontFamily) this._mainView.FindResource((object) "OpenSans");
  10739. paragraph.Inlines.Add(message);
  10740. flowDocument.Blocks.Add((Block) paragraph);
  10741. return flowDocument;
  10742. }
  10743. }
  10744. }
  10745. ?// Decompiled with JetBrains decompiler
  10746. // Type: WinApp.ViewModel.LoginBaseVM
  10747. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  10748. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  10749. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  10750.  
  10751. using Inc.Logging;
  10752. using IncMap;
  10753. using KairosPlanet.Properties;
  10754. using System;
  10755. using System.Windows;
  10756. using System.Windows.Input;
  10757. using WinApp.Data.Helpers;
  10758. using WinApp.Managers.Interfaces;
  10759. using WinApp.ViewModel.Base;
  10760.  
  10761. namespace WinApp.ViewModel
  10762. {
  10763. internal abstract class LoginBaseVM : ViewModelBase
  10764. {
  10765. private Visibility _screenVisibility = Visibility.Hidden;
  10766. private Visibility _emailErrorVisibility = Visibility.Hidden;
  10767. private Visibility _passwordErrorVisibility = Visibility.Hidden;
  10768. private bool _emailEditable = true;
  10769. private string _email;
  10770. private string _password;
  10771. private string _emailError;
  10772. private string _passwordError;
  10773.  
  10774. public string Password
  10775. {
  10776. get
  10777. {
  10778. return this._password;
  10779. }
  10780. set
  10781. {
  10782. this._password = value;
  10783. this.OnPropertyChanged("Password");
  10784. }
  10785. }
  10786.  
  10787. public string Email
  10788. {
  10789. get
  10790. {
  10791. return this._email;
  10792. }
  10793. set
  10794. {
  10795. this._email = value;
  10796. this.OnPropertyChanged("Email");
  10797. }
  10798. }
  10799.  
  10800. public Visibility ScreenVisibility
  10801. {
  10802. get
  10803. {
  10804. return this._screenVisibility;
  10805. }
  10806. set
  10807. {
  10808. this._screenVisibility = value;
  10809. this.OnPropertyChanged("ScreenVisibility");
  10810. }
  10811. }
  10812.  
  10813. public Visibility EmailErrorVisibility
  10814. {
  10815. get
  10816. {
  10817. return this._emailErrorVisibility;
  10818. }
  10819. set
  10820. {
  10821. this._emailErrorVisibility = value;
  10822. this.OnPropertyChanged("EmailErrorVisibility");
  10823. }
  10824. }
  10825.  
  10826. public Visibility PasswordErrorVisibility
  10827. {
  10828. get
  10829. {
  10830. return this._passwordErrorVisibility;
  10831. }
  10832. set
  10833. {
  10834. this._passwordErrorVisibility = value;
  10835. this.OnPropertyChanged("PasswordErrorVisibility");
  10836. }
  10837. }
  10838.  
  10839. public string EmailError
  10840. {
  10841. get
  10842. {
  10843. return this._emailError;
  10844. }
  10845. set
  10846. {
  10847. this._emailError = value;
  10848. this.OnPropertyChanged("EmailError");
  10849. }
  10850. }
  10851.  
  10852. public string PasswordError
  10853. {
  10854. get
  10855. {
  10856. return this._passwordError;
  10857. }
  10858. set
  10859. {
  10860. this._passwordError = value;
  10861. this.OnPropertyChanged("PasswordError");
  10862. }
  10863. }
  10864.  
  10865. public bool EmailEditable
  10866. {
  10867. get
  10868. {
  10869. return this._emailEditable;
  10870. }
  10871. set
  10872. {
  10873. this._emailEditable = value;
  10874. this.OnPropertyChanged("EmailEditable");
  10875. }
  10876. }
  10877.  
  10878. public ICommand DoLogin
  10879. {
  10880. get
  10881. {
  10882. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.DoLogin), (Action) (() => this.ExecuteLogin(false)));
  10883. }
  10884. }
  10885.  
  10886. protected LoginBaseVM(string email, string password)
  10887. {
  10888. this.Email = email;
  10889. this.Password = password;
  10890. }
  10891.  
  10892. protected LoginBaseVM()
  10893. {
  10894. }
  10895.  
  10896. protected void ExecuteLogin(bool autoLogin = false)
  10897. {
  10898. Logger.WriteInfo(typeof (LoginBaseVM), "ExecuteLogin()", "??????? ????? ? ??????? ?????????????...");
  10899. if (!autoLogin)
  10900. {
  10901. if (this.HasAnyError())
  10902. {
  10903. Logger.WriteWarning(typeof (LoginBaseVM), "ExecuteLogin()", "?????? ??? ?????????? ?????? ??? ????? ? ???????");
  10904. return;
  10905. }
  10906. }
  10907. try
  10908. {
  10909. switch (this.RequestLogin(this.Email, this.Password).Result)
  10910. {
  10911. case LoginResult.NoResponce:
  10912. this.HideAllErrors();
  10913. Logger.WriteWarning(typeof (LoginBaseVM), "ExecuteLogin()", "?????? ??? ????? ???????????? ? ???????. ?? ??????? ??????????? ? ???????????? ???????");
  10914. this.ShowConnectionError();
  10915. break;
  10916. case LoginResult.WrongInput:
  10917. this.EmailErrorVisibility = Visibility.Visible;
  10918. this.PasswordErrorVisibility = Visibility.Visible;
  10919. this.EmailError = Resources.Error_PasswordOrEmailInvalid;
  10920. Logger.WriteWarning(typeof (LoginBaseVM), "ExecuteLogin()", "?????? ??? ????? ???????????? ? ???????. ???????? ???? ??????");
  10921. break;
  10922. case LoginResult.UserDeleted:
  10923. Logger.WriteWarning(typeof (LoginBaseVM), "ExecuteLogin()", "?????? ??? ????? ???????????? ? ???????. ??????? ??????");
  10924. this.ShowUserDeletedError();
  10925. break;
  10926. case LoginResult.Pass:
  10927. this.PassAction(autoLogin);
  10928. Logger.WriteInfo(typeof (LoginBaseVM), "ExecuteLogin()", "???? ??????? ????????");
  10929. break;
  10930. }
  10931. }
  10932. catch (Exception ex)
  10933. {
  10934. Logger.WriteError((object) this, "ExecuteLogin()", "?????? ??? ???????? ?????? ? ???????: " + ex.Message);
  10935. }
  10936. }
  10937.  
  10938. protected abstract void PassAction(bool isAutoLogin);
  10939.  
  10940. protected abstract LoginResponce RequestLogin(string email, string password);
  10941.  
  10942. private bool HasAnyError()
  10943. {
  10944. this.HideAllErrors();
  10945. bool flag = false;
  10946. if (StringUtil.IsNullOrWhiteSpace(this.Email))
  10947. {
  10948. this.ShowEmailEmptyError();
  10949. flag = true;
  10950. }
  10951. if (StringUtil.IsNullOrWhiteSpace(this.Password))
  10952. {
  10953. this.ShowPasswordEmptyError();
  10954. flag = true;
  10955. }
  10956. return flag;
  10957. }
  10958.  
  10959. private void HideAllErrors()
  10960. {
  10961. this.EmailError = string.Empty;
  10962. this.PasswordError = string.Empty;
  10963. this.EmailErrorVisibility = Visibility.Hidden;
  10964. this.PasswordErrorVisibility = Visibility.Hidden;
  10965. }
  10966.  
  10967. private void ShowPasswordEmptyError()
  10968. {
  10969. this.PasswordErrorVisibility = Visibility.Visible;
  10970. this.PasswordError = Resources.Error_PasswordIsEmpty;
  10971. }
  10972.  
  10973. private void ShowEmailEmptyError()
  10974. {
  10975. this.EmailErrorVisibility = Visibility.Visible;
  10976. this.EmailError = Resources.Error_EmailIsEmpty;
  10977. }
  10978.  
  10979. private void ShowUserDeletedError()
  10980. {
  10981. Map.Get<IScreenManager>().ShowAlert(Resources.Error_UserDeletedError, Resources.Error);
  10982. }
  10983.  
  10984. private void ShowConnectionError()
  10985. {
  10986. Map.Get<IScreenManager>().ShowAlert(Resources.Error_ConnectionError, Resources.Error);
  10987. }
  10988. }
  10989. }
  10990. ?// Decompiled with JetBrains decompiler
  10991. // Type: WinApp.ViewModel.AppVM
  10992. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  10993. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  10994. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  10995.  
  10996. using Inc.Logging;
  10997. using IncMap;
  10998. using KairosPlanet;
  10999. using KairosPlanet.Managers.Network;
  11000. using System;
  11001. using System.Configuration;
  11002. using System.Reflection;
  11003. using System.Windows;
  11004. using Telerik.Windows.Controls;
  11005. using WinApp;
  11006. using WinApp.Managers.Interfaces;
  11007. using WinApp.Managers.Localization;
  11008. using WinApp.Managers.Network;
  11009. using WinApp.Service.Core;
  11010. using WinApp.View.Helpers;
  11011.  
  11012. namespace WinApp.ViewModel
  11013. {
  11014. internal class AppVM
  11015. {
  11016. private static readonly object _createLock = new object();
  11017. private static AppVM _instance;
  11018. private NetworkState _networkState;
  11019. private ModuleErrorState _moduleErrorState;
  11020. private long? _activePackageId;
  11021. private double _activePackagePrice;
  11022. private bool _isLoadedPackageId;
  11023. private bool _isHttpUsed;
  11024.  
  11025. public static AppVM Instance
  11026. {
  11027. get
  11028. {
  11029. if (AppVM._instance == null)
  11030. AppVM.InitializeAppVM();
  11031. return AppVM._instance;
  11032. }
  11033. }
  11034.  
  11035. public NetworkState NetworkState
  11036. {
  11037. get
  11038. {
  11039. return this._networkState;
  11040. }
  11041. set
  11042. {
  11043. if (this._networkState == value)
  11044. return;
  11045. this._networkState = value;
  11046. try
  11047. {
  11048. Map.Get<IAppTray>().Refresh();
  11049. }
  11050. catch (Exception ex)
  11051. {
  11052. throw;
  11053. }
  11054. }
  11055. }
  11056.  
  11057. public ModuleErrorState ModuleErrorState
  11058. {
  11059. get
  11060. {
  11061. return this._moduleErrorState;
  11062. }
  11063. set
  11064. {
  11065. if (this._moduleErrorState == value)
  11066. return;
  11067. Logger.WriteWarning((object) this, "ModuleErrorState", "ModuleErrorState changed from '" + (object) this._moduleErrorState + "' on '" + (string) (object) value + "'");
  11068. this._moduleErrorState = value;
  11069. if (this.ErrorStateChanged == null)
  11070. return;
  11071. this.ErrorStateChanged((object) this, new EventArgs());
  11072. }
  11073. }
  11074.  
  11075. public LoginState LoginState { get; private set; }
  11076.  
  11077. public long? ActivePackageId
  11078. {
  11079. get
  11080. {
  11081. if (!this._isLoadedPackageId)
  11082. {
  11083. this._activePackageId = new long?(Map.Get<IApplicationSettings>().ActiveProductId);
  11084. this._isLoadedPackageId = true;
  11085. }
  11086. return this._activePackageId;
  11087. }
  11088. set
  11089. {
  11090. this._activePackageId = value;
  11091. }
  11092. }
  11093.  
  11094. public bool IsHttpUsed
  11095. {
  11096. get
  11097. {
  11098. this._isHttpUsed = Map.Get<IApplicationSettings>().IsHttpUsed;
  11099. return this._isHttpUsed;
  11100. }
  11101. set
  11102. {
  11103. this._isHttpUsed = value;
  11104. }
  11105. }
  11106.  
  11107. public double ActivePackagePrice
  11108. {
  11109. get
  11110. {
  11111. return this._activePackagePrice;
  11112. }
  11113. set
  11114. {
  11115. this._activePackagePrice = value;
  11116. }
  11117. }
  11118.  
  11119. internal event EventHandler ErrorStateChanged;
  11120.  
  11121. private AppVM()
  11122. {
  11123. }
  11124.  
  11125. public static void Initialize()
  11126. {
  11127. try
  11128. {
  11129. Logger.WriteInfo(typeof (AppVM), "Initialize()", "????????????? ??????????...");
  11130. AppVM.InitializeAppVM();
  11131. AppDomain.CurrentDomain.AppendPrivatePath("Modules\\Rent module");
  11132. Logger.WriteInfo((object) typeof (AppVM), "Initialize()", "???????? ????????????? ??????????", "??????? ?????? ?????????? - " + AppVM.Instance.GetCurrentAppVersion().ToString());
  11133. }
  11134. catch (Exception ex)
  11135. {
  11136. Logger.WriteError(typeof (AppVM), "Initialize()", "?????? ??? ????????????? ??????????", ex);
  11137. }
  11138. }
  11139.  
  11140. public void OnStartUp()
  11141. {
  11142. Logger.WriteInfo(typeof (AppVM), "OnStartUp()", "????? ??????????. ????????????? ???????????...");
  11143. Bootstrapper.Bootstrap();
  11144. TelerikThemeManager.ApplyTheme();
  11145. Map.Get<ILocalizationManager>().ApplyLocalization();
  11146. Logger.WriteInfo(typeof (AppVM), "OnStartUp()", "ApplyLocalization executed");
  11147. NetworkMonitor.NetworkStateChanged += new EventHandler<NetworkStateEventArgs>(this.OnNetworkStateChanged);
  11148. NetworkMonitor.StartNetworkMonitoring();
  11149. Logger.WriteInfo(typeof (AppVM), "OnStartUp()", "NetworkMonitor started");
  11150. try
  11151. {
  11152. Map.Get<IMainWindow>().Show();
  11153. IMainWindow mainWindow = Map.Get<IMainWindow>();
  11154. mainWindow.Show();
  11155. ((UIElement) (mainWindow as RadWindow)).Focus();
  11156. Logger.WriteInfo(typeof (AppVM), "OnStartUp()", "MainWindow Show executed");
  11157. Logger.WriteInfo(typeof (AppVM), "OnStartUp()", "MainWindow Show executed");
  11158. }
  11159. catch (Exception ex)
  11160. {
  11161. throw;
  11162. }
  11163. DatabaseInitializer.Initialize();
  11164. Logger.WriteInfo(typeof (AppVM), "OnStartUp()", "DatabaseInitializer initialized");
  11165. Map.Get<IScreenManager>().SwitchToLogin();
  11166. Logger.WriteInfo(typeof (AppVM), "OnStartUp()", "?????????? ????????. ?????????? ????????????????");
  11167. }
  11168.  
  11169. public void LogIn()
  11170. {
  11171. Logger.WriteInfo(typeof (AppVM), "LogOut()", "???? ????????????...");
  11172. this.LoginState = LoginState.Done;
  11173. if (this.IsNewAppVersionAvailable())
  11174. return;
  11175. this.ShowMainWindow();
  11176. }
  11177.  
  11178. public void ShowMainWindow()
  11179. {
  11180. Map.Get<IScreenManager>().SwitchToMain();
  11181. Map.Get<IAppTray>().Refresh();
  11182. }
  11183.  
  11184. public void ProcedeLogOut()
  11185. {
  11186. Logger.WriteInfo(typeof (AppVM), "LogOut()", "????? ???????? ????????????...");
  11187. this.LoginState = LoginState.NoLogin;
  11188. Map.Get<ISessionManager>().CloseSession();
  11189. Map.Get<IScreenManager>().SwitchToLogin();
  11190. Map.Get<IAppTray>().Refresh();
  11191. }
  11192.  
  11193. internal void SetActivePackage(long productId)
  11194. {
  11195. this._activePackageId = new long?(productId);
  11196. IApplicationSettings applicationSettings = Map.Get<IApplicationSettings>();
  11197. applicationSettings.ActiveProductId = productId;
  11198. applicationSettings.Save();
  11199. SessionMonitor.Instance.SetSessionStateToLogon();
  11200. }
  11201.  
  11202. internal Version GetCurrentAppVersion()
  11203. {
  11204. return Assembly.GetAssembly(this.GetType()).GetName().Version;
  11205. }
  11206.  
  11207. private static void InitializeAppVM()
  11208. {
  11209. lock (AppVM._createLock)
  11210. {
  11211. if (AppVM._instance != null)
  11212. return;
  11213. AppVM._instance = new AppVM();
  11214. }
  11215. }
  11216.  
  11217. private void OnNetworkStateChanged(object sender, NetworkStateEventArgs e)
  11218. {
  11219. Application.Current.Dispatcher.Invoke((Delegate) (() => AppVM.Instance.NetworkState = e.State));
  11220. }
  11221.  
  11222. private bool IsNewAppVersionAvailable()
  11223. {
  11224. try
  11225. {
  11226. string appVersion = Map.Get<ISessionManager>().GetAppVersion();
  11227. if (string.IsNullOrEmpty(appVersion))
  11228. {
  11229. Logger.WriteError((object) this, "IsNewAppVersionAvailable()", "Empty app version from site");
  11230. return false;
  11231. }
  11232. Version appVersionOnSite = new Version(appVersion);
  11233. Version currentAppVersion = this.GetCurrentAppVersion();
  11234. bool isShowVersionPage = this.GetIsShowVersionPage();
  11235. if (!(currentAppVersion != appVersionOnSite))
  11236. {
  11237. if (!isShowVersionPage)
  11238. goto label_6;
  11239. }
  11240. Map.Get<IScreenManager>().SwitchToNewVersionAvailableWindow(appVersionOnSite, currentAppVersion);
  11241. return true;
  11242. }
  11243. catch (Exception ex)
  11244. {
  11245. Logger.WriteError((object) this, "CheckAppVersion()", "Error: ", ex);
  11246. }
  11247. label_6:
  11248. return false;
  11249. }
  11250.  
  11251. private bool GetIsShowVersionPage()
  11252. {
  11253. string str = ConfigurationManager.AppSettings["ShowVersionPage"];
  11254. bool result;
  11255. if (string.IsNullOrEmpty(str) || !bool.TryParse(str, out result))
  11256. return false;
  11257. return result;
  11258. }
  11259. }
  11260. }
  11261. ?// Decompiled with JetBrains decompiler
  11262. // Type: WinApp.ViewModel.MainMenu.MainMenuItem
  11263. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11264. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  11265. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  11266.  
  11267. using System;
  11268. using System.Windows.Controls;
  11269. using Telerik.Windows.Controls;
  11270.  
  11271. namespace WinApp.ViewModel.MainMenu
  11272. {
  11273. public class MainMenuItem : ViewModelBase
  11274. {
  11275. private Control _control;
  11276. private Func<Control> _createControl;
  11277. private string _name;
  11278. private bool _isSelected;
  11279. private bool _isExpanded;
  11280.  
  11281. public string Name
  11282. {
  11283. get
  11284. {
  11285. return this._name;
  11286. }
  11287. private set
  11288. {
  11289. this._name = value;
  11290. this.OnPropertyChanged("Name");
  11291. }
  11292. }
  11293.  
  11294. public Control Control
  11295. {
  11296. get
  11297. {
  11298. return this._control ?? (this._control = this._createControl());
  11299. }
  11300. protected set
  11301. {
  11302. this._control = value;
  11303. this.OnPropertyChanged("Control");
  11304. }
  11305. }
  11306.  
  11307. public bool IsSelected
  11308. {
  11309. get
  11310. {
  11311. return this._isSelected;
  11312. }
  11313. set
  11314. {
  11315. this._isSelected = value;
  11316. this.OnPropertyChanged("IsSelected");
  11317. }
  11318. }
  11319.  
  11320. public bool IsExpanded
  11321. {
  11322. get
  11323. {
  11324. return this._isExpanded;
  11325. }
  11326. set
  11327. {
  11328. this._isExpanded = value;
  11329. this.OnPropertyChanged("IsExpanded");
  11330. }
  11331. }
  11332.  
  11333. public MainMenuItem Parent { get; set; }
  11334.  
  11335. public MainMenuItem(string name, Func<Control> createControl)
  11336. {
  11337. this.\u002Ector();
  11338. this._name = name;
  11339. this._createControl = createControl;
  11340. }
  11341. }
  11342. }
  11343. ?// Decompiled with JetBrains decompiler
  11344. // Type: WinApp.ViewModel.MainMenu.CaptionMenuItem
  11345. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11346. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  11347. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  11348.  
  11349. using System;
  11350. using System.Collections;
  11351. using System.Collections.Generic;
  11352. using System.Windows.Controls;
  11353.  
  11354. namespace WinApp.ViewModel.MainMenu
  11355. {
  11356. internal class CaptionMenuItem : MainMenuItem, IEnumerable<MainMenuItem>, IEnumerable
  11357. {
  11358. private readonly List<MainMenuItem> _children = new List<MainMenuItem>();
  11359. private string _icon;
  11360.  
  11361. public string Icon
  11362. {
  11363. get
  11364. {
  11365. return this._icon;
  11366. }
  11367. private set
  11368. {
  11369. this._icon = value;
  11370. this.OnPropertyChanged("Icon");
  11371. }
  11372. }
  11373.  
  11374. public List<MainMenuItem> Children
  11375. {
  11376. get
  11377. {
  11378. return this._children;
  11379. }
  11380. }
  11381.  
  11382. public CaptionMenuItem(string icon, string name, Func<Control> control)
  11383. : base(name, control)
  11384. {
  11385. this._icon = icon;
  11386. }
  11387.  
  11388. public void Add(MainMenuItem item)
  11389. {
  11390. item.Parent = (MainMenuItem) this;
  11391. this._children.Add(item);
  11392. }
  11393.  
  11394. public IEnumerator<MainMenuItem> GetEnumerator()
  11395. {
  11396. return (IEnumerator<MainMenuItem>) this._children.GetEnumerator();
  11397. }
  11398.  
  11399. IEnumerator IEnumerable.GetEnumerator()
  11400. {
  11401. return (IEnumerator) this.GetEnumerator();
  11402. }
  11403. }
  11404. }
  11405. ?// Decompiled with JetBrains decompiler
  11406. // Type: WinApp.ViewModel.MainMenu.MainMenuCollection
  11407. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11408. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  11409. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  11410.  
  11411. using KairosPlanet.Properties;
  11412. using System;
  11413. using System.Collections;
  11414. using System.Collections.Generic;
  11415. using System.Windows.Controls;
  11416. using WinApp.View;
  11417.  
  11418. namespace WinApp.ViewModel.MainMenu
  11419. {
  11420. internal class MainMenuCollection : IEnumerable<MainMenuItem>, IEnumerable
  11421. {
  11422. private readonly CaptionMenuItem _services = new CaptionMenuItem("\xF108", Resources.MainMenu_Services, (Func<Control>) (() => (Control) new ServicesUC()));
  11423. private readonly CaptionMenuItem _statistics = new CaptionMenuItem("\xF080", Resources.MainMenu_Statistics, (Func<Control>) (() => (Control) new SessionStatisticsUC()))
  11424. {
  11425. new MainMenuItem(Resources.MainMenu_SessionHistory, (Func<Control>) (() => (Control) new SessionHistoryUC()))
  11426. };
  11427. private readonly CaptionMenuItem _profile = new CaptionMenuItem("\xF007", Resources.MainMenu_Profile, (Func<Control>) (() => (Control) new PersonalInformationUC()))
  11428. {
  11429. new MainMenuItem(Resources.MainMenu_ProfileContact, (Func<Control>) (() => (Control) new ContactInformationUC()))
  11430. };
  11431. private readonly CaptionMenuItem _settings = new CaptionMenuItem("\xF013", Resources.MainMenu_Settings, (Func<Control>) (() => (Control) new SettingsUC()));
  11432. private readonly IEnumerable<MainMenuItem> _items;
  11433.  
  11434. public CaptionMenuItem Services
  11435. {
  11436. get
  11437. {
  11438. return this._services;
  11439. }
  11440. }
  11441.  
  11442. public CaptionMenuItem Statistics
  11443. {
  11444. get
  11445. {
  11446. return this._statistics;
  11447. }
  11448. }
  11449.  
  11450. public CaptionMenuItem Profile
  11451. {
  11452. get
  11453. {
  11454. return this._profile;
  11455. }
  11456. }
  11457.  
  11458. public CaptionMenuItem Settings
  11459. {
  11460. get
  11461. {
  11462. return this._settings;
  11463. }
  11464. }
  11465.  
  11466. public MainMenuCollection()
  11467. {
  11468. this._items = (IEnumerable<MainMenuItem>) new MainMenuItem[4]
  11469. {
  11470. (MainMenuItem) this.Services,
  11471. (MainMenuItem) this.Statistics,
  11472. (MainMenuItem) this.Profile,
  11473. (MainMenuItem) this.Settings
  11474. };
  11475. }
  11476.  
  11477. public IEnumerator<MainMenuItem> GetEnumerator()
  11478. {
  11479. return this._items.GetEnumerator();
  11480. }
  11481.  
  11482. IEnumerator IEnumerable.GetEnumerator()
  11483. {
  11484. return (IEnumerator) this.GetEnumerator();
  11485. }
  11486. }
  11487. }
  11488. ?// Decompiled with JetBrains decompiler
  11489. // Type: WinApp.ViewModel.SessionRecordVM
  11490. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11491. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  11492. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  11493.  
  11494. using System;
  11495. using WinApp.Api.Data;
  11496.  
  11497. namespace WinApp.ViewModel
  11498. {
  11499. public class SessionRecordVM
  11500. {
  11501. private readonly Statistic _model;
  11502.  
  11503. public DateTime StartTime
  11504. {
  11505. get
  11506. {
  11507. return this._model.CreatedDate;
  11508. }
  11509. }
  11510.  
  11511. public DateTime? EndTime
  11512. {
  11513. get
  11514. {
  11515. return new DateTime?(this._model.CreatedDate + this.Lifetime);
  11516. }
  11517. }
  11518.  
  11519. public TimeSpan Lifetime
  11520. {
  11521. get
  11522. {
  11523. return TimeSpan.FromSeconds((double) this._model.Lifetime);
  11524. }
  11525. }
  11526.  
  11527. public bool Actual
  11528. {
  11529. get
  11530. {
  11531. return this._model.Actual;
  11532. }
  11533. }
  11534.  
  11535. public string DateString
  11536. {
  11537. get
  11538. {
  11539. return this.StartTime.ToShortDateString();
  11540. }
  11541. }
  11542.  
  11543. public string StartTimeString
  11544. {
  11545. get
  11546. {
  11547. return this.StartTime.ToShortDateString() + " " + this.StartTime.ToShortTimeString();
  11548. }
  11549. }
  11550.  
  11551. public string EndTimeString
  11552. {
  11553. get
  11554. {
  11555. if (this.EndTime.HasValue)
  11556. return this.EndTime.Value.ToShortDateString() + " " + this.EndTime.Value.ToShortTimeString();
  11557. return string.Empty;
  11558. }
  11559. }
  11560.  
  11561. public string DurationString
  11562. {
  11563. get
  11564. {
  11565. return string.Format("{0:HH:mm:ss}", (object) (DateTime.Today + this.Lifetime));
  11566. }
  11567. }
  11568.  
  11569. public SessionRecordVM(Statistic model)
  11570. {
  11571. this._model = model;
  11572. }
  11573. }
  11574. }
  11575. ?// Decompiled with JetBrains decompiler
  11576. // Type: WinApp.ViewModel.MainWindowVM
  11577. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11578. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  11579. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  11580.  
  11581. using Inc.Logging;
  11582. using IncMap;
  11583. using System;
  11584. using System.Diagnostics;
  11585. using System.Runtime.InteropServices;
  11586. using System.Threading;
  11587. using System.Windows;
  11588. using System.Windows.Controls;
  11589. using System.Windows.Input;
  11590. using System.Windows.Interop;
  11591. using System.Windows.Media;
  11592. using WinApp.Managers.Interfaces;
  11593. using WinApp.View;
  11594. using WinApp.ViewModel.Base;
  11595.  
  11596. namespace WinApp.ViewModel
  11597. {
  11598. internal class MainWindowVM : ViewModelBase
  11599. {
  11600. private static int _messageCloseAppCode = 170;
  11601. private string _header = "KairosPlanet";
  11602. private UserControl _content;
  11603. private MainWindow _mainWindow;
  11604. private HwndSource _source;
  11605.  
  11606. public string Header
  11607. {
  11608. get
  11609. {
  11610. return this._header;
  11611. }
  11612. set
  11613. {
  11614. this._header = value;
  11615. this.OnPropertyChanged("Header");
  11616. }
  11617. }
  11618.  
  11619. public UserControl Content
  11620. {
  11621. get
  11622. {
  11623. return this._content;
  11624. }
  11625. set
  11626. {
  11627. this._content = value;
  11628. this.OnPropertyChanged("Content");
  11629. }
  11630. }
  11631.  
  11632. public ICommand LogOutCommand
  11633. {
  11634. get
  11635. {
  11636. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.LogOutCommand), new Action(this.LogOut));
  11637. }
  11638. }
  11639.  
  11640. public ICommand ExitCommand
  11641. {
  11642. get
  11643. {
  11644. return this.Commands.GetOrCreateCommand<ICommand>((System.Linq.Expressions.Expression<Func<ICommand>>) (() => this.ExitCommand), new Action(this.Exit));
  11645. }
  11646. }
  11647.  
  11648. public MainWindowVM(MainWindow mainWindow)
  11649. {
  11650. this._mainWindow = mainWindow;
  11651. this._header = "KairosPlanet. " + (object) AppVM.Instance.GetCurrentAppVersion();
  11652. }
  11653.  
  11654. public void Exit()
  11655. {
  11656. Logger.WriteInfo(typeof (MainWindowVM), "Exit()", "???????? ??????????...");
  11657. Map.Get<IMainWindow>().CloseToTray = false;
  11658. Map.Get<ISessionManager>().CloseSession();
  11659. Application.Current.Shutdown();
  11660. this.CloseProcess();
  11661. }
  11662.  
  11663. internal void MainWindowLoaded()
  11664. {
  11665. this._source = PresentationSource.FromVisual((Visual) this._mainWindow) as HwndSource;
  11666. this._source.AddHook(new HwndSourceHook(this.WndProc));
  11667. }
  11668.  
  11669. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  11670. private static extern uint RegisterWindowMessage(string lpString);
  11671.  
  11672. private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
  11673. {
  11674. uint num = MainWindowVM.RegisterWindowMessage("KairosPlanetMessage");
  11675. if ((long) msg == (long) num)
  11676. {
  11677. Marshal.PtrToStringAuto(wParam);
  11678. if (wParam == new IntPtr(MainWindowVM._messageCloseAppCode))
  11679. {
  11680. this.Exit();
  11681. return IntPtr.Zero;
  11682. }
  11683. Map.Get<IMainWindow>().Open();
  11684. }
  11685. return IntPtr.Zero;
  11686. }
  11687.  
  11688. private void CloseProcess()
  11689. {
  11690. new Thread(new ThreadStart(this.CloseProcessThread))
  11691. {
  11692. IsBackground = true
  11693. }.Start();
  11694. }
  11695.  
  11696. private void CloseProcessThread()
  11697. {
  11698. Thread.Sleep(400);
  11699. Process.GetCurrentProcess().Kill();
  11700. }
  11701.  
  11702. private void LogOut()
  11703. {
  11704. AppVM.Instance.ProcedeLogOut();
  11705. }
  11706. }
  11707. }
  11708. ?// Decompiled with JetBrains decompiler
  11709. // Type: WinApp.NetworkState
  11710. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11711. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  11712. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  11713.  
  11714. namespace WinApp
  11715. {
  11716. internal enum NetworkState
  11717. {
  11718. None,
  11719. NetworkNotFound,
  11720. ServerNotFound,
  11721. ServerOnline,
  11722. }
  11723. }
  11724. ?// Decompiled with JetBrains decompiler
  11725. // Type: XamlGeneratedNamespace.GeneratedInternalTypeHelper
  11726. // Assembly: KairosPlanet, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11727. // MVID: 11FB976C-FCD4-4E7B-A3A4-41527B84CA9B
  11728. // Assembly location: C:\Program Files (x86)\KairosPlanet\KairosPlanet.exe
  11729.  
  11730. using System;
  11731. using System.CodeDom.Compiler;
  11732. using System.ComponentModel;
  11733. using System.Diagnostics;
  11734. using System.Globalization;
  11735. using System.Reflection;
  11736. using System.Windows.Markup;
  11737.  
  11738. namespace XamlGeneratedNamespace
  11739. {
  11740. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  11741. [EditorBrowsable(EditorBrowsableState.Never)]
  11742. [DebuggerNonUserCode]
  11743. public sealed class GeneratedInternalTypeHelper : InternalTypeHelper
  11744. {
  11745. protected override object CreateInstance(Type type, CultureInfo culture)
  11746. {
  11747. return Activator.CreateInstance(type, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, (Binder) null, (object[]) null, culture);
  11748. }
  11749.  
  11750. protected override object GetPropertyValue(PropertyInfo propertyInfo, object target, CultureInfo culture)
  11751. {
  11752. return propertyInfo.GetValue(target, BindingFlags.Default, (Binder) null, (object[]) null, culture);
  11753. }
  11754.  
  11755. protected override void SetPropertyValue(PropertyInfo propertyInfo, object target, object value, CultureInfo culture)
  11756. {
  11757. propertyInfo.SetValue(target, value, BindingFlags.Default, (Binder) null, (object[]) null, culture);
  11758. }
  11759.  
  11760. protected override Delegate CreateDelegate(Type delegateType, object target, string handler)
  11761. {
  11762. return (Delegate) target.GetType().InvokeMember("_CreateDelegate", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, (Binder) null, target, new object[2]
  11763. {
  11764. (object) delegateType,
  11765. (object) handler
  11766. }, (CultureInfo) null);
  11767. }
  11768.  
  11769. protected override void AddEventHandler(EventInfo eventInfo, object target, Delegate handler)
  11770. {
  11771. eventInfo.AddEventHandler(target, handler);
  11772. }
  11773. }
  11774. }
  11775. ?using System;
  11776. using System.Reflection;
  11777. using System.Runtime.CompilerServices;
  11778. using System.Runtime.InteropServices;
  11779. using System.Windows;
  11780.  
  11781. [assembly: Extension]
  11782. [assembly: AssemblyTitle("KairosPlanet")]
  11783. [assembly: AssemblyDescription("")]
  11784. [assembly: AssemblyProduct("KairosPlanet")]
  11785. [assembly: InternalsVisibleTo("KairosPlanet.Tests")]
  11786. [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
  11787. [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
  11788. [assembly: AssemblyConfiguration("")]
  11789. [assembly: AssemblyCompany("Kairos Technologies Ltd")]
  11790. [assembly: AssemblyCopyright("Copyright © Kairos Technologies 2014")]
  11791. [assembly: AssemblyTrademark("")]
  11792. [assembly: ComVisible(false)]
  11793. [assembly: CLSCompliant(false)]
  11794. [assembly: AssemblyFileVersion("1.0.18.651")]
  11795. [assembly: AssemblyInformationalVersion("1.0.18.651")]
  11796. [assembly: AssemblyVersion("1.0.18.651")]
  11797. ?// Decompiled with JetBrains decompiler
  11798. // Type: WinApp.Data.Helpers.LoginResponce
  11799. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11800. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  11801. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  11802.  
  11803. using WinApp.Data.Model;
  11804.  
  11805. namespace WinApp.Data.Helpers
  11806. {
  11807. public struct LoginResponce
  11808. {
  11809. public static LoginResponce NoResponce = new LoginResponce(LoginResult.NoResponce, (Man) null);
  11810. public static LoginResponce WrongInput = new LoginResponce(LoginResult.WrongInput, (Man) null);
  11811. public static LoginResponce UserDeleted = new LoginResponce(LoginResult.UserDeleted, (Man) null);
  11812.  
  11813. public Man UserInfo { get; private set; }
  11814.  
  11815. public LoginResult Result { get; private set; }
  11816.  
  11817. private LoginResponce(LoginResult result, Man userInfo = null)
  11818. {
  11819. this = new LoginResponce();
  11820. this.Result = result;
  11821. this.UserInfo = userInfo;
  11822. }
  11823.  
  11824. public static LoginResponce Pass(Man user)
  11825. {
  11826. return new LoginResponce(LoginResult.Pass, user);
  11827. }
  11828. }
  11829. }
  11830. ?// Decompiled with JetBrains decompiler
  11831. // Type: WinApp.Data.Helpers.DateTimeExtention
  11832. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11833. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  11834. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  11835.  
  11836. using System;
  11837.  
  11838. namespace WinApp.Data.Helpers
  11839. {
  11840. public static class DateTimeExtention
  11841. {
  11842. public static DateTime ToDateTime(this long ticks)
  11843. {
  11844. return new DateTime(ticks);
  11845. }
  11846. }
  11847. }
  11848. ?// Decompiled with JetBrains decompiler
  11849. // Type: WinApp.Data.Helpers.LoginResult
  11850. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11851. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  11852. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  11853.  
  11854. namespace WinApp.Data.Helpers
  11855. {
  11856. public enum LoginResult
  11857. {
  11858. NoResponce,
  11859. WrongInput,
  11860. UserDeleted,
  11861. Pass,
  11862. }
  11863. }
  11864. ?// Decompiled with JetBrains decompiler
  11865. // Type: WinApp.Data.Helpers.StringUtil
  11866. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11867. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  11868. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  11869.  
  11870. namespace WinApp.Data.Helpers
  11871. {
  11872. public static class StringUtil
  11873. {
  11874. public static bool IsNullOrWhiteSpace(this string str)
  11875. {
  11876. return str == null || str.Trim().Length == 0;
  11877. }
  11878. }
  11879. }
  11880. ?// Decompiled with JetBrains decompiler
  11881. // Type: WinApp.Data.Helpers.TimeSpanExtention
  11882. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11883. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  11884. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  11885.  
  11886. using System;
  11887.  
  11888. namespace WinApp.Data.Helpers
  11889. {
  11890. public static class TimeSpanExtention
  11891. {
  11892. public static TimeSpan TrimToSeconds(this TimeSpan span)
  11893. {
  11894. return TimeSpan.FromSeconds((double) (span.Ticks / 10000000L));
  11895. }
  11896.  
  11897. public static TimeSpan ToTimeSpan(this long ticks)
  11898. {
  11899. return new TimeSpan(ticks);
  11900. }
  11901.  
  11902. public static string TotalTimeString(this TimeSpan timeSpan, string format)
  11903. {
  11904. long num1 = (long) timeSpan.TotalHours;
  11905. long num2 = (long) timeSpan.TotalMinutes - num1 * 60L;
  11906. long num3 = (long) timeSpan.TotalSeconds - num1 * 3600L - num2 * 60L;
  11907. return string.Format(format, (object) num1, (object) num2, (object) num3);
  11908. }
  11909. }
  11910. }
  11911. ?// Decompiled with JetBrains decompiler
  11912. // Type: WinApp.Data.Helpers.AppData
  11913. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11914. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  11915. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  11916.  
  11917. using System;
  11918. using System.IO;
  11919.  
  11920. namespace WinApp.Data.Helpers
  11921. {
  11922. public static class AppData
  11923. {
  11924. public static string Path
  11925. {
  11926. get
  11927. {
  11928. DirectoryInfo directoryInfo = new DirectoryInfo(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WinApp"));
  11929. if (!directoryInfo.Exists)
  11930. {
  11931. directoryInfo.Create();
  11932. directoryInfo.Refresh();
  11933. }
  11934. return directoryInfo.FullName;
  11935. }
  11936. }
  11937. }
  11938. }
  11939. ?// Decompiled with JetBrains decompiler
  11940. // Type: WinApp.Data.Security.Cryptography
  11941. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11942. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  11943. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  11944.  
  11945. using Inc.Logging;
  11946. using System;
  11947. using System.Collections.Generic;
  11948. using System.Linq;
  11949. using System.Security.Cryptography;
  11950. using System.Text;
  11951.  
  11952. namespace WinApp.Data.Security
  11953. {
  11954. public static class Cryptography
  11955. {
  11956. private static readonly byte[] _entropy = Encoding.Unicode.GetBytes("WinApp Cryptography Data Salt");
  11957.  
  11958. public static byte[] GetSha1Hash(this string message)
  11959. {
  11960. return new SHA1CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(message));
  11961. }
  11962.  
  11963. public static bool CheckHash(this byte[] h1, byte[] h2)
  11964. {
  11965. return Enumerable.SequenceEqual<byte>((IEnumerable<byte>) h1, (IEnumerable<byte>) h2);
  11966. }
  11967.  
  11968. public static string GetSha1HashText(this string message, int length)
  11969. {
  11970. return Convert.ToBase64String(Cryptography.GetSha1Hash(message)).Substring(0, length);
  11971. }
  11972.  
  11973. public static string ProtectedUserData(string data)
  11974. {
  11975. if (string.IsNullOrEmpty(data))
  11976. return string.Empty;
  11977. return Convert.ToBase64String(ProtectedData.Protect(Encoding.Unicode.GetBytes(data), Cryptography._entropy, DataProtectionScope.CurrentUser));
  11978. }
  11979.  
  11980. public static string UnprotectUserData(string protectedData)
  11981. {
  11982. try
  11983. {
  11984. if (string.IsNullOrEmpty(protectedData))
  11985. return string.Empty;
  11986. return Encoding.Unicode.GetString(ProtectedData.Unprotect(Convert.FromBase64String(protectedData), Cryptography._entropy, DataProtectionScope.CurrentUser));
  11987. }
  11988. catch (Exception ex)
  11989. {
  11990. Logger.WriteError(typeof (Cryptography), "UnprotectUserData", "?? ??????? ????????????? ?????? ???????? ????????????", ex);
  11991. return (string) null;
  11992. }
  11993. }
  11994. }
  11995. }
  11996. ?// Decompiled with JetBrains decompiler
  11997. // Type: WinApp.Data.Model.Man
  11998. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  11999. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  12000. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  12001.  
  12002. using System.Runtime.Serialization;
  12003.  
  12004. namespace WinApp.Data.Model
  12005. {
  12006. [DataContract]
  12007. public class Man
  12008. {
  12009. [DataMember(Name = "user_id")]
  12010. public long Id { get; set; }
  12011.  
  12012. [DataMember(Name = "user_name")]
  12013. public string Name { get; set; }
  12014.  
  12015. [DataMember(Name = "country")]
  12016. public string Country { get; set; }
  12017.  
  12018. [DataMember(Name = "email")]
  12019. public string Email { get; set; }
  12020.  
  12021. [DataMember(Name = "gender_id")]
  12022. public int Gender { get; set; }
  12023.  
  12024. [DataMember(Name = "birth_date")]
  12025. public string BirthDate { get; set; }
  12026.  
  12027. [DataMember(Name = "created_date")]
  12028. public string CreatedDate { get; set; }
  12029.  
  12030. [DataMember(Name = "phone_number_main")]
  12031. public string PhoneNumber { get; set; }
  12032.  
  12033. [DataMember(Name = "user_status_id")]
  12034. public int UserStatus { get; set; }
  12035. }
  12036. }
  12037. ?// Decompiled with JetBrains decompiler
  12038. // Type: WinApp.Data.Model.ProductAttributes
  12039. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12040. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  12041. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  12042.  
  12043. using System.Runtime.Serialization;
  12044.  
  12045. namespace WinApp.Data.Model
  12046. {
  12047. [DataContract]
  12048. public class ProductAttributes
  12049. {
  12050. [DataMember(Name = "discSpace")]
  12051. public int DiscSpace { get; set; }
  12052.  
  12053. [DataMember(Name = "timeOnline")]
  12054. public string TimeOnline { get; set; }
  12055.  
  12056. [DataMember(Name = "basicIncome")]
  12057. public string BasicIncome { get; set; }
  12058.  
  12059. [DataMember(Name = "basicIncomePeriod")]
  12060. public string BasicIncomePeriod { get; set; }
  12061.  
  12062. [DataMember(Name = "profit")]
  12063. public string Profit { get; set; }
  12064.  
  12065. [DataMember(Name = "investmentPeriod")]
  12066. public string InvestmentPeriod { get; set; }
  12067.  
  12068. [DataMember(Name = "available")]
  12069. public string Available { get; set; }
  12070.  
  12071. [DataMember(Name = "start")]
  12072. public string Start { get; set; }
  12073. }
  12074. }
  12075. ?// Decompiled with JetBrains decompiler
  12076. // Type: WinApp.Data.Model.SessionRecord
  12077. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12078. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  12079. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  12080.  
  12081. using NPoco;
  12082. using System;
  12083.  
  12084. namespace WinApp.Data.Model
  12085. {
  12086. [TableName("SessionRecord")]
  12087. public class SessionRecord : Entity
  12088. {
  12089. [Ignore]
  12090. public DateTime StartTime { get; set; }
  12091.  
  12092. public long StartInt
  12093. {
  12094. get
  12095. {
  12096. return this.StartTime.Ticks;
  12097. }
  12098. set
  12099. {
  12100. this.StartTime = new DateTime(value);
  12101. }
  12102. }
  12103.  
  12104. [Ignore]
  12105. public DateTime EndTime { get; set; }
  12106.  
  12107. public long EndInt
  12108. {
  12109. get
  12110. {
  12111. return this.EndTime.Ticks;
  12112. }
  12113. set
  12114. {
  12115. this.EndTime = new DateTime(value);
  12116. }
  12117. }
  12118. }
  12119. }
  12120. ?// Decompiled with JetBrains decompiler
  12121. // Type: WinApp.Data.Model.ModuleState
  12122. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12123. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  12124. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  12125.  
  12126. namespace WinApp.Data.Model
  12127. {
  12128. public enum ModuleState
  12129. {
  12130. Buy,
  12131. Install,
  12132. Installed,
  12133. InstalledAndActivated,
  12134. ValidityCompleted,
  12135. Blocked,
  12136. Order,
  12137. }
  12138. }
  12139. ?// Decompiled with JetBrains decompiler
  12140. // Type: WinApp.Data.Model.Purchase
  12141. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12142. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  12143. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  12144.  
  12145. using System;
  12146. using System.Runtime.Serialization;
  12147.  
  12148. namespace WinApp.Data.Model
  12149. {
  12150. [DataContract]
  12151. public class Purchase
  12152. {
  12153. private string _dateString;
  12154.  
  12155. [DataMember(Name = "id")]
  12156. public long Id { get; set; }
  12157.  
  12158. [DataMember(Name = "buyer_user_id")]
  12159. public long BuyerUserId { get; set; }
  12160.  
  12161. [DataMember(Name = "product_id")]
  12162. public long ProductId { get; set; }
  12163.  
  12164. [DataMember(Name = "price")]
  12165. public double Price { get; set; }
  12166.  
  12167. [DataMember(Name = "status")]
  12168. public int Status { get; set; }
  12169.  
  12170. [DataMember(Name = "terms")]
  12171. public string Terms { get; set; }
  12172.  
  12173. [DataMember(Name = "package_status")]
  12174. public int PackageStatus { get; set; }
  12175.  
  12176. public DateTime? Date { get; set; }
  12177.  
  12178. [DataMember(Name = "date")]
  12179. public string DateString
  12180. {
  12181. get
  12182. {
  12183. return this._dateString;
  12184. }
  12185. set
  12186. {
  12187. this._dateString = value;
  12188. this.Date = this._dateString == null ? new DateTime?() : new DateTime?(DateTime.Parse(this._dateString));
  12189. }
  12190. }
  12191.  
  12192. public override bool Equals(object purchase)
  12193. {
  12194. return this.Id == ((Purchase) purchase).Id;
  12195. }
  12196. }
  12197. }
  12198. ?// Decompiled with JetBrains decompiler
  12199. // Type: WinApp.Data.Model.Entity
  12200. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12201. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  12202. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  12203.  
  12204. using NPoco;
  12205.  
  12206. namespace WinApp.Data.Model
  12207. {
  12208. [PrimaryKey("Id", AutoIncrement = true)]
  12209. public class Entity
  12210. {
  12211. private long _id;
  12212.  
  12213. [Ignore]
  12214. public bool IsNew { get; protected set; }
  12215.  
  12216. public long Id
  12217. {
  12218. get
  12219. {
  12220. return this._id;
  12221. }
  12222. set
  12223. {
  12224. this._id = value;
  12225. this.IsNew = false;
  12226. }
  12227. }
  12228.  
  12229. protected Entity()
  12230. {
  12231. this.IsNew = true;
  12232. }
  12233.  
  12234. public virtual Entity Clone()
  12235. {
  12236. return (Entity) this.MemberwiseClone();
  12237. }
  12238. }
  12239. }
  12240. ?// Decompiled with JetBrains decompiler
  12241. // Type: WinApp.Data.Model.ModuleInfo
  12242. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12243. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  12244. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  12245.  
  12246. using System.Runtime.Serialization;
  12247.  
  12248. namespace WinApp.Data.Model
  12249. {
  12250. [DataContract]
  12251. public class ModuleInfo
  12252. {
  12253. [DataMember]
  12254. public long Id { get; set; }
  12255.  
  12256. [DataMember]
  12257. public long ProductId { get; set; }
  12258.  
  12259. [DataMember]
  12260. public string Title { get; set; }
  12261.  
  12262. [DataMember]
  12263. public string Version { get; set; }
  12264.  
  12265. [DataMember]
  12266. public string Description { get; set; }
  12267.  
  12268. [DataMember]
  12269. public string Filename { get; set; }
  12270.  
  12271. [DataMember]
  12272. public string Url { get; set; }
  12273. }
  12274. }
  12275. ?// Decompiled with JetBrains decompiler
  12276. // Type: WinApp.Data.Model.Module
  12277. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12278. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  12279. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  12280.  
  12281. using NPoco;
  12282.  
  12283. namespace WinApp.Data.Model
  12284. {
  12285. [TableName("Module")]
  12286. public class Module : Entity
  12287. {
  12288. public int State { get; set; }
  12289.  
  12290. public long ProductId { get; set; }
  12291.  
  12292. [Ignore]
  12293. public ModuleState StateEnum
  12294. {
  12295. get
  12296. {
  12297. return (ModuleState) this.State;
  12298. }
  12299. set
  12300. {
  12301. this.State = (int) value;
  12302. }
  12303. }
  12304. }
  12305. }
  12306. ?// Decompiled with JetBrains decompiler
  12307. // Type: WinApp.Data.Model.Product
  12308. // Assembly: KairosPlanet.Data, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12309. // MVID: 146F38A9-3288-4859-BC9A-322D8E703D1E
  12310. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Data.dll
  12311.  
  12312. using System.Runtime.Serialization;
  12313.  
  12314. namespace WinApp.Data.Model
  12315. {
  12316. [DataContract]
  12317. public class Product
  12318. {
  12319. [DataMember(Name = "category_id")]
  12320. public long CategoryId { get; set; }
  12321.  
  12322. [DataMember(Name = "created_date")]
  12323. public string CreatedDate { get; set; }
  12324.  
  12325. [DataMember(Name = "creator_id")]
  12326. public long CreatorId { get; set; }
  12327.  
  12328. [DataMember(Name = "description")]
  12329. public string Description { get; set; }
  12330.  
  12331. [DataMember(Name = "id")]
  12332. public long Id { get; set; }
  12333.  
  12334. [DataMember(Name = "image_url")]
  12335. public string ImageUrl { get; set; }
  12336.  
  12337. [DataMember(Name = "price")]
  12338. public double Price { get; set; }
  12339.  
  12340. [DataMember(Name = "product_url")]
  12341. public string ProductUrl { get; set; }
  12342.  
  12343. [DataMember(Name = "status")]
  12344. public int Status { get; set; }
  12345.  
  12346. [DataMember(Name = "title")]
  12347. public string Title { get; set; }
  12348.  
  12349. [DataMember(Name = "type")]
  12350. public int Type { get; set; }
  12351.  
  12352. [DataMember(Name = "attributes")]
  12353. public ProductAttributes Attributes { get; set; }
  12354. }
  12355. }
  12356. ?using System;
  12357. using System.Reflection;
  12358. using System.Runtime.CompilerServices;
  12359. using System.Runtime.InteropServices;
  12360.  
  12361. [assembly: AssemblyInformationalVersion("1.0.18.651")]
  12362. [assembly: AssemblyFileVersion("1.0.18.651")]
  12363. [assembly: AssemblyProduct("KairosPlanet.Data")]
  12364. [assembly: InternalsVisibleTo("KairosPlanet")]
  12365. [assembly: CLSCompliant(false)]
  12366. [assembly: Extension]
  12367. [assembly: AssemblyTitle("KairosPlanet.Data")]
  12368. [assembly: AssemblyDescription("")]
  12369. [assembly: AssemblyConfiguration("")]
  12370. [assembly: ComVisible(false)]
  12371. [assembly: InternalsVisibleTo("KairosPlanet.Tests")]
  12372. [assembly: Guid("6e9f63c9-13ed-4f02-acb0-f8bf5302b813")]
  12373. [assembly: InternalsVisibleTo("KairosPlanet.Service")]
  12374. [assembly: AssemblyCompany("Kairos Technologies Ltd")]
  12375. [assembly: AssemblyCopyright("Copyright © Kairos Technologies 2014")]
  12376. [assembly: AssemblyTrademark("")]
  12377. [assembly: AssemblyVersion("1.0.18.651")]
  12378. ?// Decompiled with JetBrains decompiler
  12379. // Type: WinApp.Service.ServiceBootstrapper
  12380. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12381. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  12382. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  12383.  
  12384. using Inc.Logging;
  12385. using IncMap;
  12386. using WinApp.Data.Helpers;
  12387. using WinApp.Data.Model;
  12388. using WinApp.Service.Core;
  12389. using WinApp.Service.Repository;
  12390. using WinApp.Service.Repository.Interface;
  12391.  
  12392. namespace WinApp.Service
  12393. {
  12394. public class ServiceBootstrapper
  12395. {
  12396. public static void Bootstrap()
  12397. {
  12398. Logger.WriteInfo(typeof (ServiceBootstrapper), "Bootstrap()", "????????????? ?????????? Bootstrapper...");
  12399. Map.Inject<IDatabaseManager>((IDatabaseManager) new SQLiteDatabaseManager(AppData.Path + "\\KairosPlanet.db"));
  12400. ServiceBootstrapper.MapEntityServices<SessionRecord, ISessionRecordRepository>((ISessionRecordRepository) new SessionRecordRepository());
  12401. ServiceBootstrapper.MapEntityServices<Module, IModuleRepository>((IModuleRepository) new ModuleRepository());
  12402. Logger.WriteInfo(typeof (ServiceBootstrapper), "Bootstrap()", "????????? Bootstrapper ??????? ???????????????");
  12403. }
  12404.  
  12405. private static void MapEntityServices<T, TRepo>(TRepo repository) where T : Entity where TRepo : class, IRepository<T>
  12406. {
  12407. Map.Inject<TRepo>(repository);
  12408. Map.Route<IRepository<T>, TRepo>();
  12409. }
  12410. }
  12411. }
  12412. ?// Decompiled with JetBrains decompiler
  12413. // Type: WinApp.Service.Core.DatabaseInitializer
  12414. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12415. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  12416. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  12417.  
  12418. using Inc.Logging;
  12419. using IncMap;
  12420. using NPoco;
  12421. using System;
  12422. using System.Data;
  12423. using System.Data.SQLite;
  12424. using System.IO;
  12425.  
  12426. namespace WinApp.Service.Core
  12427. {
  12428. public class DatabaseInitializer : SqlDatabaseInitializer
  12429. {
  12430. private static readonly object _dbLockObj = new object();
  12431. private static readonly DatabaseInitializer _instance = new DatabaseInitializer();
  12432. private readonly SqlDatabaseInitializer.DbUpdate _u0 = new SqlDatabaseInitializer.DbUpdate(1L)
  12433. {
  12434. Comment = "Initial update",
  12435. Sql = "\r\n CREATE TABLE [SessionRecord](\r\n [Id] [integer] PRIMARY KEY AUTOINCREMENT,\r\n [StartInt] [integer] NOT NULL,\r\n [EndInt] [integer] NOT NULL\r\n );"
  12436. };
  12437. private readonly SqlDatabaseInitializer.DbUpdate _u1 = new SqlDatabaseInitializer.DbUpdate(2L)
  12438. {
  12439. Comment = "Initial update 2",
  12440. Sql = "\r\n CREATE TABLE [Module](\r\n [Id] [integer] PRIMARY KEY,\r\n [ProductId] [integer] NOT NULL,\r\n [State] [integer] NOT NULL DEFAULT 0\r\n );"
  12441. };
  12442.  
  12443. public static int UpdateCount
  12444. {
  12445. get
  12446. {
  12447. return DatabaseInitializer._instance.UpdateSequence.Length;
  12448. }
  12449. }
  12450.  
  12451. protected override Database Database
  12452. {
  12453. get
  12454. {
  12455. return new Database((IDbConnection) new SQLiteConnection(Map.Get<IDatabaseManager>().ConnectionString), DatabaseType.SQLite);
  12456. }
  12457. }
  12458.  
  12459. protected override SqlDatabaseInitializer.DbUpdate[] UpdateSequence
  12460. {
  12461. get
  12462. {
  12463. return new SqlDatabaseInitializer.DbUpdate[2]
  12464. {
  12465. this._u0,
  12466. this._u1
  12467. };
  12468. }
  12469. }
  12470.  
  12471. private DatabaseInitializer()
  12472. {
  12473. }
  12474.  
  12475. public static void Initialize()
  12476. {
  12477. lock (DatabaseInitializer._dbLockObj)
  12478. {
  12479. Logger.WriteInfo(typeof (DatabaseInitializer), "Initialize()", "????????????? ???? ??????...");
  12480. try
  12481. {
  12482. DatabaseInitializer.CreateDatabase();
  12483. DatabaseInitializer.CreateDatabaseSystemTable();
  12484. DatabaseInitializer.MakeDatabaseChanges();
  12485. Logger.WriteInfo(typeof (DatabaseInitializer), "Initialize()", "???? ?????? ??????? ????????????????");
  12486. }
  12487. catch (Exception exception_0)
  12488. {
  12489. Logger.WriteError(typeof (DatabaseInitializer), "Initialize()", "?????? ??? ????????????? ???? ??????", exception_0);
  12490. }
  12491. }
  12492. }
  12493.  
  12494. public static void CreateDatabase()
  12495. {
  12496. lock (DatabaseInitializer._dbLockObj)
  12497. {
  12498. try
  12499. {
  12500. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateDatabase()", "???????? ??????? ????? ???? ??????...");
  12501. if (File.Exists(Map.Get<IDatabaseManager>().DbPath))
  12502. {
  12503. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateDatabase()", "???? ???? ?????? ??????");
  12504. }
  12505. else
  12506. {
  12507. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateDatabase()", "???? ???? ?????? ?? ??????. ??????? ???? ??????...");
  12508. Map.Get<IDatabaseManager>().CreateDatabase();
  12509. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateDatabase()", "???? ?????? ??????? ???????!");
  12510. }
  12511. }
  12512. catch (Exception exception_0)
  12513. {
  12514. Logger.WriteError(typeof (DatabaseInitializer), "CreateDatabase()", "?????? ??? ???????? ???? ??????", exception_0);
  12515. }
  12516. }
  12517. }
  12518.  
  12519. private static void CreateDatabaseSystemTable()
  12520. {
  12521. lock (DatabaseInitializer._dbLockObj)
  12522. {
  12523. try
  12524. {
  12525. DatabaseInitializer._instance.CreateSystemTable();
  12526. }
  12527. catch (Exception exception_0)
  12528. {
  12529. Logger.WriteError(typeof (DatabaseInitializer), "CreateDatabaseSystemTable()", "?????? ??? ???????? ????????? ??????? ???? ??????", exception_0);
  12530. }
  12531. }
  12532. }
  12533.  
  12534. private static void MakeDatabaseChanges()
  12535. {
  12536. lock (DatabaseInitializer._dbLockObj)
  12537. {
  12538. Logger.WriteInfo(typeof (DatabaseInitializer), "MakeDatabaseChanges()", "?????????? ???? ??????...");
  12539. try
  12540. {
  12541. DatabaseInitializer._instance.MakeChanges();
  12542. Logger.WriteInfo(typeof (DatabaseInitializer), "MakeDatabaseChanges()", "?????????? ???? ?????? ?????? ???????");
  12543. }
  12544. catch (Exception exception_0)
  12545. {
  12546. Logger.WriteError(typeof (DatabaseInitializer), "MakeDatabaseChanges()", "?????? ??? ?????????? ?????????? ? ???? ??????", exception_0);
  12547. }
  12548. }
  12549. }
  12550. }
  12551. }
  12552. ?// Decompiled with JetBrains decompiler
  12553. // Type: WinApp.Service.Core.SqlDatabaseInitializer
  12554. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12555. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  12556. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  12557.  
  12558. using Inc.Logging;
  12559. using NPoco;
  12560. using System;
  12561. using System.Collections.Generic;
  12562. using System.Data.Common;
  12563. using System.Linq;
  12564.  
  12565. namespace WinApp.Service.Core
  12566. {
  12567. public abstract class SqlDatabaseInitializer
  12568. {
  12569. private const string SYSTEM_TABLE_NAME = "_systemInfo";
  12570.  
  12571. protected abstract Database Database { get; }
  12572.  
  12573. protected abstract SqlDatabaseInitializer.DbUpdate[] UpdateSequence { get; }
  12574.  
  12575. internal static string GetCreateSystemTableSqlCommand()
  12576. {
  12577. return string.Format("\r\n CREATE TABLE [{0}](\r\n [id] [integer] NOT NULL,\r\n [Date] [integer] NOT NULL,\r\n [Description] [text] NULL\r\n );\r\n ", (object) "_systemInfo");
  12578. }
  12579.  
  12580. protected virtual void MakeChanges()
  12581. {
  12582. using (Database database = this.Database)
  12583. {
  12584. Logger.WriteInfo(typeof (SqlDatabaseInitializer), "MakeChanges()", "????????? ??????? ?????? ???? ??????...");
  12585. IEnumerable<long> source;
  12586. try
  12587. {
  12588. source = (IEnumerable<long>) Enumerable.ToArray<long>(Enumerable.Select<SqlDatabaseInitializer.IdContainer, long>((IEnumerable<SqlDatabaseInitializer.IdContainer>) database.Fetch<SqlDatabaseInitializer.IdContainer>(string.Format("SELECT [Id] FROM [{0}];", (object) "_systemInfo"), new object[0]), (Func<SqlDatabaseInitializer.IdContainer, long>) (x => x.Id)));
  12589. Logger.WriteInfo(typeof (SqlDatabaseInitializer), "MakeChanges()", "?????? ???? ?????? ???????? ???????");
  12590. }
  12591. catch (DbException ex)
  12592. {
  12593. Logger.WriteWarning(typeof (SqlDatabaseInitializer), "MakeChanges()", "?????? ??? ????????? ?????? ???? ??????. ???????? ????????? ??????? ???????????");
  12594. source = (IEnumerable<long>) new long[0];
  12595. }
  12596. Logger.WriteInfo(typeof (SqlDatabaseInitializer), "MakeChanges()", "??????? ?????? ???? ?????? ????? ?????????? ??????????: " + (object) Enumerable.Count<long>(source));
  12597. Logger.WriteInfo(typeof (SqlDatabaseInitializer), "MakeChanges()", "???????? ? ?????????? ?????????? ???? ??????...");
  12598. foreach (SqlDatabaseInitializer.DbUpdate dbUpdate in this.UpdateSequence)
  12599. {
  12600. SqlDatabaseInitializer.DbUpdate update = dbUpdate;
  12601. if (Enumerable.All<long>(source, (Func<long, bool>) (x => x != update.Id)))
  12602. {
  12603. if (update.DropAll)
  12604. {
  12605. Logger.WriteWarning(typeof (SqlDatabaseInitializer), "MakeChanges()", string.Format("??? ?????????? '{0}' ?????????? ???????? ???? ??????"));
  12606. this.DropTables(database);
  12607. this.CreateSystemTable();
  12608. }
  12609. database.BeginTransaction();
  12610. Logger.WriteInfo(typeof (SqlDatabaseInitializer), "MakeChanges()", string.Format("?????????? ?????????? ?? ??????: {0} ({1})", (object) update.Id, (object) update.Comment));
  12611. this.Execute(database, update.Sql);
  12612. this.CommitVersion(database, update);
  12613. database.CompleteTransaction();
  12614. this.OnUpdate(update);
  12615. Logger.WriteInfo(typeof (SqlDatabaseInitializer), "MakeChanges()", string.Format("??????? ????????? ?????????? ???? ?????? ?? ??????: {0} ({1})", (object) update.Id, (object) update.Comment));
  12616. }
  12617. }
  12618. }
  12619. }
  12620.  
  12621. protected virtual void Execute(Database db, string command)
  12622. {
  12623. try
  12624. {
  12625. db.Execute(command, new object[0]);
  12626. }
  12627. catch (DbException ex)
  12628. {
  12629. Logger.WriteError(typeof (SqlDatabaseInitializer), "Execute()", "?????? ??? ?????????? SQL ???????", (Exception) ex);
  12630. }
  12631. }
  12632.  
  12633. protected virtual void OnUpdate(SqlDatabaseInitializer.DbUpdate update)
  12634. {
  12635. }
  12636.  
  12637. protected void CreateSystemTable()
  12638. {
  12639. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateSystemTable()", "???????? ????????? ??????? ? ???? ??????...");
  12640. this.Execute(this.Database, SqlDatabaseInitializer.GetCreateSystemTableSqlCommand());
  12641. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateSystemTable()", "????????? ??????? ??????? ???????!");
  12642. }
  12643.  
  12644. private void CommitVersion(Database db, SqlDatabaseInitializer.DbUpdate update)
  12645. {
  12646. Logger.WriteInfo(typeof (DatabaseInitializer), "CommitVersion()", "?????????? ?????? ???? ??????...");
  12647. db.Execute(new Sql(string.Format("INSERT INTO [{0}] ([Id], [Date], [Description]) VALUES (@0, @1, @2);", (object) "_systemInfo"), new object[3]
  12648. {
  12649. (object) update.Id,
  12650. (object) DateTime.Now.ToBinary(),
  12651. (object) update.Comment
  12652. }));
  12653. Logger.WriteInfo(typeof (DatabaseInitializer), "CommitVersion()", "?????? ???? ?????? ??????? ?????????");
  12654. }
  12655.  
  12656. private void DropTables(Database db)
  12657. {
  12658. Logger.WriteInfo(typeof (SqlDatabaseInitializer), "DropTables()", "???????? ???? ??????...");
  12659. db.Execute("DROP TABLE [SessionRecords]", new object[0]);
  12660. Logger.WriteInfo(typeof (SqlDatabaseInitializer), "DropTables()", "??? ??????? ???????");
  12661. }
  12662.  
  12663. protected class DbUpdate
  12664. {
  12665. public long Id { get; private set; }
  12666.  
  12667. public bool DropAll { get; set; }
  12668.  
  12669. public string Sql { get; set; }
  12670.  
  12671. public string Comment { get; set; }
  12672.  
  12673. public string Hash { get; set; }
  12674.  
  12675. public DbUpdate(long id)
  12676. {
  12677. this.Id = id;
  12678. }
  12679. }
  12680.  
  12681. private class IdContainer
  12682. {
  12683. public long Id { get; set; }
  12684. }
  12685. }
  12686. }
  12687. ?// Decompiled with JetBrains decompiler
  12688. // Type: WinApp.Service.Core.IDatabaseManager
  12689. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12690. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  12691. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  12692.  
  12693. using System.Data;
  12694.  
  12695. namespace WinApp.Service.Core
  12696. {
  12697. public interface IDatabaseManager
  12698. {
  12699. string DbPath { get; }
  12700.  
  12701. string ConnectionString { get; }
  12702.  
  12703. IDbConnection GetNewDbConnection();
  12704.  
  12705. void CreateDatabase();
  12706.  
  12707. void DeleteDatabase();
  12708. }
  12709. }
  12710. ?// Decompiled with JetBrains decompiler
  12711. // Type: WinApp.Service.Core.SQLiteDatabaseManager
  12712. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12713. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  12714. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  12715.  
  12716. using Inc.Logging;
  12717. using System;
  12718. using System.Data;
  12719. using System.Data.SQLite;
  12720. using System.IO;
  12721.  
  12722. namespace WinApp.Service.Core
  12723. {
  12724. public class SQLiteDatabaseManager : IDatabaseManager
  12725. {
  12726. private string _connectionStringTemplate = "Data Source={0};Version=3;";
  12727. private string _dbPath;
  12728. private string _connectionString;
  12729.  
  12730. public string DbPath
  12731. {
  12732. get
  12733. {
  12734. return this._dbPath;
  12735. }
  12736. }
  12737.  
  12738. public string ConnectionString
  12739. {
  12740. get
  12741. {
  12742. return this._connectionString ?? (this._connectionString = string.Format(this._connectionStringTemplate, (object) this._dbPath));
  12743. }
  12744. }
  12745.  
  12746. public SQLiteDatabaseManager(string path)
  12747. {
  12748. this._dbPath = path;
  12749. }
  12750.  
  12751. public IDbConnection GetNewDbConnection()
  12752. {
  12753. return (IDbConnection) new SQLiteConnection(this.ConnectionString);
  12754. }
  12755.  
  12756. public void CreateDatabase()
  12757. {
  12758. if (File.Exists(this.DbPath))
  12759. return;
  12760. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateDatabase()", "???????? ???? ??????...");
  12761. try
  12762. {
  12763. string directoryName = Path.GetDirectoryName(this.DbPath);
  12764. if (directoryName != null)
  12765. {
  12766. if (!Directory.Exists(directoryName))
  12767. Directory.CreateDirectory(directoryName);
  12768. }
  12769. try
  12770. {
  12771. SQLiteConnection.CreateFile(this.DbPath);
  12772. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateDatabase()", "???? ?????? ??????? ???????");
  12773. }
  12774. catch (Exception ex)
  12775. {
  12776. Logger.WriteWarning(typeof (DatabaseInitializer), "CreateDatabase()", "?????? ??? ???????? ???? ??????");
  12777. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateDatabase()", "???????? SqlLite Pool...");
  12778. SQLiteConnection.ClearAllPools();
  12779. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateDatabase()", "SqlLite Pool ??????");
  12780. SQLiteConnection.CreateFile(this.DbPath);
  12781. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateDatabase()", "???? ?????? ??????? ???????");
  12782. }
  12783. }
  12784. catch (Exception ex)
  12785. {
  12786. Logger.WriteError(typeof (DatabaseInitializer), "CreateDatabase()", "?????? ??? ???????? ???? ??????", ex);
  12787. }
  12788. }
  12789.  
  12790. public void DeleteDatabase()
  12791. {
  12792. if (!File.Exists(this.DbPath))
  12793. return;
  12794. Logger.WriteInfo(typeof (DatabaseInitializer), "DeleteDatabase()", "???????? ???? ??????...");
  12795. try
  12796. {
  12797. Logger.WriteInfo(typeof (DatabaseInitializer), "CreateDatabase()", "???????? SqlLite Pool...");
  12798. SQLiteConnection.ClearAllPools();
  12799. Logger.WriteInfo(typeof (DatabaseInitializer), "DeleteDatabase()", "SqlLite Pool ??????");
  12800. this.DeleteDatabaseFiles();
  12801. }
  12802. catch (Exception ex)
  12803. {
  12804. Logger.WriteError(typeof (DatabaseInitializer), "DeleteDatabase()", "?? ??????? ??????? ???? ??????", ex);
  12805. }
  12806. }
  12807.  
  12808. private void DeleteDatabaseFiles()
  12809. {
  12810. File.Delete(this.DbPath);
  12811. string path = Path.Combine(Path.GetDirectoryName(this.DbPath), Path.GetFileNameWithoutExtension(this.DbPath) + "_log.ldf");
  12812. if (File.Exists(path))
  12813. File.Delete(path);
  12814. Logger.WriteInfo(typeof (DatabaseInitializer), "DeleteDatabaseFiles()", "???? ?????? ??????? ???????");
  12815. }
  12816. }
  12817. }
  12818. ?// Decompiled with JetBrains decompiler
  12819. // Type: WinApp.Service.Repository.Repository`1
  12820. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12821. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  12822. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  12823.  
  12824. using IncMap;
  12825. using NPoco;
  12826. using System.Collections.Generic;
  12827. using System.Data;
  12828. using System.Data.SQLite;
  12829. using System.Linq;
  12830. using WinApp.Data.Model;
  12831. using WinApp.Service.Core;
  12832. using WinApp.Service.Repository.Interface;
  12833.  
  12834. namespace WinApp.Service.Repository
  12835. {
  12836. public class Repository<T> : IRepository<T> where T : Entity
  12837. {
  12838. protected Database Database
  12839. {
  12840. get
  12841. {
  12842. return new Database((IDbConnection) new SQLiteConnection(Map.Get<IDatabaseManager>().ConnectionString));
  12843. }
  12844. }
  12845.  
  12846. protected string TableName { get; private set; }
  12847.  
  12848. protected Repository(string tableName)
  12849. {
  12850. this.TableName = tableName;
  12851. }
  12852.  
  12853. public void Insert(T entity)
  12854. {
  12855. this.Database.Insert<T>(this.TableName, "Id", true, entity);
  12856. }
  12857.  
  12858. public void Update(T entity)
  12859. {
  12860. this.Database.Update(this.TableName, "Id", (object) entity);
  12861. }
  12862.  
  12863. public void Update(T entity, string[] fields)
  12864. {
  12865. this.Database.Update(this.TableName, "Id", (object) entity, (IEnumerable<string>) fields);
  12866. }
  12867.  
  12868. public virtual T[] FindAll()
  12869. {
  12870. return this.Database.Fetch<T>(string.Format("SELECT * FROM [{0}];", (object) this.TableName), new object[0]).ToArray();
  12871. }
  12872.  
  12873. public virtual T FindById(long id)
  12874. {
  12875. return Enumerable.SingleOrDefault<T>((IEnumerable<T>) this.Database.Fetch<T>(string.Format("SELECT * FROM [{0}] WHERE Id = @0", (object) this.TableName), new object[1]
  12876. {
  12877. (object) id
  12878. }));
  12879. }
  12880.  
  12881. public virtual T Save(T entity)
  12882. {
  12883. if (entity.IsNew)
  12884. this.Insert(entity);
  12885. else
  12886. this.Update(entity);
  12887. return entity;
  12888. }
  12889.  
  12890. public virtual void Delete(T entity)
  12891. {
  12892. this.Database.Delete((object) entity);
  12893. }
  12894.  
  12895. protected void BulkInsertRecords(IEnumerable<T> collection)
  12896. {
  12897. Database database = this.Database;
  12898. foreach (T poco in collection)
  12899. database.Insert<T>(poco);
  12900. }
  12901.  
  12902. protected IEnumerable<T> FindBy(string whereClause, params object[] parameters)
  12903. {
  12904. return (IEnumerable<T>) this.Database.Fetch<T>(string.Format("SELECT * FROM [{0}] WHERE {1}", (object) this.TableName, (object) whereClause), parameters);
  12905. }
  12906. }
  12907. }
  12908. ?// Decompiled with JetBrains decompiler
  12909. // Type: WinApp.Service.Repository.Interface.ISessionRecordRepository
  12910. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12911. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  12912. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  12913.  
  12914. using System;
  12915. using WinApp.Data.Model;
  12916.  
  12917. namespace WinApp.Service.Repository.Interface
  12918. {
  12919. public interface ISessionRecordRepository : IRepository<SessionRecord>
  12920. {
  12921. long GetTotalTime();
  12922.  
  12923. long GetTotalTimeByPeriod(DateTime periodStart, DateTime periodEnd);
  12924.  
  12925. SessionRecord[] GetByPeriod(DateTime periodStart, DateTime periodEnd);
  12926. }
  12927. }
  12928. ?// Decompiled with JetBrains decompiler
  12929. // Type: WinApp.Service.Repository.Interface.IRepository`1
  12930. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12931. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  12932. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  12933.  
  12934. using WinApp.Data.Model;
  12935.  
  12936. namespace WinApp.Service.Repository.Interface
  12937. {
  12938. public interface IRepository<T> where T : Entity
  12939. {
  12940. T[] FindAll();
  12941.  
  12942. T FindById(long id);
  12943.  
  12944. void Insert(T entity);
  12945.  
  12946. void Update(T entity);
  12947.  
  12948. void Update(T entity, string[] fields);
  12949.  
  12950. T Save(T entity);
  12951.  
  12952. void Delete(T entity);
  12953. }
  12954. }
  12955. ?// Decompiled with JetBrains decompiler
  12956. // Type: WinApp.Service.Repository.Interface.IModuleRepository
  12957. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12958. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  12959. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  12960.  
  12961. using WinApp.Data.Model;
  12962.  
  12963. namespace WinApp.Service.Repository.Interface
  12964. {
  12965. public interface IModuleRepository : IRepository<Module>
  12966. {
  12967. bool IsInstalled(long productId);
  12968.  
  12969. bool IsInstalledAndActivated(long productId);
  12970.  
  12971. Module GetModuleByProductId(long productId);
  12972. }
  12973. }
  12974. ?// Decompiled with JetBrains decompiler
  12975. // Type: WinApp.Service.Repository.ModuleRepository
  12976. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  12977. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  12978. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  12979.  
  12980. using System.Linq;
  12981. using WinApp.Data.Model;
  12982. using WinApp.Service.Repository.Interface;
  12983.  
  12984. namespace WinApp.Service.Repository
  12985. {
  12986. public class ModuleRepository : Repository<Module>, IModuleRepository, IRepository<Module>
  12987. {
  12988. public ModuleRepository()
  12989. : base("Module")
  12990. {
  12991. }
  12992.  
  12993. public bool IsInstalled(long productId)
  12994. {
  12995. Module module = Enumerable.SingleOrDefault<Module>(this.FindBy("ProductId = @0", (object) productId));
  12996. if (module == null)
  12997. return false;
  12998. return module.State == 2;
  12999. }
  13000.  
  13001. public bool IsInstalledAndActivated(long productId)
  13002. {
  13003. Module module = Enumerable.SingleOrDefault<Module>(this.FindBy("ProductId = @0", (object) productId));
  13004. if (module == null)
  13005. return false;
  13006. return module.State == 3;
  13007. }
  13008.  
  13009. public Module GetModuleByProductId(long productId)
  13010. {
  13011. return Enumerable.SingleOrDefault<Module>(this.FindBy("ProductId = @0", (object) productId)) ?? (Module) null;
  13012. }
  13013. }
  13014. }
  13015. ?// Decompiled with JetBrains decompiler
  13016. // Type: WinApp.Service.Repository.SessionRecordRepository
  13017. // Assembly: KairosPlanet.Service, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13018. // MVID: C598B940-0130-4846-9EFD-92647F3BFA24
  13019. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.Service.dll
  13020.  
  13021. using System;
  13022. using System.Linq;
  13023. using WinApp.Data.Model;
  13024. using WinApp.Service.Repository.Interface;
  13025.  
  13026. namespace WinApp.Service.Repository
  13027. {
  13028. public class SessionRecordRepository : Repository<SessionRecord>, ISessionRecordRepository, IRepository<SessionRecord>
  13029. {
  13030. public SessionRecordRepository()
  13031. : base("SessionRecord")
  13032. {
  13033. }
  13034.  
  13035. public long GetTotalTime()
  13036. {
  13037. return this.Database.ExecuteScalar<long>("SELECT SUM([EndInt] - [StartInt]) FROM [SessionRecord]", new object[0]);
  13038. }
  13039.  
  13040. public long GetTotalTimeByPeriod(DateTime periodStart, DateTime periodEnd)
  13041. {
  13042. if (periodEnd.Subtract(periodStart) < TimeSpan.Zero)
  13043. return 0;
  13044. return this.Database.ExecuteScalar<long>("SELECT SUM([EndInt] - [StartInt])\r\n FROM [SessionRecord]\r\n WHERE [StartInt] >= @0 AND [EndInt] <= @1", (object) periodStart.Ticks, (object) periodEnd.Ticks);
  13045. }
  13046.  
  13047. public SessionRecord[] GetByPeriod(DateTime periodStart, DateTime periodEnd)
  13048. {
  13049. return Enumerable.ToArray<SessionRecord>(this.FindBy("[StartInt] >= @0 AND [EndInt] <= @1", (object) periodStart.Ticks, (object) periodEnd.Ticks));
  13050. }
  13051. }
  13052. }
  13053. ?using System;
  13054. using System.Reflection;
  13055. using System.Runtime.CompilerServices;
  13056. using System.Runtime.InteropServices;
  13057.  
  13058. [assembly: InternalsVisibleTo("KairosPlanet.Tests")]
  13059. [assembly: AssemblyTitle("KairosPlanet.Service")]
  13060. [assembly: AssemblyDescription("")]
  13061. [assembly: AssemblyProduct("KairosPlanet.Service")]
  13062. [assembly: InternalsVisibleTo("KairosPlanet")]
  13063. [assembly: AssemblyConfiguration("")]
  13064. [assembly: AssemblyCompany("Kairos Technologies Ltd")]
  13065. [assembly: AssemblyCopyright("Copyright © Kairos Technologies 2014")]
  13066. [assembly: AssemblyTrademark("")]
  13067. [assembly: ComVisible(false)]
  13068. [assembly: CLSCompliant(false)]
  13069. [assembly: AssemblyFileVersion("1.0.18.651")]
  13070. [assembly: AssemblyInformationalVersion("1.0.18.651")]
  13071. [assembly: AssemblyVersion("1.0.18.651")]
  13072. ?// Decompiled with JetBrains decompiler
  13073. // Type: WinApp.Api.ApiClientFactory
  13074. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13075. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13076. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13077.  
  13078. using Inc.Logging;
  13079. using KairosPlanet.WebServiceManager;
  13080. using System;
  13081. using System.Net;
  13082. using System.Net.Security;
  13083. using System.Security.Cryptography.X509Certificates;
  13084. using System.ServiceModel;
  13085. using System.ServiceModel.Channels;
  13086. using System.ServiceModel.Description;
  13087. using WinApp.Api.Interfaces;
  13088.  
  13089. namespace WinApp.Api
  13090. {
  13091. public class ApiClientFactory : IClientFactory
  13092. {
  13093. private string _userAgent;
  13094.  
  13095. public IAuthApi CreateChannel(string login, string password, string endpoingUri, string userAgent)
  13096. {
  13097. this._userAgent = userAgent;
  13098. if (endpoingUri.ToUpper().StartsWith("HTTPS://"))
  13099. return this.CreateChannelHttps(login.ToLower(), password, endpoingUri);
  13100. return this.CreateChannelHttp(login.ToLower(), password, endpoingUri);
  13101. }
  13102.  
  13103. public void SetUserAgent(string userAgent)
  13104. {
  13105. if (string.IsNullOrEmpty(userAgent))
  13106. return;
  13107. this._userAgent = userAgent;
  13108. }
  13109.  
  13110. private IAuthApi CreateChannelHttps(string login, string password, string endpoingUri)
  13111. {
  13112. CheckPoint checkPoint = Logger.CheckPointStart("ClientFactory.CreateChannel HTTPS");
  13113. ApiAccess apiAccess;
  13114. try
  13115. {
  13116. WebHttpBinding webHttpBinding = new WebHttpBinding();
  13117. EndpointAddress remoteAddress = new EndpointAddress(endpoingUri);
  13118. webHttpBinding.UseDefaultWebProxy = true;
  13119. webHttpBinding.Security.Mode = WebHttpSecurityMode.Transport;
  13120. webHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
  13121. webHttpBinding.OpenTimeout = new TimeSpan(0, 0, 3, 0, 0);
  13122. webHttpBinding.SendTimeout = new TimeSpan(0, 0, 3, 0, 0);
  13123. webHttpBinding.MaxReceivedMessageSize = (long) int.MaxValue;
  13124. webHttpBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
  13125. webHttpBinding.AllowCookies = true;
  13126. apiAccess = new ApiAccess((Binding) webHttpBinding, remoteAddress);
  13127. apiAccess.SetUserData(login, password);
  13128. apiAccess.Endpoint.Behaviors.Add((IEndpointBehavior) new WebHttpBehavior());
  13129. apiAccess.Endpoint.Behaviors.Add((IEndpointBehavior) new HttpKairosEndpointBehavior(this._userAgent, login, password));
  13130. ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(this.ValidateRemoteCertificate);
  13131. }
  13132. finally
  13133. {
  13134. checkPoint.Close();
  13135. }
  13136. return (IAuthApi) apiAccess;
  13137. }
  13138.  
  13139. private IAuthApi CreateChannelHttp(string login, string password, string endpoingUri)
  13140. {
  13141. CheckPoint checkPoint = Logger.CheckPointStart("ClientFactory.CreateChannel HTTP");
  13142. ApiAccess apiAccess;
  13143. try
  13144. {
  13145. WebHttpBinding webHttpBinding = new WebHttpBinding();
  13146. EndpointAddress remoteAddress = new EndpointAddress(endpoingUri);
  13147. webHttpBinding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly;
  13148. webHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
  13149. webHttpBinding.OpenTimeout = new TimeSpan(0, 0, 3, 0, 0);
  13150. webHttpBinding.SendTimeout = new TimeSpan(0, 0, 3, 0, 0);
  13151. webHttpBinding.MaxReceivedMessageSize = (long) int.MaxValue;
  13152. webHttpBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
  13153. webHttpBinding.AllowCookies = true;
  13154. apiAccess = new ApiAccess((Binding) webHttpBinding, remoteAddress);
  13155. apiAccess.SetUserData(login, password);
  13156. apiAccess.Endpoint.Behaviors.Add((IEndpointBehavior) new WebHttpBehavior());
  13157. apiAccess.Endpoint.Behaviors.Add((IEndpointBehavior) new HttpKairosEndpointBehavior(this._userAgent, login, password));
  13158. }
  13159. finally
  13160. {
  13161. checkPoint.Close();
  13162. }
  13163. return (IAuthApi) apiAccess;
  13164. }
  13165.  
  13166. private bool ValidateRemoteCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors)
  13167. {
  13168. return cert.Subject.ToUpper().Contains("staging.xmlm.t4web.com.ua".ToUpper()) || cert.Subject.ToUpper().Contains("cabinet.kairosplanet.com".ToUpper());
  13169. }
  13170. }
  13171. }
  13172. ?// Decompiled with JetBrains decompiler
  13173. // Type: WinApp.Api.Data.ModuleContentResponse
  13174. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13175. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13176. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13177.  
  13178. using System.Runtime.Serialization;
  13179.  
  13180. namespace WinApp.Api.Data
  13181. {
  13182. [DataContract]
  13183. public class ModuleContentResponse
  13184. {
  13185. [DataMember(Name = "source")]
  13186. public string Source { get; set; }
  13187. }
  13188. }
  13189. ?// Decompiled with JetBrains decompiler
  13190. // Type: WinApp.Api.Data.StatisticsResponse
  13191. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13192. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13193. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13194.  
  13195. using System.Runtime.Serialization;
  13196.  
  13197. namespace WinApp.Api.Data
  13198. {
  13199. [DataContract]
  13200. public class StatisticsResponse
  13201. {
  13202. [DataMember(Name = "sessions")]
  13203. public Statistic[] Statistics { get; set; }
  13204. }
  13205. }
  13206. ?// Decompiled with JetBrains decompiler
  13207. // Type: WinApp.Api.Data.PurchaseResponse
  13208. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13209. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13210. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13211.  
  13212. using System.Runtime.Serialization;
  13213. using WinApp.Data.Model;
  13214.  
  13215. namespace WinApp.Api.Data
  13216. {
  13217. [DataContract]
  13218. public class PurchaseResponse
  13219. {
  13220. [DataMember(Name = "purchases")]
  13221. public Purchase[] Purchases { get; set; }
  13222. }
  13223. }
  13224. ?// Decompiled with JetBrains decompiler
  13225. // Type: WinApp.Api.Data.PingResponse
  13226. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13227. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13228. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13229.  
  13230. using System.Runtime.Serialization;
  13231.  
  13232. namespace WinApp.Api.Data
  13233. {
  13234. [DataContract]
  13235. public class PingResponse
  13236. {
  13237. [DataMember(Name = "lifetime")]
  13238. public long Lifetime { get; set; }
  13239.  
  13240. public long ErrorText { get; set; }
  13241. }
  13242. }
  13243. ?// Decompiled with JetBrains decompiler
  13244. // Type: WinApp.Api.Data.ActivationRequest
  13245. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13246. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13247. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13248.  
  13249. using System.Runtime.Serialization;
  13250.  
  13251. namespace WinApp.Api.Data
  13252. {
  13253. [DataContract]
  13254. public class ActivationRequest
  13255. {
  13256. [DataMember(Name = "purchase_id")]
  13257. public long PurchaseId { get; set; }
  13258. }
  13259. }
  13260. ?// Decompiled with JetBrains decompiler
  13261. // Type: WinApp.Api.Data.AppVersionResponse
  13262. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13263. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13264. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13265.  
  13266. using System.Runtime.Serialization;
  13267.  
  13268. namespace WinApp.Api.Data
  13269. {
  13270. [DataContract]
  13271. public class AppVersionResponse
  13272. {
  13273. [DataMember(Name = "id")]
  13274. public long Id { get; set; }
  13275.  
  13276. [DataMember(Name = "version")]
  13277. public string Version { get; set; }
  13278.  
  13279. [DataMember(Name = "file_name")]
  13280. public string FileName { get; set; }
  13281.  
  13282. [DataMember(Name = "path")]
  13283. public string Path { get; set; }
  13284.  
  13285. [DataMember(Name = "status")]
  13286. public bool Status { get; set; }
  13287. }
  13288. }
  13289. ?// Decompiled with JetBrains decompiler
  13290. // Type: WinApp.Api.Data.Statistic
  13291. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13292. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13293. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13294.  
  13295. using System;
  13296. using System.Runtime.Serialization;
  13297.  
  13298. namespace WinApp.Api.Data
  13299. {
  13300. [DataContract]
  13301. public class Statistic
  13302. {
  13303. private string _created;
  13304. private string _closed;
  13305.  
  13306. [DataMember(Name = "id")]
  13307. public long Id { get; set; }
  13308.  
  13309. [DataMember(Name = "actual")]
  13310. public bool Actual { get; set; }
  13311.  
  13312. [DataMember(Name = "created")]
  13313. public string Created
  13314. {
  13315. get
  13316. {
  13317. return this._created;
  13318. }
  13319. set
  13320. {
  13321. this._created = value;
  13322. this.CreatedDate = DateTime.Parse(this._created);
  13323. }
  13324. }
  13325.  
  13326. public DateTime CreatedDate { get; private set; }
  13327.  
  13328. [DataMember(Name = "lifetime")]
  13329. public long Lifetime { get; set; }
  13330. }
  13331. }
  13332. ?// Decompiled with JetBrains decompiler
  13333. // Type: WinApp.Api.Data.ModuleInfoResponse
  13334. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13335. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13336. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13337.  
  13338. using System.Runtime.Serialization;
  13339.  
  13340. namespace WinApp.Api.Data
  13341. {
  13342. [DataContract]
  13343. public class ModuleInfoResponse
  13344. {
  13345. [DataMember(Name = "id")]
  13346. public long Id { get; set; }
  13347.  
  13348. [DataMember(Name = "product_id")]
  13349. public long ProductId { get; set; }
  13350.  
  13351. [DataMember(Name = "title")]
  13352. public string Title { get; set; }
  13353.  
  13354. [DataMember(Name = "version")]
  13355. public string Version { get; set; }
  13356.  
  13357. [DataMember(Name = "description")]
  13358. public string Description { get; set; }
  13359.  
  13360. [DataMember(Name = "filename")]
  13361. public string Filename { get; set; }
  13362.  
  13363. [DataMember(Name = "url")]
  13364. public string Url { get; set; }
  13365. }
  13366. }
  13367. ?// Decompiled with JetBrains decompiler
  13368. // Type: WinApp.Api.Data.ActivationResponse
  13369. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13370. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13371. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13372.  
  13373. using System.Runtime.Serialization;
  13374.  
  13375. namespace WinApp.Api.Data
  13376. {
  13377. [DataContract]
  13378. public class ActivationResponse
  13379. {
  13380. [DataMember(Name = "packagesecurekey")]
  13381. public string PackageSecureKey { get; set; }
  13382. }
  13383. }
  13384. ?// Decompiled with JetBrains decompiler
  13385. // Type: WinApp.Api.Data.UserResponse
  13386. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13387. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13388. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13389.  
  13390. using System.Runtime.Serialization;
  13391. using WinApp.Data.Model;
  13392.  
  13393. namespace WinApp.Api.Data
  13394. {
  13395. [DataContract]
  13396. public class UserResponse
  13397. {
  13398. [DataMember(Name = "user")]
  13399. public Man User { get; set; }
  13400. }
  13401. }
  13402. ?// Decompiled with JetBrains decompiler
  13403. // Type: KairosPlanet.WebServiceManager.HttpKairosEndpointBehavior
  13404. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13405. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13406. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13407.  
  13408. using System.ServiceModel.Channels;
  13409. using System.ServiceModel.Description;
  13410. using System.ServiceModel.Dispatcher;
  13411.  
  13412. namespace KairosPlanet.WebServiceManager
  13413. {
  13414. public class HttpKairosEndpointBehavior : IEndpointBehavior
  13415. {
  13416. private readonly string _userAgent;
  13417. private readonly string _login;
  13418. private readonly string _password;
  13419.  
  13420. public HttpKairosEndpointBehavior(string userAgent, string login = "", string password = "")
  13421. {
  13422. this._userAgent = userAgent;
  13423. this._login = login.ToLower();
  13424. this._password = password;
  13425. }
  13426.  
  13427. public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
  13428. {
  13429. }
  13430.  
  13431. public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
  13432. {
  13433. HttpKairosMessageInspector messageInspector = new HttpKairosMessageInspector(this._userAgent, this._login, this._password);
  13434. clientRuntime.MessageInspectors.Add((IClientMessageInspector) messageInspector);
  13435. }
  13436.  
  13437. public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
  13438. {
  13439. }
  13440.  
  13441. public void Validate(ServiceEndpoint endpoint)
  13442. {
  13443. }
  13444. }
  13445. }
  13446. ?// Decompiled with JetBrains decompiler
  13447. // Type: KairosPlanet.WebServiceManager.HttpKairosMessageInspector
  13448. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13449. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13450. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13451.  
  13452. using System;
  13453. using System.Collections.Generic;
  13454. using System.Linq;
  13455. using System.Net;
  13456. using System.ServiceModel;
  13457. using System.ServiceModel.Channels;
  13458. using System.ServiceModel.Dispatcher;
  13459. using System.Text;
  13460.  
  13461. namespace KairosPlanet.WebServiceManager
  13462. {
  13463. public class HttpKairosMessageInspector : IClientMessageInspector
  13464. {
  13465. private static readonly HashSet<string> _requiredAuth = new HashSet<string>()
  13466. {
  13467. "/users/api/desktop/get-user/",
  13468. "/users/api/desktop/get-purchases/",
  13469. "/users/api/desktop/get-statistic/",
  13470. "/application/api/desktop/get-module-info/",
  13471. "/application/api/desktop/get-module-content/",
  13472. "/application/api/desktop/get-application-info/"
  13473. };
  13474. private readonly string _userAgent;
  13475. private readonly string _login;
  13476. private readonly string _password;
  13477.  
  13478. public HttpKairosMessageInspector(string userAgent, string login = "", string password = "")
  13479. {
  13480. this._userAgent = userAgent;
  13481. this._login = login;
  13482. this._password = password;
  13483. }
  13484.  
  13485. public void AfterReceiveReply(ref Message reply, object correlationState)
  13486. {
  13487. }
  13488.  
  13489. public object BeforeSendRequest(ref Message request, IClientChannel channel)
  13490. {
  13491. object obj;
  13492. if (request.Properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
  13493. {
  13494. HttpRequestMessageProperty requestMessageProperty = obj as HttpRequestMessageProperty;
  13495. if (requestMessageProperty != null)
  13496. {
  13497. if (!string.IsNullOrEmpty(this._login) && !string.IsNullOrEmpty(this._password))
  13498. {
  13499. string path = request.Headers.To.AbsolutePath;
  13500. if (Enumerable.Any<string>((IEnumerable<string>) HttpKairosMessageInspector._requiredAuth, (Func<string, bool>) (x => path == x)))
  13501. requestMessageProperty.Headers[HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(this._login + ":" + this._password));
  13502. }
  13503. if (string.IsNullOrEmpty(requestMessageProperty.Headers[HttpRequestHeader.UserAgent]))
  13504. requestMessageProperty.Headers[HttpRequestHeader.UserAgent] = this._userAgent;
  13505. else
  13506. request.Properties.Add(HttpRequestMessageProperty.Name, (object) new HttpRequestMessageProperty()
  13507. {
  13508. Headers = {
  13509. {
  13510. HttpRequestHeader.UserAgent,
  13511. this._userAgent
  13512. }
  13513. }
  13514. });
  13515. }
  13516. }
  13517. return (object) null;
  13518. }
  13519. }
  13520. }
  13521. ?// Decompiled with JetBrains decompiler
  13522. // Type: WinApp.Api.ApiException
  13523. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13524. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13525. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13526.  
  13527. using System;
  13528. using System.Net;
  13529.  
  13530. namespace WinApp.Api
  13531. {
  13532. public class ApiException : Exception
  13533. {
  13534. public HttpStatusCode ErrorCode { get; set; }
  13535.  
  13536. public string StatusDescription { get; set; }
  13537.  
  13538. public ApiException(string message, HttpStatusCode errorCode, string statusDescription = "")
  13539. : base(message)
  13540. {
  13541. this.ErrorCode = errorCode;
  13542. this.StatusDescription = statusDescription;
  13543. }
  13544. }
  13545. }
  13546. ?// Decompiled with JetBrains decompiler
  13547. // Type: WinApp.Api.Interfaces.IClientFactory
  13548. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13549. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13550. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13551.  
  13552. namespace WinApp.Api.Interfaces
  13553. {
  13554. public interface IClientFactory
  13555. {
  13556. IAuthApi CreateChannel(string login, string password, string endpoingUri, string userAgent);
  13557. }
  13558. }
  13559. ?// Decompiled with JetBrains decompiler
  13560. // Type: WinApp.Api.Interfaces.IApi
  13561. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13562. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13563. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13564.  
  13565. using System.ServiceModel;
  13566.  
  13567. namespace WinApp.Api.Interfaces
  13568. {
  13569. [ServiceContract]
  13570. public interface IApi : IProductsApi
  13571. {
  13572. }
  13573. }
  13574. ?// Decompiled with JetBrains decompiler
  13575. // Type: WinApp.Api.Interfaces.IUsersApi
  13576. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13577. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13578. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13579.  
  13580. using System;
  13581. using System.ServiceModel;
  13582. using System.ServiceModel.Web;
  13583. using WinApp.Api.Data;
  13584.  
  13585. namespace WinApp.Api.Interfaces
  13586. {
  13587. [ServiceContract]
  13588. public interface IUsersApi
  13589. {
  13590. [OperationContract]
  13591. [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/users/api/desktop/get-user/")]
  13592. UserResponse GetUser();
  13593.  
  13594. [OperationContract]
  13595. [WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "/users/api/desktop/ping/?packagesecurekey={packagesecurekey}")]
  13596. PingResponse Ping(string packagesecurekey);
  13597.  
  13598. [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/users/api/desktop/get-statistic/")]
  13599. [OperationContract]
  13600. StatisticsResponse GetStatistics();
  13601.  
  13602. [OperationContract(Name = "GetStatisticsExt")]
  13603. [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/users/api/desktop/get-statistic/?dateFrom={dateFrom}&dateTo={dateTo}")]
  13604. StatisticsResponse GetStatistics(DateTime dateFrom, DateTime dateTo);
  13605.  
  13606. [OperationContract]
  13607. [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/users/api/desktop/get-purchases/")]
  13608. PurchaseResponse GetPurchases();
  13609.  
  13610. [OperationContract]
  13611. [WebInvoke(Method = "PUT", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/users/api/desktop/activation/")]
  13612. ActivationResponse Activation(ActivationRequest activationRequest);
  13613.  
  13614. void SetUserData(string username, string password);
  13615.  
  13616. [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/application/api/desktop/get-application-info/")]
  13617. [OperationContract]
  13618. AppVersionResponse GetAppVersion();
  13619. }
  13620. }
  13621. ?// Decompiled with JetBrains decompiler
  13622. // Type: WinApp.Api.Interfaces.IProductsApi
  13623. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13624. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13625. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13626.  
  13627. using System.ServiceModel;
  13628. using System.ServiceModel.Web;
  13629. using WinApp.Data.Model;
  13630.  
  13631. namespace WinApp.Api.Interfaces
  13632. {
  13633. [ServiceContract]
  13634. public interface IProductsApi
  13635. {
  13636. [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/products/api/products/")]
  13637. [OperationContract]
  13638. Product[] GetProducts();
  13639.  
  13640. [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/products/api/products/?limit={limit}&offset={offset}")]
  13641. [OperationContract(Name = "GetProductsByOffset")]
  13642. Product[] GetProducts(int limit, int offset);
  13643. }
  13644. }
  13645. ?// Decompiled with JetBrains decompiler
  13646. // Type: WinApp.Api.Interfaces.IAppApi
  13647. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13648. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13649. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13650.  
  13651. using System.ServiceModel;
  13652. using System.ServiceModel.Web;
  13653. using WinApp.Api.Data;
  13654.  
  13655. namespace WinApp.Api.Interfaces
  13656. {
  13657. [ServiceContract]
  13658. public interface IAppApi
  13659. {
  13660. [OperationContract]
  13661. [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/application/api/desktop/get-module-info/?product_id={productId}")]
  13662. ModuleInfoResponse GetModuleInfo(long productId);
  13663.  
  13664. [WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/application/api/desktop/get-module-content/?product_id={productId}")]
  13665. [OperationContract]
  13666. ModuleContentResponse GetModuleContent(long productId);
  13667. }
  13668. }
  13669. ?// Decompiled with JetBrains decompiler
  13670. // Type: WinApp.Api.Interfaces.IAuthApi
  13671. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13672. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13673. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13674.  
  13675. using System.ServiceModel;
  13676.  
  13677. namespace WinApp.Api.Interfaces
  13678. {
  13679. [ServiceContract]
  13680. public interface IAuthApi : IUsersApi, IApi, IProductsApi, IAppApi
  13681. {
  13682. void Close();
  13683. }
  13684. }
  13685. ?// Decompiled with JetBrains decompiler
  13686. // Type: WinApp.Api.ApiAccess
  13687. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13688. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13689. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13690.  
  13691. using Inc.Logging;
  13692. using System;
  13693. using System.Net;
  13694. using System.ServiceModel;
  13695. using System.ServiceModel.Channels;
  13696. using WinApp.Api.Data;
  13697. using WinApp.Api.Interfaces;
  13698. using WinApp.Data.Model;
  13699.  
  13700. namespace WinApp.Api
  13701. {
  13702. public class ApiAccess : ClientBase<IAuthApi>, IAuthApi, IUsersApi, IApi, IProductsApi, IAppApi
  13703. {
  13704. public ApiAccess(Binding binding, EndpointAddress remoteAddress)
  13705. : base(binding, remoteAddress)
  13706. {
  13707. }
  13708.  
  13709. public ModuleInfoResponse GetModuleInfo(long productId)
  13710. {
  13711. return this.HandleResponse<ModuleInfoResponse>((Func<IAuthApi, ModuleInfoResponse>) (x => x.GetModuleInfo(productId)));
  13712. }
  13713.  
  13714. public ModuleContentResponse GetModuleContent(long productId)
  13715. {
  13716. return this.HandleResponse<ModuleContentResponse>((Func<IAuthApi, ModuleContentResponse>) (x => x.GetModuleContent(productId)));
  13717. }
  13718.  
  13719. public void SetUserData(string username, string password)
  13720. {
  13721. this.ClientCredentials.UserName.UserName = username.ToLower();
  13722. this.ClientCredentials.UserName.Password = password;
  13723. }
  13724.  
  13725. public StatisticsResponse GetStatistics()
  13726. {
  13727. return this.HandleResponse<StatisticsResponse>((Func<IAuthApi, StatisticsResponse>) (x => x.GetStatistics()));
  13728. }
  13729.  
  13730. public StatisticsResponse GetStatistics(DateTime dateFrom, DateTime dateTo)
  13731. {
  13732. return this.HandleResponse<StatisticsResponse>((Func<IAuthApi, StatisticsResponse>) (x => x.GetStatistics(dateFrom, dateTo)));
  13733. }
  13734.  
  13735. public UserResponse GetUser()
  13736. {
  13737. return this.HandleResponse<UserResponse>((Func<IAuthApi, UserResponse>) (x => x.GetUser()));
  13738. }
  13739.  
  13740. public PingResponse Ping(string packageSecureKey)
  13741. {
  13742. return this.HandleResponse<PingResponse>((Func<IAuthApi, PingResponse>) (x => x.Ping(packageSecureKey)));
  13743. }
  13744.  
  13745. public Product[] GetProducts()
  13746. {
  13747. return this.HandleResponse<Product[]>((Func<IAuthApi, Product[]>) (x => x.GetProducts()));
  13748. }
  13749.  
  13750. public Product[] GetProducts(int limit, int offset)
  13751. {
  13752. return this.HandleResponse<Product[]>((Func<IAuthApi, Product[]>) (x => x.GetProducts(limit, offset)));
  13753. }
  13754.  
  13755. public PurchaseResponse GetPurchases()
  13756. {
  13757. return this.HandleResponse<PurchaseResponse>((Func<IAuthApi, PurchaseResponse>) (x => x.GetPurchases()));
  13758. }
  13759.  
  13760. public ActivationResponse Activation(ActivationRequest activationRequest)
  13761. {
  13762. return this.HandleResponse<ActivationResponse>((Func<IAuthApi, ActivationResponse>) (x => x.Activation(activationRequest)));
  13763. }
  13764.  
  13765. public AppVersionResponse GetAppVersion()
  13766. {
  13767. return this.HandleResponse<AppVersionResponse>((Func<IAuthApi, AppVersionResponse>) (x => x.GetAppVersion()));
  13768. }
  13769.  
  13770. private T HandleResponse<T>(Func<IAuthApi, T> func)
  13771. {
  13772. try
  13773. {
  13774. return func(this.Channel);
  13775. }
  13776. catch (Exception ex)
  13777. {
  13778. Logger.WriteError((object) this, "HandleResponse<T>", "Method: '" + func.Method.Name + "'. Error: " + ex.Message);
  13779. WebException webException = ex.InnerException as WebException;
  13780. if (webException != null && webException.Response != null)
  13781. {
  13782. HttpWebResponse httpWebResponse = (HttpWebResponse) webException.Response;
  13783. throw new ApiException(webException.Message, httpWebResponse.StatusCode, httpWebResponse.StatusDescription);
  13784. }
  13785. throw;
  13786. }
  13787. }
  13788. }
  13789. }
  13790. ?using System;
  13791. using System.Reflection;
  13792. using System.Runtime.InteropServices;
  13793.  
  13794. [assembly: AssemblyTitle("KairosPlanet.WebServiceManager")]
  13795. [assembly: AssemblyDescription("")]
  13796. [assembly: AssemblyInformationalVersion("1.0.18.651")]
  13797. [assembly: Guid("7aa12bcc-c133-487c-b901-bb1afd1f652b")]
  13798. [assembly: AssemblyFileVersion("1.0.18.651")]
  13799. [assembly: AssemblyProduct("KairosPlanet.WebServiceManager")]
  13800. [assembly: AssemblyConfiguration("")]
  13801. [assembly: AssemblyCompany("Kairos Technologies Ltd")]
  13802. [assembly: AssemblyCopyright("Copyright © Kairos Technologies 2014")]
  13803. [assembly: AssemblyTrademark("")]
  13804. [assembly: ComVisible(false)]
  13805. [assembly: CLSCompliant(false)]
  13806. [assembly: AssemblyVersion("1.0.18.651")]
  13807. ?// Decompiled with JetBrains decompiler
  13808. // Type: WinApp.Api.ApiBootstrapper
  13809. // Assembly: KairosPlanet.WebServiceManager, Version=1.0.18.651, Culture=neutral, PublicKeyToken=null
  13810. // MVID: F6F5C251-9F2C-4C96-A6DF-4DB3276EDED0
  13811. // Assembly location: C:\Program Files (x86)\KairosPlanet\Bin\KairosPlanet.WebServiceManager.dll
  13812.  
  13813. using IncMap;
  13814. using WinApp.Api.Interfaces;
  13815.  
  13816. namespace WinApp.Api
  13817. {
  13818. public class ApiBootstrapper
  13819. {
  13820. public static void Bootstrap()
  13821. {
  13822. Map.Inject<IClientFactory>((IClientFactory) new ApiClientFactory());
  13823. }
  13824. }
  13825. }
Add Comment
Please, Sign In to add comment