Ejemplo n.º 1
0
        //FileTabPanel m_tabsPanel = new FileTabPanel();
        private IDockContent GetContentFromPersistString(string persistString)
        {
            if (persistString == typeof(ErrorPanel).ToString())
            {
                return this.m_errorPanel;
            }
            if (persistString == typeof(ProjectPanel).ToString())
            {
                return this.m_prjPanel;
            }
            if (persistString == typeof(PropertyPanel).ToString())
            {
                return this.m_propertyPanel;
            }

            string[] strArray = persistString.Split(new char[] { ',' });
            if (strArray.Length != 3)
            {
                return null;
            }
            if (strArray[0] != typeof(FileTabPanel).ToString())
            {
                return null;
            }
            var doc = new FileTabPanel();
            if (strArray[1] != string.Empty)
            {
                doc.FileName = strArray[1];
            }
            if (strArray[2] != string.Empty)
            {
                doc.Text = strArray[2];
            }

            //DocumentViewManager.Instance().AddView(doc);

            this.receiver.LoadFile(doc.FileName);

            return DocumentViewManager.Instance().GetView(doc.FileName);
            //var ctx = Assemble.CreateEditor(doc.FileName);

            //doc.Tag = ctx.Model.FileId;

            //return doc;
        }
Ejemplo n.º 2
0
        public void AddView(FileTabPanel docView)
        {
            //docView.HideOnClose = true;

            this.m_documentViews.Add(docView);

            docView.FormClosing += new FormClosingEventHandler(docView_FormClosing);
            docView.TabPageContextMenu = new ContextMenu();
            docView.TabPageContextMenu.MenuItems.Add(new MenuItem("保存", menuSave_Click));
            docView.TabPageContextMenu.MenuItems.Add(new MenuItem("关闭", menuClose_Click));
            docView.TabPageContextMenu.MenuItems.Add(new MenuItem("除此之外全关闭", menuCloseOther_Click));
            docView.TabPageContextMenu.MenuItems.Add(new MenuItem("复制完整路径", menuCopyPath_Click));
            docView.TabPageContextMenu.MenuItems.Add(new MenuItem("打开所在的文件夹", menuOpenFolder_Click));
            foreach (MenuItem menu in docView.TabPageContextMenu.MenuItems)
            {
                menu.Tag = docView;
            }
        }
Ejemplo n.º 3
0
        void OpenFile(string file, FileTabPanel docView = null)
        {
            //如果已经打开则忽略
            var view = this.m_documentViews.FirstOrDefault(x => x.FileName == file);

            if (view != null)
            {
                view.Activate();
                return;
            }
            if (this.m_documentViews.Count(x => x.FileName == file) > 0)
                return;

            var editorContext = Assemble.CreateEditor(file);
            if (editorContext == null)
            {
                MessageBox.Show(string.Format("不能打开文件", file));
                return;
            }

            editorContext.EditorContainer.Editor.Dock = DockStyle.Fill;
            if (!File.Exists(file))
            {
                MessageBox.Show(string.Format("不能打开文件", file));
                return;
            }

            var text = File.ReadAllText(file);
            editorContext.EditorContainer.Text = text;
            var model = editorContext.Model;

            var page = docView == null ? new FileTabPanel() : docView;
            page.Name = (Path.GetFileName(file));
            page.TabText = page.Text = page.Name;
            page.FileName = file;

            //page.Name = model.File;
            page.Tag = model.FileId;
            page.ToolTipText = model.File;
            page.Controls.Add(editorContext.EditorContainer.Editor);
            page.Tag = editorContext.Model.FileId;
            page.Show(this.m_documentViewContainer, DockState.Document);

            editorContext.Model.Changed += new Core.Infrastructure.Model.OnChanged(Model_Changed);
            editorContext.Model.Saved += new OnSaved(Model_Saved);
            //this.tabControl.TabPages.Add(page);
            //this.tabControl.SelectedTab = page;
            GlobalService.EditorContextManager.CurrentContext = editorContext;
            this.AddView(page);
            //GlobalService.ModelManager.Regist(editorContext.Model);
        }