예제 #1
0
 public NoUndoMWCmd(String name, CommandScope scope, bool active,
     MsgWin win, CmdType comType)
     : base(name, scope, active)
 {
     messageWindow = win;
     commandType = comType;
 }
예제 #2
0
        public DXApplication(String s)
            : base(s)
        {
            theDXApplication = this;
            anchor = null;
            serverDisconnectScheduled = false;
            network = null;

            // Create the local command scope.
            commandScope = new CommandScope();

            // Initialize the packet interface.
            serverInfo.packet = null;
            applicationPacket = null;
            messageWindow = null;

            genericHelpCmd = new HelpMenuCommand("genericAppHelp",
                null, true, HelpMenuCommand.HelpType.GenericHelp);
            helpTutorialCmd = new HelpMenuCommand("helpTutorial",
                null, true, HelpMenuCommand.HelpType.HelpTutorial);

            quitCmd = new ConfirmedQuitCommand("quit", commandScope,
                true, this);
            exitCmd = new ConfirmedExitCommand("exit", commandScope,
                true, this);
            openFileCmd = new OpenCommand("open", commandScope,
                true, this);
            messageWindowCmd = new NoUndoDXAppCommand("messageWindowCmd",
                commandScope, true, this, CommandType.OpenMessageWindow);

            openSequencerCmd = new NoUndoDXAppCommand("openSequencerCmd",
                commandScope, false, this, CommandType.OpenSequencer);
            openAllColormapCmd = new NoUndoDXAppCommand("openAllColormapCmd",
                commandScope, false, this, CommandType.OpenAllColormaps);
            loadMacroCmd = new NoUndoDXAppCommand("Load Macro Command",
                commandScope, true, this, CommandType.LoadMacro);
            executeOnceCmd = new NoUndoDXAppCommand("Execute Once",
                commandScope, false, this, CommandType.ExecuteOnce);
            executeOnChangeCmd = new NoUndoDXAppCommand("Execute On Change",
                commandScope, false, this, CommandType.ExecuteOnChange);
            endExecutionCmd = new NoUndoDXAppCommand("End Execution",
                commandScope, false, this, CommandType.EndExecution);
            connectedToServerCmd = new NoOpCommand("Connected To Server",
                commandScope, true);
            disconnectedFromServerCmd = new NoOpCommand("Disconnected From Server",
                commandScope, true);
            executingCmd = new NoOpCommand("executingCmd", commandScope, true);
            notExecutingCmd = new NoOpCommand("notExecutingCmd", commandScope, true);
            connectToServerCmd = new NoUndoDXAppCommand("Start Server",
                commandScope, true, this, CommandType.StartServer);
            resetServerCmd = new NoUndoDXAppCommand("Reset Server",
                commandScope, false, this, CommandType.ResetServer);
            disconnectFromServerCmd = new DisconnectFromServerCommand("disconnectFromServer",
                commandScope, false);
            loadMDFCmd = new NoUndoDXAppCommand("Load MDF...",
                commandScope, true, this, CommandType.LoadUserMDF);
            toggleInfoEnable = new NoUndoDXAppCommand("Enable Information",
                commandScope, true, this, CommandType.ToggleInfoEnabled);
            toggleWarningEnable = new NoUndoDXAppCommand("Enable Warnings",
                commandScope, true, this, CommandType.ToggleWarningEnabled);
            toggleErrorEnable = new NoUndoDXAppCommand("Enable Errors",
                commandScope, true, this, CommandType.ToggleErrorEnabled);
            assignProcessGroupCmd = new NoUndoDXAppCommand("assignProcessGroup",
                commandScope, true, this, CommandType.AssignProcessGroup);

            connectedToServerCmd.autoActivate(executeOnceCmd);
            connectedToServerCmd.autoActivate(executeOnChangeCmd);
            connectedToServerCmd.autoActivate(endExecutionCmd);
            connectedToServerCmd.autoActivate(disconnectedFromServerCmd);
            connectedToServerCmd.autoActivate(resetServerCmd);
            connectedToServerCmd.autoActivate(connectedToServerCmd);

            disconnectedFromServerCmd.autoActivate(connectedToServerCmd);
            disconnectedFromServerCmd.autoActivate(executeOnceCmd);
            disconnectedFromServerCmd.autoActivate(executeOnChangeCmd);
            disconnectedFromServerCmd.autoActivate(endExecutionCmd);
            disconnectedFromServerCmd.autoActivate(disconnectedFromServerCmd);
            disconnectedFromServerCmd.autoActivate(resetServerCmd);

            //
            // Once in execute on change don't allow it again until the user
            // does an endExecutionCmd
            //
            executeOnChangeCmd.autoDeactivate(executeOnChangeCmd);
            endExecutionCmd.autoActivate(executeOnChangeCmd);
            openFileCmd.autoActivate(executeOnChangeCmd);

            //
            // Set the automatic activation of any commands that depend on whether
            // or not we are currently executing.
            //
            executingCmd.autoDeactivate(openFileCmd);
            notExecutingCmd.autoActivate(openFileCmd);
            executingCmd.autoDeactivate(executeOnceCmd);
            notExecutingCmd.autoActivate(executeOnceCmd);

            //
            // Don't allow execute on change during an execute once.
            //
            executeOnceCmd.autoDeactivate(executeOnChangeCmd);
            notExecutingCmd.autoActivate(executeOnChangeCmd);

            NDAllocatorDictionary.theNDAllocatorDictionary = new NDAllocatorDictionary();

            readFirstNetwork = false;
        }
