/InstantImageUploader/ViewModels/CaptureWindowViewModel.cs
C# | 142 lines | 118 code | 24 blank | 0 comment | 15 complexity | 19a4d102c3e45c43130ac093af41c5b6 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.Windows;
-
- namespace InstantImageUploader.ViewModels
- {
- public class CaptureWindowViewModel : ViewModel
- {
- public CaptureWindowViewModel()
- {
- IsCaptureMode = true;
-
- if (ImageUploaderApplication.Current != null)
- {
- ImageUploaderApplication.Current.FailedImageUpload += (sender, e) =>
- {
- if(!string.IsNullOrEmpty(e.MessageForUser))
- {
- Messenger.Raise(new InformationMessage(e.MessageForUser, "エラー", System.Windows.MessageBoxImage.Error, "Error"));
- }
- };
-
- ImageUploaderApplication.Current.SuccessImageUpload += (sender, e) =>
- {
- if(!string.IsNullOrEmpty(e.MessageForUser))
- {
- Messenger.Raise(new InformationMessage(e.MessageForUser, "アップロード成功", System.Windows.MessageBoxImage.Error, "Success"));
- }
- };
- }
- }
-
-
- #region SendImageCommand
- private ListenerCommand<string> _SendImageCommand;
-
- public ListenerCommand<string> SendImageCommand
- {
- get
- {
- if (_SendImageCommand == null)
- {
- _SendImageCommand = new ListenerCommand<string>(SendImage);
- }
- return _SendImageCommand;
- }
- }
-
- public void SendImage(string parameter)
- {
- ImageUploaderApplication.Current.Upload(parameter);
- }
- #endregion
-
-
- #region IsCaptureMode変更通知プロパティ
- private bool _IsCaptureMode;
-
- public bool IsCaptureMode
- {
- get
- { return _IsCaptureMode; }
- set
- {
- if (_IsCaptureMode == value)
- return;
- _IsCaptureMode = value;
- RaisePropertyChanged("IsCaptureMode");
- }
- }
- #endregion
-
- #region ExitCommand
- private ViewModelCommand _ExitCommand;
-
- public ViewModelCommand ExitCommand
- {
- get
- {
- if (_ExitCommand == null)
- {
- _ExitCommand = new ViewModelCommand(Exit);
- }
- return _ExitCommand;
- }
- }
- public void Exit()
- {
- ImageUploaderApplication.Current.Exit();
- }
- #endregion
-
-
- #region InitializeCommand
- private ViewModelCommand _InitializeCommand;
-
- public ViewModelCommand InitializeCommand
- {
- get
- {
- if (_InitializeCommand == null)
- {
- _InitializeCommand = new ViewModelCommand(Initialize);
- }
- return _InitializeCommand;
- }
- }
-
- public void Initialize()
- {
- if (ImageUploaderApplication.Current.ActiveUploader == null)
- {
- return;
- }
-
- if (ImageUploaderApplication.Current.ActiveUploader.IsNeedSetting)
- {
- IsCaptureMode = false;
- Messenger.Raise(new TransitionMessage("Setting") { WindowType = ImageUploaderApplication.Current.ActiveUploader.SettingWindowType });
- ImageUploaderApplication.Current.Exit();
- }
-
- ImageUploaderApplication.Current.ActiveUploader.Initialize();
- }
- #endregion
-
-
-
-
- }
- }