コード例 #1
0
        //private double RANGE_MAX_KiB = (double)BslSettings.Instance.DownloadSizeMax;

        public TabDownloadViewModel(ControlProcessViewModel _ctrlprc_vm)
        {
            this.ControlProcess = _ctrlprc_vm;
            this.ControlProcess.FwPathDownload = this.FwPath;
            this.ControlProcess.StartAddress   = (int)this.StartAddress;
            this.ControlProcess.OutputFormat   = this.OutputFormat;
            this.ControlProcess.ByteSize       = (this.SizeInDecimal) ? (int)this.ByteSize : (int)this.ByteSize * 1024;
            this.RangeUpperValue = (double)(this.ByteSize + this.StartAddress);
            this.ByteSizeMaximum = (this.SizeInDecimal) ? this.RangeMaxD : this.RangeMaxK;
            this.RangeMaxK       = (double)BslSettings.Instance.DownloadSizeRange;
        }
コード例 #2
0
 public TabEraseViewModel(ControlProcessViewModel _ctrlprc_vm)
 {
     this.ControlProcess = _ctrlprc_vm;
 }
コード例 #3
0
 public TabUploadViewModel(ControlProcessViewModel _ctrlprc_vm, Dictionary <string, string> args)
 {
     this.ControlProcess = _ctrlprc_vm;
     this.ControlProcess.FwPathUpload = this.FwPath;
     HandleArgs(args);
 }
コード例 #4
0
        public ShellViewModel()
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(ErrHandler);

            #region Model
            this.model = new ShellModel(this);
            this.model.SelfCopyToAppLocal();
            #endregion

            #region Args
            var  args  = this.model.HandleArgs(this.model.ParseArgs());
            bool reset = false;
            if (args.ContainsKey($"{ShellModel.ARG_KEY_RESET}"))
            {
                reset = true;
            }
            #endregion

            #region Views
            var upload_v   = new TabUploadView();
            var download_v = new TabDownloadView();
            var erase_v    = new TabEraseView();
            var fwtools_v  = new TabFwToolsView();
            var bsl430_v   = new TabBSL430NETView();

            var convert_v  = new DialogFwToolsConvertView();
            var combine_v  = new DialogFwToolsCombineView();
            var validate_v = new DialogFwToolsValidateView();
            var getpw_v    = new DialogFwToolsGetPasswordView();

            this.convert_v_res  = convert_v;
            this.combine_v_res  = combine_v;
            this.validate_v_res = validate_v;
            this.getpw_v_res    = getpw_v;
            #endregion

            #region ViewModels
            var log_vm = new LogViewModel(this);
            var hex_vm = new HexViewModel();

            var processctl_vm = new ControlProcessViewModel(log_vm, this);
            AppReadyEvent += processctl_vm.AppReadyHandler;

            var upload_vm   = new TabUploadViewModel(processctl_vm, args);
            var download_vm = new TabDownloadViewModel(processctl_vm);
            var erase_vm    = new TabEraseViewModel(processctl_vm);
            var ftwtools_vm = new TabFwToolsViewModel(DialogCoordinator.Instance, convert_v,
                                                      combine_v, validate_v, getpw_v, this, hex_vm, args);

            this.Ifwtools_vm = ftwtools_vm;
            var bsl430_vm = new TabBSL430NETViewModel();
            #endregion

            #region TabItems
            Style s    = (Style)Application.Current.Resources["CustomMetroTabItem"];
            var   tabs = new List <MetroTabItem>()
            {
                new MetroTabItem()
                {
                    Content = upload_v, Header = "Upload", Tag = "Install", Style = s, DataContext = upload_vm
                },
                new MetroTabItem()
                {
                    Content = download_v, Header = "Download", Tag = "Upload", Style = s, DataContext = download_vm
                },
                new MetroTabItem()
                {
                    Content = erase_v, Header = "Erase", Tag = "Uninstall", Style = s, DataContext = erase_vm
                },
                new MetroTabItem()
                {
                    Content = fwtools_v, Header = "FW Tools", Tag = "Labflask", Style = s, DataContext = ftwtools_vm
                },
                new MetroTabItem()
                {
                    Content = bsl430_v, Header = "BSL430.NET", Tag = "Help", Style = s, DataContext = bsl430_vm
                }
            };
            #endregion

            #region Theme
            bool darkMode    = BslSettings.Instance.GeneralDarkMode;
            bool wasFirstRun = false;
            if (this.FirstRun)
            {
                darkMode = this.model.IsWinDarkMode();
                BslSettings.Instance.GeneralDarkMode = darkMode;
                this.FirstRun = false;
                wasFirstRun   = true;
            }
            this.SetTheme(darkMode);
            #endregion

            #region Shell Integration
            if (reset || BslSettings.Instance.GeneralShellAssocInstallForce)
            {
                BslSettings.Instance.GeneralShellAssocInstallForce = false;
                this.model.ShellAssocInstall(BslSettings.Instance.GeneralShellAssociation, this.model.AppDataShellPath);
            }
            if (reset || BslSettings.Instance.GeneralShellExtInstallForce)
            {
                BslSettings.Instance.GeneralShellExtInstallForce = false;
                this.model.ShellExtInstall(BslSettings.Instance.GeneralShellExtension, this.model.AppDataShellPath);
            }
            #endregion

            #region MainViewModel Activate
            var main_vm = new MainViewModel(this, tabs, processctl_vm, download_vm, darkMode);
            Imain_vm = main_vm;
            this.ActivateItem(main_vm);
            #endregion

            ShowWindow();
            AppReadyEvent?.Invoke();
            if (wasFirstRun)
            {
                Task.Delay(1000).ContinueWith(t => this.model.AskForShellIntegration());
            }
        }