Exemplo n.º 1
0
        public UpdateAvailable(Models.UpdateCheck update = null)
        {
            InitializeComponent();

            this.DataContext = MainViewModel;

            this.Width  *= MainViewModel.UIScaleFactor;
            this.Height *= MainViewModel.UIScaleFactor;

            var _markdownPipelineBuilder = new Markdig.MarkdownPipelineBuilder();

            _markdownPipelineBuilder.Extensions.Add(new Markdig.Extensions.Tables.PipeTableExtension());
            _markdownPipeline = _markdownPipelineBuilder.Build();
            try
            {
                var cssPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", "CSS", "markdown.css");
                _css = System.IO.File.ReadAllText(cssPath);

                if (MainViewModel.UISettings?.UITheme?.ToLower() == "dark")
                {
                    cssPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", "CSS", "dark-mode.css");
                    _css   += System.IO.File.ReadAllText(cssPath);
                }
            }
            catch
            {
                // will fail in design mode
            }

            _update = update;
        }
Exemplo n.º 2
0
        public Models.UpdateCheck GetLatestVersion()
        {
            Models.UpdateCheck updateCheck;

            // TODO: Pull the latest version from the configuration data somewhere
            updateCheck = new Models.UpdateCheck()
            {
                LatestMajorVersion = 0,
                LatestMinorVersion = 3,
                FirmwareURL        = "https://microcube.info/FirmwareDistrib/v03.bin"
            };

            return(updateCheck);
        }
Exemplo n.º 3
0
        private async void PerformUpdateConfirmation(Models.UpdateCheck updateCheck)
        {
            // offer to start download and notify when ready to apply

            var d = new Windows.UpdateAvailable(updateCheck)
            {
                Owner = Window.GetWindow(this)
            };

            if (d.ShowDialog() == true)
            {
                _appViewModel.IsUpdateInProgress = true;
                UpdateIcon.Spin         = true;
                UpdateIcon.Icon         = FontAwesome.WPF.FontAwesomeIcon.Superpowers;
                UpdateIcon.SpinDuration = 1;

                _appViewModel.UpdateCheckResult  = await new Utils.UpdateCheckUtils().UpdateWithDownload();
                _appViewModel.IsUpdateInProgress = false;
                UpdateIcon.Spin = false;
            }
            else
            {
                // if update is mandatory (where there is a major bug etc) quit until user updates
                if (updateCheck.MustUpdate)
                {
                    // offer to take user to download page
                    var gotoDownload = MessageBox.Show(Application.Current.MainWindow, updateCheck.Message.Body + "\r\nVisit download page now?", ConfigResources.AppName, MessageBoxButton.YesNo);
                    if (gotoDownload == MessageBoxResult.Yes)
                    {
                        Utils.Helpers.LaunchBrowser(ConfigResources.AppWebsiteURL);
                    }
                    else
                    {
                        MessageBox.Show(Application.Current.MainWindow, SR.Update_MandatoryUpdateQuit);
                    }

                    //quit
                    App.Current.Shutdown();
                }
            }
        }
Exemplo n.º 4
0
        public UpdateAvailable(Models.UpdateCheck update = null)
        {
            InitializeComponent();

            this.DataContext = MainViewModel;

            this.Width  *= MainViewModel.UIScaleFactor;
            this.Height *= MainViewModel.UIScaleFactor;

            var _markdownPipelineBuilder = new Markdig.MarkdownPipelineBuilder();

            _markdownPipelineBuilder.Extensions.Add(new Markdig.Extensions.Tables.PipeTableExtension());
            _markdownPipeline = _markdownPipelineBuilder.Build();
            try
            {
                _css = System.IO.File.ReadAllText(System.AppDomain.CurrentDomain.BaseDirectory + "\\Assets\\CSS\\markdown.css");
            }
            catch
            {
                // will fail in design mode
            }

            _update = update;
        }