PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/InstantImageUploader/ViewModels/UploaderViewModel.cs

https://bitbucket.org/ugaya40/instant-image-uploader
C# | 112 lines | 90 code | 22 blank | 0 comment | 10 complexity | 3f8b84525f85fb845061d962bf180767 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ComponentModel;
  6. using Livet;
  7. using Livet.Commands;
  8. using Livet.Messaging;
  9. using Livet.Messaging.IO;
  10. using Livet.Messaging.Windows;
  11. using InstantImageUploader.Models;
  12. using System.IO;
  13. using System.Xml.Serialization;
  14. using InstantImageUploader.Properties;
  15. namespace InstantImageUploader.ViewModels
  16. {
  17. public class UploaderViewModel : ViewModel
  18. {
  19. IImageUploader _model;
  20. public UploaderViewModel(IImageUploader model)
  21. {
  22. _model = model;
  23. if (ImageUploaderApplication.Current.ActiveUploader != null)
  24. {
  25. if (ImageUploaderApplication.Current.ActiveUploader.ImageUploaderName == ImageUploaderName)
  26. {
  27. IsDefault = true;
  28. }
  29. }
  30. }
  31. #region IsDefault変更通知プロパティ
  32. private bool _IsDefault;
  33. public bool IsDefault
  34. {
  35. get
  36. { return _IsDefault; }
  37. set
  38. {
  39. if (_IsDefault == value)
  40. return;
  41. _IsDefault = value;
  42. if (_IsDefault)
  43. {
  44. Settings.Default.ActiveImageUploaderName = ImageUploaderName;
  45. Settings.Default.Save();
  46. }
  47. RaisePropertyChanged("IsDefault");
  48. }
  49. }
  50. #endregion
  51. public string ImageUploaderName
  52. {
  53. get { return _model.ImageUploaderName; }
  54. }
  55. public string Description
  56. {
  57. get { return _model.Description; }
  58. }
  59. public string Author
  60. {
  61. get { return _model.Author; }
  62. }
  63. public string Url
  64. {
  65. get { return _model.Url; }
  66. }
  67. #region SettingCommand
  68. private ViewModelCommand _SettingCommand;
  69. public ViewModelCommand SettingCommand
  70. {
  71. get
  72. {
  73. if (_SettingCommand == null)
  74. {
  75. _SettingCommand = new ViewModelCommand(Setting,CanSetting);
  76. }
  77. return _SettingCommand;
  78. }
  79. }
  80. public void Setting()
  81. {
  82. Messenger.Raise(new TransitionMessage("Setting") { WindowType = _model.SettingWindowType });
  83. }
  84. public bool CanSetting()
  85. {
  86. return _model.SettingWindowType != null;
  87. }
  88. #endregion
  89. }
  90. }