/// <summary> /// Convert an object to a document /// </summary> /// <param name="context">The type context</param> /// <param name="culture">The culture of the conversion</param> /// <param name="value">The value to convert</param> /// <returns>The converted value</returns> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { object ret = null; if (value.GetType() == typeof(string)) { BaseNodeConfig config = context.Instance as BaseNodeConfig; if (config != null) { foreach (BaseNodeConfig node in config.Document.Nodes) { if (node.Label == value.ToString()) { return(node); } } } } else if (typeof(T).IsAssignableFrom(value.GetType())) { ret = value; } else { ret = base.ConvertFrom(context, culture, value); } return(ret); }
/// <summary> /// Convert an object to a document /// </summary> /// <param name="context">The type context</param> /// <param name="culture">The culture of the conversion</param> /// <param name="value">The value to convert</param> /// <returns>The converted value</returns> public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { object ret = null; if (value.GetType() == typeof(String)) { BaseNodeConfig config = context.Instance as BaseNodeConfig; foreach (T doc in CANAPEProject.CurrentProject.GetDocumentsByType(typeof(T))) { if ((config == null) || (!config.Document.Equals(doc))) { if (doc.Name.Equals((string)value, StringComparison.OrdinalIgnoreCase)) { ret = doc; break; } } } } else if (typeof(T).IsAssignableFrom(value.GetType())) { ret = value; } else { ret = base.ConvertFrom(context, culture, value); } return(ret); }
/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="dest"></param> /// <param name="biDirection"></param> /// <param name="pathName"></param> /// <param name="weak"></param> public LineConfig(BaseNodeConfig source, BaseNodeConfig dest, bool biDirection, string pathName, bool weak) { SourceNode = source; DestNode = dest; BiDirection = biDirection; PathName = pathName; WeakPath = weak; }
/// <summary> /// Add an edge with a label /// </summary> /// <param name="label">The label to add</param> /// <param name="destNode">The destination node</param> /// <returns>The edge configuration</returns> public LineConfig AddEdge(string label, BaseNodeConfig destNode) { LineConfig edge = AddEdge(destNode); edge.Label = label; return(edge); }
/// <summary> /// Adds an edge between the destination node of this edge /// and another if it doesn't exist /// </summary> /// <param name="destNode">The destination node</param> /// <returns>The edge configuration</returns> public LineConfig AddEdge(BaseNodeConfig destNode) { if (_document != null) { return(_document.AddEdge(null, this.DestNode, destNode)); } return(null); }
/// <summary> /// Add a list of edges to a set of nodes /// </summary> /// <param name="node">The first node to add</param> /// <param name="nodes">The list of nodes</param> public void AddEdge(BaseNodeConfig node, params BaseNodeConfig[] nodes) { if (nodes.Length > 0) { BaseNodeConfig curr_node = node; this.AddEdge(node); for (int i = 0; i < nodes.Length; ++i) { curr_node.AddEdge(nodes[i]); curr_node = nodes[i]; } } }
/// <summary> /// Get list of standard values /// </summary> /// <param name="context">The type context</param> /// <returns>The list of document names</returns> public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { List <T> docs = new List <T>(); BaseNodeConfig config = context.Instance as BaseNodeConfig; foreach (T doc in CANAPEProject.CurrentProject.GetDocumentsByType(typeof(T))) { if ((config == null) || (!config.Document.Equals(doc))) { docs.Add(doc); } } return(new StandardValuesCollection(docs.ToArray())); }
/// <summary> /// Get list of standard values /// </summary> /// <param name="context">The type context</param> /// <returns>The list of document names</returns> public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { List <T> nodes = new List <T>(); BaseNodeConfig config = context.Instance as BaseNodeConfig; if (config != null) { foreach (BaseNodeConfig node in config.Document.Nodes) { T n = node as T; if ((n != null) && !n.Equals(config)) { nodes.Add(n); } } } return(new TypeConverter.StandardValuesCollection(nodes.ToArray())); }
/// <summary> /// Update the graph factory from list of nodes and lines /// </summary> /// <param name="nodes">The list of nodes</param> /// <param name="lines">The list of lines</param> public void UpdateGraph(BaseNodeConfig[] nodes, LineConfig[] lines) { lock (_lockObject) { _nodes = (BaseNodeConfig[])nodes.Clone(); _lines = (LineConfig[])lines.Clone(); foreach (BaseNodeConfig node in _nodes) { node.Document = this; } RebuildFactory(); } Dirty = true; }
/// <summary> /// Add an edge for false, based on the current path name /// </summary> /// <param name="destNode">The destination node</param> /// <returns>The edge configuration</returns> public LineConfig AddFalseEdge(BaseNodeConfig destNode) { return(AddEdge(String.Format("!{0}", _pathName), destNode)); }
/// <summary> /// Add an edge for true, based on the current path name /// </summary> /// <param name="destNode">The destination node</param> /// <returns>The edge configuration</returns> public LineConfig AddTrueEdge(BaseNodeConfig destNode) { return(AddEdge(_pathName, destNode)); }
private void DeleteByConfig(BaseNodeConfig config) { GraphNode n = netEditor.GetNodeByTag(config); if (n != null) { netEditor.DeleteNode(n); } }
/// <summary> /// Add an existing node to the editor /// </summary> /// <param name="config">The node entry</param> /// <param name="p">The point to set</param> /// <param name="z">The z co-ordinate</param> private GraphNode AddNode(BaseNodeConfig config, PointF p, float z) { GraphNodeTemplate template = _templates[config.GetNodeName()]; GraphNode n = netEditor.AddNode(p, z, config.Id, config.Label, template.Shape, template.Width, template.Height, template.BackColor, template.LineColor, template.SelectedLineColor, template.TextColor, template.HatchedColor, config); SetNode(n); netEditor.SelectedObject = n; return n; }
/// <summary> /// Copy a node config, used to allow external applications to create a suitable node /// </summary> /// <param name="node"></param> public static void CopyNode(BaseNodeConfig config) { SlaveLayerNodeConfig slaveConfig = config as SlaveLayerNodeConfig; if (slaveConfig != null) { // Copy the master, not slave config = slaveConfig.Master; } Clipboard.SetData(NODECONFIG_DATA, config); }