/// <summary> /// Executes the HasCertainColorCommand command. /// </summary> public void ExecuteHasCertainColorCommand() { // create the processing command HasCertainColorCommand command = new HasCertainColorCommand(); // set properties of command PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Has Certain Color Command Properties", true); if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } if (ExecuteProcessingCommand(command, false)) { if (command.Result) { MessageBox.Show(String.Format("Image has {0} color.", command.Color)); } else { MessageBox.Show(String.Format("Image does not have {0} color.", command.Color)); } } }
private void menuItemNewAgentOnClick(object sender, EventArgs e) { using (var form = new PropertyGridForm("New Agent")) { var pluginFactory = new NeuralSimulationPluginFactory(string.Empty, string.Empty, 0); form.PropertyGrid.GetToolStrip().AddButton("New Network", ShowNewNetworkDialog); form.PropertyGrid.SelectedObject = pluginFactory; form.FormClosing += (s, closingEvent) => { if (form.DialogResult == DialogResult.OK) { try { Assert.NotNullOrWhiteSpace(pluginFactory.Name, "Property Name is required."); Assert.NotNullOrWhiteSpace(pluginFactory.Network, "Property Network is required."); Assert.Unique(pluginFactory.Name, Workspace.Instance.SimulationPlugins.Select(driver => driver.Name), "Name already exists."); Workspace.Instance.SimulationPlugins.Add(pluginFactory); Add(pluginFactory); } catch (Exception exception) { closingEvent.Cancel = true; MessageBox.Show(exception.Message, "New Neural Agent", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }; form.ShowDialog(); } }
/// <summary> /// Executes the IsDocumentImageCommand command. /// </summary> public void ExecuteIsDocumentImageCommand() { #if !REMOVE_DOCCLEANUP_PLUGIN IsDocumentImageCommand command = new IsDocumentImageCommand(); // set properties of command PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Is Document Image Properties", true); if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } if (ExecuteProcessingCommand(command, false)) { if (command.IsDocumentImage) { if (command.IsInvertedDocumentImage) { MessageBox.Show("Is inverted document image."); } else { MessageBox.Show("Is document image."); } } else { MessageBox.Show("Image is not document image."); } } #endif }
/// <summary> /// Executes the FillRectangleCommand command. /// </summary> public void ExecuteFillRectangleCommand() { // create the processing command FillRectangleCommand command = new FillRectangleCommand(); RectangularSelectionTool visualTool = null; if (_viewer.VisualTool != null && _viewer.VisualTool is RectangularSelectionTool) { visualTool = (RectangularSelectionTool)_viewer.VisualTool; if (!visualTool.Rectangle.IsEmpty) { command.Rectangles = new Rectangle[] { visualTool.Rectangle } } ; } // set properties of command PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Fill Rectangle Command Properties", true); if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } if (visualTool != null) { visualTool.Rectangle = Rectangle.Empty; } // execute the command ExecuteProcessingCommand(command, true); }
private void ShowNewNetworkDialog() { using (var form = new PropertyGridForm("New Network")) { var networkDefinition = new AgentNetworkDefinition(null, 2, 26, 12); form.PropertyGrid.SelectedObject = networkDefinition; form.FormClosing += (s, closingEvent) => { if (form.DialogResult == DialogResult.OK) { try { var network = new AgentNetwork(networkDefinition, new He(0)); Workspace.Instance.Add(networkDefinition.Name, network); } catch (Exception exception) { closingEvent.Cancel = true; MessageBox.Show(exception.Message, "New Network", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }; form.ShowDialog(); } }
/// <summary> /// Handles the Click event of MrcImageSegmentationSettingsButton object. /// </summary> private void mrcImageSegmentationSettingsButton_Click(object sender, EventArgs e) { #if !REMOVE_DOCCLEANUP_PLUGIN && !REMOVE_PDF_PLUGIN // create image segmentation settings dialog using (PropertyGridForm dialog = new PropertyGridForm(MrcCompressionSettings.ImageSegmentation, "Image segmentation settings")) { // show dialog dialog.ShowDialog(); } #endif }
/// <summary> /// Executes the AdvancedReplaceColorCommand command. /// </summary> public void ExecuteAdvancedReplaceColorCommand() { #if !REMOVE_DOCCLEANUP_PLUGIN // create the processing command AdvancedReplaceColorCommand command = new AdvancedReplaceColorCommand(); // set properties of command PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Advanced Replace Color Command Properties", true); if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } ExecuteProcessingCommand(command, true); #endif }
/// <summary> /// Executes the GetTextOrientationCommand command. /// </summary> public void ExecuteGetTextOrientationCommand() { #if !REMOVE_DOCCLEANUP_PLUGIN GetTextOrientationCommand command = new GetTextOrientationCommand(); command.Results = new ProcessingCommandResults(); // set properties of command PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Get Text Orientation Command Properties", true); if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } if (ExecuteProcessingCommand(command, false)) { GetTextOrientationCommandResult result = (GetTextOrientationCommandResult)command.Results[0]; ImageOrthogonalOrientation documentOrientation = result.Orientation; switch (documentOrientation) { case ImageOrthogonalOrientation.Undefined: MessageBox.Show(String.Format("Document orientation is not defined.")); break; case ImageOrthogonalOrientation.Rotated0: MessageBox.Show(String.Format("Document has the right orientation.")); break; case ImageOrthogonalOrientation.Rotated90: MessageBox.Show(String.Format("Document is rotated by 90 degrees clockwise.")); break; case ImageOrthogonalOrientation.Rotated180: MessageBox.Show(String.Format("Document is rotated by 180 degrees clockwise.")); break; case ImageOrthogonalOrientation.Rotated270: MessageBox.Show(String.Format("Document is rotated by 270 degrees clockwise.")); break; default: throw new NotImplementedException(); } } #endif }
/// <summary> /// Executes the GetRotationAngleCommand command. /// </summary> public void ExecuteGetRotationAngleCommand() { GetRotationAngleCommand command = new GetRotationAngleCommand(); // set properties of command using (PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Get Rotation Angle Command Properties", true)) { if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } if (ExecuteProcessingCommand(command, false)) { MessageBox.Show(String.Format("Most probably rotation angle is {0} degree.", command.Angle.ToString("f2"))); } } }
/// <summary> /// Executes the OverlayCommand command. /// </summary> public void ExecuteOverlayWithBlendingCommand() { // create the processing command OverlayWithBlendingCommand command = new OverlayWithBlendingCommand(); // set properties of command PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Overlay with Blending Command Properties", true); if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } // save a reference to the overlay image, image will be disposed when command is finished _overlayImage = command.OverlayImage; // execute the command ExecuteProcessingCommand(command, true); }
/// <summary> /// Executes the DrawImageCommand command. /// </summary> public void ExecuteDrawImageCommand() { // create the processing command DrawImageCommand command = ImageProcessingCommandFactory.CreateDrawImageCommand(_viewer.Image); // set properties of command PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Draw Image Command Properties", true); if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } // save a reference to the overlay image, image will be disposed when command is finished _overlayImage = command.OverlayImage; // execute the command ExecuteProcessingCommand(command, true); }
/// <summary> /// Executes the ImageComparisonCommand command. /// </summary> public void ExecuteComparisonCommand() { // create the processing command ImageComparisonCommand command = new ImageComparisonCommand(); // set properties of command PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Image Comparison Command Properties", true); if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } // save a reference to the comparison image, image will be disposed when command is finished _comparisonImage = command.Image; // execute the command ExecuteProcessingCommand(command, true); }
private void TrainOnSpace(ListViewItem item) { if (item.Tag is ISpaceTemplateFactory spaceFactory) { using (var gridForm = new PropertyGridForm("Training")) { var trainerSettings = new NeuralAgentTrainerConfiguration(); trainerSettings.Space = spaceFactory.Name; gridForm.PropertyGrid.SelectedObject = trainerSettings; if (gridForm.ShowDialog() == DialogResult.OK) { using (var trainer = new NeuralAgentTrainer(trainerSettings)) { trainer.Train(); trainer.Simulate(); trainer.SaveAsTemplate(); } } } } }