예제 #1
0
        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);
                    }
                }
            }
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
 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);
        }
예제 #6
0
 protected override void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface)
 {
     base.OnInterfaceChanged(oldInterface, newInterface);
     if (newInterface is ControlRouter router)
     {
         DataContext = new ControlRouterViewModel(router.Model);
     }
 }
예제 #7
0
 public M2000CCompositeVisual(string name, Size nativeSize)
     : base(name, nativeSize)
 {
     PersistChildren             = false;
     Children.CollectionChanged += Children_CollectionChanged;
     _defaultInterfaceName       = "";
     _defaultBindingName         = "";
     _defaultInterface           = null;
 }
예제 #8
0
 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);
     }
 }
예제 #9
0
 protected override void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface)
 {
     base.OnInterfaceChanged(oldInterface, newInterface);
     if (newInterface == null)
     {
         DataContext = null;
         return;
     }
     DataContext = new ProfileInterfaceViewModel((ProfileInterface)newInterface);
 }
예제 #10
0
 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();
            }
        }
예제 #12
0
 /// <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;
     }
 }
예제 #14
0
        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);
        }
예제 #15
0
        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);
            }
        }
예제 #17
0
        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);
        }
예제 #18
0
        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);
            }
        }
예제 #19
0
        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);
                        }
                    }
                }
            }
        }
예제 #20
0
 public InterfaceAddUndoEvent(HeliosProfile profile, HeliosInterface newInterface)
 {
     _profile   = profile;
     _interface = newInterface;
 }
 public InterfaceDeleteUndoEvent(HeliosProfile profile, HeliosInterface oldInterface)
 {
     _profile   = profile;
     _interface = oldInterface;
 }
예제 #22
0
 public static bool TryManage(HeliosInterface heliosInterface, out InterfaceStatus managed)
 {
     managed = new InterfaceStatus(heliosInterface);
     return(true);
 }
예제 #23
0
 protected virtual void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface)
 {
 }
예제 #24
0
        private ProfileExplorerTreeItem(HeliosInterface heliosInterface, ProfileExplorerTreeItem parent, ProfileExplorerTreeItemType includeTypes)
            : this(heliosInterface.Name, "", parent, includeTypes)
        {
            _itemType = ProfileExplorerTreeItemType.Interface;
            _item = heliosInterface;

            AddChild(heliosInterface, includeTypes);
        }
예제 #25
0
 public InterfaceDeleteUndoEvent(HeliosProfile profile, HeliosInterface oldInterface)
 {
     _profile = profile;
     _interface = oldInterface;
 }
예제 #26
0
 protected virtual void OnInterfaceChanged(HeliosInterface oldInterface, HeliosInterface newInterface)
 {
 }
예제 #27
0
 public InterfaceItem(HeliosInterface heliosInterface)
     : base(heliosInterface.Name)
 {
     HeliosInterface = heliosInterface;
 }