Beispiel #1
0
        /// <summary>
        /// Loads the window settings manually, which is useful if <see cref="AutoLoad"/> is false.
        /// </summary>
        /// <returns>True if the previous settings were re-loaded; false if no previous settings existed.</returns>
        public bool Load()
        {
            bool result = false;

            if (!WindowsUtility.IsInDesignMode(this.Window))
            {
                using (ISettingsStore store = ApplicationInfo.CreateUserSettingsStore())
                {
                    ISettingsNode?settingsNode = this.GetSettingsNode(store, false);
                    if (settingsNode != null)
                    {
                        NativeMethods.LoadWindowPlacement(this.Window, settingsNode, this.LoadStateOverride);
                        result = true;
                    }
                    else if (this.LoadStateOverride != null)
                    {
                        this.Window.WindowState = this.LoadStateOverride.Value;
                    }

                    this.LoadSettings?.Invoke(this, new SettingsEventArgs(store.RootNode));
                }
            }

            return(result);
        }
Beispiel #2
0
        private void UpdateLink_Clicked(object sender, RoutedEventArgs e)
        {
            if (this.updateLink.Tag is Release latest && WindowsUtility.ShellExecute(this, latest.HtmlUri.ToString()))
            {
                FinishLink(sender, e);
            }

            e.Handled = true;
        }
Beispiel #3
0
        private void WebLink_Clicked(object sender, RoutedEventArgs e)
        {
            if (WindowsUtility.ShellExecute(this, "http://www.menees.com"))
            {
                FinishLink(sender, e);
            }

            e.Handled = true;
        }
Beispiel #4
0
        private void OKClicked(object sender, RoutedEventArgs e)
        {
            string?error = this.validate?.Invoke(this.value.Text);

            if (error.IsEmpty())
            {
                this.DialogResult = true;
            }
            else
            {
                WindowsUtility.ShowError(this, error);
            }
        }
Beispiel #5
0
        private void EmailLink_Clicked(object sender, RoutedEventArgs e)
        {
            // UriBuilder always adds a '/' after the email address, which shows up in the opened
            // mail message's To field.  So we'll manually build a mailto-compatible Uri.
            string link = string.Format("mailto:[email protected]?subject={0} {1}", this.productName.Text, this.version.Text);

            if (WindowsUtility.ShellExecute(this, link))
            {
                FinishLink(sender, e);
            }

            e.Handled = true;
        }
Beispiel #6
0
        /// <summary>
        /// Saves the window settings manually, which is useful if <see cref="AutoSave"/> is false.
        /// </summary>
        public void Save()
        {
            if (!WindowsUtility.IsInDesignMode(this.Window))
            {
                using (ISettingsStore store = ApplicationInfo.CreateUserSettingsStore())
                {
                    ISettingsNode?settingsNode = this.GetSettingsNode(store, true);
                    if (settingsNode != null)
                    {
                        NativeMethods.SaveWindowPlacement(this.Window, settingsNode);
                    }

                    this.SaveSettings?.Invoke(this, new SettingsEventArgs(store.RootNode));

                    // Make sure the settings get saved out.
                    store.Save();
                }
            }
        }