示例#1
0
        private void MetaDataBrowser_Enter(object sender, EventArgs e)
        {
            if (IsTreeBusy)
            {
                return;
            }

            if (this.toolBar1.Visible == false)
            {
                this.toolBar1.Visible  = true;
                this.chkSystem.Visible = true;
            }

            if ((this.mdi != null) &&
                (this.mdi.DockPanel != null))
            {
                if ((this.mdi.DockPanel.ActiveDocument is IMyGenDocument) &&
                    (StaticMyMeta.IsConnected))
                {
                    IMyGenDocument doc = this.mdi.DockPanel.ActiveDocument as IMyGenDocument;
                    this.toolBarButtonExecute.Enabled = true;
                }
                else
                {
                    this.toolBarButtonExecute.Enabled = false;
                }
            }
        }
示例#2
0
        public void OpenDocuments(params string[] filenames)
        {
            foreach (var file in filenames)
            {
                var info = new FileInfo(file);

                if (!info.Exists)
                {
                    continue;
                }

                if (IsDocumentOpen(info.FullName))
                {
                    FindDocument(info.FullName).DockContent.Activate();
                }
                else
                {
                    var            isOpened = false;
                    IMyGenDocument mygenDoc = EditorManager.OpenDocument(this, info.FullName);
                    if (mygenDoc != null)
                    {
                        isOpened = true;
                        mygenDoc.DockContent.Show(MainDockPanel);
                        AddRecentFile(info.FullName);
                    }

                    if (!isOpened)
                    {
                        MessageBox.Show(this, info.Name + ": unknown file type", "Unknown file type");
                    }
                }
            }
        }
示例#3
0
        public IMyGenDocument FindDocument(string text, params IMyGenDocument[] docsToExclude)
        {
            IMyGenDocument found = null;

            if (MainDockPanel.DocumentStyle == DocumentStyle.SystemMdi)
            {
                foreach (Form form in MdiChildren)
                {
                    if (form is IMyGenDocument)
                    {
                        IMyGenDocument doc = form as IMyGenDocument;
                        if (doc.DocumentIndentity == text)
                        {
                            foreach (IMyGenDocument exclude in docsToExclude)
                            {
                                if (exclude == doc)
                                {
                                    doc = null;
                                }
                            }
                            if (doc != null)
                            {
                                found = doc;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (IDockContent content in MainDockPanel.Documents)
                {
                    if (content is IMyGenDocument)
                    {
                        IMyGenDocument doc = content as IMyGenDocument;
                        if (doc.DocumentIndentity == text)
                        {
                            foreach (IMyGenDocument exclude in docsToExclude)
                            {
                                if (exclude == doc)
                                {
                                    doc = null;
                                }
                            }
                            if (doc != null)
                            {
                                found = doc;
                                break;
                            }
                        }
                    }
                }
            }

            return(found);
        }
示例#4
0
        private void DocMenuItem_OnClicked(object sender, EventArgs e)
        {
            var i = sender as ToolStripMenuItem;

            if (i != null)
            {
                IMyGenDocument mgd = FindDocument(i.Tag.ToString());
                mgd.DockContent.Activate();
            }
        }
示例#5
0
 public void CreateDocument(params string[] fileTypes)
 {
     foreach (var fileType in fileTypes)
     {
         IMyGenDocument mygenDoc = EditorManager.CreateDocument(this, fileType);
         if (mygenDoc != null)
         {
             mygenDoc.DockContent.Show(MainDockPanel);
         }
     }
 }
示例#6
0
        public static IMyGenDocument CreateDocument(IMyGenerationMDI mdi, string fileType)
        {
            IMyGenDocument mygenDoc = null;

            foreach (IEditorManager manager in PluginManager.EditorManagers.Values)
            {
                if (manager.FileTypes.Contains(fileType))
                {
                    mygenDoc = manager.Create(mdi, fileType);
                    if (mygenDoc != null)
                    {
                        break;
                    }
                }
            }
            return(mygenDoc);
        }
示例#7
0
        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            if (IsTreeBusy)
            {
                return;
            }

            switch (e.Button.Tag as string)
            {
            case "refresh":

                if (this.IsUserDataDirty)
                {
                    DialogResult result = MessageBox.Show("The User Meta Data has been Modified, Do you wish to save the modifications?",
                                                          "User Meta Data", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                    if (result == DialogResult.Yes)
                    {
                        this.SaveUserMetaData();
                    }
                }

                //DefaultSettings settings = DefaultSettings.Instance;
                //this.Setup(settings);
                this.Setup();
                break;

            case "execute":
                if (this.mdi.DockPanel.ActiveDocument != null)
                {
                    if ((this.mdi.DockPanel.ActiveDocument is IMyGenDocument) && (StaticMyMeta.IsConnected))
                    {
                        IMyGenDocument doc = this.mdi.DockPanel.ActiveDocument as IMyGenDocument;

                        Recordset rs = StaticMyMeta.DefaultDatabase.ExecuteSql(doc.TextContent);
                        if ((rs != null) && (rs.State != (int)ADODB.ObjectStateEnum.adStateClosed))
                        {
                            rs.Close();
                        }
                    }
                }
                break;
            }
        }
        public void Execute(IMyGenerationMDI mdi, params string[] args)
        {
            SqlToolForm stf = null;
            int         cnt = 0;

            do
            {
                foreach (IDockContent d in mdi.DockPanel.Documents)
                {
                    if (d is SqlToolForm)
                    {
                        stf = d as SqlToolForm;
                        if (stf.IsNew && stf.IsEmpty)
                        {
                            break;
                        }
                        else
                        {
                            stf = null;
                        }
                    }
                }

                if (stf == null)
                {
                    mdi.CreateDocument(SqlToolEditorManager.SQL_FILE);
                }
                cnt++;
            } while (stf == null && cnt < 2);

            if (stf != null)
            {
                if (mdi.DockPanel.ActiveDocument != null)
                {
                    if (mdi.DockPanel.ActiveDocument is IMyGenDocument)
                    {
                        IMyGenDocument doc = mdi.DockPanel.ActiveDocument as IMyGenDocument;
                        stf.TextContent = doc.TextContent;
                    }
                }
                stf.Show();
                stf.Activate();
            }
        }
示例#9
0
        public static IMyGenDocument OpenDocument(IMyGenerationMDI mdi, string filename)
        {
            IMyGenDocument mygenDoc = null;
            FileInfo       info     = new FileInfo(filename);

            if (info.Exists)
            {
                foreach (IEditorManager manager in PluginManager.EditorManagers.Values)
                {
                    if (manager.CanOpenFile(info))
                    {
                        mygenDoc = manager.Open(mdi, info);
                        if (mygenDoc != null)
                        {
                            break;
                        }
                    }
                }
            }
            return(mygenDoc);
        }
示例#10
0
        public bool IsDocumentOpen(string text, params IMyGenDocument[] docsToExclude)
        {
            IMyGenDocument doc = FindDocument(text, docsToExclude);

            return(doc != null);
        }