예제 #1
0
        private void PluginControl_Load(object sender, EventArgs e)
        {
            // Loads or creates the settings for the plugin
            if (!SettingsManager.Instance.TryLoad(GetType(), out Settings settings))
            {
                settings = new Settings();
            }

            Settings.Instance = settings;

            tsbIncludeFetchXml.Checked = settings.IncludeFetchXml;

            if (settings.RememberSession && settings.Session != null)
            {
                foreach (var doc in dockPanel.Documents.OfType <Form>().ToArray())
                {
                    doc.Close();
                }

                foreach (var tab in settings.Session)
                {
                    IDocumentWindow query = null;

                    switch (tab.Type)
                    {
                    case "SQL":
                        query = CreateQuery(_objectExplorer.SelectedConnection, null);
                        break;

                    case "FetchXML":
                        query = CreateFetchXML(null);
                        break;

                    case "M":
                        query = CreateM(null);
                        break;

                    default:
                        continue;
                    }

                    try
                    {
                        query.RestoreSessionDetails(tab);
                    }
                    catch
                    {
                        ((Form)query).Close();
                    }
                }
            }
            else
            {
                tsbNewQuery_Click(this, EventArgs.Empty);
            }
        }
예제 #2
0
            internal static WindowConfig FromDocumentWindow(IDocumentWindow window)
            {
                var document = window.Document;

                return(new WindowConfig()
                {
                    RealFileName = document.RealFileName,
                    Type = window.GetType(),
                    SpecialMode = document.SpecialMode
                });
            }
예제 #3
0
 internal CocoStudio.Core.Document FindDocument(IDocumentWindow window)
 {
     foreach (CocoStudio.Core.Document document in this.Documents)
     {
         if (document.Window == window)
         {
             return(document);
         }
     }
     return((CocoStudio.Core.Document)null);
 }
예제 #4
0
        private void OnWindowClosed(object sender, DocumentWindowEventArgs e)
        {
            IDocumentWindow window = (IDocumentWindow)sender;

            CocoStudio.Core.Document document = this.FindDocument(window);
            window.Closing -= new EventHandler <DocumentWindowEventArgs>(this.OnWindowClosing);
            window.Closed  -= new EventHandler <DocumentWindowEventArgs>(this.OnWindowClosed);
            this.documents.Remove(document);
            this.OnDocumentClosed(document);
            document.DisposeDocument();
        }
예제 #5
0
 public void RemoveTab(MonoDevelop.Components.DockNotebook.DockNotebook tabControl, int pageNum, bool animate)
 {
     try
     {
         this.LockActiveWindowChangeEvent();
         IDocumentWindow activeWorkbenchWindow = this.ActiveWorkbenchWindow;
         tabControl.RemoveTab(pageNum, animate);
     }
     finally
     {
         this.UnlockActiveWindowChangeEvent();
     }
 }
예제 #6
0
        internal protected virtual void OnShowTitleContextMenu(IDocumentWindow caller, KryptonContextMenuItems items)
        {
            if (!string.IsNullOrEmpty(RealFileName))
            {
                //var documentWindow = caller as DocumentWindow;
                //var workspaceWindow = caller as WorkspaceWindow;
                //bool isFirstLevel = ( documentWindow != null && !documentWindow.IsWindowInWorkspace ) || workspaceWindow != null;

                //if( isFirstLevel )
                {
                    items.Items.Add(new KryptonContextMenuItem(EditorLocalization.Translate("General", "Find in Resources window"), (s, e) =>
                    {
                        EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow(new string[] { RealFileName });
                        EditorAPI.SelectDockWindow(EditorAPI.FindWindow <ResourcesWindow>());
                    }));
                }

                //!!!!

                //!!!!только редактору сцен

                //if( caller is DocumentWindow )
                //{

                //	var item = new KryptonContextMenuItem( EditorLocalization.Translate( "General", "Use Camera" ), null );

                //	var items2 = new List<KryptonContextMenuItemBase>();

                //	items2.Add( new KryptonContextMenuItem( "Default", ( s, e ) =>
                //	{
                //		//EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow( new string[] { RealFileName } );
                //	} ) );

                //	items2.Add( new KryptonContextMenuItem( "Camera 1", ( s, e ) =>
                //	{
                //		//EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow( new string[] { RealFileName } );
                //	} ) );

                //	items2.Add( new KryptonContextMenuItem( "Camera 2", ( s, e ) =>
                //	{
                //		//EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow( new string[] { RealFileName } );
                //	} ) );

                //	item.Items.Add( new KryptonContextMenuItems( items2.ToArray() ) );
                //	items.Items.Add( item );
                //}
            }
        }
예제 #7
0
 internal CocoStudio.Core.Document WrapDocument(IDocumentWindow window)
 {
     if (window == null)
     {
         return((CocoStudio.Core.Document)null);
     }
     CocoStudio.Core.Document document = this.FindDocument(window);
     if (document != null)
     {
         return(document);
     }
     CocoStudio.Core.Document doc = new CocoStudio.Core.Document(window);
     window.Closing += new EventHandler <DocumentWindowEventArgs>(this.OnWindowClosing);
     window.Closed  += new EventHandler <DocumentWindowEventArgs>(this.OnWindowClosed);
     this.documents.Add(doc);
     doc.OnDocumentAttached();
     this.OnDocumentOpened(new DocumentEventArgs(doc));
     return(doc);
 }
