/// <summary> /// Allow dragging the source element onto the target /// </summary> protected override void OnDraggingBegun(MouseActionEventArgs e) { if (mySourceElement == null) { mySourceElement = ElementFromShape <ORMModelElement>(MouseDownHitShape); } base.OnDraggingBegun(e); } /// <summary>
/// <summary> /// Get the source object type or role after the /// base class sets the source shape /// </summary> /// <param name="e">MouseActionEventArgs</param> protected override void OnClicked(MouseActionEventArgs e) { base.OnClicked(e); if (mySourceElement == null) { mySourceElement = ElementFromShape <ORMModelElement>(MouseDownHitShape); } }
private CustomProperty FindCustomProperty(ORMModelElement modelElement) { if (modelElement != null) { foreach (ModelElement extensionElement in modelElement.ExtensionCollection) { CustomProperty customProperty = extensionElement as CustomProperty; if (customProperty != null && customProperty.CustomPropertyDefinition == this.customPropertyDefinition) { return(customProperty); } } } return(null); }
public sealed override void ResetValue(object component) { ORMModelElement modelElement = EditorUtility.ResolveContextInstance(component, false) as ORMModelElement; System.Diagnostics.Debug.Assert(modelElement != null); CustomProperty customProperty = FindCustomProperty(modelElement); if (customProperty != null) { using (Transaction transaction = this.StartTransaction(modelElement)) { customProperty.Delete(); transaction.Commit(); } } }
public sealed override void SetValue(object component, object value) { CustomPropertyDefinition customPropertyDefinition = this.customPropertyDefinition; ORMModelElement modelElement = EditorUtility.ResolveContextInstance(component, false) as ORMModelElement; System.Diagnostics.Debug.Assert(modelElement != null); CustomProperty customProperty = FindCustomProperty(modelElement); using (Transaction transaction = this.StartTransaction(modelElement)) { if (customProperty != null) { if (!object.Equals(customProperty.Value, value)) { if (value == null || object.Equals(customPropertyDefinition.DefaultValue, value)) { customProperty.Delete(); } else { customProperty.Value = value; } } } else if (value != null && !object.Equals(customPropertyDefinition.DefaultValue, value)) { customProperty = new CustomProperty(modelElement.Partition, new PropertyAssignment(CustomProperty.ValueDomainPropertyId, value)); customProperty.CustomPropertyDefinition = customPropertyDefinition; modelElement.ExtensionCollection.Add(customProperty); } if (transaction.HasPendingChanges) { transaction.Commit(); } } }
private Transaction StartTransaction(ORMModelElement modelElement) { return(modelElement.Store.TransactionManager.BeginTransaction(ElementPropertyDescriptor.GetSetValueTransactionName(this.customPropertyDefinition.Name))); }
private void Reset() { mySourceElement = null; myEmulateDrag = false; }