public void UpdateTheme(Theme theme)
        {
            try
            {
                _border.Color      = theme.BorderSettings.Normal;
                _border.HoverColor = theme.BorderSettings.Hover;

                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font        = theme.TextSetting.Font;
                _headerFont = ThemeManager.Theme.TextSetting.Font;

                _itemEnabled  = theme.ListItemSettings.Item;
                _itemSelected = theme.ListItemSettings.ItemSelected;
                _itemHover    = theme.ListItemSettings.ItemHover;

                _columnHeaderColor = theme.OtherSettings.ColumnHeader;
                _headerText        = theme.OtherSettings.ColumnText;

                _colorState = new ColorState
                {
                    Enabled  = theme.BackgroundSettings.Type4,
                    Disabled = theme.BackgroundSettings.Type1
                };
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
Exemple #2
0
        public void UpdateTheme(Theme theme)
        {
            try
            {
                _border.Color      = theme.BorderSettings.Normal;
                _border.HoverColor = theme.BorderSettings.Hover;

                ForeColor           = theme.TextSetting.Enabled;
                _textStyle.Enabled  = theme.TextSetting.Enabled;
                _textStyle.Disabled = theme.TextSetting.Disabled;

                Font = theme.TextSetting.Font;

                _borderEdge.BackColor = theme.OtherSettings.Line;

                _backColorState = new ColorState
                {
                    Enabled  = theme.OtherSettings.BoxEnabled,
                    Disabled = theme.OtherSettings.BoxDisabled
                };

                _buttonColor = theme.OtherSettings.FlatControlEnabled;

                _menuTextColor  = theme.TextSetting.Enabled;
                _menuItemNormal = theme.ListItemSettings.Item;
                _menuItemHover  = theme.ListItemSettings.ItemHover;
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
        public void UpdateTheme(Theme theme)
        {
            try
            {
                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font             = theme.TextSetting.Font; // TODO: 16F - Bold
                _subscriptFont   = theme.TextSetting.Font; // TODO: - Bold
                _superscriptFont = theme.TextSetting.Font; // TODO: - Bold

                _superscriptColor = theme.TextSetting.SuperscriptColor;
                _subscriptColor   = theme.TextSetting.SubscriptColor;

                _colorState = new ControlColorState
                {
                    Enabled  = theme.BackgroundSettings.Type1,
                    Disabled = theme.BackgroundSettings.Type1
                };

                _backCircleColor = theme.OtherSettings.BackCircle;
                _foreCircleColor = theme.OtherSettings.ForeCircle;
                _progressColor   = theme.OtherSettings.Progress;
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
Exemple #4
0
        ///// <summary>
        /////     Verify the install files folder exists before extracting.
        ///// </summary>
        // public void VerifyExtract()
        // {
        // if (!Directory.Exists(_installFilesFolder))
        // {
        // VisualExceptionDialog.Show(new DirectoryNotFoundException("The install files path cannot be found. " + _installFilesFolder));
        // }

        // if (!File.Exists(DownloadedFile))
        // {
        // VisualExceptionDialog.Show(new DirectoryNotFoundException("The downloaded file doesn't exist. " + DownloadedFile));
        // }
        // }

        /// <summary>
        ///     Verify the install folder exists before installing.
        /// </summary>
        public void VerifyInstall()
        {
            if (!Directory.Exists(_executablePath))
            {
                VisualExceptionDialog.Show(new DirectoryNotFoundException("The install path cannot be found. " + _executablePath));
            }
        }
Exemple #5
0
        /// <summary>Saves the package to file.</summary>
        /// <param name="path">The file path.</param>
        /// <param name="saveOptions">The save options.</param>
        public void Save(string path, SaveOptions saveOptions = SaveOptions.DisableFormatting)
        {
            try
            {
                XElement _downloadsElement = new XElement(Enum.GetName(typeof(PackageData), 1));

                foreach (Uri _url in _downloads)
                {
                    XElement _urlElement = new XElement("Link", _url.OriginalString);
                    _downloadsElement.Add(_urlElement);
                }

                XDocument _packageFile = new XDocument(new XElement(
                                                           @"Comet",
                                                           new XElement(Enum.GetName(typeof(PackageData), 0), _changeLog),
                                                           new XElement(Enum.GetName(typeof(PackageData), 2), _filename),
                                                           new XElement(Enum.GetName(typeof(PackageData), 3), _name),
                                                           new XElement(Enum.GetName(typeof(PackageData), 4), _release.Date.ToShortDateString()),
                                                           new XElement(Enum.GetName(typeof(PackageData), 5), _version),
                                                           _downloadsElement));

                _packageFile.Save(path, saveOptions);
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }
Exemple #6
0
        /// <summary>
        ///     Saves the history to log file.
        /// </summary>
        public void Save()
        {
            try
            {
                XDocument _historyLogFile = new XDocument();

                XElement _headerElement = new XElement("HistoryLogs");
                _historyLogFile.Add(_headerElement);

                foreach (HistoryLogEntry _historyLog in _historyLogs)
                {
                    XElement _historyLogElement = new XElement("LogEntry");
                    _historyLogElement.Add(new XElement("FilePath", _historyLog.FilePath));
                    _historyLogElement.Add(new XElement("DateModified", _historyLog.DateModified.ToLongDateString()));

                    _headerElement.Add(_historyLogElement);
                }

                _historyLogFile.Save(_logFile, SaveOptions.None);
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }
Exemple #7
0
        /// <summary>Load a package from a file path.</summary>
        /// <param name="filePath">The file path.</param>
        public void Load(string filePath)
        {
            try
            {
                if (string.IsNullOrEmpty(filePath))
                {
                    throw new NoNullAllowedException(StringManager.IsNullOrEmpty(filePath));
                }

                if (File.Exists(filePath))
                {
                    XDocument _xmlPackageDocument = XDocument.Load(filePath);
                    Deserialize(_xmlPackageDocument);
                }
                else
                {
                    VisualExceptionDialog.Show(new FileNotFoundException(StringManager.FileNotFound(filePath)));
                }
            }
            catch (WebException)
            {
                VisualExceptionDialog.Show(new FileNotFoundException(StringManager.RemoteFileNotFound(filePath)));
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }
Exemple #8
0
        /// <summary>
        ///     Deserialize the history log file.
        /// </summary>
        /// <param name="logFile">The file path.</param>
        private void Deserialize(XContainer logFile)
        {
            try
            {
                _historyLogs = new List <HistoryLogEntry>();

                foreach (XElement _historyLogEntries in logFile.Descendants("LogEntry"))
                {
                    var    _entryFilePath = _historyLogEntries.Descendants("FilePath").Nodes();
                    string _file          = string.Concat(_entryFilePath);

                    // var _dateModified = _historyLogEntries.Descendants("DateModified").Nodes();
                    // string _dateTime = string.Concat(_dateModified);
                    if (File.Exists(_file))
                    {
                        HistoryLogEntry _historyLogEntry = new HistoryLogEntry(_file);

                        if (!Exists(_historyLogEntry))
                        {
                            _historyLogs.Add(_historyLogEntry);
                        }
                    }
                }

                UpdateMenu();
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }
Exemple #9
0
        public void UpdateTheme(Theme theme)
        {
            try
            {
                _colorState = new ColorState
                {
                    Enabled  = theme.OtherSettings.ProgressBackground,
                    Disabled = theme.OtherSettings.ProgressDisabled
                };

                _hatch.BackColor = Color.FromArgb(0, theme.OtherSettings.HatchBackColor);
                _hatch.ForeColor = Color.FromArgb(20, theme.OtherSettings.HatchForeColor);

                _progressColor = theme.OtherSettings.Progress;

                _border.Color      = theme.BorderSettings.Normal;
                _border.HoverColor = theme.BorderSettings.Hover;

                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font = theme.TextSetting.Font;

                BackColorState.Enabled  = theme.ColorStateSettings.Enabled;
                BackColorState.Disabled = theme.ColorStateSettings.Disabled;
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
        public void UpdateTheme(Theme theme)
        {
            try
            {
                Border.Color      = theme.BorderSettings.Normal;
                Border.HoverColor = theme.BorderSettings.Hover;

                CheckStyle.CheckColor = theme.OtherSettings.Progress;

                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font = theme.TextSetting.Font;

                BoxColorState.Enabled  = theme.ColorStateSettings.Enabled;
                BoxColorState.Disabled = theme.ColorStateSettings.Disabled;
                BoxColorState.Hover    = theme.ColorStateSettings.Hover;
                BoxColorState.Pressed  = theme.ColorStateSettings.Pressed;
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
        /// <summary>Retrieves the adjusted <see cref="Control" />-<see cref="Size" />.</summary>
        /// <param name="height">The height.</param>
        /// <returns>The <see cref="Size" />.</returns>
        private Size GetAdjustedSize(int height = 25)
        {
            try
            {
                var _x = 0;

                if (_helpButton.Visible)
                {
                    _x += _helpButton.Width;
                }

                if (_minimizeButton.Visible)
                {
                    _x += _minimizeButton.Width;
                }

                if (_maximizeButton.Visible)
                {
                    _x += _maximizeButton.Width;
                }

                if (_closeButton.Visible)
                {
                    _x += _closeButton.Width;
                }

                return(new Size(_x, height));
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
                return(new Size(25, 25));
            }
        }
        public void UpdateTheme(Theme theme)
        {
            try
            {
                _border.Color      = theme.ColorPalette.BorderNormal;
                _border.HoverColor = theme.ColorPalette.BorderHover;

                _foreColor          = theme.ColorPalette.TextEnabled;
                _textDisabledColor  = theme.ColorPalette.TextDisabled;
                _textStyle.Enabled  = theme.ColorPalette.TextEnabled;
                _textStyle.Disabled = theme.ColorPalette.TextDisabled;

                _borderEdge.BackColor = theme.ColorPalette.BorderNormal;

                _backColorState = new ColorState {
                    Enabled = theme.ColorPalette.VisualComboBoxEnabled, Disabled = theme.ColorPalette.VisualComboBoxDisabled
                };

                _buttonColor = theme.ColorPalette.ElementEnabled;

                _menuTextColor  = theme.ColorPalette.TextEnabled;
                _menuItemNormal = theme.ColorPalette.Item;
                _menuItemHover  = theme.ColorPalette.ItemHover;
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
Exemple #13
0
        public void UpdateTheme(Theme theme)
        {
            try
            {
                _border.Color      = theme.BorderSettings.Normal;
                _border.HoverColor = theme.BorderSettings.Hover;

                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font = theme.TextSetting.Font;

                _backColorState = new ColorState
                {
                    Enabled  = theme.BackgroundSettings.Type4,
                    Disabled = theme.BackgroundSettings.Type1
                };
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
        /// <summary>Read the resource from the file.</summary>
        /// <param name="file">The file path.</param>
        /// <param name="resource">The resource name.</param>
        /// <returns>The <see cref="string" />.</returns>
        internal static string ReadResource(string file, string resource)
        {
            Assembly _assembly = LoadAssembly(file);

            try
            {
                string result;
                using (Stream stream = _assembly.GetManifestResourceStream(resource))
                    using
                    (StreamReader reader = new StreamReader(stream))
                    {
                        result = reader.ReadToEnd();
                    }

                return(result);
            }
            catch (ArgumentNullException e)
            {
                // Value cannot be null.Parameter name: stream'
                // The embedded resource cannot be found. Set type to 'Embedded Resource'.
                VisualExceptionDialog.Show(e);
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            return(null);
        }
Exemple #15
0
        /// <summary>Loads the <see cref="Theme" /> from the file path.</summary>
        /// <param name="filePath">The file path.</param>
        public void Load(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new NoNullAllowedException(ExceptionMessenger.IsNullOrEmpty(filePath));
            }

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(ExceptionMessenger.FileNotFound(filePath));
            }

            try
            {
                if (File.Exists(filePath))
                {
                    XDocument _themeDocument = XDocument.Load(filePath);
                    _rawTheme = File.ReadAllText(filePath);
                    Deserialize(_themeDocument);
                }
                else
                {
                    VisualExceptionDialog.Show(new FileNotFoundException(ExceptionMessenger.FileNotFound(filePath)));
                }
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }
        public void UpdateTheme(Theme theme)
        {
            try
            {
                _border.Color      = theme.BorderSettings.Normal;
                _border.HoverColor = theme.BorderSettings.Hover;

                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font = theme.TextSetting.Font;

                _borderEdge.BackColor    = theme.BorderSettings.Normal;
                _borderButtons.BackColor = theme.OtherSettings.Line;

                _buttonForeColor = theme.OtherSettings.LightText;
                _buttonFont      = new Font(theme.TextSetting.Font.FontFamily, 14, FontStyle.Bold);
                _buttonColor     = theme.BackgroundSettings.Type2;

                _colorState = new ColorState
                {
                    Enabled  = theme.BackgroundSettings.Type2,
                    Disabled = theme.BackgroundSettings.Type1
                };
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
Exemple #17
0
        public void UpdateTheme(Theme theme)
        {
            try
            {
                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font = theme.TextSetting.Font;

                _colorState = new ColorState
                {
                    Enabled  = theme.BackgroundSettings.Type3,
                    Disabled = theme.OtherSettings.ControlDisabled
                };

                _progress = theme.OtherSettings.Progress;
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
Exemple #18
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics _graphics = e.Graphics;

            _graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            try
            {
                Size _stringSize;

                Color _backColor = ControlColorState.BackColorState(_backColorState, Enabled, MouseState);
                Color _foreColor = ControlColorState.BackColorState(_foreColorState, Enabled, MouseState);

                _graphics.FillRectangle(new SolidBrush(_backColor), ClientRectangle);

                switch (_boxType)
                {
                case ControlBoxType.Default:
                {
                    Font _specialFont = new Font("Marlett", 12);
                    _stringSize = GraphicsManager.MeasureText(Text, _specialFont, _graphics);
                    Point _location = new Point(((Width / 2) - (_stringSize.Width / 2)) + _offsetLocation.X, ((Height / 2) - (_stringSize.Height / 2)) + _offsetLocation.Y);

                    _graphics.DrawString(Text, _specialFont, new SolidBrush(_foreColor), _location);
                    break;
                }

                case ControlBoxType.Image:
                {
                    Point _location = new Point(((Width / 2) - (_image.Width / 2)) + _offsetLocation.X, ((Height / 2) - (_image.Height / 2)) + _offsetLocation.Y);
                    _graphics.DrawImage(_image, _location);
                    break;
                }

                case ControlBoxType.Text:
                {
                    _stringSize = GraphicsManager.MeasureText(Text, Font, _graphics);
                    Point _location = new Point(((Width / 2) - (_stringSize.Width / 2)) + _offsetLocation.X, ((Height / 2) - (_stringSize.Height / 2)) + _offsetLocation.Y);

                    _graphics.DrawString(Text, Font, new SolidBrush(_foreColor), _location);
                    break;
                }

                default:
                {
                    throw new ArgumentOutOfRangeException(nameof(_boxType), _boxType, null);
                }
                }
            }
            catch (Exception exception)
            {
                VisualExceptionDialog.Show(exception);
            }
        }
Exemple #19
0
 /// <summary>
 ///     Background worker checks for updates.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The event args.</param>
 private void BackgroundUpdateCheckerDoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         _state = UpdaterState.Checking;
         OnCheckingForUpdate(new UpdaterStateEventArgs(GetEntryAssembly, _installOptions, _updateServerPackagePath, _state));
     }
     catch (Exception exception)
     {
         VisualExceptionDialog.Show(exception);
     }
 }
Exemple #20
0
 /// <summary>Loads a <see cref="Theme" /> from resources.</summary>
 /// <param name="theme">The theme.</param>
 private void LoadThemeFromResources(Themes theme)
 {
     try
     {
         _rawTheme = ResourceManager.ReadResource(Assembly.GetExecutingAssembly().Location, $"VisualPlus.Resources.Themes.{theme.ToString()}.xml");
         XDocument _resourceDocumentTheme = XDocument.Parse(_rawTheme);
         Deserialize(_resourceDocumentTheme);
     }
     catch (Exception e)
     {
         VisualExceptionDialog.Show(e);
     }
 }
        /// <summary>Loads the assembly file.</summary>
        /// <param name="file">The file path.</param>
        /// <returns>The <see cref="Assembly" />.</returns>
        private static Assembly LoadAssembly(string file)
        {
            if (string.IsNullOrEmpty(file))
            {
                VisualExceptionDialog.Show(new NoNullAllowedException(ExceptionMessenger.IsNullOrEmpty(file)));
            }

            if (!File.Exists(file))
            {
                VisualExceptionDialog.Show(new NoNullAllowedException(ExceptionMessenger.FileNotFound(file)));
            }

            return(Assembly.LoadFile(file));
        }
Exemple #22
0
        /// <summary>
        ///     Deserialize the settings file.
        /// </summary>
        /// <param name="settingsFile">The settings document.</param>
        private void Deserialize(XContainer settingsFile)
        {
            try
            {
                _updaterSettings.AutoUpdate                 = Convert.ToBoolean(string.Concat(settingsFile.Descendants("AutoUpdate").Nodes()));
                _updaterSettings.DisplayWelcomePage         = Convert.ToBoolean(string.Concat(settingsFile.Descendants("DisplayWelcomePage").Nodes()));
                _updaterSettings.NotifyUpdateAvailable      = Convert.ToBoolean(string.Concat(settingsFile.Descendants("NotifyUpdateAvailable").Nodes()));
                _updaterSettings.NotifyUpdateReadyToInstall = Convert.ToBoolean(string.Concat(settingsFile.Descendants("NotifyBeforeInstallingUpdates").Nodes()));

                _applicationSettings.MaxRecentProjects = Convert.ToInt32(string.Concat(settingsFile.Descendants("MaxRecentProjects").Nodes()));
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }
Exemple #23
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            try
            {
                Graphics _graphics = e.Graphics;
                _graphics.Clear(Parent.BackColor);
                _graphics.SmoothingMode     = SmoothingMode.HighQuality;
                _graphics.TextRenderingHint = TextStyle.TextRenderingHint;
                Rectangle _clientRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1);
                ControlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _border);
                _graphics.FillRectangle(new SolidBrush(BackColor), new Rectangle(ClientRectangle.X - 1, ClientRectangle.Y - 1, ClientRectangle.Width + 1, ClientRectangle.Height + 1));

                Color _backColor = ControlColorState.BackColorState(BackColorState, Enabled, MouseState);

                e.Graphics.SetClip(ControlGraphicsPath);
                VisualBackgroundRenderer.DrawBackground(e.Graphics, _backColor, BackgroundImage, MouseState, _clientRectangle, _border);

                Color _textColor = Enabled ? ForeColor : TextStyle.Disabled;

                if (_image != null)
                {
                    VisualControlRenderer.DrawContent(e.Graphics, ClientRectangle, Text, Font, _textColor, _image, _image.Size, _textImageRelation);
                }
                else
                {
                    StringFormat _stringFormat = new StringFormat
                    {
                        Alignment     = _textAlignment,
                        LineAlignment = _textLineAlignment
                    };

                    VisualControlRenderer.DrawContentText(e.Graphics, ClientRectangle, Text, Font, _textColor, _stringFormat);
                }

                VisualBorderRenderer.DrawBorderStyle(e.Graphics, _border, ControlGraphicsPath, MouseState);
                DrawAnimation(e.Graphics);
                e.Graphics.ResetClip();
            }
            catch (Exception exception)
            {
                VisualExceptionDialog.Show(exception);
            }
        }
Exemple #24
0
        public void UpdateTheme(Theme theme)
        {
            try
            {
                ForeColor          = theme.TextSetting.Enabled;
                TextStyle.Enabled  = theme.TextSetting.Enabled;
                TextStyle.Disabled = theme.TextSetting.Disabled;

                Font = theme.TextSetting.Font;
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }

            Invalidate();
            OnThemeChanged(new ThemeEventArgs(theme));
        }
Exemple #25
0
        /// <summary>
        ///     Checking for update.
        /// </summary>
        /// <param name="e">The sender.</param>
        protected virtual void OnCheckingForUpdate(UpdaterStateEventArgs e)
        {
            if (_state == UpdaterState.Outdated)
            {
                CheckingForUpdate?.Invoke(new UpdaterStateEventArgs(GetEntryAssembly, _installOptions, _updateServerPackagePath, _state));
                return;
            }

            CheckingForUpdate?.Invoke(new UpdaterStateEventArgs(GetEntryAssembly, _installOptions, _updateServerPackagePath, _state));
            if (NetworkManager.InternetAvailable)
            {
                if (NetworkManager.SourceExists(e.PackagePath.OriginalString))
                {
                    if (ApplicationManager.CheckForUpdate(e.Assembly, e.PackagePath))
                    {
                        _updateAvailable = true;
                        NotificationUpdateAvailable();
                        _state = UpdaterState.Outdated;
                        CheckingForUpdate?.Invoke(new UpdaterStateEventArgs(GetEntryAssembly, _installOptions, _updateServerPackagePath, _state));
                    }
                    else
                    {
                        _updateAvailable = false;
                        _state           = UpdaterState.Updated;
                        CheckingForUpdate?.Invoke(new UpdaterStateEventArgs(GetEntryAssembly, _installOptions, _updateServerPackagePath, _state));
                    }
                }
                else
                {
                    _state           = UpdaterState.PackageNotFound;
                    _updateAvailable = false;
                    CheckingForUpdate?.Invoke(new UpdaterStateEventArgs(GetEntryAssembly, _installOptions, _updateServerPackagePath, _state));
                    VisualExceptionDialog.Show(new FileNotFoundException(StringManager.RemoteFileNotFound(e.PackagePath.OriginalString)));
                }
            }
            else
            {
                _state           = UpdaterState.NoConnection;
                _updateAvailable = false;
                CheckingForUpdate?.Invoke(new UpdaterStateEventArgs(GetEntryAssembly, _installOptions, _updateServerPackagePath, _state));
            }

            _backgroundUpdateChecker.CancelAsync();
        }
Exemple #26
0
        /// <summary>Draws the selector.</summary>
        /// <param name="graphics">The specified graphics to draw on.</param>
        /// <param name="selectorType">The selector Type.</param>
        private void DrawSelector(Graphics graphics, SelectorTypes selectorType)
        {
            if (_selectorVisible)
            {
                try
                {
                    for (var tabIndex = 0; tabIndex <= TabCount - 1; tabIndex++)
                    {
                        VisualTabPage _tabPage = (VisualTabPage)TabPages[tabIndex];
                        _tabPage.Rectangle = GetStyledTabRectangle(tabIndex);

                        if (tabIndex == SelectedIndex)
                        {
                            switch (selectorType)
                            {
                            case SelectorTypes.Arrow:
                            {
                                DrawSelectorArrow(graphics, _tabPage.Rectangle);
                                break;
                            }

                            case SelectorTypes.Line:
                            {
                                DrawSelectorLine(graphics, _tabPage.Rectangle);
                                break;
                            }

                            default:
                            {
                                throw new ArgumentOutOfRangeException(nameof(selectorType), selectorType, null);
                            }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    VisualExceptionDialog.Show(e);
                }
            }
        }
Exemple #27
0
        /// <summary>Load a package from a uri.</summary>
        /// <param name="uri">The uri.</param>
        public void Load(Uri uri)
        {
            try
            {
                if (string.IsNullOrEmpty(uri.OriginalString))
                {
                    throw new NoNullAllowedException(StringManager.IsNullOrEmpty(uri.OriginalString));
                }

                if (!NetworkManager.IsURLFormatted(uri.OriginalString))
                {
                    throw new UriFormatException(StringManager.UrlNotWellFormatted(uri.OriginalString));
                }

                if (NetworkManager.InternetAvailable)
                {
                    XDocument _xmlPackageDocument = XDocument.Load(uri.OriginalString);
                    Deserialize(_xmlPackageDocument);

                    // Bug: Gets thrown on slow connection.
                    // if (!NetworkManager.SourceExists(url))
                    // {
                    // throw new FileNotFoundException(StringManager.PackageNotFound(url));
                    // }
                    // else
                    // {
                    // // Load from url
                    // XDocument _xPackage = XDocument.Load(url);
                    // Deserialize(_xPackage);
                    // }
                }
            }
            catch (WebException)
            {
                VisualExceptionDialog.Show(new FileNotFoundException(StringManager.RemoteFileNotFound(uri.OriginalString)));
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }
Exemple #28
0
        /// <summary>
        ///     Saves the settings to file.
        /// </summary>
        public void Save()
        {
            try
            {
                XDocument _settingsDocument = new XDocument();
                XElement  _headerElement    = new XElement("Settings");
                _settingsDocument.Add(_headerElement);

                _headerElement.Add(new XElement("AutoUpdate", _updaterSettings.AutoUpdate));
                _headerElement.Add(new XElement("NotifyUpdateAvailable", _updaterSettings.NotifyUpdateAvailable));
                _headerElement.Add(new XElement("NotifyBeforeInstallingUpdates", _updaterSettings.NotifyUpdateReadyToInstall));
                _headerElement.Add(new XElement("DisplayWelcomePage", _updaterSettings.DisplayWelcomePage));

                _headerElement.Add(new XElement("MaxRecentProjects", _applicationSettings.MaxRecentProjects));

                _settingsDocument.Save(FilePath, SaveOptions.None);
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }
Exemple #29
0
        /// <summary>Load a package from filename.</summary>
        /// <param name="path">The file path</param>
        /// <param name="encoding">The encoding.</param>
        public void Load(string path, Encoding encoding)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new NoNullAllowedException(StringManager.IsNullOrEmpty(path));
            }

            if (!File.Exists(path))
            {
                throw new FileNotFoundException(StringManager.FileNotFound(path));
            }

            try
            {
                XDocument _packageFile = XDocument.Parse(File.ReadAllText(path, encoding));
                Deserialize(_packageFile);
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }
Exemple #30
0
        /// <summary>Prevents a default instance of the <see cref="StyleManager" /> class from being created.</summary>
        private StyleManager()
        {
            try
            {
                ConstructDefaultThemeFile();

                if (_customThemePath == null)
                {
                    string _themePath = Settings.TemplatesFolder + @"DefaultTheme.xml";
                    _theme           = new Theme(_themePath);
                    _customThemePath = _themePath;
                }

                _formCollection = new List <Form>();

                _themeType = Settings.DefaultValue.DefaultStyle;
                _theme     = new Theme(_themeType);
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }