Esempio n. 1
0
        /// <summary>
        /// Init JPP command loads all essential elements of the program, including the helper DLL files.
        /// </summary>
        public static void InitJPP()
        {
            Logger.Log("Loading JPP Core...\n");
            //Create the main UI
            RibbonTab JPPTab = CreateTab();

            CreateCoreMenu(JPPTab);

            //Load the additional DLL files, but only not if running in debug mode
            #if !DEBUG
            Update();
            #endif
            LoadModules();


            //Create settings window
            //TODO: move common window creation code to utilities method
            _settingsWindow             = new PaletteSet("JPP", new Guid("9dc86012-b4b2-49dd-81e2-ba3f84fdf7e3"));
            _settingsWindow.Size        = new Size(600, 800);
            _settingsWindow.Style       = (PaletteSetStyles)((int)PaletteSetStyles.ShowAutoHideButton + (int)PaletteSetStyles.ShowCloseButton);
            _settingsWindow.DockEnabled = (DockSides)((int)DockSides.Left + (int)DockSides.Right);

            ElementHost settingsWindowHost = new ElementHost();
            settingsWindowHost.AutoSize = true;
            settingsWindowHost.Dock     = DockStyle.Fill;
            settingsWindowHost.Child    = new SettingsUserControl();
            _settingsWindow.Add("Settings", settingsWindowHost);
            _settingsWindow.KeepFocus = false;

            //Load click handler;
            ClickOverride = ClickOverride.Current;

            //Check for registry key for autoload
            if (!RegistryHelper.IsAutoload())
            {
                //No autoload found
                //TODO: try to condense this into a helper method
                TaskDialog autoloadPrompt = new TaskDialog();
                autoloadPrompt.WindowTitle     = Constants.Friendly_Name;
                autoloadPrompt.MainInstruction = "JPP Library does not currently load automatically. Would you like to enable this?";
                autoloadPrompt.MainIcon        = TaskDialogIcon.Information;
                autoloadPrompt.FooterText      = "May cause unexpected behaviour on an unsupported version of Autocad";
                autoloadPrompt.FooterIcon      = TaskDialogIcon.Warning;
                autoloadPrompt.Buttons.Add(new TaskDialogButton(0, "No, continue without"));
                autoloadPrompt.Buttons.Add(new TaskDialogButton(1, "Enable autoload"));
                autoloadPrompt.DefaultButton = 0;
                autoloadPrompt.Callback      = delegate(ActiveTaskDialog atd, TaskDialogCallbackArgs e, object sender)
                {
                    if (e.Notification == TaskDialogNotification.ButtonClicked)
                    {
                        if (e.ButtonId == 1)
                        {
                            //TODO: Disable when registry is ok
                            //RegistryHelper.CreateAutoload();
                            Application.ShowAlertDialog("Autload creation currently disabled.");
                        }
                    }
                    return(false);
                };
                autoloadPrompt.Show(Application.MainWindow.Handle);
            }

            Logger.Log("JPP Core loaded.\n");
        }
Esempio n. 2
0
        public static void CreateUI()
        {
            //Create the main UI
            RibbonTab jppTab = CreateTab();

            CreateCoreMenu(jppTab);

            //Create settings window
            //TODO: move common window creation code to utilities method
            _settingsWindow = new PaletteSet("JPP", new Guid("9dc86012-b4b2-49dd-81e2-ba3f84fdf7e3"))
            {
                Size  = new Size(600, 800),
                Style = (PaletteSetStyles)((int)PaletteSetStyles.ShowAutoHideButton +
                                           (int)PaletteSetStyles.ShowCloseButton),
                DockEnabled = (DockSides)((int)DockSides.Left + (int)DockSides.Right)
            };

            ElementHost settingsWindowHost = new ElementHost();

            settingsWindowHost.AutoSize = true;
            settingsWindowHost.Dock     = DockStyle.Fill;
            settingsWindowHost.Child    = new SettingsUserControl();
            _settingsWindow.Add("Settings", settingsWindowHost);
            _settingsWindow.KeepFocus = false;

            //Check for registry key for autoload
            if (!RegistryHelper.IsAutoload())
            {
                //No autoload found
                //TODO: try to condense this into a helper method
                TaskDialog autoloadPrompt = new TaskDialog();
                autoloadPrompt.WindowTitle     = Resources.Core_FriendlyName;
                autoloadPrompt.MainInstruction = Resources.Core_Autoload_QueryEnable;
                autoloadPrompt.MainIcon        = TaskDialogIcon.Information;
                autoloadPrompt.FooterText      = Resources.Core_Autoload_Warn;
                autoloadPrompt.FooterIcon      = TaskDialogIcon.Warning;
                autoloadPrompt.Buttons.Add(new TaskDialogButton(0, Resources.Core_Autoload_Skip));
                autoloadPrompt.Buttons.Add(new TaskDialogButton(1, Resources.Core_Autoload_Enable));
                autoloadPrompt.DefaultButton = 0;
                autoloadPrompt.Callback      = delegate(ActiveTaskDialog atd, TaskDialogCallbackArgs e, object sender)
                {
                    if (e.Notification != TaskDialogNotification.ButtonClicked)
                    {
                        return(false);
                    }
                    if (e.ButtonId == 1)
                    {
                        //TODO: Disable when registry is ok
                        //RegistryHelper.CreateAutoload();
                        Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog(
                            "Autload creation currently disabled.");
                    }

                    return(false);
                };
                autoloadPrompt.Show(Autodesk.AutoCAD.ApplicationServices.Core.Application.MainWindow.Handle);
            }

            //Load click handler;
            _clickOverride = ClickOverride.Current;
        }