コード例 #1
0
ファイル: MainForm.cs プロジェクト: tanmoydeb07/LiteDevelop
        private bool SaveUnsavedFiles(ISavableFile[] unsavedItems)
        {
            if (unsavedItems.Length > 0)
            {
                using (var dialog = new UnsavedFilesDialog(unsavedItems))
                {
                    switch (dialog.ShowDialog())
                    {
                    case System.Windows.Forms.DialogResult.Yes:
                        foreach (var item in dialog.GetItemsToSave())
                        {
                            item.Save(_extensionHost.CreateOrGetReporter("Build"));
                        }
                        break;

                    case System.Windows.Forms.DialogResult.No:
                        break;

                    case System.Windows.Forms.DialogResult.Cancel:
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: lanicon/LiteDevelop
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            (_extensionHost.ControlManager as ControlManager).NotifyUnsavedFilesWhenClosing = false;

            var unsavedItems = GetUnsavedItems();

            if (unsavedItems.Length > 0)
            {
                using (var dialog = new UnsavedFilesDialog(unsavedItems))
                {
                    switch (dialog.ShowDialog())
                    {
                    case System.Windows.Forms.DialogResult.Yes:
                        foreach (var item in dialog.GetItemsToSave())
                        {
                            item.Save(_extensionHost.CreateOrGetReporter("Build"));
                        }
                        break;

                    case System.Windows.Forms.DialogResult.No:
                        break;

                    case System.Windows.Forms.DialogResult.Cancel:
                        e.Cancel = true;
                        break;
                    }
                }
            }

            if (!e.Cancel)
            {
                SaveDockPanelState();
                Rectangle usingBounds = (WindowState == FormWindowState.Normal ? this.Bounds : this.RestoreBounds);
                LiteDevelopSettings.Instance.SetValue("MainWindow.Location", usingBounds.Location);
                LiteDevelopSettings.Instance.SetValue("MainWindow.Size", usingBounds.Size);
                LiteDevelopSettings.Instance.SetValue("MainWindow.Maximized", WindowState == FormWindowState.Maximized);
            }

            (_extensionHost.ControlManager as ControlManager).NotifyUnsavedFilesWhenClosing = true;
        }
コード例 #3
0
 private void ViewContent_Closing(object sender, System.Windows.Forms.FormClosingEventArgs e)
 {
     var documentContent = DocumentContent;
     if (_extensionHost.ControlManager.NotifyUnsavedFilesWhenClosing && documentContent != null && documentContent.AssociatedFile != null)
     {
         if (documentContent.AssociatedFile.HasUnsavedData)
         {
             var dialog = new UnsavedFilesDialog(new OpenedFile[1] { documentContent.AssociatedFile });
             switch (dialog.ShowDialog())
             {
                 case DialogResult.Yes:
                     dialog.GetItemsToSave()[0].Save(_extensionHost.CreateOrGetReporter("Build"));
                     break;
                 case DialogResult.Cancel:
                     e.Cancel = true;
                     break;
             }
         }
     }
 }