Exemplo n.º 1
0
        //---------------------------------------------------------------------------
        #region ** handle commands

        internal override void HandleItemEvent(RibbonEventArgs e)
        {
            RibbonItem item = (RibbonItem)e.Item;

            if (e.EventType == RibbonEventType.Click)
            {
                switch (item.ID)
                {
                case "Spelling":
                    Ribbon.SpellCheck();
                    break;

                case "ShowErrors":
                    Ribbon.SetActiveSpellChecking(((RibbonToggleButton)item).Pressed);
                    break;

                case "SetLanguage":
                    Ribbon.SetSpellingLanguage();
                    break;

                case "WordCount":
                    using (WordCount dlg = new WordCount(Editor.Text))
                    {
                        dlg.Font = Ribbon.Font;
                        dlg.ShowDialog();
                    }
                    break;
                }
            }
        }
Exemplo n.º 2
0
        void HandleCheckBoxAction(object sender, RibbonEventArgs e)
        {
            var methodName = e.Control.Tag + "_Click";

            Tracer.WriteTraceMethodLine(DELEGATE_TO_VIEW, methodName);
            var flags = BindingFlags.Instance | BindingFlags.NonPublic;
            var mi    = RibbonView.GetType().GetMethod(methodName, flags);

            if (mi != null)
            {
                var checkBoxAction = (Action <object, RibbonEventArgs>)
                                     Delegate.CreateDelegate(
                    typeof(Action <object, RibbonEventArgs>), RibbonView, mi);

                checkBoxAction(sender, e);

                switch (e.Control.Tag)
                {
                case "PageTitle":
                    RibbonView.PageTitleControls.ForEach
                        (item => RibbonUI.InvalidateControl(item.ToString()));
                    break;

                case "RuleLinesSpacing":
                    RibbonView.RuleLinesSpacingControls.ForEach
                        (item => RibbonUI.InvalidateControl(item.ToString()));
                    RibbonUI.InvalidateControl("No_Ruled_Lines");
                    break;
                }
            }
            else
            {
                Tracer.WriteErrorLine("Method '{0}' not found", methodName);
            }
        }
Exemplo n.º 3
0
 protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
 {
     //Commands.DocumentAdmin.Execute(SceneContext.Instance);
     OfficeWord.Application app = SceneContext.Instance.WordAppAdmin.Application;
     OfficeWord.Document    doc = app.ActiveDocument;
     if (doc != null)
     {
         if (SceneContext.Instance.SecretDataAdmin.Get(doc) == null)
         {
             MessageBox.Show("该文档不是通过文档工具打开的文档,无法使用此功能!");
         }
         else
         {
             SceneContext.Instance.SecretDataAdmin.Remove(doc);
             doc.Save();
             string filename     = doc.FullName;
             string tempFileName = Path.Combine(Logger.TemporaryDirectory, doc.Name);
             File.Copy(filename, tempFileName);
             if (SceneContext.Instance.FileServer.Upload(tempFileName, doc.Name))
             {
                 MessageBox.Show("文件保存成功!");
             }
             // 缺省参数
             object unknown = Type.Missing;
             doc.Close(ref unknown, ref unknown, ref unknown);
             File.Delete(tempFileName);
             File.Delete(filename);
         }
     }
 }