예제 #8
0
 private void SetWorkbenchTitle()
 {
     try
     {
         IDocumentWindow activeWorkbenchWindow = this.ActiveWorkbenchWindow;
         if (activeWorkbenchWindow != null)
         {
             if (activeWorkbenchWindow.ViewContent.IsUntitled)
             {
                 this.SetDefaultTitle();
             }
             else
             {
                 string str = string.Empty;
                 if (activeWorkbenchWindow.ViewContent.IsDirty)
                 {
                     str = "*";
                 }
                 if (activeWorkbenchWindow.ViewContent.Project != null)
                 {
                     this.Title = activeWorkbenchWindow.ViewContent.Project.Name + " - " + activeWorkbenchWindow.ViewContent.PathRelativeToProject + str + " - " + BrandingService.ApplicationName;
                 }
                 else
                 {
                     this.Title = activeWorkbenchWindow.ViewContent.ContentName + str + " - " + BrandingService.ApplicationName;
                 }
             }
         }
         else
         {
             this.SetDefaultTitle();
             if (this.IsInFullViewMode)
             {
                 this.ToggleFullViewMode();
             }
         }
     }
     catch (Exception)
     {
         this.SetDefaultTitle();
     }
 }
예제 #9
0
        private bool SelectLastActiveWindow(IDocumentWindow cur)
        {
            if (this.lastActiveWindows.Count == 0)
            {
                return(false);
            }
            IDocumentWindow documentWindow;

            do
            {
                documentWindow = this.lastActiveWindows.Last.Value;
                this.lastActiveWindows.RemoveLast();
            }while (this.lastActiveWindows.Count > 0 && (documentWindow == cur || documentWindow == null || documentWindow != null && documentWindow.ViewContent == null));
            if (documentWindow == null || documentWindow == cur)
            {
                return(false);
            }
            documentWindow.SelectWindow();
            return(true);
        }
예제 #10
0
 private void OnActiveWindowChanged(object sender, EventArgs e)
 {
     if (this.activeWindowChangeLock > 0 || this.lastActive == this.ActiveWorkbenchWindow)
     {
         return;
     }
     if (this.lastActive != null)
     {
         ((DocumentWindow)this.lastActive).OnDeactivated();
     }
     this.lastActive = this.ActiveWorkbenchWindow;
     if (!this.closeAll && this.ActiveWorkbenchWindow != null)
     {
         ((DocumentWindow)this.ActiveWorkbenchWindow).OnActivated();
     }
     Services.ProjectOperations.CurrentSelectedProject = this.lastActive == null ? (Project)null : this.lastActive.ViewContent.Project;
     if (this.closeAll || this.ActiveWorkbenchWindowChanged == null)
     {
         return;
     }
     this.ActiveWorkbenchWindowChanged((object)this, e);
 }
예제 #11
0
        private void OnWindowClosing(object sender, DocumentWindowEventArgs args)
        {
            IDocumentWindow window = (IDocumentWindow)sender;

            if (!args.Forced && window.ViewContent != null && window.ViewContent.IsDirty)
            {
                string str = "";
                if (window.ViewContent.ContentName != null)
                {
                    str = Path.GetFileName(window.ViewContent.ContentName);
                }
                switch (MessageBox.Show(string.Format(LanguageInfo.MessageBox188_AskSaveCurFile, (object)str), new ButtonText(LanguageInfo.Command_Save, LanguageInfo.Dialog_ButtonDontSave, LanguageInfo.Dialog_ButtonCancel), (Window)null, (string)null, MessageBoxImage.Info))
                {
                case MessageBoxResult.Yes:
                    if (window.ViewContent.ContentName == null)
                    {
                        this.FindDocument(window).Save();
                        args.Cancel = window.ViewContent.IsDirty;
                    }
                    else
                    {
                        try
                        {
                            window.ViewContent.Closing();
                            if (window.ViewContent.IsFile)
                            {
                                window.ViewContent.Save(window.ViewContent.ContentName);
                            }
                            else
                            {
                                window.ViewContent.Save();
                            }
                            DocumentWindowEventArgs documentWindowEventArgs = args;
                            int num = documentWindowEventArgs.Cancel | window.ViewContent.IsDirty ? 1 : 0;
                            documentWindowEventArgs.Cancel = num != 0;
                        }
                        catch (Exception ex)
                        {
                            args.Cancel = true;
                            MessageBox.Show(LanguageInfo.Output_FailedToSaveFile, (Window)null, (string)null, MessageBoxImage.Info);
                        }
                    }
                    if (args.Cancel)
                    {
                        this.FindDocument(window).Select();
                        break;
                    }
                    break;

                case MessageBoxResult.No:
                    args.Cancel = false;
                    window.ViewContent.DiscardChanges();
                    break;

                case MessageBoxResult.Cancel:
                    args.Cancel = true;
                    break;
                }
            }
            this.OnDocumentClosing(this.FindDocument(window));
        }
예제 #12
0
 public Document(IDocumentWindow window)
 {
     this.Window = window;
 }