示例#1
0
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            if (e.Property == ProfileProperty)
            {
                HeliosProfile oldProfile = e.OldValue as HeliosProfile;
                if (oldProfile != null)
                {
                    oldProfile.Monitors.CollectionChanged -= new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Monitors_CollectionChanged);
                }

                if (Profile != null)
                {
                    Profile.Monitors.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Monitors_CollectionChanged);
                }

                Dispatcher.Invoke(new Action(UpdateMonitors));
            }
            else if (e.Property == ShowPanelsProperty)
            {
                foreach (HeliosVisualView panelView in _children)
                {
                    panelView.Visibility = ShowPanels ? Visibility.Visible : Visibility.Hidden;
                }
            }

            base.OnPropertyChanged(e);
        }
示例#2
0
        void Profile_ProfileStarted(object sender, EventArgs e)
        {
            ConfigManager.LogManager.LogDebug("UDP interface starting. (Interface=\"" + Name + "\")");
            try
            {
                _bindEndPoint = new IPEndPoint(IPAddress.Any, Port);
                _socket       = new Socket(AddressFamily.InterNetwork,
                                           SocketType.Dgram,
                                           ProtocolType.Udp);
                _socket.ExclusiveAddressUse = false;
                // https://github.com/BlueFinBima/Helios/issues/140
                _socket.Bind(_bindEndPoint);
                _client   = new IPEndPoint(IPAddress.Any, 0);
                _started  = true;
                _clientID = "";
                _profile  = Profile;


                _startuptimer          = new Timer();
                _startuptimer.Elapsed += OnStartupTimer;
                _startuptimer.Interval = 10000;  // 10 seconds for Delayed Startup
                _startuptimer.Start();
                ConfigManager.LogManager.LogInfo("Startup timer started.");
                WaitForData();
            }
            catch (System.Net.Sockets.SocketException se)
            {
                ConfigManager.LogManager.LogError("UDP interface startup error. (Interface=\"" + Name + "\")");
                ConfigManager.LogManager.LogError("UDP Socket Exception on Profile Start.  " + se.Message, se);
            }
        }
        public ProfileExplorerTreeItem(HeliosProfile profile, ProfileExplorerTreeItemType includeTypes)
            : this(profile.Name, "", null, includeTypes)
        {
            _item     = profile;
            _itemType = ProfileExplorerTreeItemType.Profile;

            if (includeTypes.HasFlag(ProfileExplorerTreeItemType.Monitor))
            {
                ProfileExplorerTreeItem monitors = new ProfileExplorerTreeItem("Monitors", profile.Monitors, this, includeTypes);
                if (monitors.HasChildren)
                {
                    Children.Add(monitors);
                }
            }

            if (includeTypes.HasFlag(ProfileExplorerTreeItemType.Interface))
            {
                ProfileExplorerTreeItem interfaces = new ProfileExplorerTreeItem("Interfaces", profile.Interfaces, this, includeTypes);
                if (interfaces.HasChildren)
                {
                    Children.Add(interfaces);
                }
                profile.Interfaces.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Interfaces_CollectionChanged);
            }
        }
示例#4
0
        private void WriteProfile(HeliosProfile profile)
        {
            StatusBarMessage = "Saving Profile...";
            GetLoadingAdorner();

            System.Threading.Thread t = new System.Threading.Thread(delegate()
            {
                if (!ConfigManager.ProfileManager.SaveProfile(profile))
                {
                    Dispatcher.Invoke(DispatcherPriority.Normal, (Action)ErrorDuringSave);
                }
                ConfigManager.UndoManager.ClearHistory();
                profile.IsDirty = false;
                Dispatcher.Invoke(DispatcherPriority.Background, new Action(RemoveLoadingAdorner));
                Dispatcher.Invoke(DispatcherPriority.Background, (System.Threading.SendOrPostCallback) delegate { SetValue(StatusBarMessageProperty, ""); }, "");

                string layoutFileName = Path.ChangeExtension(profile.Path, "hply");
                if (File.Exists(layoutFileName))
                {
                    File.Delete(layoutFileName);
                }
                Dispatcher.Invoke(DispatcherPriority.Background, (LayoutDelegate)_layoutSerializer.Serialize, layoutFileName);
            });
            t.Start();
        }
