/// <summary> /// This function is used to initialize all the commands in the system /// </summary> private void InitializeCommands() { // Wire up menus and toolbar buttons #region View Setup Commands commandResetView = new Command(new Command.Action(paneModelView.SceneRender.ResetView)); ToolStripButtonCommander.Connect(tsbResetView, commandResetView); ToolStripMenuItemCommander.Connect(miResetView, commandResetView); commandXYView = new Command(new Command.Action(paneModelView.SceneRender.SetXYView)); ToolStripButtonCommander.Connect(tsbXYView, commandXYView); ToolStripMenuItemCommander.Connect(miXYView, commandXYView); commandYZView = new Command(new Command.Action(paneModelView.SceneRender.SetYZView)); ToolStripButtonCommander.Connect(tsbYZView, commandYZView); ToolStripMenuItemCommander.Connect(miYZView, commandYZView); commandZXView = new Command(new Command.Action(paneModelView.SceneRender.SetZXView)); ToolStripButtonCommander.Connect(tsbZXView, commandZXView); ToolStripMenuItemCommander.Connect(miZXView, commandZXView); commandFitView = new Command(new Command.Action(paneModelView.SceneRender.SetFitView)); ToolStripButtonCommander.Connect(tsbFitView, commandFitView); ToolStripMenuItemCommander.Connect(miFitView, commandFitView); commandDomainView = new Command(new Command.Action(ViewDomain)); ToolStripButtonCommander.Connect(tsbViewDomain, commandDomainView); #endregion #region File Operations Commands commandFileOpen = new Command(new Command.Action(this.OpenExistedProject)); ToolStripButtonCommander.Connect(tsbFileOpen, commandFileOpen); ToolStripMenuItemCommander.Connect(miFileOpen, commandFileOpen); commandFileSave = new Command(new Command.Action(this.SaveProject)); ToolStripButtonCommander.Connect(tsbFileSave, commandFileSave); ToolStripMenuItemCommander.Connect(miFileSave, commandFileSave); commandFileSaveAs = new Command(new Command.Action(this.SaveProjectAs)); ToolStripMenuItemCommander.Connect(miFileSaveAs, commandFileSaveAs); commandFileNew = new Command(new Command.Action(this.CreateNewProject)); ToolStripButtonCommander.Connect(tsbFileNew, commandFileNew); ToolStripMenuItemCommander.Connect(miFileNew, commandFileNew); commandExit = new Command(new Command.Action(this.Exit)); ToolStripMenuItemCommander.Connect(miExit, commandExit); commandSaveScreenshot = new Command(new Command.Action(this.SaveScreenshot)); ToolStripMenuItemCommander.Connect(miSaveScreenshot, commandSaveScreenshot); #endregion #region Single Edit commandCut = new Command(new Command.Action(this.CutSingle)); ToolStripButtonCommander.Connect(tsbCut, commandCut); ToolStripMenuItemCommander.Connect(miCut, commandCut); commandCopy = new Command(new Command.Action(this.CopySingle)); ToolStripButtonCommander.Connect(tsbCopy, commandCopy); ToolStripMenuItemCommander.Connect(miCopy, commandCopy); commandPaste = new Command(new Command.Action(this.PasteSingle)); ToolStripButtonCommander.Connect(tsbPaste, commandPaste); ToolStripMenuItemCommander.Connect(miPaste, commandPaste); #endregion #region Simulation Settings commandSource = new Command(new Command.Action(this.SetupExcitationSource)); ToolStripButtonCommander.Connect(tsbSource, commandSource); ToolStripMenuItemCommander.Connect(miSource, commandSource); commandDomain = new Command(new Command.Action(this.SetupDomain)); ToolStripButtonCommander.Connect(tsbDomain, commandDomain); ToolStripMenuItemCommander.Connect(miDomain, commandDomain); commandGeneralOptions = new Command(new Command.Action(this.SetupGeneralOptions)); ToolStripMenuItemCommander.Connect(miGeneralOptions, commandGeneralOptions); commandMesh = new Command(new Command.Action(this.SetupMesh)); ToolStripButtonCommander.Connect(tsbMeshSize, commandMesh); ToolStripMenuItemCommander.Connect(miMeshSize, commandMesh); commandParallel = new Command(new Command.Action(this.SetupParallelInfo)); ToolStripButtonCommander.Connect(tsbParallelInfo, commandParallel); ToolStripMenuItemCommander.Connect(miPrallelInfo, commandParallel); commandHuygensBox = new Command(new Command.Action(this.SetupHuygensBox)); ToolStripButtonCommander.Connect(tsbHuygensBox, commandHuygensBox); commandPreCalculate = new Command(new Command.Action(this.Precalculate)); ToolStripButtonCommander.Connect(tsbPrecalculate, commandPreCalculate); #endregion #region Single EO Settings commandVoltageExcitation = new Command(new Command.Action(this.SetupVoltageExcitation)); ToolStripButtonCommander.Connect(tsbVoltageSource, commandVoltageExcitation); commandVoltageOutput = new Command(new Command.Action(this.SetupVoltageOutput)); ToolStripButtonCommander.Connect(tsbVoltageOutput, commandVoltageOutput); commandCurrentExcitation = new Command(new Command.Action(this.SetupCurrentExcitation)); ToolStripButtonCommander.Connect(tsbCurrentSource, commandCurrentExcitation); commandCurrentOutput = new Command(new Command.Action(this.SetupCurrentOutput)); ToolStripButtonCommander.Connect(tsbCurrentOutput, commandCurrentOutput); commandPointOutput = new Command(new Command.Action(this.SetupPointOutput)); ToolStripButtonCommander.Connect(tsbPointOutput, commandPointOutput); commandRemoveExcitation = new Command(new Command.Action(this.RemoveEO)); ToolStripButtonCommander.Connect(tsbRemoveExcitation, commandRemoveExcitation); #endregion #region Modeling Settings commandSelect = new Command(new Command.Action(this.SelectTool)); ToolStripButtonCommander.Connect(tsbSelect, commandSelect); commandCreateCubiod = new Command(new Command.Action(this.CreateCubiod)); ToolStripButtonCommander.Connect(tsbCube, commandCreateCubiod); commandCreateCone = new Command(new Command.Action(this.CreateCone)); ToolStripButtonCommander.Connect(tsbCone, commandCreateCone); commandCreatePoint = new Command(new Command.Action(this.CreatePoint)); ToolStripButtonCommander.Connect(tsbPoint, commandCreatePoint); commandCreateLine = new Command(new Command.Action(this.CreateLine)); ToolStripButtonCommander.Connect(tsbLine, commandCreateLine); commandCreateRectangle = new Command(new Command.Action(this.CreateRectangle)); ToolStripButtonCommander.Connect(tsbRectangle, commandCreateRectangle); commandCreateSphere = new Command(new Command.Action(this.CreateSphere)); ToolStripButtonCommander.Connect(tsbSphere, commandCreateSphere); commandCreateCylinder = new Command(new Command.Action(this.CreateCylinder)); ToolStripButtonCommander.Connect(tsbCylinder, commandCreateCylinder); commandCreateRound = new Command(new Command.Action(this.CreateRound)); ToolStripButtonCommander.Connect(tsbCircle, commandCreateRound); #endregion #region Helper commandAbout = new Command(new Command.Action(this.ShowAbout)); ToolStripMenuItemCommander.Connect(miAbout, commandAbout); commandHelperContent = new Command(new Command.Action(this.ShowHelperContent)); ToolStripMenuItemCommander.Connect(miHelpContent, commandHelperContent); #endregion }
// Connect is a shared (static) method that performs the task of adapting a menu // item to a command. The commander exists only to wire up the two objects -- // it is not used further public static void Connect(ToolStripMenuItem item, Command command) { ToolStripMenuItemCommander unused = new ToolStripMenuItemCommander(item, command); }