public List <string> labelsFromText(string text) { List <string> labels = StringCollectionConverter.convert(text); labels.RemoveAt(0); return(labels); }
private void numOfSteps_Changed() { if (checkForSeedAndRuleSets()) { int num, i = 0; int[] numOfCalls = new int[Program.settings.numOfRuleSets]; List <string> numbers = StringCollectionConverter.convert(this.numOfRandSteps.Text.Trim()); Boolean successfulEntry = true; this.numOfRandSteps.Text = "#steps"; foreach (string a in numbers) { if (i == Program.settings.numOfRuleSets) { if (DialogResult.Yes == MessageBox.Show("There are no rulesets to assign to " + a + ". Would you like to continue with current limits?", "More arguments than rulesets.", MessageBoxButtons.YesNo, MessageBoxIcon.Error)) { successfulEntry = true; break; } else { successfulEntry = false; break; } } if ((int.TryParse(a, out num)) && (num > 0) && (num <= Program.settings.maxRulesToApply)) { numOfCalls[i++] = num; } else if (DialogResult.Yes == MessageBox.Show("Unable to change \"" + a + "\" for Rule-Set #" + i + " into number greater than zero and less than or equal to " + Program.settings.maxRulesToApply + ". Do you approve of setting to the value of " + Program.settings.maxRulesToApply + "? (If no, this call will be cancelled.)", "Value not defined.", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { numOfCalls[i++] = Program.settings.maxRulesToApply; } else { successfulEntry = false; break; } } if (successfulEntry) { Boolean display = (DialogResult.Yes == MessageBox.Show("Would you like to see the graph " + "after each rule application?", "Display Interim Graphs", MessageBoxButtons.YesNo, MessageBoxIcon.Information)); Generation.randomChoose GenerationApproach = new Generation.randomChoose(Program.seed, Program.rulesets, numOfCalls, display, Program.settings.recompileRules, Program.settings.execDir, Program.settings.compiledparamRules); addAndShowSearchController(new searchProcessController(GenerationApproach), true); searchControls[searchControls.Count - 1].SendToBack(); } } }
public string textFromNameAndLabels(string name, List <string> labels) { if (labels.Count > 0) { return(name + " (" + StringCollectionConverter.convert(labels) + ")"); } else { return(name); } }
public void updateGraphControl(Netron.GraphLib.UI.GraphControl graphControl1, Label globalLabelsText) { if (this.globalLabels.Count > 0) { globalLabelsText.Text = StringCollectionConverter.convert(this.globalLabels); } else { globalLabelsText.Text = " "; } foreach (node n in nodes) { n.displayShape.Text = textForNode(n); /* make sure node is of right type - if not call the replacement function */ if ((n.nodeType != null) && (n.GetType() != typeof(GraphSynth.Representation.ruleNode)) && (n.GetType() != n.nodeType)) { replaceNodeWithInheritedType(n); } } foreach (arc a in arcs) { if (a.doublyDirected) { a.displayShape.LineEnd = ConnectionEnd.BothFilledArrow; } else if (a.directed) { a.displayShape.LineEnd = ConnectionEnd.RightFilledArrow; } else { a.displayShape.LineEnd = ConnectionEnd.NoEnds; } a.displayShape.Text = textForArc(a); /* make sure node is of right type - if not call the replacement function */ if ((a.arcType != null) && (a.GetType() != typeof(GraphSynth.Representation.ruleArc)) && (a.GetType() != a.arcType)) { replaceArcWithInheritedType(a, a.From, a.To); } } }
private void applyButton_Click(object sender, EventArgs e) { newSettings.stringOfRSFileNames = StringCollectionConverter.convert(newSettings.defaultRSFileNames); globalSettings tempSettings = Program.settings; Program.settings = newSettings; SearchIO.defaultVerbosity = newSettings.defaultVerbosity; try { newSettings.loadDefaultSeedAndRuleSets(); } catch (Exception ee) { if (DialogResult.Yes == MessageBox.Show("Settings did not work because of the following error: " + ee.ToString() + " Revert to Previous Settings?", "Error in Settings. Revert back?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { Program.settings = tempSettings; } return; } cancelButton_Click(sender, e); }
public string nameFromText(string candidateName) { return(StringCollectionConverter.convert(candidateName)[0]); }
public void initializeGraphControl(Netron.GraphLib.UI.GraphControl graphControl1, Label globalLabelsText) { Random rnd = new Random(); #region display the nodes for (int i = nodes.Count - 1; i >= 0; i--) { node n = nodes[i]; if (n.screenX == 0.0 && n.screenY == 0.0) { n.screenX = rnd.Next(50, graphControl1.Width - 100); n.screenY = rnd.Next(20, graphControl1.Height - 20); } List <string> shapeData = StringCollectionConverter.convert(n.shapekey); if (shapeData.Count == 0) { shapeData.Add(""); } n.displayShape = graphControl1.AddShape(shapeData[0], new PointF(n.screenX, n.screenY)); if (shapeData.Count > 1) { n.displayShape.ShapeColor = Color.FromArgb(int.Parse(shapeData[1])); n.displayShape.Width = float.Parse(shapeData[2]); n.displayShape.Height = float.Parse(shapeData[3]); } } #endregion #region display the arcs foreach (arc a in arcs) { node fromNode = a.From; node toNode = a.To; Connector fromConnect = null; Connector toConnect = null; if ((fromNode == null) || (fromNode.displayShape == null)) { a.fromConnector = 0; fromConnect = addNullShape(graphControl1, 0).Connectors[0]; } else if ((a.fromConnector == -1) || (a.fromConnector >= fromNode.displayShape.Connectors.Count)) { a.fromConnector = rnd.Next(fromNode.displayShape.Connectors.Count); fromConnect = fromNode.displayShape.Connectors[a.fromConnector]; } else { fromConnect = fromNode.displayShape.Connectors[a.fromConnector]; } /* now repeat same process for To */ if ((toNode == null) || (toNode.displayShape == null)) { a.toConnector = 0; toConnect = addNullShape(graphControl1, 1).Connectors[0]; } else if ((a.toConnector == -1) || (a.toConnector >= toNode.displayShape.Connectors.Count)) { a.toConnector = rnd.Next(toNode.displayShape.Connectors.Count); toConnect = toNode.displayShape.Connectors[a.toConnector]; } else { toConnect = toNode.displayShape.Connectors[a.toConnector]; } a.displayShape = graphControl1.AddConnection(fromConnect, toConnect); a.displayShape.ShowLabel = true; List <string> styleData = StringCollectionConverter.convert(a.styleKey); if (styleData.Count > 0) { a.displayShape.LinePath = styleData[0]; } if (styleData.Count > 1) { a.displayShape.LineColor = Color.FromArgb(int.Parse(styleData[1])); a.displayShape.LineWeight = (ConnectionWeight)int.Parse(styleData[2]); a.displayShape.LineStyle = (System.Drawing.Drawing2D.DashStyle) int.Parse(styleData[3]); } } #endregion this.updateGraphControl(graphControl1, globalLabelsText); }
public void updateGraphControl(Netron.GraphLib.UI.GraphControl graphControl1, Label globalLabelsText) { try { string defaultShapeKey = "8ED1469D-90B2-43ab-B000-4FF5C682F530"; Boolean isFixed = true; Random rnd = new Random(); #region Global Labels if (this.globalLabels.Count > 0) { globalLabelsText.Text = StringCollectionConverter.convert(this.globalLabels); } else { globalLabelsText.Text = " "; } #endregion #region display the nodes for (int i = nodes.Count - 1; i >= 0; i--) { node n = nodes[i]; #region if it has no displayShape if (n.displayShape == null) { if (n.shapekey == null) { n.shapekey = defaultShapeKey; } if (n.screenX == 0.0 && n.screenY == 0.0) { n.screenX = rnd.Next(50, graphControl1.Width - 100); n.screenY = rnd.Next(20, graphControl1.Height - 20); isFixed = false; } else { isFixed = true; } n.displayShape = graphControl1.AddShape(n.shapekey, new PointF(n.screenX, n.screenY)); /* if the prev. statement didn't take, it's likely the shapekey wasn't recognized. * there we try again with the default ShapeKey. */ if (n.displayShape == null) { n.displayShape = graphControl1.AddShape(defaultShapeKey, new PointF(n.screenX, n.screenY)); } } #endregion else if (!graphControl1.Shapes.Contains(n.displayShape)) { /* a shape is defined for the node but is not displayed */ n.displayShape = graphControl1.AddShape(n.displayShape); } n.displayShape.Text = textForNode(n); n.displayShape.IsFixed = isFixed; /* make sure node is of right type - if not call the replacement function */ if ((n.nodeType != null) && (n.GetType() != typeof(GraphSynth.Representation.ruleNode)) && (n.GetType() != n.nodeType)) { replaceNodeWithInheritedType(n); } } #endregion #region display the arcs for (int i = arcs.Count - 1; i >= 0; i--) { arc a = arcs[i]; node fromNode = a.From; node toNode = a.To; Connector fromConnect = null; Connector toConnect = null; if ((fromNode == null) || (fromNode.displayShape == null)) { a.fromConnector = 0; if (a.displayShape == null || a.displayShape.From.BelongsTo == null) { fromConnect = addNullShape(graphControl1, 0).Connectors[0]; } else { fromConnect = a.displayShape.From; } } else if ((a.fromConnector == -1) || (a.fromConnector >= fromNode.displayShape.Connectors.Count)) { a.fromConnector = rnd.Next(fromNode.displayShape.Connectors.Count); fromConnect = fromNode.displayShape.Connectors[a.fromConnector]; } else { fromConnect = fromNode.displayShape.Connectors[a.fromConnector]; } /* now repeat same process for To */ if ((toNode == null) || (toNode.displayShape == null)) { a.toConnector = 0; if (a.displayShape == null || a.displayShape.To.BelongsTo == null) { toConnect = addNullShape(graphControl1, 1).Connectors[0]; } else { toConnect = a.displayShape.To; } } else if ((a.toConnector == -1) || (a.toConnector >= toNode.displayShape.Connectors.Count)) { a.toConnector = rnd.Next(toNode.displayShape.Connectors.Count); toConnect = toNode.displayShape.Connectors[a.toConnector]; } else { toConnect = toNode.displayShape.Connectors[a.toConnector]; } if (((a.displayShape != null) && (!graphControl1.Connections.Contains(a.displayShape)) && ((a.displayShape.From == null) || (a.displayShape.To == null))) || ((a.displayShape == null) && (fromConnect == null) && (toConnect == null))) { removeArc(a); } else { if (a.displayShape == null) { a.displayShape = graphControl1.AddConnection(fromConnect, toConnect); } else if (!graphControl1.Connections.Contains(a.displayShape)) { a.displayShape = graphControl1.AddConnection(a.displayShape.From, a.displayShape.To); } /* a shape is defined for the node but is not displayed * Rectangular, Default, Bezier */ if (a.curveStyle != null) { a.displayShape.LinePath = a.curveStyle; } if (a.doublyDirected) { a.displayShape.LineEnd = ConnectionEnd.BothFilledArrow; } else if (a.directed) { a.displayShape.LineEnd = ConnectionEnd.RightFilledArrow; } else { a.displayShape.LineEnd = ConnectionEnd.NoEnds; } a.displayShape.Text = textForArc(a); a.displayShape.ShowLabel = true; } /* make sure node is of right type - if not call the replacement function */ if ((a.arcType != null) && (a.GetType() != typeof(GraphSynth.Representation.ruleArc)) && (a.GetType() != a.arcType)) { replaceArcWithInheritedType(a, fromNode, toNode); } } #endregion } catch (Exception e) { MessageBox.Show("There was an error displaying the graph. Please save work and re-open. (Error: " + e.ToString() + ")", "Error Displaying Graph", MessageBoxButtons.OK, MessageBoxIcon.Error); } }