/InstantImageUploader/ViewModels/UploaderViewModel.cs
C# | 112 lines | 90 code | 22 blank | 0 comment | 10 complexity | 3f8b84525f85fb845061d962bf180767 MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.ComponentModel;
-
- using Livet;
- using Livet.Commands;
- using Livet.Messaging;
- using Livet.Messaging.IO;
- using Livet.Messaging.Windows;
-
- using InstantImageUploader.Models;
- using System.IO;
- using System.Xml.Serialization;
- using InstantImageUploader.Properties;
-
- namespace InstantImageUploader.ViewModels
- {
- public class UploaderViewModel : ViewModel
- {
- IImageUploader _model;
-
- public UploaderViewModel(IImageUploader model)
- {
- _model = model;
-
- if (ImageUploaderApplication.Current.ActiveUploader != null)
- {
- if (ImageUploaderApplication.Current.ActiveUploader.ImageUploaderName == ImageUploaderName)
- {
- IsDefault = true;
- }
- }
- }
-
-
- #region IsDefault変更通知プロパティ
- private bool _IsDefault;
-
- public bool IsDefault
- {
- get
- { return _IsDefault; }
- set
- {
- if (_IsDefault == value)
- return;
- _IsDefault = value;
-
- if (_IsDefault)
- {
- Settings.Default.ActiveImageUploaderName = ImageUploaderName;
- Settings.Default.Save();
- }
-
- RaisePropertyChanged("IsDefault");
- }
- }
- #endregion
-
-
- public string ImageUploaderName
- {
- get { return _model.ImageUploaderName; }
- }
-
- public string Description
- {
- get { return _model.Description; }
- }
-
- public string Author
- {
- get { return _model.Author; }
- }
-
- public string Url
- {
- get { return _model.Url; }
- }
-
-
-
- #region SettingCommand
- private ViewModelCommand _SettingCommand;
-
- public ViewModelCommand SettingCommand
- {
- get
- {
- if (_SettingCommand == null)
- {
- _SettingCommand = new ViewModelCommand(Setting,CanSetting);
- }
- return _SettingCommand;
- }
- }
-
- public void Setting()
- {
- Messenger.Raise(new TransitionMessage("Setting") { WindowType = _model.SettingWindowType });
- }
-
- public bool CanSetting()
- {
- return _model.SettingWindowType != null;
- }
- #endregion
-
- }
- }