private void Delete_Executed(object sender, ExecutedRoutedEventArgs e) { ProfileExplorerTreeItem item = ProfileExplorerTree.SelectedItem as ProfileExplorerTreeItem; if (item != null) { if (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Panel) || item.ItemType.HasFlag(ProfileExplorerTreeItemType.Visual)) { HeliosVisual visual = item.ContextItem as HeliosVisual; HeliosVisualContainer container = visual.Parent as HeliosVisualContainer; if (container != null) { ConfigManager.UndoManager.AddUndoItem(new ControlDeleteUndoEvent(container, new List <HeliosVisual> { visual }, new List <int> { container.Children.IndexOf(visual) })); OnDeleting(visual); container.Children.Remove(visual); } } else if (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Interface)) { HeliosInterface interfaceItem = item.ContextItem as HeliosInterface; if (interfaceItem != null) { DeleteInterface(interfaceItem); } } } }
/// <summary> /// Called immediately after construction when our factory installs the Interface property, not /// executed at run time (Profile Editor only) /// </summary> protected override void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface) { base.OnInterfaceChanged(oldInterface, newInterface); DCSExportConfiguration configuration; DCSVehicleImpersonation vehicleImpersonation; if (newInterface is DCSInterface dcsInterface) { // create or connect to configuration objects _phantomFix = new DCSPhantomMonitorFixConfig(dcsInterface); configuration = dcsInterface.Configuration; vehicleImpersonation = dcsInterface.VehicleImpersonation; } else { // provoke crash on attempt to use _phantomFix = null; configuration = null; vehicleImpersonation = null; } // need to rebind everything on the form SetValue(ConfigurationProperty, configuration); SetValue(PhantomFixProperty, _phantomFix); SetValue(VehicleImpersonationProperty, vehicleImpersonation); }
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 void AddInterfaceIfSupported(HeliosInterface heliosInterface) { if (InterfaceStatus.TryManage(heliosInterface, out InterfaceStatus interfaceStatus)) { InterfaceStatuses.Add(interfaceStatus); interfaceStatus.Subscription?.Subscribe(this); } }
private ProfileExplorerTreeItem(HeliosInterface heliosInterface, ProfileExplorerTreeItem parent, ProfileExplorerTreeItemType includeTypes) : this(heliosInterface.Name, "", parent, includeTypes) { _itemType = ProfileExplorerTreeItemType.Interface; _item = heliosInterface; AddChild(heliosInterface, includeTypes); }
protected override void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface) { base.OnInterfaceChanged(oldInterface, newInterface); if (newInterface is ControlRouter router) { DataContext = new ControlRouterViewModel(router.Model); } }
public M2000CCompositeVisual(string name, Size nativeSize) : base(name, nativeSize) { PersistChildren = false; Children.CollectionChanged += Children_CollectionChanged; _defaultInterfaceName = ""; _defaultBindingName = ""; _defaultInterface = null; }
public void DeleteInterface(HeliosInterface interfaceItem) { if (MessageBox.Show(Window.GetWindow(this), "Are you sure you want to remove the " + interfaceItem.Name + " interface from the profile? This will remove all bindings associated with this interface.", "Remove Interface", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No, MessageBoxOptions.None) == MessageBoxResult.Yes) { ConfigManager.UndoManager.AddUndoItem(new InterfaceDeleteUndoEvent(Profile, interfaceItem)); OnDeleting(interfaceItem); Profile.Interfaces.Remove(interfaceItem); } }
protected override void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface) { base.OnInterfaceChanged(oldInterface, newInterface); if (newInterface == null) { DataContext = null; return; } DataContext = new ProfileInterfaceViewModel((ProfileInterface)newInterface); }
protected override void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface) { base.OnInterfaceChanged(oldInterface, newInterface); if (newInterface == null) { // shut down DataContext = null; return; } DataContext = new ProcessControlViewModel((ProcessControlInterface)newInterface); }
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(); } }
/// <summary> /// Called immediately after construction when our factory installs the Interface property, not /// executed at run time (Profile Editor only) /// </summary> protected override void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface) { base.OnInterfaceChanged(oldInterface, newInterface); if (newInterface is MonitorSetup monitorSetupInterface) { _model = new MonitorSetupViewModel(monitorSetupInterface); DataContext = _model; } else { // deinit; provoke crash on attempt to use Dispose(); } }
/// <summary> /// Called immediately after construction when our factory installs the Interface property, not /// executed at run time (Profile Editor only) /// </summary> protected override void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface) { base.OnInterfaceChanged(oldInterface, newInterface); if (newInterface is AdditionalViewports viewportsInterface) { _interface = viewportsInterface; DataContext = new AdditionalViewportsViewModel(_interface.ViewportPatches); } else { // deinit; provoke crash on attempt to use _interface = null; DataContext = null; } }
protected override void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface) { PhidgetLEDBoard oldBoard = oldInterface as PhidgetLEDBoard; if (oldBoard != null) { oldBoard.Detach(); } PhidgetLEDBoard newBoard = newInterface as PhidgetLEDBoard; if (newBoard != null) { newBoard.Attach(); } GroupsViewModel = new LedGroupsViewModel(newInterface as PhidgetLEDBoard); }
protected override void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface) { PhidgetsServoBoard oldBoard = oldInterface as PhidgetsServoBoard; if (oldBoard != null) { oldBoard.Detach(); } PhidgetsServoBoard newBoard = newInterface as PhidgetsServoBoard; if (newBoard != null) { newBoard.Attach(); } _motorList.Clear(); for (int i = 0; i < newBoard.ServoCount; i++) { _motorList.Add("Servo " + i); } }
private InterfaceStatus(HeliosInterface heliosInterface) { Interface = heliosInterface; ReadyCheck = heliosInterface as IReadyCheck; Name = $"{heliosInterface.Name}"; if (heliosInterface is IExtendedDescription extendedInfo) { Description = extendedInfo.Description; } else { Description = Name; } HeliosInterfaceDescriptor descriptor = ConfigManager.ModuleManager.InterfaceDescriptors[heliosInterface.TypeIdentifier]; HasEditor = descriptor.InterfaceEditorType != null; Subscription = heliosInterface as IStatusReportNotify; Subscription?.Subscribe(this); }
private void Delete_Executed(object sender, ExecutedRoutedEventArgs e) { ProfileExplorerTreeItem item = ProfileExplorerTree.SelectedItem as ProfileExplorerTreeItem; if (item != null) { if (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Panel) || item.ItemType.HasFlag(ProfileExplorerTreeItemType.Visual)) { HeliosVisual visual = item.ContextItem as HeliosVisual; HeliosVisualContainer container = visual.Parent as HeliosVisualContainer; if (container != null) { ConfigManager.UndoManager.AddUndoItem(new ControlDeleteUndoEvent(container, new List <HeliosVisual> { visual }, new List <int> { container.Children.IndexOf(visual) })); OnDeleting(visual); container.Children.Remove(visual); } } else if (item.ItemType.HasFlag(ProfileExplorerTreeItemType.Interface)) { HeliosInterface interfaceItem = item.ContextItem as HeliosInterface; if (interfaceItem != null) { if (MessageBox.Show(Window.GetWindow(this), "Are you sure you want to remove the " + interfaceItem.Name + " interface from the profile. This will remove all bindings associated with this interface.", "Remove Interface", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No, MessageBoxOptions.None) == MessageBoxResult.Yes) { ConfigManager.UndoManager.AddUndoItem(new InterfaceDeleteUndoEvent(Profile, interfaceItem)); OnDeleting(interfaceItem); Profile.Interfaces.Remove(interfaceItem); } } } } }
public InterfaceAddUndoEvent(HeliosProfile profile, HeliosInterface newInterface) { _profile = profile; _interface = newInterface; }
public InterfaceDeleteUndoEvent(HeliosProfile profile, HeliosInterface oldInterface) { _profile = profile; _interface = oldInterface; }
public static bool TryManage(HeliosInterface heliosInterface, out InterfaceStatus managed) { managed = new InterfaceStatus(heliosInterface); return(true); }
protected virtual void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface) { }
public InterfaceItem(HeliosInterface heliosInterface) : base(heliosInterface.Name) { HeliosInterface = heliosInterface; }