public void OnMenu_Button_Clicked(object sender, EventArgs e) { SySal.SySalNExTControls.SySalButton btn = sender as SySal.SySalNExTControls.SySalButton; if (btn.Tag is MenuItem[]) { m_CurrentMenu = btn.Tag as MenuItem[]; SetCurrentMenu(); } else if (btn.Tag != null && btn.Tag is MenuItem.dOnMenuItem) { ((MenuItem.dOnMenuItem)btn.Tag).Invoke(e); } }
public MenuItem(string text, object action, dMenuItemEnabler enabler, string tooltiptext) { Text = text; Action = action; Button = new SySal.SySalNExTControls.SySalButton(); Button.Text = Text; Button.BackColor = Color.Transparent; Button.BackgroundImage = null; Button.AutoSize = true; Button.Visible = false; Button.ForeColor = Color.DodgerBlue; Button.FocusedColor = Color.Navy; Button.Font = new Font("Segoe UI", 14); Button.Tag = Action; Enabler = enabler; ToolTipText = tooltiptext; UpMenu = null; }
public SySalMainForm() { InitializeComponent(); MainMenu = new MenuItem[] { new MenuItem("Setup", new MenuItem[] { new MenuItem("Scanner", new MenuItem.dOnMenuItem(this.OnMenu_Setup_Scanner), MenuItem.MenuItemEnablerTrue, "Set up the general properties of the Scanner:\r\nchoose directories and hardware control libraries."), new MenuItem("Stage", new MenuItem.dOnMenuItem(this.OnMenu_Setup_Stage), new MenuItem.dMenuItemEnabler(delegate() { return(TheScanner.iStage != null); }), "Configure the chosen stage control library:\r\ndefine encoder/micron and step/micron conversions,\r\nlimiters, speed limits and reference positions."), new MenuItem("Grabber", new MenuItem.dOnMenuItem(this.OnMenu_Setup_Grabber), new MenuItem.dMenuItemEnabler(delegate() { return(TheScanner.iGrab != null); }), "Configure the camera, grabbing mode, memory allocation, etc.."), new MenuItem("GPU", new MenuItem.dOnMenuItem(this.OnMenu_Setup_GPU), new MenuItem.dMenuItemEnabler(delegate() { return(TheScanner.iGPU != null && TheScanner.iGPU.Length > 0); }), "Choose the GPU devices to be used for image processing and set up their operating parameters."), new MenuItem("Imaging", new MenuItem.dOnMenuItem(this.OnMenu_Setup_Imaging), new MenuItem.dMenuItemEnabler(delegate() { return(TheScanner.iGPU != null && TheScanner.iGPU.Length > 0); }), "Define the features of the objective:\r\nmagnification factor and various corrections to be applied."), new MenuItem("NExT", null, MenuItem.MenuItemEnablerFalse, "Configure the Scanner to work in a SySal.NExT environment as a server.") }, new MenuItem.dMenuItemEnabler(delegate() { return(TheScanner.iStage != null); }), "Basic setup to start working with the Scanner." ), new MenuItem("ScanServer", new MenuItem[] { new MenuItem("Start", new MenuItem.dOnMenuItem(this.OnMenu_StartScanServer), new MenuItem.dMenuItemEnabler(delegate() { return(TheScanner.NSS_connected == false); }), "Starts listening."), new MenuItem("Stop", new MenuItem.dOnMenuItem(this.OnMenu_StopScanServer), new MenuItem.dMenuItemEnabler(delegate() { return(TheScanner.NSS_connected); }), "Stop listening\r\n(the current action will be completed).") }, new MenuItem.dMenuItemEnabler(delegate() { return(TheScanner.iGPU != null && TheScanner.iGPU.Length > 0 && TheScanner.iStage != null); }), "Have this program listen and execute task request from the network." ), new MenuItem("Acquisition", new MenuItem[] { new MenuItem("Marks", new MenuItem.dOnMenuItem(this.OnMenu_AcquireMarks), MenuItem.MenuItemEnablerTrue, "Define the reference marks on the current plate."), new MenuItem("Quasi-static", new MenuItem.dOnMenuItem(this.OnMenu_QuasiStaticAcquisition), MenuItem.MenuItemEnablerTrue, "Quasi-static acquisition, useful for high-quality data taking\r\nand building samples of images to work out optical corrections\r\nor to develop image handling/tracking algorithms."), new MenuItem("Full speed", new MenuItem.dOnMenuItem(this.OnMenu_FullSpeedAcquisition), MenuItem.MenuItemEnablerTrue, "Acquire data at the maximum possible speed with the standard procedure.") }, new MenuItem.dMenuItemEnabler(delegate() { return(TheScanner.NSS_connected == false && TheScanner.iGPU != null && TheScanner.iGPU.Length > 0 && TheScanner.iStage != null); }), "Perform user-defined scanning tasks.\r\nThis is primarily a tool to define scanning parameters,\r\nbut some simple scanning tasks may be accomplished too." ) }; m_UpMenuButton = new SySal.SySalNExTControls.SySalButton(); m_UpMenuButton.Visible = false; m_UpMenuButton.Text = "<<"; m_UpMenuButton.BackColor = Color.Transparent; m_UpMenuButton.AutoSize = true; m_UpMenuButton.ForeColor = Color.DodgerBlue; m_UpMenuButton.FocusedColor = Color.Navy; m_UpMenuButton.Font = new Font("Segoe UI", 14); SetMenuUpLinks(MainMenu); m_CurrentMenu = MainMenu; s_TheMainForm = this; }