예제 #1
0
        void HandleStartupEvent(object sender, EventArgs e)
        {
            Tracer.WriteTraceMethodLine();
            if (sender is API.IOneNoteAddIn)
            {
                var application = ((API.IOneNoteAddIn)sender).Application;
                RibbonView = new RibbonView(application);

                ButtonClick       += RibbonView.NotebookButton_Click;
                ButtonClick       += RibbonView.PageColor_None;
                ColorClick        += RibbonView.PageColor_Click;
                GetSuperTip       += RibbonView.GetSuperTip;
                LoadImage         += RibbonView.PageColor_LoadImage;
                ShowForm          += RibbonView.OptionsForm_Show;
                ToggleButtonClick += (snd, evt) =>
                {
                    RibbonView.RuleLinesVisible_Toggle(snd, evt);

                    RibbonView.RuleLinesSpacingControls.ForEach(
                        item => RibbonUI.InvalidateControl(item.ToString()));
                };

                RibbonUI?.ActivateTabMso("TabHome");
            }
        }
예제 #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);
            }
        }
예제 #3
0
 void HandleShutdownEvent(object sender, EventArgs e)
 {
     Tracer.WriteTraceMethodLine();
     if (RibbonView != null)
     {
         RibbonView.Dispose();
         RibbonView = null;
     }
 }
예제 #4
0
        TResult DelegateToView <TResult>(
            Office.IRibbonControl control, string methodName)
        {
            var result = default(TResult);
            var flags  = BindingFlags.Instance | BindingFlags.NonPublic;
            var mi     = RibbonView.GetType().GetMethod(methodName, flags);

            if (mi != null)
            {
                var viewFunc = (Func <Office.IRibbonControl, TResult>)
                               Delegate.CreateDelegate(
                    typeof(Func <Office.IRibbonControl, TResult>), RibbonView, mi);

                return(viewFunc(control));
            }
            Tracer.WriteErrorLine("Method '{0}' not found", methodName);
            return(result);
        }