示例#5
0
        public ProfileExplorerTreeItem(HeliosProfile profile, ProfileExplorerTreeItemType includeTypes)
            : this(profile.Name, "", null, includeTypes)
        {
            ContextItem = profile;
            ItemType    = ProfileExplorerTreeItemType.Profile;

            if (includeTypes.HasFlag(ProfileExplorerTreeItemType.Monitor))
            {
                ProfileExplorerTreeItem monitors = new ProfileExplorerTreeItem("Monitors", profile.Monitors, this, includeTypes);
                if (monitors.HasChildren)
                {
                    Children.Add(monitors);
                }
                profile.Monitors.CollectionChanged += Monitors_CollectionChanged;
            }

            if (includeTypes.HasFlag(ProfileExplorerTreeItemType.Interface))
            {
                ProfileExplorerTreeItem interfaces = new ProfileExplorerTreeItem("Interfaces", profile.Interfaces, this, includeTypes);
                if (interfaces.HasChildren)
                {
                    Children.Add(interfaces);
                }
                profile.Interfaces.CollectionChanged += Interfaces_CollectionChanged;
            }
        }
示例#6
0
        public void Reload(HeliosProfile profile)
        {
            if (_profile != null)
            {
                // disconnect
                _profile.Interfaces.CollectionChanged -= Profile_InterfacesChanged;
                _profile = null;
            }

            // signal all interfaces removed so that any running view models / editors can refresh
            InterfaceStatuses?.Clear();

            if (profile == null)
            {
                // empty status is correct
                return;
            }

            // add back new interface status objects for new profile
            foreach (HeliosInterface heliosInterface in profile.Interfaces)
            {
                AddInterfaceIfSupported(heliosInterface);
            }

            PerformChecks();
            profile.Interfaces.CollectionChanged += Profile_InterfacesChanged;
            _profile = profile;
        }
示例#7
0
        void Profile_ProfileStopped(object sender, EventArgs e)
        {
            foreach (MonitorWindow window in _windows)
            {
                window.Close();
            }

            _windows.Clear();

            HeliosProfile profile = sender as HeliosProfile;

            if (profile != null)
            {
                profile.ControlCenterShown  -= Profile_ShowControlCenter;
                profile.ControlCenterHidden -= Profile_HideControlCenter;
                profile.ProfileStopped      -= Profile_ProfileStopped;
            }

            if (_dispatcherTimer != null)
            {
                _dispatcherTimer.Stop();
                _dispatcherTimer = null;
            }

            SetLicenseMessage();

            //EGalaxTouch.ReleaseTouchScreens();
        }
        internal List<DirectXControllerGuid> GetAvailableControllers(HeliosProfile profile)
        {
            List<DirectXControllerGuid> controllers = new List<DirectXControllerGuid>();
            List<DirectXControllerGuid> usedControllers = new List<DirectXControllerGuid>();

            foreach (HeliosInterface profileInterface in profile.Interfaces)
            {
                DirectXControllerInterface controllerInterface = profileInterface as DirectXControllerInterface;
                if (controllerInterface != null)
                {
                    usedControllers.Add(controllerInterface.ControllerId);
                }
            }

            IList<DeviceInstance> gameControllerList = DirectInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly);
            foreach(DeviceInstance controllerInstance in gameControllerList)
            {
                DirectXControllerGuid joystickId = new DirectXControllerGuid(controllerInstance.ProductName, controllerInstance.InstanceGuid);
                if (!usedControllers.Contains(joystickId))
                {
                    controllers.Add(joystickId);
                }
            }

            return controllers;
        }
示例#9
0
        void Profile_ProfileStopped(object sender, EventArgs e)
        {
            foreach (MonitorWindow window in _windows)
            {
                window.Close();
            }

            _windows.Clear();

            HeliosProfile profile = sender as HeliosProfile;

            if (profile != null)
            {
                profile.ControlCenterShown   -= Profile_ShowControlCenter;
                profile.ControlCenterHidden  -= Profile_HideControlCenter;
                profile.ProfileStopped       -= Profile_ProfileStopped;
                profile.ProfileHintReceived  -= Profile_ProfileHintReceived;
                profile.DriverStatusReceived -= Profile_DriverStatusReceived;
                profile.ClientChanged        -= Profile_ClientChanged;
            }

            if (_dispatcherTimer != null)
            {
                _dispatcherTimer.Stop();
                _dispatcherTimer = null;
            }

            StatusMessage = StatusValue.License;

            //EGalaxTouch.ReleaseTouchScreens();
        }
