Exemplo n.º 1
0
        protected override void OnEnvironmentOpen()
        {
            AnalyticsUtils.StartSession();

            Application.UserInterfaceManager.UserInteractionDisabled = true;
            var loadingBar = new LoadingBar("Loading Export Environment...");

            loadingBar.SetProgress(new ProgressUpdate("Preparing UI Managers...", 1, 10));
            loadingBar.Show();
            HighlightManager.EnvironmentOpening(OpenAssemblyDocument);

            // Disable non-jointed components
            disabledAssemblyOccurrences = new List <ComponentOccurrence>();
            disabledAssemblyOccurrences.AddRange(InventorUtils.DisableUnconnectedComponents(OpenAssemblyDocument));

            loadingBar.SetProgress(new ProgressUpdate("Loading Robot Skeleton...", 2, 10));
            // Load robot skeleton and prepare UI
            RobotDataManager = new RobotDataManager();
            if (!RobotDataManager.LoadRobotSkeleton(new Progress <ProgressUpdate>(loadingBar.SetProgress)))
            {
                loadingBar.Close();
                Application.UserInterfaceManager.UserInteractionDisabled = false;
                InventorUtils.ForceQuitExporter(OpenAssemblyDocument);
                return;
            }

            if (RobotDataManager.wasForceQuit)
            {
                return;
            }

            loadingBar.SetProgress(new ProgressUpdate("Loading Joint Data...", 7, 10));
            RobotDataManager.LoadRobotData(OpenAssemblyDocument);

            loadingBar.SetProgress(new ProgressUpdate("Initializing UI...", 8, 10));
            // Create dockable window UI
            var uiMan = Application.UserInterfaceManager;

            advancedJointEditor.CreateDockableWindow(uiMan);
            jointViewKey.Init(uiMan);
            guideManager.Init(uiMan);

            guideManager.Visible = AddInSettingsManager.ShowGuide;

            loadingBar.SetProgress(new ProgressUpdate("Loading Robot Skeleton...", 9, 10));
            // Load skeleton into joint editors
            advancedJointEditor.LoadRobot(RobotDataManager);
            jointEditorForm.LoadRobot(RobotDataManager);
            loadingBar.Close();
            Application.UserInterfaceManager.UserInteractionDisabled = false;
        }
Exemplo n.º 2
0
        protected override void OnEnvironmentClose()
        {
            Application.UserInterfaceManager.UserInteractionDisabled = true;
            var loadingBar = new LoadingBar("Closing Export Environment...");

            loadingBar.SetProgress(new ProgressUpdate("Saving Robot Data...", 3, 5));
            loadingBar.Show();
            RobotDataManager.SaveRobotData(OpenAssemblyDocument);
            loadingBar.Close();
            Application.UserInterfaceManager.UserInteractionDisabled = false;

            if (!RobotDataManager.wasForceQuit)
            {
                var exportResult = MessageBox.Show(new Form {
                    TopMost = true
                },
                                                   "The robot configuration has been saved to your assembly document.\nWould you like to export your robot to Synthesis?",
                                                   "Robot Configuration Complete",
                                                   MessageBoxButtons.YesNo);

                if (exportResult == DialogResult.Yes)
                {
                    UnsupportedComponentsForm.CheckUnsupportedComponents(RobotDataManager.RobotBaseNode.ListAllNodes());
                    if (ExportForm.PromptExportSettings(RobotDataManager))
                    {
                        if (RobotDataManager.ExportRobot())
                        {
                            AnalyticsUtils.LogEvent("Export", "Succeeded");
                            if (Instance.AddInSettingsManager.OpenSynthesis)
                            {
                                SynthesisUtils.OpenSynthesis(RobotDataManager.RobotName);
                            }
                        }
                        else
                        {
                            AnalyticsUtils.LogEvent("Export", "Cancelled");
                        }
                    }
                }
            }

            // Re-enable disabled components
            if (disabledAssemblyOccurrences != null)
            {
                InventorUtils.EnableComponents(disabledAssemblyOccurrences);
            }
            disabledAssemblyOccurrences = null;

            advancedJointEditor.DestroyDockableWindow();
            guideManager.DestroyDockableWindow();
            jointViewKey.DestroyDockableWindow();
            AnalyticsUtils.EndSession();
        }