Beispiel #1
0
        internal SettingIoViewModel(
            RootSettingSync rootModel, AutomationSettingSync model, SaveFileManager saveFileManager, IMessageSender sender
            ) : base(sender)
        {
            _rootModel       = rootModel;
            _model           = model;
            _saveFileManager = saveFileManager;

            OpenInstructionUrlCommand       = new ActionCommand(OpenInstructionUrl);
            RequestEnableAutomationCommand  = new ActionCommand(OnEnableAutomationRequested);
            RequestDisableAutomationCommand = new ActionCommand(OnDisableAutomationRequested);
            ApplyPortNumberCommand          = new ActionCommand(ApplyPortNumber);

            ShowSaveModalCommand = new ActionCommand(ShowSaveModal);
            ShowLoadModalCommand = new ActionCommand(ShowLoadModal);

            ExportSettingToFileCommand   = new ActionCommand(SaveSettingToFile);
            ImportSettingFromFileCommand = new ActionCommand(LoadSettingFromFile);

            AutomationPortNumberText = new RProperty <string>(
                _model.AutomationPortNumber.Value.ToString(), v =>
            {
                //フォーマット違反になってないかチェック
                PortNumberIsInvalid.Value = !(int.TryParse(v, out int i) && i >= 0 && i < 65536);
            });

            _model.AutomationPortNumber.PropertyChanged += (_, __) =>
            {
                AutomationPortNumberText.Value = _model.AutomationPortNumber.Value.ToString();
            };
        }
Beispiel #2
0
        public MainWindowViewModel()
        {
            Model           = new RootSettingSync(MessageSender, MessageIo.Receiver);
            SettingFileIo   = new SettingFileIo(Model, MessageSender);
            SaveFileManager = new SaveFileManager(SettingFileIo, Model, MessageSender);

            WindowSetting          = new WindowSettingViewModel(Model.Window, MessageSender);
            MotionSetting          = new MotionSettingViewModel(Model.Motion, MessageSender, MessageIo.Receiver);
            GamepadSetting         = new GamepadSettingViewModel(Model.Gamepad, MessageSender);
            LayoutSetting          = new LayoutSettingViewModel(Model.Layout, Model.Gamepad, MessageSender, MessageIo.Receiver);
            LightSetting           = new LightSettingViewModel(Model.Light, MessageSender);
            WordToMotionSetting    = new WordToMotionSettingViewModel(Model.WordToMotion, MessageSender, MessageIo.Receiver);
            ExternalTrackerSetting = new ExternalTrackerViewModel(Model.ExternalTracker, Model.Motion, MessageSender, MessageIo.Receiver);
            SettingIo = new SettingIoViewModel(Model, Model.Automation, SaveFileManager, MessageSender);
            //オートメーションの配線: 1つしかないのでザツにやる。OC<T>をいじる関係でUIスレッド必須なことに注意
            Model.Automation.LoadSettingFileRequested += v =>
                                                         Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                                                        () => SaveFileManager.LoadSetting(v.Index, v.LoadCharacter, v.LoadNonCharacter, true))
                                                                                                    );

            _runtimeHelper = new RuntimeHelper(MessageSender, MessageIo.Receiver, Model);

            LoadVrmCommand           = new ActionCommand(LoadVrm);
            LoadVrmByFilePathCommand = new ActionCommand <string>(LoadVrmByFilePath);
            ConnectToVRoidHubCommand = new ActionCommand(ConnectToVRoidHubAsync);

            OpenVRoidHubCommand      = new ActionCommand(() => UrlNavigate.Open("https://hub.vroid.com/"));
            AutoAdjustCommand        = new ActionCommand(() => MessageSender.SendMessage(MessageFactory.Instance.RequestAutoAdjust()));
            OpenSettingWindowCommand = new ActionCommand(() => SettingWindow.OpenOrActivateExistingWindow(this));

            ResetToDefaultCommand  = new ActionCommand(ResetToDefault);
            LoadPrevSettingCommand = new ActionCommand(LoadPrevSetting);

            TakeScreenshotCommand       = new ActionCommand(_runtimeHelper.TakeScreenshot);
            OpenScreenshotFolderCommand = new ActionCommand(_runtimeHelper.OpenScreenshotSavedFolder);

            MessageIo.Receiver.ReceivedCommand      += OnReceiveCommand;
            SaveFileManager.VRoidModelLoadRequested += id => LoadSavedVRoidModel(id, false);
        }
 /// <summary>
 /// ファイルI/Oを行うときに操作対象とするモデルを指定してインスタンスを初期化します。
 /// </summary>
 /// <param name="model"></param>
 public SettingFileIo(RootSettingSync model, IMessageSender sender)
 {
     _model  = model;
     _sender = sender;
 }
Beispiel #4
0
 public SaveFileManager(SettingFileIo fileIo, RootSettingSync setting, IMessageSender sender)
 {
     SettingFileIo = fileIo;
     _setting      = setting;
     _sender       = sender;
 }
 internal static SaveLoadDataViewModel CreateForLoad(RootSettingSync rootModel, SaveFileManager model, Action actToClose)
 => new SaveLoadDataViewModel(rootModel, model, true, actToClose);