示例#10
0
        public ProfileExplorerTreeItem(HeliosProfile profile, ProfileExplorerTreeItemType includeTypes)
            : this(profile.Name, "", null, includeTypes)
        {
            _item = profile;
            _itemType = ProfileExplorerTreeItemType.Profile;

            if (includeTypes.HasFlag(ProfileExplorerTreeItemType.Monitor))
            {
                ProfileExplorerTreeItem monitors = new ProfileExplorerTreeItem("Monitors", profile.Monitors, this, includeTypes);
                if (monitors.HasChildren)
                {
                    Children.Add(monitors);
                }
            }

            if (includeTypes.HasFlag(ProfileExplorerTreeItemType.Interface))
            {
                ProfileExplorerTreeItem interfaces = new ProfileExplorerTreeItem("Interfaces", profile.Interfaces, this, includeTypes);
                if (interfaces.HasChildren)
                {
                    Children.Add(interfaces);
                }
                profile.Interfaces.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Interfaces_CollectionChanged);
            }
        }
        internal List <DirectXControllerGuid> GetAvailableControllers(HeliosProfile profile)
        {
            List <DirectXControllerGuid> controllers     = new List <DirectXControllerGuid>();
            List <DirectXControllerGuid> usedControllers = new List <DirectXControllerGuid>();

            foreach (HeliosInterface profileInterface in profile.Interfaces)
            {
                DirectXControllerInterface controllerInterface = profileInterface as DirectXControllerInterface;
                if (controllerInterface != null)
                {
                    usedControllers.Add(controllerInterface.ControllerId);
                }
            }

            IList <DeviceInstance> gameControllerList = DirectInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly);

            foreach (DeviceInstance controllerInstance in gameControllerList)
            {
                DirectXControllerGuid joystickId = new DirectXControllerGuid(controllerInstance.ProductName, controllerInstance.InstanceGuid);
                if (!usedControllers.Contains(joystickId))
                {
                    controllers.Add(joystickId);
                }
            }

            return(controllers);
        }
示例#12
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();
            }
        }
示例#13
0
        void Profile_ProfileStopped(object sender, EventArgs e)
        {
            _started = false;
            _socket.Close();
            _socket = null;

            _profile = null;
        }
示例#14
0
 private void ResetRemovedMonitor(HeliosProfile profile, int monitorIndex, MonitorResetItem item, int monitorToRemove)
 {
     ConfigManager.LogManager.LogDebug($"Removing Monitor {monitorIndex + 1} and saving its controls for replacement");
     Dispatcher.Invoke(DispatcherPriority.Background, new Action <HeliosObject>(CloseProfileItem), profile.Monitors[monitorToRemove]);
     Dispatcher.Invoke(DispatcherPriority.Background, new Action(item.RemoveControls));
     ConfigManager.UndoManager.AddUndoItem(new DeleteMonitorUndoEvent(profile, profile.Monitors[monitorToRemove], monitorToRemove));
     profile.Monitors.RemoveAt(monitorToRemove);
 }
