Exemplo n.º 1
0
        public void OnAction(Office.IRibbonControl control)
        {
            try
            {
                switch (control.Id)
                {
                case "customButton1":
                    MessageBox.Show("This is the first sample button.", _prodId);
                    break;

                case "customButton2":
                    MessageBox.Show("This is the second sample button.", _prodId);
                    break;

                default:
                    MessageBox.Show("Unkown Control Id: " + control.Id, _prodId);
                    break;
                }
            }
            catch (Exception exception)
            {
                string message = string.Format("An error occured.{0}{0}{1}", Environment.NewLine, exception.Message);
                MessageBox.Show(message, _prodId, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
 // Defined in RibbonUI.xml to track the user clicked ouer checkbutton. Then we upate the panel visibility at hand.
 public void OnCheckPanelToggle(Office.IRibbonControl control, bool pressed)
 {
     if (TaskPanes.Count > 0)
     {
         TaskPanes[0].Visible = pressed;
     }
 }
Exemplo n.º 3
0
        public void OnAction(Office.IRibbonControl control)
        {
            try
            {
                string appInfo = string.Format("\n\nHost application: {0}.{1}\nVersion: {2}",
                                               TypeDescriptor.GetComponentName(_application.UnderlyingObject),
                                               _application.UnderlyingTypeName,
                                               Invoker.Default.PropertyGet(_application, "Version")
                                               );

                switch (control.Id)
                {
                case "customButton1":
                    MessageBox.Show("This is the first sample button. " + appInfo, ADDIN_TITLE, MessageBoxButtons.OK);
                    break;

                case "customButton2":
                    MessageBox.Show("This is the second sample button. " + appInfo, ADDIN_TITLE, MessageBoxButtons.OK);
                    break;

                case "btnAbout":
                    MessageBox.Show("Sample add-in using IDTExtensibility2 interface that is registered to multiple Microsoft Office applications.", ADDIN_TITLE, MessageBoxButtons.OK);
                    break;

                default:
                    MessageBox.Show("Unkown Control Id: " + control.Id, ADDIN_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }
            }
            catch (Exception ex)
            {
                string message = string.Format("Error occured: {0}", ex.Message);
                MessageBox.Show(message, _progId, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        public void OnAction(NetOffice.OfficeApi.IRibbonControl control)
        {
            try
            {
                switch (control.Id)
                {
                case "customButton1":

                    MessageBox.Show("This is the first sample button. " + Application.FriendlyTypeName, "NetOfficeTools.SuperAddinCS4");
                    break;

                case "customButton2":
                    MessageBox.Show("This is the second sample button." + Application.FriendlyTypeName, "NetOfficeTools.SuperAddinCS4");
                    break;

                default:
                    MessageBox.Show("Unkown Control Id: " + control.Id, "NetOfficeTools.SuperAddinCS4");
                    break;
                }
            }
            catch (Exception throwedException)
            {
                string details = string.Format("{1}{1}Details:{1}{1}{0}", throwedException.Message, Environment.NewLine);
                MessageBox.Show("An error occured in OnAction." + details, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        public void OnAction(Office.IRibbonControl control)
        {
            try
            {
                switch (control.Id)
                {
                case "customButton1":
                    MessageBox.Show("This is the first sample button.", _progId);
                    break;

                case "customButton2":
                    MessageBox.Show("This is the second sample button.", _progId);
                    break;

                default:
                    MessageBox.Show("Unkown Control Id: " + control.Id, _progId);
                    break;
                }
            }
            catch (Exception throwedException)
            {
                string details = string.Format("{1}{1}Details:{1}{1}{0}", throwedException.Message, Environment.NewLine);
                MessageBox.Show("An error occured." + details, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
 // Defined in RibbonUI.xml to make sure the checkbutton state is up-to-date and synchronized with taskpane visibility.
 public bool OnGetPressedPanelToggle(Office.IRibbonControl control)
 {
     if (TaskPanes.Count > 0)
     {
         return(TaskPanes[0].Visible);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 7
0
        public void OnAction(Office.IRibbonControl control)
        {
            try
            {
                string message = string.Format("Thanks for click on a Ribbon.\r\nHostApp is {0}.{1} Version:{2}",
                                               TypeDescriptor.GetComponentName(_application.UnderlyingObject), _application.UnderlyingTypeName, Invoker.PropertyGet(_application, "Version"));

                MessageBox.Show(message, _progId, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception exception)
            {
                string message = string.Format("An error occured.{0}{0}{1}", Environment.NewLine, exception.Message);
                MessageBox.Show(message, _progId, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 8
0
        public void OnRibbonButtonClick(NetOffice.OfficeApi.IRibbonControl control)
        {
            try
            {
                switch (control.Id)
                {
                case "customButton1":
                    MessageBox.Show(String.Format("Hosted in {0}", Application.InstanceFriendlyName));
                    break;

                case "customButton2":
                    MessageBox.Show(String.Format("Loading Time {0}", LoadingTimeElapsed));
                    break;
                }
            }
            catch (Exception throwedException)
            {
                Utils.Dialog.ShowError(throwedException, "Unexpected state in SuperAddinCS4 OnClickRibbonButton");
            }
        }
Exemplo n.º 9
0
        public void SampleButton1_Click(Office.IRibbonControl control)
        {
            try
            {
                //MessageBox.Show("Me is " + _id.ToString());

                if (Parent.HasShimHost)
                {
                    Parent.CallShimHost();
                }
                else
                {
                    string message = "I dont have a shim host :(";
                    MessageBox.Show(message, "InnerAddin.MyRibbonExtensibility");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString(), "SampleButton1_Click");
                throw;
            }
        }
Exemplo n.º 10
0
        public void OnAction(NetOffice.OfficeApi.IRibbonControl control)
        {
            try
            {
                switch (control.Id)
                {
                case "customButton1":
                    Utils.Dialog.ShowMessageBox("This is the first sample button. " + Application.FriendlyTypeName, "NetOfficeTools.SuperAddinCS4", DialogResult.None);
                    break;

                case "customButton2":
                    Utils.Dialog.ShowMessageBox("This is the second sample button. " + Application.FriendlyTypeName, "NetOfficeTools.SuperAddinCS4", DialogResult.None);
                    break;

                default:
                    Utils.Dialog.ShowMessageBox("Unkown Control Id: " + control.Id, "NetOfficeTools.SuperAddinCS4", DialogResult.None);
                    break;
                }
            }
            catch (Exception throwedException)
            {
                Utils.Dialog.ShowError(throwedException, "Unexpected state in SuperAddinCS4 OnAction");
            }
        }
Exemplo n.º 11
0
 // Defined in RibbonUI.xml to catch the user click for the about button
 public void OnClickAboutButton(Office.IRibbonControl control)
 {
     Utils.Dialog.ShowDiagnostics();
 }
Exemplo n.º 12
0
 public void OnClickAboutButton(Office.IRibbonControl control)
 {
     Current.GetType().InvokeMember("OnClickAboutButton",
                                    BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance,
                                    null, Current, new object[] { control });
 }
Exemplo n.º 13
0
 public string GetButtonLabel(NetOffice.OfficeApi.IRibbonControl control)
 {
     return("自定义\n");
 }
Exemplo n.º 14
0
 // defined in RibbonUI.xml to catch the user click for the about button
 public void OnClickAboutButton(Office.IRibbonControl control)
 {
     Utils.Dialog.ShowAbout("NetOffice Addin Example", "http://netoffice.codeplex.com", "<No licence set>");
 }
Exemplo n.º 15
0
 // defined in RibbonUI.xml to make sure the checkbutton state is up-to-date and synchronized with taskpane visibility.
 public bool OnGetPressedPanelToggle(Office.IRibbonControl control)
 {
     return(TaskPanes[0].Visible);
 }
Exemplo n.º 16
0
 // defined in RibbonUI.xml to catch the user click for the about button
 public void OnClickAboutButton(Office.IRibbonControl control)
 {
     MessageBox.Show("NetOffice Tools - Extended Sample Addin.", "ExtendedPPointCS4.Addin");
 }
Exemplo n.º 17
0
 public void ButtonAction(NetOffice.OfficeApi.IRibbonControl control)
 {
     MessageBox.Show("Hello World");
 }
Exemplo n.º 18
0
 public stdole.IPictureDisp GetButtonImage(NetOffice.OfficeApi.IRibbonControl control)
 {
     return(PictureConverter.IconToPictureDisp(Properties.Resources.SampleIcon2));
 }
Exemplo n.º 19
0
 // Defined in RibbonUI.xml to catch the user click for the about button
 public void OnClickAboutButton(Office.IRibbonControl control)
 {
     Utils.Dialog.ShowAbout("NetOffice Add-in Sample", "https://netoffice.io", "");
 }
Exemplo n.º 20
0
 public void OnCheckPanelToggle(Office.IRibbonControl control, bool pressed)
 {
     Current.GetType().InvokeMember("OnCheckPanelToggle",
                                    BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance,
                                    null, Current, new object[] { control, pressed });
 }
Exemplo n.º 21
0
 public string GetLabel(Office.IRibbonControl control)
 {
     return(Factory.Settings.ExceptionMessage);
 }
Exemplo n.º 22
0
        public void SampleButton2_Click(Office.IRibbonControl control)
        {
            string message = "I'm alive :)" + Environment.NewLine + "My Hash is: " + GetHashCode();

            MessageBox.Show(message, "InnerAddin.MyRibbonExtensibility");
        }
Exemplo n.º 23
0
 public bool OnGetPressedPanelToggle(Office.IRibbonControl control)
 {
     return((bool)Current.GetType().InvokeMember("OnGetPressedPanelToggle",
                                                 BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance,
                                                 null, Current, new object[] { control }));
 }