protected void OnValueChanged(DesignerPropertyInfo property) { if (!_valueWasAssigned) { return; } Nodes.Node node = _object as Nodes.Node; if (node != null) { node.OnPropertyValueChanged(true); } else { Attachments.Attachment attach = _object as Attachments.Attachment; if (attach != null) { attach.OnPropertyValueChanged(true); } } if (ValueWasChanged != null) { ValueWasChanged(this, property); } }
/// <summary> /// Loads an attachment which is attached to a node. /// </summary> /// <param name="node">The node the attachment is created for.</param> /// <param name="xml">The XML node the attachment retrieves its name and attributes from.</param> /// <returns>Returns the created Attachment.</returns> protected Attachments.Attachment CreateAttachment(List <Nodes.Node.ErrorCheck> result, Node node, XmlNode xml) { try { // get the type of the attachment and create it // maintain compatibility with version 1 //string clss= GetAttribute(xml, "Class"); string clss; if (!GetAttribute(xml, "Class", out clss)) { string find = ".Events." + GetAttribute(xml, "name"); Type found = Plugin.FindType(find); if (found != null) { clss = found.FullName; } } Type t = Plugin.GetType(clss); if (t == null) { throw new Exception(string.Format(Resources.ExceptionUnknownEventType, clss)); } Attachments.Attachment attach = Attachments.Attachment.Create(t, node); // initialise the attachments properties IList <DesignerPropertyInfo> properties = attach.GetDesignerProperties(); for (int p = 0; p < properties.Count; ++p) { if (properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave)) { continue; } InitProperty(result, xml, attach, properties[p]); } // update attacheent with attributes attach.OnPropertyValueChanged(false); return(attach); } catch (Exception ex) { string msgError = string.Format("{0}\n{1}:\n{2} Of Node {3}", ex.Message, this.Filename, "Attachment", node.Id); //throw new Exception(msg); MessageBox.Show(msgError, Resources.LoadError, MessageBoxButtons.OK); } return(null); }
/// <summary> /// Loads an attachment which is attached to a node. /// </summary> /// <param name="node">The node the attachment is created for.</param> /// <param name="xml">The XML node the attachment retrieves its name and attributes from.</param> /// <returns>Returns the created Attachment.</returns> protected Attachments.Attachment CreateAttachment(Node node, XmlNode xml) { // get the type of the attachment and create it // maintain compatibility with version 1 //string clss= GetAttribute(xml, "Class"); string clss; if (!GetAttribute(xml, "Class", out clss)) { string find = ".Events." + GetAttribute(xml, "name"); Type found = Plugin.FindType(find); if (found != null) { clss = found.FullName; } } Type t = Plugin.GetType(clss); if (t == null) { throw new Exception(string.Format(Resources.ExceptionUnknownEventType, clss)); } Attachments.Attachment attach = Attachments.Attachment.Create(t, node); // initialise the attachments properties IList <DesignerPropertyInfo> properties = attach.GetDesignerProperties(); for (int p = 0; p < properties.Count; ++p) { if (properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave)) { continue; } InitProperty(xml, attach, properties[p]); } // update attacheent with attributes attach.OnPropertyValueChanged(false); return(attach); }
/// <summary> /// Loads an attachment which is attached to a node. /// </summary> /// <param name="node">The node the attachment is created for.</param> /// <param name="xml">The XML node the attachment retrieves its name and attributes from.</param> /// <returns>Returns the created Attachment.</returns> protected Attachments.Attachment CreateAttachment(Node node, XmlNode xml) { try { // get the type of the attachment and create it // maintain compatibility with version 1 //string clss= GetAttribute(xml, "Class"); string clss; if (!GetAttribute(xml, "Class", out clss)) { string find = ".Events." + GetAttribute(xml, "name"); Type found = Plugin.FindType(find); if (found != null) { clss = found.FullName; } } Type t = Plugin.GetType(clss); if (t == null) { throw new Exception(string.Format(Resources.ExceptionUnknownEventType, clss)); } Attachments.Attachment attach = Attachments.Attachment.Create(t, node); // initialise the attachments properties IList <DesignerPropertyInfo> properties = attach.GetDesignerProperties(); for (int p = 0; p < properties.Count; ++p) { if (properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave)) { continue; } InitProperty(xml, attach, properties[p]); } // update attacheent with attributes attach.OnPropertyValueChanged(false); Attachments.Event evt = attach as Attachments.Event; if (evt != null) { foreach (XmlNode xnode in xml.ChildNodes) { if (xnode.NodeType == XmlNodeType.Element) { switch (xnode.Name.ToLowerInvariant()) { // load parameters case ("parameters"): LoadParameters(xnode, node, evt.Pars); break; } } } } return(attach); } catch (Exception ex) { string msgError = string.Format("{0}\n{1}:\n{2}", ex.Message, this.Filename, "Attachment"); //throw new Exception(msg); MessageBox.Show(msgError, Resources.LoadError, MessageBoxButtons.OK); } return(null); }