示例#15
0
        private void ResetMonitorsThread(ResetMonitors resetDialog, HeliosProfile profile)
        {
            ConfigManager.UndoManager.StartBatch();
            ConfigManager.LogManager.LogDebug("Resetting Monitors");
            try
            {
                // WARNING: monitor naming is 1-based but indexing and NewMonitor references are 0-based
                Monitor[] localMonitors = ConfigManager.DisplayManager.Displays.ToArray <Monitor>();

                // pass1: process all new and/or old monitors in order
                int existingMonitors = Math.Min(localMonitors.Length, profile.Monitors.Count);
                int totalMonitors    = Math.Max(localMonitors.Length, profile.Monitors.Count);

                // monitors that are preserved
                for (int monitorIndex = 0; monitorIndex < existingMonitors; monitorIndex++)
                {
                    MonitorResetItem item = resetDialog.MonitorResets[monitorIndex];
                    ResetExistingMonitor(monitorIndex, item);
                }

                // monitors added (may be zero iterations)
                for (int monitorIndex = existingMonitors; monitorIndex < localMonitors.Length; monitorIndex++)
                {
                    // monitorIndex does not refer to any reset item, as we are off the end of the list
                    ResetAddedMonitor(profile, monitorIndex, localMonitors[monitorIndex]);
                }

                // monitors removed (may be zero iterations)
                for (int monitorIndex = existingMonitors; monitorIndex < resetDialog.MonitorResets.Count; monitorIndex++)
                {
                    MonitorResetItem item = resetDialog.MonitorResets[monitorIndex];
                    ResetRemovedMonitor(profile, monitorIndex, item, localMonitors.Length);
                }

                // pass2: place all controls that were temporarily lifted and
                // copy over any settings from source to target monitors
                foreach (MonitorResetItem item in resetDialog.MonitorResets)
                {
                    ConfigManager.LogManager.LogDebug($"Placing controls for old monitor {item.OldMonitor.Name} onto Monitor {item.NewMonitor + 1}");
                    Dispatcher.Invoke(DispatcherPriority.Background, new Action <Monitor>(item.PlaceControls), profile.Monitors[item.NewMonitor]);
                    Dispatcher.Invoke(DispatcherPriority.Background, new Action <Monitor>(item.CopySettings), profile.Monitors[item.NewMonitor]);
                }

                ConfigManager.UndoManager.CloseBatch();
            }
            catch (Exception ex)
            {
                ConfigManager.LogManager.LogError("Reset Monitors - Unhandled exception", ex);
                ConfigManager.LogManager.LogError("Rolling back any undoable operations from monitor reset");
                ConfigManager.UndoManager.UndoBatch();
                MessageBox.Show("Error encountered while resetting monitors; please file a bug with the contents of the application log", "Error");
            }
            finally
            {
                Dispatcher.Invoke(DispatcherPriority.Background, new Action(RemoveLoadingAdorner));
            }
        }
示例#16
0
        // WARNING: monitorIndex refers to a new monitor that does not yet exist, and there is no monitor reset item for it
        private void ResetAddedMonitor(HeliosProfile profile, int monitorIndex, Monitor display)
        {
            ConfigManager.LogManager.LogDebug($"Adding Monitor {monitorIndex + 1}");
            Monitor monitor = new Monitor(display);

            monitor.Name           = $"Monitor {monitorIndex + 1}";
            monitor.FillBackground = false;
            ConfigManager.UndoManager.AddUndoItem(new AddMonitorUndoEvent(profile, monitor));
            Dispatcher.Invoke(DispatcherPriority.Background, new Action <Monitor>(profile.Monitors.Add), monitor);
        }
示例#17
0
        public override List<HeliosInterface> GetInterfaceInstances(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            List<HeliosInterface> cardInterfaces = new List<HeliosInterface>();
            foreach (String serialNumber in DTSCard.CardSerialNumbers)
            {
                // TODO Check to see if card already in profile.
                cardInterfaces.Add(new DTSCardInterface(serialNumber));
            }

            return cardInterfaces;
        }
示例#18
0
 private static IEnumerable <string> ResetRemovedMonitor(ICallbacks parent, HeliosProfile profile, int monitorIndex, ViewModel.MonitorResetItem item, int monitorToRemove)
 {
     Logger.Debug($"removing Monitor {monitorIndex + 1} and saving its controls for replacement");
     parent.CloseProfileItem(profile.Monitors[monitorToRemove]);
     foreach (string progress in item.RemoveControls())
     {
         yield return(progress);
     }
     ConfigManager.UndoManager.AddUndoItem(new UndoEvents.DeleteMonitorUndoEvent(profile, profile.Monitors[monitorToRemove], monitorToRemove));
     profile.Monitors.RemoveAt(monitorToRemove);
 }
示例#19
0
        // WARNING: monitorIndex refers to a new monitor that does not yet exist, and there is no monitor reset item for it
        private static void ResetAddedMonitor(HeliosProfile profile, int monitorIndex, Monitor display)
        {
            Logger.Debug($"adding Monitor {monitorIndex + 1}");
            Monitor monitor = new Monitor(display)
            {
                Name = $"Monitor {monitorIndex + 1}", FillBackground = false
            };

            ConfigManager.UndoManager.AddUndoItem(new UndoEvents.AddMonitorUndoEvent(profile, monitor));
            profile.Monitors.Add(monitor);
        }
