Hi every body
i have devoloped a custom MessageBox Class to use it in other application,as below
# public partial class MessageBoxCustomized : Window
# {
#
# static MessageBoxResult _msgboxresult;
# public MessageBoxCustomized()
# {
# InitializeComponent();
# _msgboxresult = MessageBoxResult.None;
# Owner = Application.Current.MainWindow;
#
#
# }
#
# public void MessageBoxManager(MessageBoxButtonbutsta)
# {
# switch(butsta)
# {
# case MessageBoxButton.OK:
# agreeButt.Visibility = System.Windows.Visibility.Collapsed;
# cancelButt.Visibility = System.Windows.Visibility.Collapsed;
# disagreeButt.Content = "Ok";
# break;
#
# case MessageBoxButton.OKCancel:
# agreeButt.Visibility = System.Windows.Visibility.Collapsed;
# midcol.Width = new GridLength(0);
# disagreeButt.Content = "Ok";
# break;
# case MessageBoxButton.YesNo:
# cancelButt.Visibility = System.Windows.Visibility.Collapsed;
# mbgnd.Width = new GridLength(0);
# break;
# }
# }
#
# public static void Show(string msg)
# {
# MessageBoxCustomized msgBox = new MessageBoxCustomized();
# msgBox.msgTxt.Content = msg;
# msgBox.MessageBoxManager(MessageBoxButton.OK);
# System.Media.SystemSounds.Exclamation.Play();
# msgBox.ShowDialog();
#
# }
#
# public static void Show(string msg, string title)
# {
# MessageBoxCustomized msgBox = new MessageBoxCustomized();
# msgBox.msgTxt.Content = msg;
# msgBox.Title = title;
# msgBox.MessageBoxManager(MessageBoxButton.OK);
# System.Media.SystemSounds.Exclamation.Play();
# msgBox.ShowDialog();
#
# }
#
# public static MessageBoxResult Show(string msg, string title, MessageBoxButton butsta)
# {
# MessageBoxCustomized msgBox = new MessageBoxCustomized();
# msgBox.msgTxt.Content = msg;
# msgBox.Title = title;
# msgBox.MessageBoxManager(butsta);
# System.Media.SystemSounds.Exclamation.Play();
# msgBox.ShowDialog();
#
# return _msgboxresult;
# }
#
#
#
# private void agreeButt_Click(object sender, RoutedEventArgs e)
# {
# _msgboxresult=MessageBoxResult.Yes;
# Close();
# }
#
# private void disagreeButtutt_Click(object sender, RoutedEventArgs e)
# {
# if ((string)disagreeButt.Content == "Ok")
# _msgboxresult=MessageBoxResult.OK;
# else
# _msgboxresult=MessageBoxResult.No;
# Close();
#
# }
#
# private void cancelButt_Click(object sender, RoutedEventArgs e)
# {
# _msgboxresult=MessageBoxResult.Cancel;
# }
#
# private void Activate_Title_Icons(object sender, MouseEventArgs e)
# {
# Close_btn.Fill = (Brush)App.Current.Resources["Close_act"];
# }
#
# private void Deactivate_Title_Icons(object sender, MouseEventArgs e)
# {
# Close_btn.Fill = (Brush)App.Current.Resources["Close_inact"];
# }
#
# private void Close_pressing(object sender, MouseButtonEventArgs e)
# {
# Close_btn.Fill = (Brush)App.Current.Resources["Close_pr"];
# }
#
# private void EXIT(object sender, MouseButtonEventArgs e)
# {
# this.Close();// Environment.Exit(0);
# }
#
# private void titLab_MouseMove(object sender, MouseEventArgs e)
# {
# if (e.LeftButton == MouseButtonState.Pressed)
# this.DragMove();
# }
#}
and i made the application which will use it
and it work fine except in one place and it's Window_Closing handler.
here's a snapshot of my code
# private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
# {
#
# if (savingRequest == true)
# {
#
# switch (MessageBoxCustomized.Show("Save Changes", "Attention", MessageBoxButton.YesNoCancel))
# {
# case MessageBoxResult.Yes:
# {
# notifyIcon.Dispose();
# SaveTreeView();
# }
# break;
#
# case MessageBoxResult.No: notifyIcon.Dispose();
# break;
#
# case MessageBoxResult.Cancel:e.Cancel = ;true;
#
# break;
#
# }
# }
# //MessageBox.Show(
If i replce the custom MessageBox with the standard windows MessageBox it works fine as i want but when i use my custom message box the compiler skip all the code from the statement
switch (MessageBoxCustomized.Show("Save Changes", "Attention",MessageBoxButton.YesNoCancel))
and terminate the application and i don't know why and so pls advise