Exemplo n.º 4
0
        internal void OptionsForm_Show(object sender, RibbonEventArgs e)
        {
            if (sender is API.AddInBase && e.Control.Tag == "OptionsForm")
            {
                Tracer.WriteTraceMethodLine();
                var addIn         = sender as API.AddInBase;
                var savedTemplate = Properties.Settings.Default.PageTemplate;
                using (var form = new UI.OptionsForm())
                {
                    form.AboutIconImage_ResourceName = Component.AppIcon_ResourceName;
                    form.AboutText = string.Join(Environment.NewLine, new[] {
                        addIn.Description,
                        Component.AssemblyInfo.Copyright,
                        $"Version {Component.AssemblyInfo.ProductVersion}"
                    });
                    form.Title = $"{Component.AssemblyInfo.Title} Options";

                    var owner = e.Control.Context as OneNote.Window;
                    form.ShowDialog(new Utils.WinHelper.Win32Window(owner));
                }
                if (Properties.Settings.Default.PageTemplate != savedTemplate)
                {
                    _binder.Rebind(addIn.Application);
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
Exemplo n.º 5
0
 protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
 {
     //Commands.DocumentAdmin.Execute(SceneContext.Instance);
     OfficeWord.Application app = SceneContext.Instance.WordAppAdmin.Application;
     OfficeWord.Document    doc = app.ActiveDocument;
     if (doc != null)
     {
         doc.Save();
         var entry = new SecretEntry()
         {
             LoginEntity = null,
             BizFileName = doc.FullName,
             BizFileId   = "",
         };
         SceneContext.Instance.SecretDataAdmin.Set(doc, entry);
         string filename     = doc.FullName;
         string tempFileName = Path.Combine(Logger.TemporaryDirectory, doc.Name);
         File.Copy(filename, tempFileName);
         if (SceneContext.Instance.FileServer.Upload(tempFileName, doc.Name))
         {
             MessageBox.Show("文件新增成功!");
         }
         File.Delete(tempFileName);
     }
 }
Exemplo n.º 6
0
        protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
        {
            // 缺省参数
            object unknown = Type.Missing;
            //doc.Close(ref saveChange, ref nullobj, ref nullobj);
            var    doc     = SceneContext.Instance.WordAppAdmin.ActiveDocument;
            string docName = "";

            if (doc != null)
            {
                docName = doc.FullName;
                SceneContext.Instance.SecretDataAdmin.Remove(doc);
                object saveChanges = false;
                doc.Close(ref saveChanges, ref unknown, ref unknown);
            }
            //删除此文件
            if (!string.IsNullOrEmpty(docName))
            {
                File.Delete(docName);
            }

            var panes      = SceneContext.Instance.CustomTaskPanesAdmin.CustomTaskPanes;
            int panesCount = panes.Count;

            if (panesCount > 0)
            {
                CustomTaskPane taskPane = panes[0];
                if (taskPane.Visible)
                {
                    taskPane.Visible = false;
                }
            }
        }
Exemplo n.º 7
0
        internal void RuleLinesSpacing_Click(object sender, RibbonEventArgs e)
        {
            if (e.Control.Tag != "RuleLinesSpacing")
            {
                return;
            }

            Tracer.WriteTraceMethodLine();
            var id = e.Control.Id;

            Tracer.WriteDebugLine("Id = {0}, Pressed = {1}", id, e.Pressed);

            if (e.Pressed)
            {
                var t = typeof(RuleLinesSpacingEnum);
                if (Enum.IsDefined(t, id))
                {
                    var ruleLinesSpacingEnum = EnumHelper.Parse <RuleLinesSpacingEnum>(id);
                    _binder.PageSettings.RuleLinesHorizontalSpacing = ruleLinesSpacingEnum;
                    _binder.PageSettings.RuleLinesVisible           = true;
                }
                else
                {
                    Tracer.WriteErrorLine("'{0}' is not a valid {1} value", id, t.Name);
                }
            }
            else // set default value
            {
                _binder.PageSettings.RuleLinesVisible = false;
            }
        }
Exemplo n.º 8
0
        internal void PageTitle_Click(object sender, RibbonEventArgs e)
        {
            if (e.Control.Tag != "PageTitle")
            {
                return;
            }

            Tracer.WriteTraceMethodLine();
            var id = e.Control.Id;

            Tracer.WriteDebugLine("Id = {0}, Pressed = {1}", id, e.Pressed);

            if (e.Pressed)
            {
                var t = typeof(PageTitleEnum);
                if (Enum.IsDefined(t, id))
                {
                    _binder.PageSettings.Title = EnumHelper.Parse <PageTitleEnum>(id);
                }
                else
                {
                    Tracer.WriteErrorLine("'{0}' is not a valid {1} value", id, t.Name);
                }
            }
            else // set default value
            {
                _binder.PageSettings.Title = PageTitleEnum.SlashDelimitedDate_MM_DD_YYYY;
            }
        }
Exemplo n.º 9
0
 internal void NotebookButton_Click(object sender, RibbonEventArgs e)
 {
     if (e.Control.Id == "NotebookButton")
     {
         _binder.CreateJournalPage();
     }
 }
Exemplo n.º 10
0
 internal void PageColor_None(object sender, RibbonEventArgs e)
 {
     if (e.Control.Id == "PageColorNone")
     {
         Tracer.WriteTraceMethodLine();
         _binder.PageSettings.Color = PageColorEnum.None;
     }
 }
Exemplo n.º 11
0
        internal void PageColor_Click(object sender, RibbonEventArgs e)
        {
            Tracer.WriteTraceMethodLine();

            if (e.Control.Id == "PageColorGallery")
            {
                var fmt = "Id = {0}, selectedId = {1}, selectedIndex = {2}";
                Tracer.WriteDebugLine(fmt, e.Control.Id, e.SelectedId, e.SelectedIndex);
                _binder.PageSettings.Color = PageColorControls[e.SelectedIndex];
            }
        }
Exemplo n.º 12
0
        internal void RuleLinesVisible_Toggle(object sender, RibbonEventArgs e)
        {
            if (e.Control.Tag != "RuleLinesVisible")
            {
                return;
            }

            Tracer.WriteTraceMethodLine();
            var pressed = e.Pressed;

            _binder.PageSettings.RuleLinesVisible = !pressed;
            Tracer.WriteDebugLine("Id = {0}, Pressed = {1}", e.Control.Id, pressed);
        }
Exemplo n.º 13
0
        private void rbnMain_RibbonEvent(object sender, RibbonEventArgs e)
        {
            switch (e.EventType)
            {
            case RibbonEventType.Click:
                RibbonClick(e.Item as RibbonItem);
                break;

            case RibbonEventType.ChangeCommitted:
                RibbonChangeCommitted(e.Item as RibbonItem);
                break;
            }
        }
Exemplo n.º 14
0
        protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
        {
            if (SceneContext.Instance.Login())
            {
                xRibbonButton.Invalidate();
            }
            string path = Path.Combine(SceneContext.Instance.BundleContext.Bundle.Location, "Documents");

            if (!Directory.Exists(path))
            {
                //DirectorySecurity security=new DirectorySecurity();
                //security.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));
                Directory.CreateDirectory(path);
            }
        }
Exemplo n.º 15
0
        public void OnAction(RibbonElement elment, RibbonEventArgs e)
        {
            if (e == null)
            {
                return;
            }
            var xRibbonButton = (XRibbonButton)elment;

            if (xRibbonButton == null)
            {
                return;
            }

            this.OnButtonAction(xRibbonButton, e);
        }
Exemplo n.º 16
0
 void c1Ribbon1_RibbonEvent(object sender, RibbonEventArgs e)
 {
     switch (e.EventType)
     {
     case RibbonEventType.ChangeCommitted:
     case RibbonEventType.ChangeCanceled:
     case RibbonEventType.Click:
     case RibbonEventType.DialogLauncherClick:
     case RibbonEventType.DropDownClosed:
         if (this.c1Ribbon1.Focused)
         {
             this.richTextBox1.Focus();
         }
         break;
     }
 }
Exemplo n.º 17
0
        public void OnAction(RibbonElement elment, RibbonEventArgs e)
        {
            var args = (RibbonToggleButtonEventArgs)e;

            if (e == null)
            {
                return;
            }
            var xRibbonToggleButton = (XRibbonToggleButton)elment;

            if (xRibbonToggleButton == null)
            {
                return;
            }


            this.OnToggleButtonAction(xRibbonToggleButton, args);
        }
Exemplo n.º 18
0
        // handles Ribbon item events to show topic in C1DynamicHelp
        private void rib_RibbonEvent(object sender, RibbonEventArgs e)
        {
            switch (e.EventType)
            {
            case RibbonEventType.LostFocus:
            case RibbonEventType.DeselectTab:
                // notify the C1DynamicHelp control that the Leave event occurred for e.Item,
                // so a new help topic may need to be displayed
                this.HandleUIElementEvent(e.Item, UIElementEvents.Leave);
                break;

            case RibbonEventType.GotFocus:
            case RibbonEventType.SelectTab:
                // notify the C1DynamicHelp control that the Enter event occurred for e.Item,
                // so a new help topic may need to be displayed
                this.HandleUIElementEvent(e.Item, UIElementEvents.Enter);
                break;
            }
        }
Exemplo n.º 19
0
        private void c1Ribbon_RibbonEvent(object sender, RibbonEventArgs e)
        {
            // Restore focus to the browser control after interacting with the ribbon
            switch (e.EventType)
            {
            case RibbonEventType.ChangeCommitted:
            case RibbonEventType.ChangeCanceled:
            case RibbonEventType.Click:
            case RibbonEventType.DialogLauncherClick:
            case RibbonEventType.DropDownClosed:
            {
                if (c1Ribbon.Focused)
                {
                    webBrowser.Focus();
                }

                break;
            }
            }
        }
Exemplo n.º 20
0
        internal override void HandleItemEvent(RibbonEventArgs e)
        {
            RibbonItem item = (RibbonItem)e.Item;

            if (e.EventType == RibbonEventType.Click)
            {
                if (item == _modeDesign)
                {
                    SetEditorMode(EditorMode.Design);
                }
                else if (item == _modeSource)
                {
                    SetEditorMode(EditorMode.Source);
                }
                else if (item == _modePreview)
                {
                    SetEditorMode(EditorMode.Preview);
                }
                else if (item == _fixErrors)
                {
                    _isFixing = true;
                    try
                    {
                        Editor.FixSource();
                    }
                    finally
                    {
                        _isFixing = false;
                    }
                    _fixErrors.Enabled        = false;
                    _validateDocument.Enabled = false;
                }
                else if (item == _validateDocument)
                {
                    bool errorsFixed = (Editor as C1RibbonEditorXhtml).ValidateSource();
                    _fixErrors.Enabled        = !errorsFixed;
                    _validateDocument.Enabled = false;
                }
            }
        }
Exemplo n.º 21
0
        private void rbnMain_RibbonEvent(object sender, RibbonEventArgs e)
        {
            if (Updating)
            {
                return;
            }

            switch (e.EventType)
            {
            case RibbonEventType.Click:
                RibbonClick(e.Item as RibbonItem);
                break;

            case RibbonEventType.ChangeCommitted:
                RibbonChangeCommitted(e.Item as RibbonItem);
                break;

            case RibbonEventType.DropDown:
                RibbonDropDown(e.Item as RibbonItem);
                break;
            }
        }
Exemplo n.º 22
0
        protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
        {
            Log.Debug("---VersionCommand--Begin:" + DateTime.Now.ToLongTimeString());
            CustomTaskPaneCollection panes = SceneContext.Instance.CustomTaskPanesAdmin.CustomTaskPanes;
            int panesCount = panes.Count;

            Log.Debug("---VersionCommand--01:" + DateTime.Now.ToLongTimeString());
            if (panesCount == 0)
            {
                var pane = new CustomPane();
                Log.Debug("---VersionCommand--02:" + DateTime.Now.ToLongTimeString());
                var host = new PaneDecorator(pane);
                Log.Debug("---VersionCommand--03:" + DateTime.Now.ToLongTimeString());
                panes.Add(host, "版本信息");
                Log.Debug("---VersionCommand--04:" + DateTime.Now.ToLongTimeString());
            }
            CustomTaskPane taskPane = panes[0];

            taskPane.VisibleChanged += new EventHandler(taskPane_VisibleChanged);
            taskPane.Width           = 430;
            taskPane.Visible         = true;
        }
Exemplo n.º 23
0
 public void OnShowForm(object sender, RibbonEventArgs e) =>
 ShowForm?.Invoke(sender, e);
Exemplo n.º 24
0
        //---------------------------------------------------------------------------
        #region ** handle commands

        internal override void HandleItemEvent(RibbonEventArgs e)
        {
            RibbonItem item = (RibbonItem)e.Item;

            if (e.EventType == RibbonEventType.Click)
            {
                PageSettings ps;

                switch (item.ID)
                {
                // margins
                case "MarginNormal":
                    ps         = Editor.PrintDocument.DefaultPageSettings;
                    ps.Margins = new Margins(100, 100, 100, 100);
                    break;

                case "MarginNarrow":
                    ps         = Editor.PrintDocument.DefaultPageSettings;
                    ps.Margins = new Margins(50, 50, 50, 50);
                    break;

                case "MarginModerate":
                    ps         = Editor.PrintDocument.DefaultPageSettings;
                    ps.Margins = new Margins(75, 75, 100, 100);
                    break;

                case "MarginWide":
                    ps         = Editor.PrintDocument.DefaultPageSettings;
                    ps.Margins = new Margins(200, 200, 200, 200);
                    break;

                case "MarginOffice":
                    ps         = Editor.PrintDocument.DefaultPageSettings;
                    ps.Margins = new Margins(125, 125, 100, 100);
                    break;

                case "CustomMargins":
                    using (PageSetupDialog dlg = new PageSetupDialog())
                    {
                        dlg.Document = Editor.PrintDocument;
                        dlg.ShowDialog();
                    }
                    break;

                // orientation
                case "Landscape":
                    ps           = Editor.PrintDocument.DefaultPageSettings;
                    ps.Landscape = true;
                    break;

                case "Portrait":
                    ps           = Editor.PrintDocument.DefaultPageSettings;
                    ps.Landscape = false;
                    break;

                // paper size
                default:
                    PaperSize paperSize = item.Tag as PaperSize;
                    if (paperSize != null)
                    {
                        ps           = Editor.PrintDocument.DefaultPageSettings;
                        ps.PaperSize = paperSize;
                    }
                    break;
                }
            }
        }
Exemplo n.º 25
0
 protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
 {
     //Commands.DocumentAdmin.Execute(SceneContext.Instance);
     throw new NotImplementedException("功能暂时未实现!");
 }
Exemplo n.º 26
0
        protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
        {
            OfficeWord.Application app = SceneContext.Instance.WordAppAdmin.Application;

            var file = new FilesForm(context, app);

            if (file.ShowDialog() == DialogResult.OK)
            {
                if (string.IsNullOrEmpty(file.LocalFileName))
                {
                    return;
                }
                // 关闭当前的文档
                object missing = System.Reflection.Missing.Value;

                var newFile = new FileInfo(file.LocalFileName);
                if (newFile.Exists)
                {
                    // 注入用户数据
                    //CreateCustomXml(openFileName, loginObj);

                    // 打开该文件
                    object fileNameObj = file.LocalFileName;
                    object visible     = true;
                    app.ScreenUpdating = false;
                    OfficeWord.Document wDoc = app.Documents.Open(ref fileNameObj, ref missing, ref missing
                                                                  , ref missing, ref missing, ref missing
                                                                  , ref missing, ref missing, ref missing
                                                                  , ref missing, ref missing, ref visible
                                                                  , ref missing, ref missing, ref missing
                                                                  , ref missing);
                    app.ScreenUpdating = true;
                    // 记录当前文档数据
                    var entry = new SecretEntry()
                    {
                        LoginEntity = null,
                        BizFileName = file.LocalFileName,
                        BizFileId   = "",
                    };
                    SceneContext.Instance.SecretDataAdmin.Set(wDoc, entry);

                    //wDoc.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdPrintView;
                    // 记录当前文档数据
                    //SecretEntry entry = new SecretEntry()
                    //{
                    //    LoginEntity = loginEntity,
                    //    BizFileName = fileInfo.FullName,
                    //    BizFileId = fileInfo.FileId,
                    //    AuthAdmin = secretEntry.AuthAdmin,
                    //};
                    //context.SecretDataAdmin.Set(wDoc, entry);

                    // 获取数据
                    //string xml = wDoc.SelectPartXmlByNamespace("---namespace----");

                    //object saveChange = false;
                    //doc.Close(ref saveChange, ref nullobj, ref nullobj);
                }
            }



            //var dialog = new F.OpenFileDialog();
            //dialog.InitialDirectory = @"C:\";
            //dialog.Filter = "所有Word文档|*.docx;*.docm;*.dotx;*.doc;*.dot;*.htm;*.html|Word文档|*.docx|启用宏的Word文档|*.docm|Xml文件|*.xml|Word97-2003文档|*.doc";
            //dialog.FilterIndex = 1;
            //if (dialog.ShowDialog() == F.DialogResult.OK)
            //{
            //    string fileName = dialog.FileName;
            //    //// 检查文件是否已打开
            //    //string fileName = context.WordAppAdmin.Application.ActiveDocument.Name;
            //    //if (fileName.Equals(dialog.FileName))
            //    //{
            //    //    MessageBox.Show(string.Format("文件 {0}已打开.",fileName));
            //    //    return false;
            //    //}
        }
Exemplo n.º 27
0
        internal override void HandleItemEvent(RibbonEventArgs e)
        {
            RibbonItem item = (RibbonItem)e.Item;

            if (e.EventType == RibbonEventType.Click)
            {
                switch (item.ID)
                {
                case "DateAndTime":
                    using (InsertDateTime dlg = new InsertDateTime())
                    {
                        dlg.ShowDialog(Editor);
                    }
                    break;

                case "Symbol":
                    _symbolDlg.ShowDialog(Editor);
                    break;

                case "PageBreak":
                    Editor.InsertPageBreak();
                    break;

                case "Picture":
                    Editor.InsertPicture();
                    break;

                case "FlashMovie":
                    Editor.InsertFlashMovie();
                    break;

                case "Hyperlink":
                    Editor.InsertHyperlink();
                    break;

                case "Bookmark":
                    Editor.InsertBookmark();
                    break;

                case "InsertTable":
                    Editor.InsertTable();
                    break;

                case "InsertRowAbove":
                    Editor.InsertTableRowAbove();
                    break;

                case "InsertRowBelow":
                    Editor.InsertTableRowBelow();
                    break;

                case "InsertColumnBefore":
                    Editor.InsertTableColumnBefore();
                    break;

                case "InsertColumnAfter":
                    Editor.InsertTableColumnAfter();
                    break;

                case "DeleteTable":
                    Editor.DeleteTable();
                    break;

                case "DeleteRows":
                    Editor.DeleteTableRows();
                    break;

                case "DeleteColumns":
                    Editor.DeleteTableColumns();
                    break;

                case "TableProperties":
                    Editor.TableProperties();
                    break;

                case "TableRowProperties":
                    Editor.TableRowProperties();
                    break;

                case "TableColumnProperties":
                    Editor.TableColumnProperties();
                    break;

                case "TableCellProperties":
                    Editor.TableCellProperties();
                    break;
                }
            }

            base.HandleItemEvent(e);
        }
Exemplo n.º 28
0
 public void OnToggleButtonClick(object sender, RibbonEventArgs e) =>
 ToggleButtonClick?.Invoke(sender, e);
Exemplo n.º 29
0
 protected void onTabSelect(object sender, RibbonEventArgs e)
 {
     serverEvent.InnerHtml = serverEvent.InnerHtml + span + "Ribbon Tab" + e.CurrentTabIndex + "</span>is Selected</span><hr>";
 }
Exemplo n.º 30
0
 protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
 {
     //SceneContext.Instance.Logout();
 }