示例#20
0
        protected override void OnProfileChanged(HeliosProfile oldProfile)
        {
            if (oldProfile != null)
            {
                oldProfile.ProfileStarted -= Profile_ProfileStarted;
                oldProfile.ProfileStopped -= Profile_ProfileStopped;
            }

            Profile.ProfileStarted += Profile_ProfileStarted;
            Profile.ProfileStopped += Profile_ProfileStopped;
            base.OnProfileChanged(oldProfile);
        }
示例#21
0
        void Profile_ProfileStopped(object sender, EventArgs e)
        {
            _started = false;
            _socket.Close();
            _socket = null;

            _profile = null;
            if (_startuptimer != null)
            {
                _startuptimer.Stop();
            }
        }
        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();
            }
        }
        public override List<HeliosInterface> GetInterfaceInstances(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            List<HeliosInterface> interfaces = new List<HeliosInterface>();

            foreach (DirectXControllerGuid guid in GetAvailableControllers(profile))
            {
                DirectXControllerInterface newInterface = new DirectXControllerInterface();
                newInterface.ControllerId = guid;
                interfaces.Add(newInterface);
            }

            return interfaces;
        }
        protected override void OnProfileChanged(HeliosProfile oldProfile)
        {
            if (oldProfile != null)
            {
                oldProfile.ProfileTick -= new EventHandler(Profile_ProfileTick);
            }

            if (Profile != null)
            {
                Profile.ProfileTick += new EventHandler(Profile_ProfileTick);
            }
            base.OnProfileChanged(oldProfile);
        }
示例#25
0
        private void NewProfile()
        {
            if (CheckSave())
            {
                Profile = new HeliosProfile();
                ConfigManager.UndoManager.ClearHistory();

                AddNewDocument(Profile.Monitors[0]);

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
示例#26
0
        protected override void OnProfileChanged(HeliosProfile oldProfile)
        {
            base.OnProfileChanged(oldProfile);

            if (oldProfile != null)
            {
                oldProfile.ProfileTick -= Profile_Tick;
            }

            if (Profile != null)
            {
                Profile.ProfileTick += Profile_Tick;
            }
        }
示例#27
0
        private bool IsUnique(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            foreach (HeliosInterface heliosInterface in profile.Interfaces)
            {
                HeliosInterfaceDescriptor interfaceDescriptor = ConfigManager.ModuleManager.InterfaceDescriptors[heliosInterface.GetType()];
                if (interfaceDescriptor.TypeIdentifier.Equals(descriptor.TypeIdentifier))
                {
                    // If any existing interfaces in the profile have the same type identifier do not add them.
                    return(false);
                }
            }

            return(true);
        }
示例#28
0
        private static void LoadSources(BindingsPanel p)
        {
            ProfileExplorerTreeItemType triggerTypes = ProfileExplorerTreeItemType.Interface | ProfileExplorerTreeItemType.Monitor | ProfileExplorerTreeItemType.Panel | ProfileExplorerTreeItemType.Visual | ProfileExplorerTreeItemType.Trigger;
            ProfileExplorerTreeItemType actionTypes  = ProfileExplorerTreeItemType.Interface | ProfileExplorerTreeItemType.Monitor | ProfileExplorerTreeItemType.Panel | ProfileExplorerTreeItemType.Visual | ProfileExplorerTreeItemType.Action;

            if (p.BindingObject != null)
            {
                if (p.BindingObject.Profile != p._actionTriggerProfile)
                {
                    HeliosProfile newProfile = p.BindingObject.Profile;

                    if (p._actionsList != null)
                    {
                        p._actionsList.Disconnect();
                    }
                    if (p._triggerList != null)
                    {
                        p._triggerList.Disconnect();
                    }

                    p._actionsList          = new ProfileExplorerTreeItem(newProfile, actionTypes);
                    p._triggerList          = new ProfileExplorerTreeItem(newProfile, triggerTypes);
                    p._actionTriggerProfile = newProfile;
                }
            }

            if (p.BindingType == BindingPanelType.Input)
            {
                if (p._triggerList == null)
                {
                    p.ProfileExplorerItems = null;
                }
                else
                {
                    p.ProfileExplorerItems = p._triggerList.Children;
                }
            }
            else if (p.BindingType == BindingPanelType.Output)
            {
                if (p._actionsList == null)
                {
                    p.ProfileExplorerItems = null;
                }
                else
                {
                    p.ProfileExplorerItems = p._actionsList.Children;
                }
            }
        }
示例#29
0
        protected override void OnProfileChanged(HeliosProfile oldProfile)
        {
            base.OnProfileChanged(oldProfile);
            if (oldProfile != null)
            {
                oldProfile.ProfileStarted -= new EventHandler(Profile_ProfileStarted);
                oldProfile.ProfileStopped -= new EventHandler(Profile_ProfileStopped);
            }

            if (Profile != null)
            {
                Profile.ProfileStarted += new EventHandler(Profile_ProfileStarted);
                Profile.ProfileStopped += new EventHandler(Profile_ProfileStopped);
            }
        }
        public override List<HeliosInterface> GetInterfaceInstances(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            HashSet<int> serialNumbers = new HashSet<int>();
            List<HeliosInterface> interfaces = new List<HeliosInterface>();

            foreach (HeliosInterface currentInterface in profile.Interfaces)
            {
                PhidgetInterface phidgetInterface = currentInterface as PhidgetInterface;
                if (phidgetInterface != null)
                {
                    serialNumbers.Add(phidgetInterface.SerialNumber);
                }
            }

            foreach (Phidget phidget in PhidgetManager.Devices)
            {
                if (!serialNumbers.Contains(phidget.SerialNumber))
                {
                    switch (phidget.Type)
                    {
                        case "PhidgetStepper":
                            if (descriptor.TypeIdentifier.Equals("Helios.Phidgets.UnipolarStepperBoard"))
                            {
                                interfaces.Add(new PhidgetStepperBoard(phidget.SerialNumber));
                            }
                            break;
                        case "PhidgetLED":
                            if (descriptor.TypeIdentifier.Equals("Helios.Phidgets.LedBoard"))
                            {
                                interfaces.Add(new PhidgetLEDBoard(phidget.SerialNumber));
                            }
                            break;
                        case "PhidgetAdvancedServo":
                        case "PhidgetServo":
                            if (descriptor.TypeIdentifier.Equals("Helios.Phidgets.AdvancedServoBoard"))
                            {
                                interfaces.Add(new PhidgetsServoBoard(phidget.SerialNumber));
                            }
                            break;
                        default:
                            break;
                    }
                    ConfigManager.LogManager.LogInfo("Found phidget Type = " + phidget.Type + " Serail Number = " + phidget.SerialNumber.ToString());
                }
            }

            return interfaces;
        }
示例#31
0
        protected override void DetachFromProfileOnMainThread(HeliosProfile oldProfile)
        {
            base.DetachFromProfileOnMainThread(oldProfile);
            if (!(ConfigManager.ImageManager is IImageManager2 images))
            {
                return;
            }

            oldProfile.ProfileStopped          -= Profile_ProfileStopped;
            oldProfile.ProfileStarted          -= Profile_ProfileStarted;
            oldProfile.PropertyChanged         -= Profile_PropertyChanged;
            images.ImageLoadSuccess            -= Images_ImageLoadSuccess;
            images.ImageLoadFailure            -= Images_ImageLoadFailure;
            ConfigManager.UndoManager.Empty    -= UndoManager_Empty;
            ConfigManager.UndoManager.NonEmpty -= UndoManager_NonEmpty;
        }
示例#32
0
        void Profile_ProfileStarted(object sender, EventArgs e)
        {
            ConfigManager.LogManager.LogDebug("UDP interface starting. (Interface=\"" + Name + "\")");
            _bindEndPoint = new IPEndPoint(IPAddress.Any, Port);
            _socket       = new Socket(AddressFamily.InterNetwork,
                                       SocketType.Dgram,
                                       ProtocolType.Udp);
            _socket.ExclusiveAddressUse = false;
            _socket.Bind(_bindEndPoint);
            _client   = new IPEndPoint(IPAddress.Any, 0);
            _started  = true;
            _clientID = "";

            WaitForData();

            _profile = Profile;
        }
示例#33
0
        private void LoadProfile(string path)
        {
            StatusBarMessage = "Loading Profile...";
            GetLoadingAdorner();

            System.Threading.Thread t = new System.Threading.Thread(delegate()
            {
                HeliosProfile profile = ConfigManager.ProfileManager.LoadProfile(path, Dispatcher);

                ConfigManager.UndoManager.ClearHistory();

                // Load the graphics so everything is more responsive after load
                if (profile != null)
                {
                    foreach (Monitor monitor in profile.Monitors)
                    {
                        LoadVisual(monitor);
                    }
                }

                Dispatcher.Invoke(DispatcherPriority.Send, (System.Threading.SendOrPostCallback) delegate { SetValue(ProfileProperty, profile); }, profile);

                Dispatcher.Invoke(DispatcherPriority.Background, new Action(RemoveLoadingAdorner));

                Dispatcher.Invoke(DispatcherPriority.Background, (System.Threading.SendOrPostCallback) delegate { SetValue(StatusBarMessageProperty, ""); }, "");

                // TODO Restore docking panel layout
                if (profile != null)
                {
                    string layoutFileName = Path.ChangeExtension(profile.Path, "hply");
                    if (File.Exists(layoutFileName))
                    {
                        Dispatcher.Invoke(DispatcherPriority.Background, (LayoutDelegate)_layoutSerializer.Deserialize, layoutFileName);
                    }
                }
                else
                {
                    ConfigManager.LogManager.LogDebug("Docking Panel Layout Problem.  Profile Object Null during restore of hply for " + path);
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
            });
            t.Start();
        }
示例#34
0
        private void ResetMonitors_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ResetMonitors resetDialog = new ResetMonitors(Profile);

            resetDialog.Owner = this;
            bool?reset = resetDialog.ShowDialog();

            if (reset.HasValue && reset.Value)
            {
                GetLoadingAdorner();
                // this value comes from a dependency property that can only be
                // read on this thread
                HeliosProfile profile = Profile;

                // now run monitor import as another thread
                new System.Threading.Thread(() => { ResetMonitorsThread(resetDialog, profile); }).Start();
            }
        }
示例#35
0
        protected override void DetachFromProfileOnMainThread(HeliosProfile oldProfile)
        {
            // stop updating shadow collections
            oldProfile.Monitors.CollectionChanged -= Monitors_CollectionChanged;
            oldProfile.PropertyChanged            -= Profile_PropertyChanged;

            base.DetachFromProfileOnMainThread(oldProfile);

            // deallocate timer we allocate on Attach
            _geometryChangeTimer?.Stop();
            _geometryChangeTimer = null;

            // deallocate renderer we allocate on Attach
            _renderer?.Dispose();
            _renderer = null;

            ClearShadowObjects();
        }
示例#36
0
        public ResetMonitors(HeliosProfile profile)
        {
            _profile = profile;
            HeliosProfile newProfile = new HeliosProfile();

            _monitors = new List<MonitorResetItem>(profile.Monitors.Count);
            for (int i = 0; i < profile.Monitors.Count; i++)
            {
                _monitors.Add(new MonitorResetItem(profile.Monitors[i], i, i < newProfile.Monitors.Count ? i : 0));
            }

            _newMonitors = new List<String>(newProfile.Monitors.Count);
            foreach (Monitor monitor in newProfile.Monitors)
            {
                _newMonitors.Add(monitor.Name);
            }

            InitializeComponent();

            OldLayout.Profile = profile;
            NewLayout.Profile = newProfile;
        }
示例#37
0
 public AddInterfaceDialog(HeliosProfile profile)
 {
     InitializeComponent();
     _profile = profile;
     UpdateAvailableInterfaces();
 }
示例#38
0
 public AddMonitorUndoEvent(HeliosProfile profile, Monitor monitor)
 {
     _profile = profile;
     _monitor = monitor;
 }
        protected override void OnProfileChanged(HeliosProfile oldProfile)
        {
            base.OnProfileChanged(oldProfile);
            if (oldProfile != null)
            {
                oldProfile.ProfileStarted -= new EventHandler(Profile_ProfileStarted);
                oldProfile.ProfileTick -= new EventHandler(Profile_ProfileTick);
                oldProfile.ProfileStopped -= new EventHandler(Profile_ProfileStopped);
            }

            if (Profile != null)
            {
                Profile.ProfileStarted += new EventHandler(Profile_ProfileStarted);
                Profile.ProfileTick += new EventHandler(Profile_ProfileTick);
                Profile.ProfileStopped += new EventHandler(Profile_ProfileStopped);
            }
        }
        private bool IsUnique(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            foreach (HeliosInterface heliosInterface in profile.Interfaces)
            {
                HeliosInterfaceDescriptor interfaceDescriptor = ConfigManager.ModuleManager.InterfaceDescriptors[heliosInterface.GetType()];
                if (interfaceDescriptor.TypeIdentifier.Equals(descriptor.TypeIdentifier))
                {
                    // If any existing interfaces in the profile have the same type identifier do not add them.
                    return false;
                }
            }

            return true;
        }
 public override List<HeliosInterface> GetAutoAddInterfaces(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
 {
     return new List<HeliosInterface>();
 }
示例#42
0
        private void WriteProfile(HeliosProfile profile)
        {
            StatusBarMessage = "Saving Profile...";
            GetLoadingAdorner();

            System.Threading.Thread t = new System.Threading.Thread(delegate()
            {
                if (!ConfigManager.ProfileManager.SaveProfile(profile))
                {
                    Dispatcher.Invoke(DispatcherPriority.Normal, (Action)ErrorDuringSave);
                }
                ConfigManager.UndoManager.ClearHistory();
                profile.IsDirty = false;
                Dispatcher.Invoke(DispatcherPriority.Background, new Action(RemoveLoadingAdorner));
                Dispatcher.Invoke(DispatcherPriority.Background, (System.Threading.SendOrPostCallback)delegate { SetValue(StatusBarMessageProperty, ""); }, "");

                string layoutFileName = Path.ChangeExtension(profile.Path, "layout");
                if (File.Exists(layoutFileName))
                {
                    File.Delete(layoutFileName);
                }
                Dispatcher.Invoke(DispatcherPriority.Background, (LayoutDelegate)_layoutSerializer.Serialize, layoutFileName);
            });
            t.Start();
        }
示例#43
0
        void Profile_ProfileStopped(object sender, EventArgs e)
        {
            _started = false;
            _socket.Close();
            _socket = null;

            _profile = null;
        }
示例#44
0
        protected override void OnProfileChanged(HeliosProfile oldProfile)
        {
            if (oldProfile != null)
            {
                oldProfile.ProfileStarted -= Profile_ProfileStarted;
                oldProfile.ProfileStopped -= Profile_ProfileStopped;
            }

            Profile.ProfileStarted += Profile_ProfileStarted;
            Profile.ProfileStopped += Profile_ProfileStopped;
            base.OnProfileChanged(oldProfile);
        }
 public InterfaceDeleteUndoEvent(HeliosProfile profile, HeliosInterface oldInterface)
 {
     _profile = profile;
     _interface = oldInterface;
 }
示例#46
0
        protected override void OnProfileChanged(HeliosProfile oldProfile)
        {
            base.OnProfileChanged(oldProfile);

            if (oldProfile != null)
            {
                oldProfile.ProfileTick -= Profile_Tick;
            }

            if (Profile != null)
            {
                Profile.ProfileTick += Profile_Tick;
            }
        }
        protected override void OnProfileChanged(HeliosProfile oldProfile)
        {
            if (oldProfile != null)
            {
                oldProfile.ProfileTick -= new EventHandler(Profile_ProfileTick);
            }

            if (Profile != null)
            {
                Profile.ProfileTick += new EventHandler(Profile_ProfileTick);
            }
            base.OnProfileChanged(oldProfile);
        }
示例#48
0
        private void NewProfile()
        {
            if (CheckSave())
            {
                Profile = new HeliosProfile();
                ConfigManager.UndoManager.ClearHistory();

                AddNewDocument(Profile.Monitors[0]);

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
示例#49
0
 public DeleteMonitorUndoEvent(HeliosProfile profile, Monitor monitor, int index)
 {
     _profile = profile;
     _monitor = monitor;
     _index = index;
 }
示例#50
0
        void Profile_ProfileStarted(object sender, EventArgs e)
        {
            ConfigManager.LogManager.LogDebug("UDP interface starting. (Interface=\"" + Name + "\")");
            _bindEndPoint = new IPEndPoint(IPAddress.Any, Port);
            _socket = new Socket(AddressFamily.InterNetwork,
                                      SocketType.Dgram,
                                      ProtocolType.Udp);
            _socket.ExclusiveAddressUse = false;
            _socket.Bind(_bindEndPoint);
            _client = new IPEndPoint(IPAddress.Any, 0);
            _started = true;
            _clientID = "";

            WaitForData();

            _profile = Profile;
        }