Exemplo n.º 1
0
        //TODO:菜单的执行事件
        static void AllMenuClick(object sender, EventArgs e)
        {
            MyMenuItem item = sender as MyMenuItem;

            if (item == null)
            {
                return;
            }

            ///检查其Enabled状态
            if (!MenuStateManager.GetAndSetMenuEnabled(item.KeyId))
            {
                return;
            }

            switch (item.KeyId)
            {
                #region 新建页面
            case "MainMenu.file.newFile.page.index":
                #region
            {
                BaseFolderElementNode rootChannelNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewPage(rootChannelNode.Element, PageType.Home);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.page.general":
                #region
            {
                BaseFolderElementNode rootChannelNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewPage(rootChannelNode.Element, PageType.General);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.page.hr":
                #region
            {
                BaseFolderElementNode rootChannelNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewPage(rootChannelNode.Element, PageType.Hr);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.page.inviteBidding":
                #region
            {
                BaseFolderElementNode rootChannelNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewPage(rootChannelNode.Element, PageType.InviteBidding);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.page.knowledge":
                #region
            {
                BaseFolderElementNode rootChannelNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewPage(rootChannelNode.Element, PageType.Knowledge);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.page.product":
                #region
            {
                BaseFolderElementNode rootChannelNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewPage(rootChannelNode.Element, PageType.Product);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.page.project":
                #region
            {
                BaseFolderElementNode rootChannelNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewPage(rootChannelNode.Element, PageType.Project);
                break;
            }
                #endregion
                #endregion
                #region 新建模板

            case "MainMenu.file.newFile.tmplt.index":
                #region
            {
                BaseFolderElementNode tmpltRootNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode.TmpltRootNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewTmplt(tmpltRootNode.Element, TmpltType.Home);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.tmplt.general":
                #region
            {
                BaseFolderElementNode tmpltRootNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode.TmpltRootNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewTmplt(tmpltRootNode.Element, TmpltType.General);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.tmplt.hr":
                #region
            {
                BaseFolderElementNode tmpltRootNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode.TmpltRootNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewTmplt(tmpltRootNode.Element, TmpltType.Hr);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.tmplt.inviteBidding":
                #region
            {
                BaseFolderElementNode tmpltRootNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode.TmpltRootNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewTmplt(tmpltRootNode.Element, TmpltType.InviteBidding);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.tmplt.knowledge":
                #region
            {
                BaseFolderElementNode tmpltRootNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode.TmpltRootNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewTmplt(tmpltRootNode.Element, TmpltType.Knowledge);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.tmplt.product":
                #region
            {
                BaseFolderElementNode tmpltRootNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode.TmpltRootNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewTmplt(tmpltRootNode.Element, TmpltType.Product);
                break;
            }

                #endregion
            case "MainMenu.file.newFile.tmplt.project":
                #region
            {
                BaseFolderElementNode tmpltRootNode = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.SiteManagerNode.RootChannelNode.TmpltRootNode;
                WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree.NewTmplt(tmpltRootNode.Element, TmpltType.Project);
                break;
            }

                #endregion
                #endregion
            case "MainMenu.file.new":
                #region
            {
                Service.Workbench.ShowDialogForCreateProject();
                break;
            }

                #endregion
            case "MainMenu.file.open":
                #region
            {
                Service.Workbench.ShowDialogForOpenProject();
                break;
            }

                #endregion
            case "MainMenu.file.close":
                #region
                if (WorkbenchForm.MainForm.MainDockPanel.ActiveDocument != null)
                {
                    WorkbenchForm.MainForm.MainDockPanel.ActiveDocument.DockHandler.Close();
                }
                break;

                #endregion
            case "MainMenu.file.closeProj":
                #region
            {
                Service.Project.CloseProject();
                break;
            }

                #endregion
            case "MainMenu.file.save":
                #region
                Save();
                break;

                #endregion
            case "MainMenu.file.saveAll":
                #region
                SaveAll();
                break;

                #endregion
            case "MainMenu.file.pub":
                #region
                ///先保存全部
                SaveAll();

                ///检查并提示网站是否有主页
                if (!Service.Sdsite.CurrentDocument.RootChannel.HasEffectiveDefaultPage)
                {
                    if (MessageService.Show("没有为网站设置主页,发布后的网站将没有主页。\r\n\r\n是否确定现在发布?",
                                            MessageBoxButtons.OKCancel)
                        == DialogResult.Cancel)
                    {
                        return;
                    }
                }

                Publish publish = new Publish();
                publish.ExecutePublish();
                break;

                #endregion
            case "MainMenu.file.opennet":
                #region
                string url = @"http://{0}.{1}.{2}";
                url = string.Format(url, Service.Sdsite.CurrentDocument.SdsiteName,
                                    Service.User.UserID, "SimplusD.net");
                Process.Start(url);
                break;

                #endregion
            case "MainMenu.file.preview":
                #region
                ///先保存
                SaveAll();
                Service.WebView.StartupProcess();
                break;

                #endregion
            case "MainMenu.file.exit":
                #region
                //System.Windows.Forms.Application.Exit();
                WorkbenchForm.MainForm.Close();
                break;

                #endregion
            case "MainMenu.edit.undo":
                #region
            {
                WorkbenchForm.MainForm.ActiveView.Undo();
                break;
            }

                #endregion
            case "MainMenu.edit.redo":
                #region
            {
                WorkbenchForm.MainForm.ActiveView.Redo();
                break;
            }

                #endregion
            case "MainMenu.edit.find":
                #region
            {
                FindOptions.Singler.Reset();
                //FindAndReplaceForm.Initialize(WorkbenchForm.MainForm);
                FindAndReplaceForm findForm = new FindAndReplaceForm(true);
                findForm.Owner = _mainForm;
                findForm.Show();
                break;
            }

                #endregion
            case "MainMenu.edit.replace":
                #region
                FindOptions.Singler.Reset();
                // FindAndReplacePad.Initialize(WorkbenchForm.MainForm);
                FindAndReplaceForm replaceForm = new FindAndReplaceForm(false);
                replaceForm.Owner = _mainForm;
                replaceForm.Show();
                break;

                #endregion
            case "MainMenu.edit.findNext":
                #region
            {
                FindOptions.Singler.Reset();
                //FindAndReplacePad.Initialize(WorkbenchForm.MainForm);
                FindAndReplaceForm findForm = new FindAndReplaceForm(true);
                findForm.Owner = _mainForm;
                findForm.Show();
                break;
            }

                #endregion
            case "MainMenu.edit.cut":
                #region
            {
                WorkbenchForm.MainForm.ActiveView.Cut();
                break;
            }

                #endregion
            case "MainMenu.edit.copy":
                #region
            {
                WorkbenchForm.MainForm.ActiveView.Copy();
                break;
            }

                #endregion
            case "MainMenu.edit.paste":
                #region
            {
                WorkbenchForm.MainForm.ActiveView.Paste();
                break;
            }

                #endregion
            case "MainMenu.edit.delete":
                #region
            {
                WorkbenchForm.MainForm.ActiveView.Delete();
                break;
            }

                #endregion
            case "MainMenu.edit.selectAll":
                #region
            {
                WorkbenchForm.MainForm.ActiveView.SelectAll();
                break;
            }

                #endregion
            case "MainMenu.edit.option":
                #region
            {
                SoftwareOptionForm form = new SoftwareOptionForm();
                form.ShowDialog();
                break;
            }

                #endregion
            case "MainMenu.view.wizard":
                #region
                WorkbenchForm.MainForm.DeHideAllPad();
                WorkbenchForm.MainForm.MainWizardPad.Show();
                break;

                #endregion
            case "MainMenu.view.property":
                #region
                WorkbenchForm.MainForm.DeHideAllPad();
                WorkbenchForm.MainForm.MainPropertyPad.Show();
                break;

                #endregion
            case "MainMenu.view.result":
                #region
                WorkbenchForm.MainForm.DeHideAllPad();
                WorkbenchForm.MainForm.MainResultPad.Show();
                break;

                #endregion
            case "MainMenu.view.siteManager":
                #region
                WorkbenchForm.MainForm.DeHideAllPad();
                WorkbenchForm.MainForm.MainTreePad.Show();
                break;

                #endregion
            case "MainMenu.view.previewPad":
                #region
                WorkbenchForm.MainForm.DeHideAllPad();
                WorkbenchForm.MainForm.MainPreviewPad.Show();
                break;

                #endregion
            case "MainMenu.view.fullScreenShow":
                #region
                if (!WorkbenchForm.MainForm.IsHideAllPad)
                {
                    WorkbenchForm.MainForm.HideAllPad();
                }
                else
                {
                    WorkbenchForm.MainForm.DeHideAllPad();
                }
                break;

                #endregion
            case "MainMenu.site.Manager":
                #region
            {
                Service.Workbench.OpenWorkDocument(WorkDocumentType.Manager, Service.Sdsite.CurrentDocument.RootChannel.Id);
                break;
            }

                #endregion
            case "MainMenu.site.tagMangager":
                #region
            {
                //SiteTagManagerForm form = new SiteTagManagerForm();
                //form.ShowDialog();
                break;
            }

                #endregion
            case "MainMenu.site.siteProperty":
                #region
            {
                Service.Workbench.OpenWorkDocument(WorkDocumentType.SiteProperty, Service.Sdsite.CurrentDocument.SdsiteName);
                break;
            }

                #endregion
            case "MainMenu.page.addPage":
                #region
            {
                //MyTreeView myTree = WorkbenchForm.MainForm.MainTreePad.TreeViewExPad.MyTree;
                //NewPageFormNoChan newPage = new NewPageFormNoChan(PageType.None);
                //newPage.Show();
                NewPageForm form = new NewPageForm(null, PageType.None);
                form.ShowDialog();
                break;
            }

                #endregion
            case "MainMenu.page.contentProperty":
                #region
            {
                string           pageId = ((MdiHtmlDesignForm)WorkbenchForm.MainForm.ActiveMdiChild).PageId;
                PagePropertyForm pageTextPropertyForm = new PagePropertyForm(pageId);
                pageTextPropertyForm.Show();
                break;
            }

                #endregion
            case "MainMenu.tmplt.addTmplt":
                #region
            {
                break;
            }

                #endregion
            case "MainMenu.report.ADStat":
                #region
                #endregion
            case "MainMenu.window.resetWindowLayout":
                #region
            {
                WorkbenchForm.MainForm.ResetAllPad();
                break;
            }

                #endregion
            case "MainMenu.window.closeAllWindow":
                #region
            {
                Service.Workbench.CloseAllForm();
                break;
            }

                #endregion
            case "MainMenu.user.logout":
                #region
            {
                Service.User.Logout();
                break;
            }

                #endregion
            case "MainMenu.help.help":
                #region
                Process.Start(Path.Combine(PathService.CHS_Folder, "SimplusD!Help.chm"));
                break;

                #endregion
            case "MainMenu.help.checkUpdate":
                #region
                Service.Remote.CheckUpdate(true);
                break;

                #endregion
            case "MainMenu.help.aboutJeelu":
                #region
                //AboutJeelu aboutJL = new AboutJeelu();
                //aboutJL.ShowDialog();
                break;

                #endregion
            case "MainMenu.help.aboutSimplusD":
                #region
                SimplusDAboutForm aboutSD = new SimplusDAboutForm();
                aboutSD.ShowDialog();
                break;

                #endregion
            default:
                Service.Exception.ShowDefaultException(new Exception("未知的KeyId:" + item.KeyId));
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化
        /// </summary>
        public static void Initialize(string sdsite)
        {
            System.Windows.Forms.Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException       += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            _willOpenFile = sdsite;

            CssResources.Initialize();

            //初始化的顺序是有一定规则的
            Service.Util.Initialize();
            Service.Property.Initialize();
            PathService.Initialize(Application.StartupPath);
            Utility.Pinyin.Initialize(Path.Combine(PathService.SoftwarePath, "pinyin.mb"));
            ResourceService.Initialize();
            StringParserService.Initialize(ResourceService.GetResourceText);
            SoftwareOption.Load();
            ResourcesReader.InitializeResources("Configuration", SoftwareOption.General.ApplicationLanguage, null);
            Service.FileBinding.Initialize();
            Service.DesignData.Load(PathService.Config_PadLayout);
            Service.RecentFiles.Initialize();
            Service.SiteDataManager.Initialize();
            Service.ListView.InitColumn();
            SiteResourceService.Initialize(SelectResource, GetResourcePath, GetResourceAbsPath, GetResourceUrl, ImportResourceFile);
            AutoLayoutPanel.Initialize(PathService.CL_DataSources_Folder);

            LayoutConfiguration.LoadLayoutConfiguration();
            _mainForm = new WorkbenchForm();

            CssUtility.Initialize(_mainForm.SelectImageResource);
            ////初始化的顺序是有一定规则的
            Service.User.Initialize(_mainForm.ShowLoginForm);
            Service.WebView.Initialize(_mainForm.SinglePagePublish);
            MessageService.Initialize(_mainForm);
            ToolbarManager.Initialize(_mainForm);
            MenuStripManager.Initialize(_mainForm);
            StatusBarManager.Initialize(_mainForm);
            FindAndReplaceForm.Initialize(_mainForm);
            //ResultsPad.Initialize(_mainForm);
            MenuStateManager.Initialize();

            Service.StatusBar.Initialize(StatusBarManager.CurrentStatusStrip);
            Service.Workbench.Initialize(
                _mainForm,
                _mainForm.OpenWorkDocument,
                _mainForm.NavigationUrl,
                _mainForm.MainTreePad.TreeViewExPad.RefreshSiteTreeData,
                ShowDialogForCreateProject,
                ShowDialogForOpenProject,
                _mainForm.GotoTree,
                _mainForm.ActivateForm);

            ///监听项目的打开事件
            Service.Project.ProjectOpened  += new EventHandler(ProjectService_ProjectOpened);
            Service.Project.ProjectClosing += new EventHandler(ProjectService_ProjectClosing);
            Service.Project.ProjectClosed  += new EventHandler(ProjectService_ProjectClosed);

            OnWorkbenchCreated();

            _mainForm.OnActiveWorkspaceTypeChanged(new WorkspaceTypeEventArgs(WorkspaceType.Default));
            _mainForm.MainDockPanel.ActiveDocumentChanged += new EventHandler(_mainForm.MainDockPanel_ActiveDocumentChanged);

            if (Initialized != null)
            {
                Initialized(null, EventArgs.Empty);
            }
        }