Exemplo n.º 1
0
        /// <summary>
        /// Manage the closing, for exemple saving dirty document
        /// </summary>
        /// <param name="e"></param>
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            //document never saved
            if (string.IsNullOrEmpty(Context.FullName))
            {
                MessageBoxResult answer = MessageBoxDlg.Show(
                    ReflectionStudio.Properties.Resources.MSG_PRJ_ASK_SAVE,
                    ReflectionStudio.Properties.Resources.MSG_TITLE,
                    MessageBoxButton.YesNoCancel,
                    MessageBoxImage.Question);

                if (answer == MessageBoxResult.Yes)
                {
                    ApplicationCommands.Save.Execute(this, Application.Current.MainWindow);
                }

                if (answer == MessageBoxResult.Cancel)
                {
                    e.Cancel = true;
                }
            }

            //document is dirty ??

            base.OnClosing(e);
        }
        private void OnGetCaptureCommand(object sender, ExecutedRoutedEventArgs e)
        {
            e.Handled = true;

            //message
            MessageBoxResult answer = MessageBoxDlg.Show(ReflectionStudio.Properties.Resources.MSG_DELETE_DISTANT_SNAP,
                                                         ReflectionStudio.Properties.Resources.MSG_TITLE,
                                                         MessageBoxButton.YesNoCancel,
                                                         MessageBoxImage.Error);

            DistantSnapshotService.Instance.RetreiveCapture(null, answer == MessageBoxResult.No ? false : true);
        }
 private void BtnDownload_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if (DistantSnapshotService.Instance.RetreiveCapture(dataGridSnap.SelectedItem.ToString(), true))
     {
         //message
         MessageBoxResult answer = MessageBoxDlg.Show(
             ReflectionStudio.Properties.Resources.MSG_SNAP_RETREIVE_SUCCESS,
             ReflectionStudio.Properties.Resources.MSG_TITLE,
             MessageBoxButton.OK,
             MessageBoxImage.Information);
     }
 }
        private void BtnDelete_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (DistantSnapshotService.Instance.DeleteCapture(dataGridSnap.SelectedItem.ToString()))
            {
                dataGridSnap.Items.RemoveAt(dataGridSnap.SelectedIndex);

                //message
                MessageBoxDlg.Show(
                    ReflectionStudio.Properties.Resources.MSG_SNAP_DELETE_SUCCESS,
                    ReflectionStudio.Properties.Resources.MSG_TITLE,
                    MessageBoxButton.OK,
                    MessageBoxImage.Information);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Displays a message box with specified text
        /// </summary>
        /// <param name="text">The text to display in the message box</param>
        /// <param name="caption">The text to display in the message box</param>
        /// <param name="buttons">
        /// One of the System.Windows.Forms.MessageBoxButtons values that specifies which
        /// buttons to display in the message box</param>
        /// <param name="icon">
        /// One of the System.Windows.Forms.MessageBoxIcon values that specifies which
        /// icon to display in the message box</param>
        /// <param name="defaultButton">
        /// One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies
        /// the default button for the message box</param>
        /// <returns>One of the System.Windows.Forms.DialogResult values</returns>
        public static DialogResult Show(string text, string caption,
                                        MessageBoxButtons buttons, MessageBoxIcon icon,
                                        MessageBoxDefaultButton defaultButton)
        {
            using (var form = new MessageBoxDlg(text, caption, buttons, icon))
            {
                if (Environment.OSVersion.Platform != PlatformID.WinCE)
                {
                    form.Show();
                }
                else
                {
                    return(form.ShowDialog());
                }
                //MessageBox.Show(text, caption, buttons, icon, defaultButton);
            }

            return(DialogResult.OK);
        }
        /// <summary>
        /// Execute for AddDataSource command, display the provider dialog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void AddDataSourceCommandHandler(object sender, ExecutedRoutedEventArgs e)
        {
            e.Handled = true;

            //load the providers?
            if (Providers.Count > 0)
            {
                //display the dialog
                ProviderChoiceDialog providerDlg = new ProviderChoiceDialog();
                providerDlg.Owner       = Application.Current.MainWindow;
                providerDlg.DataContext = Providers;

                //if ok, display the dialog from selected provider
                if (providerDlg.ShowDialog() == true)
                {
                    //if ok, create the source
                    IDbSourcePanel providerNewSourcePanel = providerDlg.SelectedProvider.GetSourcePanelInterface() as IDbSourcePanel;

                    //display the dialog
                    NewDataSourceDialog sourceDlg = new NewDataSourceDialog();
                    sourceDlg.Owner       = Application.Current.MainWindow;
                    sourceDlg.SourcePanel = providerNewSourcePanel;

                    if (sourceDlg.ShowDialog() == true)
                    {
                        // will add a new source to the workspace
                        AddSource(providerNewSourcePanel.SourceName, providerDlg.SelectedProvider, providerNewSourcePanel.ConnectionString);
                    }
                }
            }
            else
            {
                //warning
                MessageBoxDlg.Show(ReflectionStudio.Properties.Resources.MSG_NO_DBPROVIDER,
                                   ReflectionStudio.Properties.Resources.MSG_TITLE,
                                   MessageBoxButton.OK,
                                   MessageBoxImage.Warning);
            }
        }
Exemplo n.º 7
0
        private bool CloseProject()
        {
            Tracer.Verbose("MainWindow:CloseProject", "START");

            bool bIsClosed = false;

            try
            {
                if (ProjectService.Instance.Current == null)
                {
                    return(true);
                }

                if (ProjectService.Instance.Current.IsChanged)
                {
                    while (!bIsClosed)
                    {
                        //message
                        MessageBoxResult answer = MessageBoxDlg.Show(
                            ReflectionStudio.Properties.Resources.MSG_PRJ_ASK_SAVE,
                            ReflectionStudio.Properties.Resources.MSG_TITLE,
                            MessageBoxButton.YesNoCancel,
                            MessageBoxImage.Error);

                        if (answer == MessageBoxResult.No)
                        {
                            bIsClosed = true;
                        }

                        if (answer == MessageBoxResult.Yes)
                        {
                            bIsClosed = ProjectService.Instance.Save();
                        }

                        if (answer == MessageBoxResult.Cancel)
                        {
                            bIsClosed = false;
                        }
                    }
                }
                else
                {
                    bIsClosed = true;
                }

                if (bIsClosed)
                {
                    bIsClosed = ProjectService.Instance.Close();
                }

                return(bIsClosed);
            }
            catch (Exception err)
            {
                Tracer.Error("MainWindow.CloseProject", err);
                return(false);
            }
            finally
            {
                Tracer.Verbose("MainWindow:CloseProject", "END");
            }
        }