Exemplo n.º 1
0
        private void tvProjects_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                tvProjects.SelectedNode = e.Node;

                menuProject.Items.Clear();

                //判斷是否可以開啟
                IEditorManager editorManager = e.Node.Tag as IEditorManager;
                if (editorManager != null)
                {
                    if (editorManager.Editors.Count == 1)
                    {
                        IEditable     editable = editorManager.Editors[0];
                        ToolStripItem item     = menuProject.Items.Add(editable.DocumentTitle, actImgs.Images[editable.ImageKey], cmEdit_Click);
                        item.Tag = editable;
                    }
                    else if (editorManager.Editors.Count > 0)
                    {
                        ToolStripMenuItem menuItem = new ToolStripMenuItem("開啟");
                        menuProject.Items.Add(menuItem);

                        foreach (IEditable editable in editorManager.Editors)
                        {
                            ToolStripItem item = menuItem.DropDownItems.Add(editable.DocumentTitle, actImgs.Images[editable.ImageKey], cmEdit_Click);
                            item.Tag = editable;
                        }
                    }
                }

                //判斷是否可以改名
                ToolStripMenuItem cmRename = new ToolStripMenuItem("重新命名(&N)");
                this.CheckMenuItemVisiable(typeof(IRenameable), cmRename);
                cmRename.Click += new EventHandler(cmRename_Click);
                cmRename.Image  = actImgs.Images["rename"];

                //判斷是否可以新增
                IAddable addable = e.Node.Tag as IAddable;
                if (addable != null)
                {
                    menuProject.Items.Add(addable.TitleOfAdd, actImgs.Images["add"], cmAdd_Click);
                }

                //判斷是否可以重新整理
                ToolStripMenuItem cmReload = new ToolStripMenuItem("重新整理(&R)");
                this.CheckMenuItemVisiable(typeof(IReloadable), cmReload);
                cmReload.Click += new EventHandler(cmReload_Click);
                cmReload.Image  = actImgs.Images["reload"];

                //判斷是否可以刪除
                IDeleteable deleteable = e.Node.Tag as IDeleteable;
                if (deleteable != null)
                {
                    menuProject.Items.Add(deleteable.TitleOfDelete, actImgs.Images["delete"], cmDelete_Click);
                }

                //判斷是否可以測試
                ITestable testable = e.Node.Tag as ITestable;
                if (testable != null)
                {
                    menuProject.Items.Add(testable.TitleOfTest, actImgs.Images[testable.TestImageKey], cmTest_Click);
                }

                //判斷是否可以匯出
                ToolStripMenuItem cmExport = new ToolStripMenuItem("匯出(&E)");
                this.CheckMenuItemVisiable(typeof(IExportable), cmExport);
                cmExport.Click += new EventHandler(cmExport_Click);
                cmExport.Image  = actImgs.Images["export"];

                //判斷是否可以匯入
                ToolStripMenuItem cmImport = new ToolStripMenuItem("匯入(&I)");
                this.CheckMenuItemVisiable(typeof(IImportable), cmImport);
                cmImport.Click += new EventHandler(cmImport_Click);
                cmImport.Image  = actImgs.Images["import"];

                //判斷是否可以加入專案
                IJoinProject join = e.Node.Tag as IJoinProject;
                if (join != null)
                {
                    menuProject.Items.Add("加入專案(&J)", actImgs.Images["join"], cmJoinProject_Click);
                }

                //判斷是否可以匯入
                ILeaveProject leave = e.Node.Tag as ILeaveProject;
                if (leave != null)
                {
                    menuProject.Items.Add("從專案卸載(&L)", actImgs.Images["leave"], cmLeaveProject_Click);
                }

                //判斷是否可以上傳
                ISyncUpload upload = e.Node.Tag as ISyncUpload;
                if (upload != null)
                {
                    menuProject.Items.Add("同步至伺服器(&U)", actImgs.Images["upload"], cmUpload_Click);
                }

                //判斷是否可以下載
                ISyncDownload download = e.Node.Tag as ISyncDownload;
                if (download != null)
                {
                    menuProject.Items.Add("自伺服器同步(&D)", actImgs.Images["download"], cmDownload_Click);
                }

                //判斷是否可以設定
                ISetupable setup = e.Node.Tag as ISetupable;
                if (setup != null)
                {
                    menuProject.Items.Add(setup.SetupTitle + "(&S)", actImgs.Images["setup"], cmSetup_Click);
                }

                //判斷是否可以佈署
                IDeployable deploy = e.Node.Tag as IDeployable;
                if (deploy != null)
                {
                    menuProject.Items.Add("佈署(&L)", actImgs.Images["deploy"], cmDeploy_Click);
                }

                //判斷是否可以佈署到實體
                IDeployToPhysical deployToPhysical = e.Node.Tag as IDeployToPhysical;
                if (deployToPhysical != null)
                {
                    menuProject.Items.Add("佈署到實體(&P)", actImgs.Images["deployToPhysical"], tsbtnDeployToPhysical_Click);
                }

                //判斷是否可以從實體 Service 載入
                IImportFromPhysical importFromPhysical = e.Node.Tag as IImportFromPhysical;
                if (importFromPhysical != null)
                {
                    menuProject.Items.Add("實體 Service 載入(&X)", actImgs.Images["importFromPhysical"], tsbtnImportFromPhysical_Click);
                }

                menuProject.Show(e.Location);
            }
        }
