Source

main / Source / Excel / Excel.AddIn / Excel.AddIn / Ribbon.cs

using System;
using DataUp.Excel.Common;
using Microsoft.Office.Tools;
using Microsoft.Office.Tools.Ribbon;

namespace DataUp.Excel.Addin
{
    public partial class Ribbon
    {
        public bool IsSuppressCSVCheck
        {
            get
            {
                return false;
            }
        }

        /// <summary>
        /// Host control for Custom Task Pane
        /// </summary>
        private CustomTaskPaneHost customTaskPaneHost;

        /// <summary>
        /// custom task pane instance
        /// </summary>
        private CustomTaskPane customTaskPane;

        #region Events

        internal event EventHandler ValidateClicked;

        internal event EventHandler FixAllErrorsClicked;

        internal event EventHandler GenerateMetadataClicked;

        internal event EventHandler GenerateParaMetaDataClicked;

        internal event EventHandler ClearParameterMetaDataClicked;

        internal event EventHandler ResetParamterMetaDataClicked;

        internal event EventHandler GenerateCitationClicked;

        internal event EventHandler PostToRepositoryClicked;

        #endregion

        internal void HideCustomTaskPane()
        {
            this.customTaskPane.Visible = false;
        }

        internal void DisableCustomTaskPaneButtons()
        {
            btnValidate.Enabled = false;
            btnGenerateParaMetadata.Enabled = false;
            btnGenerateMetadata.Enabled = false;
            btnGenerateCitation.Enabled = false;
            btnPostRepository.Enabled = false;
        }

        internal void EnableCustomTaskPaneButtons()
        {
            btnValidate.Enabled = true;
            btnGenerateParaMetadata.Enabled = true;
            btnGenerateMetadata.Enabled = true;
            btnGenerateCitation.Enabled = true;
            btnPostRepository.Enabled = true;
        }

        private void Ribbon_Load(object sender, RibbonUIEventArgs e)
        {
            this.InitializeCustomTaskPane();

            // Set the Excel application to Common.Globals, so that it can be used across.
            ThisAddIn.ExcelApplication = Globals.ThisAddIn.Application;

            // Initialize Controller.
            Controller.Instance.Initialize(this.customTaskPaneHost.TaskPane, this);
        }

        /// <summary>
        /// Initializes custom task pane
        /// </summary>
        private void InitializeCustomTaskPane()
        {
            this.customTaskPaneHost = new CustomTaskPaneHost();
            this.customTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(this.customTaskPaneHost, "Error Details");
            this.customTaskPane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight;
            this.customTaskPane.Visible = false;
            this.customTaskPane.Width = 315;
        }

        private void OnValidateClick(object sender, RibbonControlEventArgs e)
        {
            this.customTaskPane.Visible = true;
            this.ValidateClicked.OnFire(sender, new EventArgs());
        }

        private void OnFixAllErrorsClick(object sender, RibbonControlEventArgs e)
        {
            this.FixAllErrorsClicked.OnFire(sender, new EventArgs());
        }

        private void OnGenerateMetadataClick(object sender, RibbonControlEventArgs e)
        {
            this.customTaskPane.Visible = false;
            this.GenerateMetadataClicked.OnFire(sender, new EventArgs());

            ribbonTab.Visible = true;
        }

        private void OnGenerateParaMetadataClick(object sender, RibbonControlEventArgs e)
        {
            this.customTaskPane.Visible = false;
            this.GenerateParaMetaDataClicked.OnFire(sender, new EventArgs());

            ribbonTab.Visible = true;
        }

        private void OnClearParaMetadataClick(object sender, RibbonControlEventArgs e)
        {
            this.ClearParameterMetaDataClicked.OnFire(sender, new EventArgs());
        }

        private void OnResetParaMetadataClick(object sender, RibbonControlEventArgs e)
        {
            this.ResetParamterMetaDataClicked.OnFire(sender, new EventArgs());
        }

        private void OnGenerateCitationClick(object sender, RibbonControlEventArgs e)
        {
            this.customTaskPane.Visible = false;

            this.GenerateCitationClicked.OnFire(sender, new EventArgs());

            ribbonTab.Visible = true;
        }

        private void btnPostRepository_Click(object sender, RibbonControlEventArgs e)
        {
            this.customTaskPane.Visible = false;
            this.PostToRepositoryClicked.OnFire(sender, new EventArgs());

            ribbonTab.Visible = true;
        }

        private void btnDemo_Click(object sender, RibbonControlEventArgs e)
        {
            System.Diagnostics.Process.Start(Constants.DemoVideoLink);
        }
    }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.