Example #1
0
 protected virtual void OnWindowStartupLocationChanged( WindowStartupLocation oldValue, WindowStartupLocation newValue )
 {
   // TODO: Add your property changed side-effects. Descendants can override as well.
 }
Example #2
0
 public static void SetWindowStartupLocation(DependencyObject element, WindowStartupLocation value)
 {
     element.SetValue(WindowStartupLocationProperty, value);
 }
Example #3
0
 private static bool IsValidWindowStartupLocation(WindowStartupLocation value)
 {
     return value == WindowStartupLocation.CenterOwner
         || value == WindowStartupLocation.CenterScreen
         || value == WindowStartupLocation.Manual;
 }
Example #4
0
        public static void DisplayException(Exception e, Window owner, WindowStartupLocation windowStartupLocation)
        {
            UiInvoke(() =>
            {
                string fileName = "pshandler_error_" + DateTime.Now.Ticks + ".log";

                StringBuilder sbFile = new StringBuilder();
                sbFile.AppendLine("Message: " + e.Message);
                sbFile.AppendLine("Type: " + e.GetType());
                sbFile.AppendLine("Data: " + e.Data);
                sbFile.AppendLine("HResult: " + e.HResult);
                sbFile.AppendLine("HelpLink: " + e.HelpLink);
                sbFile.AppendLine("InnerException: " + e.InnerException);
                sbFile.AppendLine("Source: " + e.Source);
                sbFile.AppendLine("TargetSite: " + e.TargetSite);
                sbFile.AppendLine("StackTrace:");
                sbFile.AppendLine();
                sbFile.AppendLine(e.StackTrace);

                File.WriteAllText(fileName, sbFile.ToString());

                StringBuilder sbMessageBox = new StringBuilder();
                sbMessageBox.AppendLine(e.Message);
                sbMessageBox.AppendLine();
                sbMessageBox.AppendLine(e.GetType().ToString());
                sbMessageBox.AppendLine();
                sbMessageBox.AppendLine("Log file: " + fileName);

                WindowMessage.ShowDialog(sbMessageBox.ToString(), "Error", WindowMessageButtons.OK, WindowMessageImage.Error, owner, windowStartupLocation);
            });
        }
        public WindowMessage(string message, string title, WindowMessageButtons buttons, WindowMessageImage image, Window owner, WindowStartupLocation windowStartupLocation, WindowMessageTextType windowMessageTextType, FontFamily fontFamily = null, double fontSize = 12)
        {
            InitializeComponent();

            if (owner != null)
            {
                Owner = owner;
            }
            WindowStartupLocation = windowStartupLocation;

            Title = title;
            TextBlock_Message.Text = message;
            TextBox_Message.Text = message;
            TextBlock_Message.FontSize = fontSize;
            TextBox_Message.FontSize = fontSize;

            switch (windowMessageTextType)
            {
                case WindowMessageTextType.TextBlock:
                    TextBlock_Message.Visibility = Visibility.Visible;
                    TextBox_Message.Visibility = Visibility.Collapsed;
                    break;
                case WindowMessageTextType.TextBox:
                    TextBlock_Message.Visibility = Visibility.Collapsed;
                    TextBox_Message.Visibility = Visibility.Visible;
                    break;
            }

            Image_Error.Visibility = Visibility.Collapsed;
            Image_Information.Visibility = Visibility.Collapsed;
            Image_Question.Visibility = Visibility.Collapsed;
            Image_Warning.Visibility = Visibility.Collapsed;
            switch (image)
            {
                case WindowMessageImage.Error:
                    Image_Error.Visibility = Visibility.Visible;
                    break;
                case WindowMessageImage.Information:
                    Image_Information.Visibility = Visibility.Visible;
                    break;
                case WindowMessageImage.Question:
                    Image_Question.Visibility = Visibility.Visible;
                    break;
                case WindowMessageImage.Warning:
                    Image_Warning.Visibility = Visibility.Visible;
                    break;
                default:
                    break;
            }

            Button_OK.Visibility = Visibility.Collapsed;
            Button_Yes.Visibility = Visibility.Collapsed;
            Button_No.Visibility = Visibility.Collapsed;
            Button_Cancel.Visibility = Visibility.Collapsed;
            switch (buttons)
            {
                case WindowMessageButtons.OK:
                    Button_OK.Visibility = Visibility.Visible;
                    break;
                case WindowMessageButtons.OKCancel:
                    Button_OK.Visibility = Visibility.Visible;
                    Button_OK.Margin = new Thickness(0, 0, 5, 0);
                    Button_Cancel.Visibility = Visibility.Visible;
                    break;
                case WindowMessageButtons.YesNo:
                    Button_Yes.Visibility = Visibility.Visible;
                    Button_Yes.Margin = new Thickness(0, 0, 5, 0);
                    Button_No.Visibility = Visibility.Visible;
                    break;
                case WindowMessageButtons.YesNoCancel:
                    Button_Yes.Visibility = Visibility.Visible;
                    Button_Yes.Margin = new Thickness(0, 0, 5, 0);
                    Button_No.Visibility = Visibility.Visible;
                    Button_No.Margin = new Thickness(0, 0, 5, 0);
                    Button_Cancel.Visibility = Visibility.Visible;
                    break;
                default:
                    Button_OK.Visibility = Visibility.Visible;
                    break;
            }

            if (fontFamily != null)
            {
                TextBlock_Message.FontFamily = fontFamily;
                TextBox_Message.FontFamily = fontFamily;
            }
        }
 public static WindowMessageResult ShowDialog(string message, string title, WindowMessageButtons buttons, WindowMessageImage image, Window owner,
     WindowStartupLocation windowStartupLocation = WindowStartupLocation.CenterOwner, WindowMessageTextType windowMessageTextType = WindowMessageTextType.TextBlock, FontFamily fontFamily = null, double fontSize = 12)
 {
     WindowMessage windowMessage = new WindowMessage(message, title, buttons, image, owner, windowStartupLocation, windowMessageTextType, fontFamily, fontSize);
     ((Window)windowMessage).ShowDialog();
     return windowMessage.Result;
 }
 public WindowSettingsBuilder WithStartupLocation(WindowStartupLocation startupLocation)
 {
     settings.WindowStartupLocation = startupLocation;
     return this;
 }
Example #8
0
 /// <summary>
 /// Provides derived classes an opportunity to handle changes
 /// to the WindowStartupLocation property.
 /// </summary>
 /// <param name="oldWindowStartupLocation">The old WindowStartupLocation value</param>
 /// <param name="newWindowStartupLocation">The new WindowStartupLocation value</param>
 protected virtual void OnWindowStartupLocationChanged(
     WindowStartupLocation oldWindowStartupLocation, WindowStartupLocation newWindowStartupLocation)
 {
 }