private ProfileExplorerTreeItem(HeliosBinding item, ProfileExplorerTreeItem parent, ProfileExplorerTreeItemType includeTypes) : this(item.Description, "", parent, includeTypes) { _item = item; _itemType = ProfileExplorerTreeItemType.Binding; item.PropertyChanged += Binding_PropertyChanged; }
public void Disconnect() { switch (ItemType) { case ProfileExplorerTreeItemType.Monitor: case ProfileExplorerTreeItemType.Panel: case ProfileExplorerTreeItemType.Visual: HeliosVisual visual = (HeliosVisual)ContextItem; visual.PropertyChanged -= HeliosObject_PropertyChanged; visual.Children.CollectionChanged -= VisualChildren_CollectionChanged; visual.Triggers.CollectionChanged -= Triggers_CollectionChanged; visual.Actions.CollectionChanged -= Actions_CollectionChanged; break; case ProfileExplorerTreeItemType.Interface: HeliosInterface heliosInterface = (HeliosInterface)ContextItem; heliosInterface.PropertyChanged -= HeliosObject_PropertyChanged; heliosInterface.Triggers.CollectionChanged -= Triggers_CollectionChanged; heliosInterface.Actions.CollectionChanged -= Actions_CollectionChanged; break; case ProfileExplorerTreeItemType.Action: IBindingAction action = (IBindingAction)ContextItem; action.Target.InputBindings.CollectionChanged -= Bindings_CollectionChanged; break; case ProfileExplorerTreeItemType.Trigger: IBindingTrigger trigger = (IBindingTrigger)ContextItem; trigger.Source.OutputBindings.CollectionChanged -= Bindings_CollectionChanged; break; case ProfileExplorerTreeItemType.Value: break; case ProfileExplorerTreeItemType.Binding: HeliosBinding binding = (HeliosBinding)ContextItem; binding.PropertyChanged += Binding_PropertyChanged; break; case ProfileExplorerTreeItemType.Profile: HeliosProfile profile = (HeliosProfile)ContextItem; profile.PropertyChanged -= HeliosObject_PropertyChanged; profile.Interfaces.CollectionChanged -= Interfaces_CollectionChanged; profile.Monitors.CollectionChanged -= Monitors_CollectionChanged; break; case ProfileExplorerTreeItemType.Folder: // no resources; children are disconnected from their resources below in tail recursion break; default: break; } foreach (ProfileExplorerTreeItem child in Children) { child.Disconnect(); } }
private static void Delete_CanExecute(object target, CanExecuteRoutedEventArgs e) { BindingsPanel editor = target as BindingsPanel; HeliosBinding binding = e.Parameter as HeliosBinding; if (editor != null) { e.Handled = true; e.CanExecute = binding != null || editor.SelectedBinding != null; } }
public void Disconnect() { switch (ItemType) { case ProfileExplorerTreeItemType.Monitor: case ProfileExplorerTreeItemType.Panel: case ProfileExplorerTreeItemType.Visual: HeliosVisual visual = ContextItem as HeliosVisual; visual.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(hobj_PropertyChanged); visual.Children.CollectionChanged -= new System.Collections.Specialized.NotifyCollectionChangedEventHandler(VisualChildren_CollectionChanged); visual.Triggers.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Triggers_CollectionChanged); visual.Actions.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Actions_CollectionChanged); break; case ProfileExplorerTreeItemType.Interface: HeliosInterface item = ContextItem as HeliosInterface; item.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(hobj_PropertyChanged); item.Triggers.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Triggers_CollectionChanged); item.Actions.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Actions_CollectionChanged); break; case ProfileExplorerTreeItemType.Action: IBindingAction action = ContextItem as IBindingAction; action.Target.InputBindings.CollectionChanged -= Bindings_CollectionChanged; break; case ProfileExplorerTreeItemType.Trigger: IBindingTrigger trigger = ContextItem as IBindingTrigger; trigger.Source.OutputBindings.CollectionChanged -= Bindings_CollectionChanged; break; case ProfileExplorerTreeItemType.Value: break; case ProfileExplorerTreeItemType.Binding: HeliosBinding binding = ContextItem as HeliosBinding; binding.PropertyChanged += Binding_PropertyChanged; break; case ProfileExplorerTreeItemType.Profile: HeliosProfile profile = ContextItem as HeliosProfile; profile.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(hobj_PropertyChanged); break; default: break; } foreach (ProfileExplorerTreeItem child in Children) { child.Disconnect(); } }
private void AddNewBinding(IBindingTrigger trigger, IBindingAction action) { HeliosBinding binding = new HeliosBinding(trigger, action); if (action.ActionRequiresValue && (ConfigManager.ModuleManager.CanConvertUnit(trigger.Unit, action.Unit))) { binding.ValueSource = BindingValueSources.TriggerValue; } else { binding.ValueSource = BindingValueSources.StaticValue; } BindingAddUndoEvent undoEvent = new BindingAddUndoEvent(binding); undoEvent.Do(); ConfigManager.UndoManager.AddUndoItem(undoEvent); }
private bool ShouldAddBinding(HeliosBinding child) { if (!_includeTypes.HasFlag(ProfileExplorerTreeItemType.Binding)) { // we don't do bindings return(false); } if (child.Action != ContextItem && child.Trigger != ContextItem) { // not attached to this item return(false); } // auto expand if anything added IsExpanded = true; return(true); }
private static void Delete_Executed(object target, ExecutedRoutedEventArgs e) { BindingsPanel editor = target as BindingsPanel; HeliosBinding binding = e.Parameter as HeliosBinding; if (editor != null) { BindingDeleteUndoEvent undo; if (binding != null) { undo = new BindingDeleteUndoEvent(binding); } else { undo = new BindingDeleteUndoEvent(editor.SelectedBinding); } undo.Do(); ConfigManager.UndoManager.AddUndoItem(undo); e.Handled = true; } }
private void AddNewBinding(IBindingTrigger trigger, IBindingAction action) { HeliosBinding binding = new HeliosBinding(trigger, action); if (action.ActionRequiresValue && (ConfigManager.ModuleManager.CanConvertUnit(trigger.Unit, action.Unit))) { binding.ValueSource = BindingValueSources.TriggerValue; } else { binding.ValueSource = BindingValueSources.StaticValue; } // default cascading triggers according to settings binding.BypassCascadingTriggers = !GlobalOptions.HasDefaultCascadeTriggers; // build and install specialized undo context to remove binding on undo BindingAddUndoEvent undoEvent = new BindingAddUndoEvent(binding); undoEvent.Do(); ConfigManager.UndoManager.AddUndoItem(undoEvent); }
public void TraceTriggerFired(HeliosBinding heliosBinding) { // NOTE: deliberately crash if any of these are null HeliosObject target = heliosBinding.Action.Target; // IsTracing indicates a soft loop, IsExecuting indicates a hard loop if (IsTracing(target) || heliosBinding.IsExecuting) { if (!_tracesReported.Contains(heliosBinding.Description)) { string loopType = heliosBinding.IsExecuting ? "Hard" : "Soft"; Logger.Warn($"{loopType} binding loop detected; Object {target.Name} may have triggered itself"); _traceLoop = true; _tracesReported.Add(heliosBinding.Description); } _tracingSource = target; } HeliosObject source = (heliosBinding.Trigger).Source; SetTracing(source); }
public void EndTraceTriggerFired(HeliosBinding heliosBinding) { if (_traceLoop) { // log every node traversed while returning back through the sources // after detecting a loop // NOTE: LongDescription is extremely expensive, but that's ok because we trace every loop only once Logger.Warn($" binding loop includes {heliosBinding.Description} ({heliosBinding.LongDescription})"); } HeliosObject source = heliosBinding.Trigger.Source; if (!IsTracing(source)) { // not part of a loop being traced return; } // returning back through the sources ClearTracing(source); if (_tracingSource != source) { // not the source currently being traced return; } if (_traceLoop) { // found source of loop, finish trace _traceLoop = false; Logger.Warn(" binding loop trace complete"); } // not tracing any more _tracingSource = null; }
public BindingAddUndoEvent(HeliosBinding binding) { _binding = binding; }
public BindingDeleteUndoEvent(HeliosBinding binding) { _binding = binding; }