public MainWindowViewModel()
        {
            EdgeLocalStateFilePath.SetValidateNotifyError(IsExitisFile);
            EdgeCookiesFilePath.SetValidateNotifyError(IsExitisFile);
            ChromeLocalStateFilePath.SetValidateNotifyError(IsExitisFile);
            ChromeCookiesFilePath.SetValidateNotifyError(IsExitisFile);
            ObsCookiesFilePath.SetValidateNotifyError(IsExitisFile);
            EdgeCommand   = new[] { EdgeLocalStateFilePath.ObserveHasErrors, EdgeCookiesFilePath.ObserveHasErrors, ObsCookiesFilePath.ObserveHasErrors }.CombineLatestValuesAreAllFalse().ToReactiveCommand <Models.CommandParameter>();
            ChromeCommand = new[] { ChromeLocalStateFilePath.ObserveHasErrors, ChromeCookiesFilePath.ObserveHasErrors, ObsCookiesFilePath.ObserveHasErrors }.CombineLatestValuesAreAllFalse().ToReactiveCommand <Models.CommandParameter>();

            LocalStateFilePath.SetValidateNotifyError(IsExitisFile);
            SrcCookieFilePath.SetValidateNotifyError(IsExitisFile);
            DestCookieFilePath.SetValidateNotifyError(IsExitisFile);
            HostKey.SetValidateNotifyError(host =>
            {
                if (String.IsNullOrWhiteSpace(host))
                {
                    return("Empty");
                }

                return(null);
            });

            ParamCommand = new[] { LocalStateFilePath.ObserveHasErrors, SrcCookieFilePath.ObserveHasErrors, HostKey.ObserveHasErrors, DestCookieFilePath.ObserveHasErrors }.CombineLatestValuesAreAllFalse().ToReactiveCommand <Models.CommandParameter>();

            EdgeCommand.Subscribe(ExecuteCommand.Execute);
            ChromeCommand.Subscribe(ExecuteCommand.Execute);
            ParamCommand.Subscribe(ExecuteCommand.Execute);

            OkCommand.Subscribe(async _ =>
            {
                Executing.Value = true;

                try
                {
                    await System.Threading.Tasks.Task.Run(() =>
                    {
                        CookieManager.Converter.Convert(Environment.ExpandEnvironmentVariables(Param.LocalStateFilePath), Environment.ExpandEnvironmentVariables(Param.SrcCookieFilePath), Param.HostKey, Environment.ExpandEnvironmentVariables(Param.DestCookieFilePath));
                    });
                }
                catch
                {
                    IsErrorDialogOpen.Value = true;
                }

                Executing.Value    = false;
                IsDialogOpen.Value = false;
            }
                                );

            ExecuteCommand.Subscribe(param =>
            {
                IsDialogOpen.Value = true;
                Param = param;
            });

            CancelCommand.Subscribe(_ => IsDialogOpen.Value = false);

            ErrorOkCommand.Subscribe(_ => IsErrorDialogOpen.Value = false);
        }
 public MenuItemVm(IButtonItemModel model, IShellContainerVm shellContainerVm)
     : base(shellContainerVm)
 {
     MenuItemBackgroundColor        = new SolidColorBrush(model.Color.ToRgbColor());
     MenuItemBackgroundOverColor    = new SolidColorBrush(model.Color.ToRgbLightColor(20));
     MenuItemBackgroundPressedColor = new SolidColorBrush(model.Color.ToRgbLightColor(-20));
     MenuItemLogo   = new BitmapImage(new Uri(URI_RESOURCE + model.Image));
     Title          = model.Title;
     ExecuteCommand = ReactiveCommand.Create(Observable.Return(true));
     _parameters    = model.Parameters;
     ExecuteCommand.Subscribe(_ => ShellContainerVm.ChangeCurrentView(model.Code.ToEnum(), true, false, _parameters));
 }
Exemplo n.º 3
0
        public TreeItemContext(string taskName)
        {
            this.TaskName = new ReactiveProperty <string>(taskName);

            ExecuteCommand.Subscribe(() =>
            {
                //実行する
            });

            DeleteCommand.Subscribe(() =>
            {
                //自身を削除
            });
        }
Exemplo n.º 4
0
        public LwsViewModel()
        {
            model = new LwsModel();

            Output = model.Output.ToReadOnlyReactiveCollection();
            EnchantGroupList.AddRange(Const.EnchantmentList.Select(item => item.Name));

            ExecuteCommand.Subscribe(_ => Execute());
            ExitCommand.Subscribe(_ => Exit());

            SelectedGroupIndex.Subscribe(_ =>
            {
                EnchantNameList.Clear();
                EnchantNameList.AddRange(GetEnchantNameList().Select(i => i.Name));
                SelectedNameIndex.Value = 0;
            });

            Disposable.Add(Output);
            Disposable.Add(ExecuteCommand);
            Disposable.Add(ExitCommand);
        }