Exemplo n.º 2
0
        private void DoJoinProject()
        {
            IJoinProject join = tvProjects.SelectedNode.Tag as IJoinProject;

            join.JoinProject();
        }
Exemplo n.º 3
0
        private void tvProjects_AfterSelect(object sender, TreeViewEventArgs e)
        {
            INodeHandler handler = e.Node.Tag as INodeHandler;

            if (handler != null)
            {
                if (handler.IsFirstClick)
                {
                    handler.OnFirstClick();
                }
                else
                {
                    handler.OnClick();
                }
            }
            splitContainer1.Panel2.Controls.Clear();

            IDeleteable del = handler as IDeleteable;

            tsbtnDelete.Enabled = false;
            if (del != null)
            {
                tsbtnDelete.Enabled     = true;
                tsbtnDelete.ToolTipText = del.TitleOfDelete;
                menuProject.Items.Add(del.TitleOfDelete, actImgs.Images["delete"], cmDelete_Click);
            }

            IAddable add = handler as IAddable;

            tsbtnAdd.Enabled = false;
            if (add != null)
            {
                tsbtnAdd.Enabled     = true;
                tsbtnAdd.ToolTipText = add.TitleOfAdd;
                menuProject.Items.Add(add.TitleOfAdd, actImgs.Images["add"], cmAdd_Click);
            }

            IReloadable reload = handler as IReloadable;

            tsbtnReload.Enabled = false;
            if (reload != null)
            {
                tsbtnReload.Enabled = true;
            }

            ITestable test = handler as ITestable;

            tsbtnTest.Enabled = false;
            if (test != null)
            {
                tsbtnTest.Image   = actImgs.Images[test.TestImageKey];
                tsbtnTest.Enabled = true;
            }

            IRenameable rename = handler as IRenameable;

            tsbtnRename.Enabled = false;
            if (rename != null)
            {
                tsbtnRename.Enabled = true;
            }

            IExportable export = handler as IExportable;

            tsbtnExport.Enabled = false;
            if (export != null)
            {
                tsbtnExport.Enabled = true;
            }

            ISetupable setup = handler as ISetupable;

            cmSetup.Enabled = false;
            if (setup != null)
            {
                cmSetup.Enabled = true;
            }

            IDeployable deploy = handler as IDeployable;

            cmDeploy.Enabled = false;
            if (deploy != null)
            {
                cmDeploy.Enabled = true;
            }

            IDeployToPhysical phyDeploy = handler as IDeployToPhysical;

            tsbtnDeployToPhysical.Enabled = false;
            if (phyDeploy != null)
            {
                tsbtnDeployToPhysical.Enabled = true;
            }

            IImportFromPhysical phyImport = handler as IImportFromPhysical;

            tsbtnImportFromPhysical.Enabled = false;
            if (phyImport != null)
            {
                tsbtnImportFromPhysical.Enabled = true;
            }

            IImportable import = handler as IImportable;

            tsbtnImport.Enabled = false;
            if (import != null)
            {
                tsbtnImport.Enabled = true;
            }

            IJoinProject joinProject = handler as IJoinProject;

            tsbtnJoinProject.Enabled = false;
            if (joinProject != null)
            {
                tsbtnJoinProject.Enabled = true;
            }

            ILeaveProject leaveProject = handler as ILeaveProject;

            tsbtnLeaveProject.Enabled = false;
            if (leaveProject != null)
            {
                tsbtnLeaveProject.Enabled = true;
            }

            ISyncUpload syncUplaod = handler as ISyncUpload;

            cmUpload.Enabled = false;
            if (syncUplaod != null)
            {
                cmUpload.Enabled = true;
            }

            ISyncUpload syncDownload = handler as ISyncUpload;

            cmDownload.Enabled = false;
            if (syncDownload != null)
            {
                cmDownload.Enabled = true;
            }

            tsEditMode.Items.Clear();
            rsbtnSave.Enabled = false;
            IEditorManager manager = handler as IEditorManager;

            if (manager != null)
            {
                rsbtnSave.Enabled = false;
                foreach (IEditable editable in manager.Editors)
                {
                    ToolStripItem item = tsEditMode.Items.Add(editable.ModeTitle, actImgs.Images[editable.ImageKey], cmEdit_Click);
                    item.ToolTipText = editable.ModeTitle;
                    item.Text        = string.Empty;
                    item.Tag         = editable;
                }
            }
        }