예제 #3
0
        public override bool initialize(ref string[] argv)
        {
            bool wasSetBusy = false;

            base.initialize(ref argv);

            if (!DXApplication.DXApplicationClassInitialized)
            {
                installDefaultResources();
                DXApplicationClassInitialized = true;
            }

            if (resource.executiveModule == null)
                resource.executiveModule = "lib/dx.mdf";
            if (resource.uiModule == null)
                resource.uiModule = "ui/ui.mdf";
            if (resource.userModules == null)
                resource.userModules = Environment.GetEnvironmentVariable("DXMDF");
            if (resource.macros == null)
                resource.macros = Environment.GetEnvironmentVariable("DXMACROS");
            if (resource.server == null)
                resource.server = Environment.GetEnvironmentVariable("DXHOST");
            if (resource.server == null)
                resource.server = "localhost";
            if (resource.server.Contains(","))
            {
                // Remove the port number if it exists (i.e DXHOST=slope,1920)
                resource.server = resource.server.Substring(0, resource.server.IndexOf(','));
            }
            if (resource.netPath == null)
                resource.netPath = Environment.GetEnvironmentVariable("DXNETPATH");
            if (resource.cryptKey == null)
                resource.cryptKey = Environment.GetEnvironmentVariable("DXCRYPTKEY");

            // If the app does not allow editor access or we are starting up without
            // displaying the anchor window, force one of (image or menubar) mode.
            if ((InEditMode && !appAllowsEditorAccess()) ||
                resource.noAnchorAtStartup)
            {
                if (InMenuBarMode)
                    resource.anchorMode = MENUBAR_ANCHOR_MODE;
                else
                    resource.anchorMode = IMAGE_ANCHOR_MODE;
            }

            // Echo the resources.
            if (resource.debugMode)
            {
                if (resource.port != 0)
                    Console.WriteLine("port        = {0}", resource.port);
                if (resource.memorySize != 0)
                    Console.WriteLine("memory size = {0}", resource.memorySize);
                if (resource.server != null)
                    Console.WriteLine("server = {0}", resource.server);
                if (resource.executive != null)
                    Console.WriteLine("executive = {0}", resource.executive);
                if (resource.workingDirectory != null)
                    Console.WriteLine("working directory = {0}",
                     resource.workingDirectory);
                if (resource.netPath != null)
                    Console.WriteLine("net path = {0}", resource.netPath);
                if (resource.program != null)
                    Console.WriteLine("program = {0}", resource.program);
                if (resource.cfgfile != null)
                    Console.WriteLine("cfgfile = {0}", resource.cfgfile);
                if (getUIRoot() != null)
                    Console.WriteLine("root = {0}", getUIRoot());
                if (resource.macros != null)
                    Console.WriteLine("macros = {0}", resource.macros);
                if (resource.errorPath != null)
                    Console.WriteLine("error path = {0}", resource.errorPath);
                if (resource.echoVersion)
                    Console.WriteLine("echo version");
                if (resource.anchorMode != null)
                    Console.WriteLine("anchor mode = {0}", resource.anchorMode);
                if (resource.noAnchorAtStartup)
                    Console.WriteLine("hiding anchor at startup");
                if (resource.debugMode)
                    Console.WriteLine("debug mode");
                if (resource.runUIOnly)
                    Console.WriteLine("run UI only");
                if (resource.showHelpMessage)
                    Console.WriteLine("show help message");
                if (resource.userModules != null)
                    Console.WriteLine("user mdf = {0}", resource.userModules);
                if (resource.executiveModule != null)
                    Console.WriteLine("executive mdf = {0}", resource.executiveModule);
                if (resource.uiModule != null)
                    Console.WriteLine("ui mdf = {0}", resource.uiModule);
                if (resource.suppressStartupWindows)
                    Console.WriteLine("suppress startup windows");

                if (resource.applicationPort != 0)
                    Console.WriteLine("application port = {0}", resource.applicationPort);
                if (resource.applicationHost != null)
                    Console.WriteLine("application host = {0}", resource.applicationHost);

                //
                // Image printing resources.
                //
                if (resource.printImageCommand != null)
                    Console.WriteLine("print image command = '{0}'",
                        resource.printImageCommand);
                if (resource.printImageFormat != null)
                    Console.WriteLine("print image format = '{0}'",
                        resource.printImageFormat);
                if (resource.printImagePageSize != null)
                    Console.WriteLine("print image page size = '{0}'",
                        resource.printImagePageSize);
                Console.WriteLine("print image resolution = {0}",
                        resource.printImageResolution);

                //
                // Image saving resources.
                //
                if (resource.saveImageFormat != null)
                    Console.WriteLine("save image format = '{0}'",
                        resource.saveImageFormat);
                if (resource.saveImagePageSize != null)
                    Console.WriteLine("save image page size = '{0}'",
                        resource.saveImagePageSize);
                Console.WriteLine("save image resolution = {0}",
                        resource.saveImageResolution);

                //
                // UI restrictions
                //
                if (resource.restrictionLevel != null)
                    Console.WriteLine("restriction level {0}",
                            resource.restrictionLevel);
                if (resource.noEditorAccess)
                    Console.WriteLine("no editor access");
                if (resource.limitedNetFileSelection)
                    Console.WriteLine("limited network file selection");
                if (resource.noImageRWNetFile)
                    Console.WriteLine("no net file read/write");
                if (resource.noImageSaving)
                    Console.WriteLine("no image saving");
                if (resource.noImagePrinting)
                    Console.WriteLine("no image printing");
                if (resource.noImageLoad)
                    Console.WriteLine("no image load ");
                if (resource.limitImageOptions)
                    Console.WriteLine("limit image options");
                if (resource.noRWConfig)
                    Console.WriteLine("no cfg save");
                if (resource.noPanelEdit)
                    Console.WriteLine("no panel edit");
                if (resource.noInteractorEdits)
                    Console.WriteLine("no interactor style");
                if (resource.noInteractorAttributes)
                    Console.WriteLine("no interactor attributes");
                if (resource.noInteractorMovement)
                    Console.WriteLine("no interactor movement");
                if (resource.noOpenAllPanels)
                    Console.WriteLine("no open all panels");
                if (resource.noPanelAccess)
                    Console.WriteLine("no panel access");
                if (resource.noPanelOptions)
                    Console.WriteLine("no panel options");
                if (resource.noMessageInfoOption)
                    Console.WriteLine("no message info option");
                if (resource.noMessageWarningOption)
                    Console.WriteLine("no message warning option");
                if (resource.noDXHelp)
                    Console.WriteLine("no DX help");

                //
                // automatic graph layout
                //
                if (resource.autoLayoutHeight > 0)
                    Console.WriteLine("automatic graph layout height = {0}",
                    resource.autoLayoutHeight);
                if (resource.autoLayoutGroupSpacing > 0)
                    Console.WriteLine("automatic graph layout group spacing = {0}",
                    resource.autoLayoutGroupSpacing);
                if (resource.autoLayoutNodeSpacing > 0)
                    Console.WriteLine("automatic graph layout node spacing = {0}",
                    resource.autoLayoutNodeSpacing);
            }

            if (resource.echoVersion)
            {
                String vers = String.Format("{0} User Interface, version {1}.{2}.{3} ({4})",
                    getFormalName(), global::WinDX.UI.Resources.MAJOR_VERSION,
                global::WinDX.UI.Resources.MINOR_VERSION,
                global::WinDX.UI.Resources.MICRO_VERSION,
                File.GetLastWriteTime(Application.ExecutablePath));

                MessageBox.Show(vers, "Version");
                Application.Exit();
            }

            // Fix me! May need to turn off help here.

            // Validate and set automatic graph layout values
            if (resource.autoLayoutHeight > 0)
            {
                String errmsg = GraphLayout.SetHeightPerLevel(resource.autoLayoutHeight);
                if (errmsg != null)
                {
                    MessageBox.Show(errmsg, "Startup Error");
                    return false;
                }
            }
            if (resource.autoLayoutGroupSpacing > 0)
            {
                String errmsg = GraphLayout.SetGroupSpacing(resource.autoLayoutGroupSpacing);
                if (errmsg != null)
                {
                    MessageBox.Show(errmsg, "Startup Error");
                    return false;
                }
            }
            if (resource.autoLayoutNodeSpacing > 0)
            {
                String errmsg = GraphLayout.SetNodeSpacing(resource.autoLayoutNodeSpacing);
                if (errmsg != null)
                {
                    MessageBox.Show(errmsg, "Startup Error");
                    return false;
                }
            }

            // Post the copyright message if the anchor window came up.
            if (!resource.noAnchorAtStartup)
                postCopyrightNotice();

            // Validate the resources and options
            if (InEditMode && !appAllowsEditorAccess())
            {
                MessageBox.Show("-edit and -noEditorAccess options are incompatible.", "Startup Error");
                return false;
            }

            if (appAllowsImageRWNetFile() && appLimitsNetFileSelection() &&
                resource.netPath == null)
            {
                MessageBox.Show("The \"limitedNetFileSelection\" or \"noImageRWNetFile\" " +
                    "option requires\na directory pathname specified by " +
                    "the \"DXNETPATH\" environment variable, \n" +
                    "the -netPath command line option, or\n" +
                    "the *netPath resource.", "Startup Error");
                return false;
            }

            // Setup Server Information
            serverInfo.autoStart = (resource.port <= 0);
            serverInfo.server = resource.server;
            serverInfo.executive = resource.executive;
            serverInfo.workingDirectory = resource.workingDirectory;
            serverInfo.userModules = resource.userModules;
            serverInfo.port = (resource.port == 0 ? 1900 : resource.port);
            serverInfo.memorySize = resource.memorySize;
            serverInfo.executiveFlags = "";
            serverInfo.children = new List<DXChild>();
            serverInfo.queuedPackets = new List<DXPacketIF>();

            if (argv != null)
            {
                foreach (String arg in argv)
                {
                    serverInfo.executiveFlags += arg + " ";
                }
            }

            if (InDataViewerMode)
            {
                resource.executeOnChange = true;
                resource.noImageRWNetFile = true;
                resource.noRWConfig = true;
                resource.noImageLoad = true;
                resource.noDXHelp = true;
                resource.noPGroupAssignment = true;
                resource.limitImageOptions = true;
                resource.noScriptCommands = true;
                resource.noConnectionMenus = true;
                resource.noWindowsMenus = true;
                resource.anchorMode = IMAGE_ANCHOR_MODE;
                resource.noAnchorAtStartup = true;
                resource.suppressStartupWindows = true;
                resource.noConfirmedQuit = true;
            }

            // Create the first/root/anchor network and place it in the
            // network list.
            network = newNetwork();

            if (appAllowsEditorAccess())
            {
                // Initialize the ConfigurationDialog allocator for the editor
                CDBAllocatorDictionary.theCDBAllocatorDictionary = new CDBAllocatorDictionary();

                // Initialize the StandIn allocator for the editor.
                SIAllocatorDictionary.theSIAllocatorDictionary = new SIAllocatorDictionary();
            }
            // Move to the indicated directory
            if (serverInfo.workingDirectory != null)
            {
                try
                {
                    Directory.SetCurrentDirectory(serverInfo.workingDirectory);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Unable to set Working Directory");
                }
            }

            loadMDF();
            loadIDF();
            if (resource.userModules != null)
                loadUDF(resource.userModules, null, false);

            // Decorator Styles
            DecoratorStyle.BuildtheDecoratorStyleDictionary();

            // load the initial set of user macros.
            MacroDefinition.LoadMacroDirectories(resource.macros);

            // Create the anchor window
            if (!InEditMode)
            {
                if (InImageMode)
                    anchor = newImageWindow(network);
                else if (InMenuBarMode)
                    anchor = new DXAnchorWindow("dxAnchor", true, true);
                else
                {
                    MessageBox.Show("Unrecognized anchor mode.", "Startup Error");
                    Application.Exit();
                }
                // Initialize the anchor window so it can handle reading in the network
                // before being managed.
                if (applyWindowPlacements() ||
                    resource.noAnchorAtStartup)
                {
                    anchor.Show();
                    anchor.Visible = true;
                }
                else
                {
                    anchor.Show();
                    anchor.Visible = true;
                    setBusyCursor(true);
                    wasSetBusy = true;
                }
            }
            else
            {
                anchor = newNetworkEditor(network);
                if (anchor == null)
                    return false;

                anchor.Show();
                setBusyCursor(true);
                wasSetBusy = true;
            }

            // Create the message and debug windows
            messageWindow = newMsgWin();

            // If quested, read in the network.  This is after opening the anchor
            // window because image nodes may wish to bind with the initial image
            // window, etc.
            if (resource.program != null)
                openFile(resource.program, resource.cfgfile);

            if (InDataViewerMode)
            {
                Node n = network.findNode("Import");
                if (n == null)
                {
                    ErrorDialog ed = new ErrorDialog();
                    ed.post("Can not find Import tool in viewing program.");
                }
                else
                {
                    String s = resource.viewDataFile;
                    Debug.Assert(s != null);
                    n.setInputValue(1, s);
                }
            }

            if (resource.noAnchorAtStartup)
            {
                anchor.Show();
            }
            else if (!anchor.Visible)
            {
                anchor.Show();
                setBusyCursor(true);
                wasSetBusy = true;
            }

            if (!resource.runUIOnly)
            {
                // Connect to exec first
                DXChild c = startServer();

                completeConnection(c);
            }

            // If there is an application to talk to, connect to it.
            if (resource.applicationPort != 0)
                connectToApplication(resource.applicationHost,
                    resource.applicationPort);

            if (wasSetBusy)
                setBusyCursor(false);

            return true;
        }
예제 #4
0
 public MWClearCmd(String name, CommandScope scope, bool active, MsgWin win)
     : base(name, scope, active)
 {
     messageWindow = win;
 }