Exemplo n.º 1
0
        /// <summary>
        /// Instiantiation of EventManager
        /// </summary>
        private MacroUI(IMacroEngine engine)
        {
            s_Instance = this;
            m_IsLoaded = false;

            MacroEngine = engine;
        }
Exemplo n.º 2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            s_Instance = this;

            Executor executor = null;

            m_Engine = MacroEngine.CreateApplicationInstance(executor);
            m_UI     = MacroUI.CreateApplicationInstance(m_Engine);


            AssemblyDeclaration Interop_Assembly = new AssemblyDeclaration("Microsoft.Office.Interop.Excel", "./", true);

            m_UI.AddAssembly(Interop_Assembly);

            Excel.Application oExcelApp = GetExcel();

            m_UI.SetExecutionValue("HOSTNAME", "Standalone App");
            m_UI.SetExecutionValue("Excel", oExcelApp.Application);
            m_UI.SetExecutionValue("MISSING", Type.Missing);

            m_UI.AddAccent("ExcelAccent", new Uri("pack://application:,,,/Macro Editor;component/Themes/Accents/ExcelAccent.xaml"));
            m_UI.AddAccent("WordAccent", new Uri("pack://application:,,,/Macro Editor;component/Themes/Accents/WordAccent.xaml"));
            m_UI.AddAccent("PowerPointAccent", new Uri("pack://application:,,,/Macro Editor;component/Themes/Accents/PowerPointAccent.xaml"));
            m_UI.AddAccent("OneNoteAccent", new Uri("pack://application:,,,/Macro Editor;component/Themes/Accents/OneNoteAccent.xaml"));
            m_UI.AddAccent("AccessAccent", new Uri("pack://application:,,,/Macro Editor;component/Themes/Accents/AccessAccent.xaml"));
            m_UI.AddAccent("OutlookAccent", new Uri("pack://application:,,,/Macro Editor;component/Themes/Accents/OutlookAccent.xaml"));
            m_UI.AddAccent("PublisherAccent", new Uri("pack://application:,,,/Macro Editor;component/Themes/Accents/PublisherAccent.xaml"));

            m_UI.SetAccent("ExcelAccent");

            Events.InvokeEvent("ApplicationLoaded");

            MainWindow = m_UI.MainWindow;
            MainWindow.Show();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes the UI and Interop and binds events to the AddIn.
        /// </summary>
        /// <param name="application">Excel Application</param>
        /// <param name="dispatcher">Excel UI Dispatcher</param>
        /// <param name="RibbonMacros">A serialized list of ribbon accessible macros</param>
        public static MacroUI CreateApplicationInstance(IMacroEngine engine)
        {
            MacroUI ui = new MacroUI(engine);

            string[]  workspaces = new string[] { Path.GetFullPath(Files.AssemblyDirectory + "/Macros/") };
            HostState state      = new HostState(workspaces, Properties.Settings.Default.ActiveDocument, Properties.Settings.Default.IncludedLibraries);

            engine.Instantiate(state);
            ui.Instantiate(state);


            ui.MainWindow = new MainWindow()
            {
                DataContext = new MainWindowViewModel()
            };
            ((MainWindowViewModel)ui.MainWindow.DataContext).SetTheme(Macro_Editor.Properties.Settings.Default.Theme);

            if (ui.m_IsRibbonLoaded)
            {
                Events.InvokeEvent("LoadRibbonMacros");
            }

            ui.m_IsLoaded = true;

            return(ui);
        }