Exemple #1
0
        private void ControlMouseDown(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement senderControl = sender as FrameworkElement;

            if (senderControl != null)
            {
                HeliosVisual control = (HeliosVisual)senderControl.Tag;
                if (control != null && _editor != null && !control.IsLocked)
                {
                    if (_editor.SelectedItems.Contains(control))
                    {
                        if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                        {
                            _editor.SelectedItems.Remove(control);
                        }
                        else
                        {
                            _editor.SelectedItems.Clear();
                            _editor.SelectedItems.Add(control);
                        }
                    }
                    else
                    {
                        if (!Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                        {
                            _editor.SelectedItems.Clear();
                        }
                        _editor.SelectedItems.Add(control);
                    }
                    _editor.Focus();
                }
            }
        }
        private void SetPropertyEditors()
        {
            PropertyEditors.Clear();

            HeliosVisual visual = BindingFocus as HeliosVisual;

            if (visual != null)
            {
                // Setup Layout Panel
                HeliosPropertyEditor layoutEditor;
                if (visual is Monitor)
                {
                    layoutEditor = new MonitorPropertyEditor();
                }
                else
                {
                    layoutEditor = new LayoutPropertyEditor();
                }
                layoutEditor.Control = visual;
                PropertyEditors.Add(layoutEditor);

                foreach (HeliosPropertyEditorDescriptor descriptor in ConfigManager.ModuleManager.GetPropertyEditors(visual.TypeIdentifier))
                {
                    HeliosPropertyEditor editor = descriptor.CreateInstance();
                    editor.Control = visual;
                    PropertyEditors.Add(editor);
                }
            }
        }
Exemple #3
0
        internal ShadowVisual(IShadowVisualParent parent, Monitor monitor, HeliosVisual visual, bool recurse = true)
        {
            // create a shadow object
            _parent  = parent;
            Monitor  = monitor;
            Visual   = visual;
            Viewport = visual as IViewportExtent;
            if (IsViewport)
            {
                _parent.AddViewport(this);
            }

            // observe changes
            monitor.Moved   += Monitor_Modified;
            monitor.Resized += Monitor_Modified;
            visual.Moved    += Visual_Modified;
            visual.Resized  += Visual_Modified;
            visual.Children.CollectionChanged += Visual_Children_CollectionChanged;

            // NOTE: changes in monitor children tracked in ShadowMonitor

            if (recurse)
            {
                Instrument(monitor, visual);
            }
        }
Exemple #4
0
 /// <summary>
 /// recusively add all descendants for tracking
 /// </summary>
 /// <param name="monitor"></param>
 /// <param name="visual"></param>
 protected void Instrument(Monitor monitor, HeliosVisual visual)
 {
     foreach (HeliosVisual child in visual.Children)
     {
         Children[child] = new ShadowVisual(_parent, monitor, child);
     }
 }
Exemple #5
0
        private Point GetLocationForControl(HeliosVisual visual, Point location)
        {
            Point startLocation;

            HeliosVisual parent = visual.Parent;

            if (parent != null && !(parent is Monitor))
            {
                startLocation = GetLocationForControl(parent, location);
            }
            else
            {
                startLocation = location;
            }

            Point controlLocation = startLocation;

            switch (visual.Rotation)
            {
            case HeliosVisualRotation.CW:
                controlLocation.X = controlLocation.Y;
                controlLocation.Y = visual.Height - controlLocation.X;
                break;

            case HeliosVisualRotation.CCW:
                controlLocation.X = visual.Width - controlLocation.Y;
                controlLocation.Y = location.X;
                break;
            }

            controlLocation.X -= visual.Left;
            controlLocation.Y -= visual.Top;

            return(controlLocation);
        }
Exemple #6
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);
                    }
                }
            }
        }
        public void OnDropCompleted(IDataObject obj, Point dragPoint)
        {
            HeliosVisual item = obj.GetData("Helios.Visual") as HeliosVisual;

            if (item == null)
            {
                return;
            }

            if (Math.Abs(_target.ZoomFactor) < 0.0001)
            {
                return;
            }
            Point scaledPoint = new Point(dragPoint.X / _target.ZoomFactor, dragPoint.Y / _target.ZoomFactor);

            _target.SnapManager.Location = scaledPoint;

            item.Left = Math.Max(0d, _target.SnapManager.NewLocation.X);
            item.Top  = Math.Max(0d, _target.SnapManager.NewLocation.Y);
            item.Name = _target.VisualContainer.Children.GetUniqueName(item);
            _target.VisualContainer.Children.Add(item);
            _target.SelectedItems.Clear();
            _target.SelectedItems.Add(item);
            _target.Focus();

            ConfigManager.UndoManager.AddUndoItem(new ControlAddUndoEvent(_target.VisualContainer, item));
        }
Exemple #8
0
        private ProfileExplorerTreeItem(HeliosVisual visual, ProfileExplorerTreeItem parent, ProfileExplorerTreeItemType includeTypes)
            : this(visual.Name, "", parent, includeTypes)
        {
            if (visual.GetType() == typeof(Monitor))
            {
                ItemType = ProfileExplorerTreeItemType.Monitor;
            }
            else if (visual.GetType() == typeof(HeliosPanel))
            {
                ItemType = ProfileExplorerTreeItemType.Panel;
            }
            else
            {
                ItemType = ProfileExplorerTreeItemType.Visual;
            }
            ContextItem = visual;

            AddChild(visual, includeTypes);

            foreach (HeliosVisual child in visual.Children)
            {
                if ((child is HeliosPanel && _includeTypes.HasFlag(ProfileExplorerTreeItemType.Panel)) ||
                    (child != null && _includeTypes.HasFlag(ProfileExplorerTreeItemType.Visual)))
                {
                    Children.Add(new ProfileExplorerTreeItem(child, this, _includeTypes));
                }
            }

            visual.Children.CollectionChanged += VisualChildren_CollectionChanged;
        }
        private ProfileExplorerTreeItem(HeliosVisual visual, ProfileExplorerTreeItem parent, ProfileExplorerTreeItemType includeTypes)
            : this(visual.Name, "", parent, includeTypes)
        {
            if (visual.GetType() == typeof(Monitor))
            {
                _itemType = ProfileExplorerTreeItemType.Monitor;
            }
            else if (visual.GetType() == typeof(HeliosPanel))
            {
                _itemType = ProfileExplorerTreeItemType.Panel;
            }
            else
            {
                _itemType = ProfileExplorerTreeItemType.Visual;
            }
            _item = visual;

            AddChild(visual, includeTypes);

            foreach (HeliosVisual child in visual.Children)
            {
                if ((child is HeliosPanel && _includeTypes.HasFlag(ProfileExplorerTreeItemType.Panel)) ||
                    (child is HeliosVisual && _includeTypes.HasFlag(ProfileExplorerTreeItemType.Visual)))
                {
                    Children.Add(new ProfileExplorerTreeItem(child, this, _includeTypes));
                }
            }

            visual.Children.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(VisualChildren_CollectionChanged);
        }
Exemple #10
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();
            }
        }
Exemple #11
0
 internal void Update(HeliosVisual viewport)
 {
     _viewport.X      = viewport.Left;
     _viewport.Y      = viewport.Top;
     _viewport.Width  = viewport.Width;
     _viewport.Height = viewport.Height;
     Update();
 }
Exemple #12
0
 private void LoadVisual(HeliosVisual visual)
 {
     Dispatcher.Invoke(DispatcherPriority.Background, new Action <HeliosVisual, Dispatcher>(PreLoadrenderer), visual, Dispatcher);
     foreach (HeliosVisual control in visual.Children)
     {
         LoadVisual(control);
     }
 }
Exemple #13
0
        private void TransformControl(HeliosVisual visual, double scale, Point translation)
        {
            visual.Left   = visual.Left * scale + translation.X;
            visual.Top    = visual.Top * scale + translation.Y;
            visual.Width  = Math.Max(visual.Width * scale, 1d);
            visual.Height = Math.Max(visual.Height * scale, 1d);

            // child coordinates are relative, so we don't have to translate
            visual.ScaleChildren(scale, scale);
        }
Exemple #14
0
 public HeliosVisualView GetViewerForVisual(HeliosVisual visual)
 {
     foreach (HeliosVisualView view in Children)
     {
         if (view.Visual == visual)
         {
             return(view);
         }
     }
     return(null);
 }
Exemple #15
0
        internal bool TryClaimControl(out HeliosVisual visual)
        {
            visual = _mostRecentlySelected;
            if (_mostRecentlySelected == null)
            {
                return(false);
            }

            // claimed
            _mostRecentlySelected = null;
            return(true);
        }
Exemple #16
0
        private void CheckBounds(HeliosVisual visual, Monitor monitor)
        {
            if (visual.DisplayRectangle.Right > monitor.Width)
            {
                visual.Left = Math.Max(0d, monitor.Width - visual.DisplayRectangle.Width);
            }

            if (visual.DisplayRectangle.Bottom > monitor.Height)
            {
                visual.Top = Math.Max(0d, monitor.Height - visual.DisplayRectangle.Height);
            }
        }
Exemple #17
0
 private int IndexOfChildView(HeliosVisual visual)
 {
     for (int i = 0; i < Children.Count; i++)
     {
         HeliosVisualView view = Children[i] as HeliosVisualView;
         if (view != null && view.Visual == visual)
         {
             return(i);
         }
     }
     return(-1);
 }
        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();
            }
        }
Exemple #19
0
        private void ItemLockChecked(object sender, RoutedEventArgs e)
        {
            FrameworkElement senderControl = sender as FrameworkElement;

            if (senderControl != null)
            {
                HeliosVisual control = (HeliosVisual)senderControl.Tag;
                if (control != null && _editor != null && _editor.SelectedItems.Contains(control))
                {
                    _editor.SelectedItems.Remove(control);
                }
            }
        }
Exemple #20
0
        protected virtual void OnRemoved(HeliosVisual oldChild)
        {
            if (!Children.ContainsKey(oldChild))
            {
                // this has happened before and it is unclear why
                ConfigManager.LogManager.LogInfo(
                    $"the Visual object {oldChild.Name} of type {oldChild.TypeIdentifier} was not found in the data used for tracking viewports and monitors; probable program error");
                return;
            }

            ShadowVisual shadow = Children[oldChild];

            shadow.Dispose();
            Children.Remove(oldChild);
        }
        public bool IsValidDataObject(IDataObject dataObject, Point dropPoint)
        {
            bool valid = dataObject.GetDataPresent("Helios.Visual");

            if (valid)
            {
                HeliosVisual item = dataObject.GetData("Helios.Visual") as HeliosVisual;

                _target.LoadSnapTargets(false);
                _target.SnapManager.Action     = SnapAction.Drop;
                _target.SnapManager.Size       = item.DisplayRectangle.Size;
                _target.SnapManager.DragVector = new Vector(0, 0);
            }
            return(valid);
        }
        public UIElement GetVisualFeedback(IDataObject obj)
        {
            HeliosVisual item = obj.GetData("Helios.Visual") as HeliosVisual;

            if (item == null)
            {
                return(null);
            }

            HeliosVisualView view = new HeliosVisualView();

            view.Visual = item;
            view.Width  = item.Width * _target.ZoomFactor;
            view.Height = item.Height * _target.ZoomFactor;
            return(view);
        }
Exemple #23
0
        private void SetPropertyEditors()
        {
            PropertyEditors.Clear();

            HeliosVisual visual = BindingFocus as HeliosVisual;

            if (visual == null)
            {
                return;
            }

            // Setup Layout Panel
            HeliosPropertyEditor layoutEditor;

            if (visual is Monitor)
            {
                layoutEditor = new MonitorPropertyEditor();
            }
            else
            {
                layoutEditor = new LayoutPropertyEditor();
            }
            layoutEditor.Control = visual;
            PropertyEditors.Add(layoutEditor);

            // find editors that explicitly support this exact visual
            foreach (HeliosPropertyEditorDescriptor descriptor in ConfigManager.ModuleManager.GetPropertyEditors(visual.TypeIdentifier))
            {
                HeliosPropertyEditor editor = descriptor.CreateInstance();
                editor.Control = visual;
                PropertyEditors.Add(editor);
            }

            if (!(ConfigManager.ModuleManager is IModuleManager2 capabilities))
            {
                // legacy build does not support this interface
                return;
            }

            // probe for additional editors based on supported interfaces
            foreach (HeliosCapabilityEditorDescriptor descriptor in capabilities.GetCapabilityEditors(visual))
            {
                HeliosPropertyEditor editor = descriptor.CreateInstance();
                editor.Control = visual;
                PropertyEditors.Add(editor);
            }
        }
Exemple #24
0
        private static void OnVisualChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HeliosVisualView view = d as HeliosVisualView;

            if (view != null)
            {
                HeliosVisual oldVisual = e.OldValue as HeliosVisual;
                if (oldVisual != null)
                {
                    oldVisual.Children.CollectionChanged -= view.VisualChildren_CollectionChanged;
                    oldVisual.DisplayUpdate -= view.Visual_DisplayUpdate;
                    oldVisual.Resized       -= view.Visual_ResizeMove;
                    oldVisual.Moved         -= view.Visual_ResizeMove;
                    oldVisual.HiddenChanged -= view.Visual_HiddenChanged;
                }

                view.Children.Clear();

                if (view.Visual != null)
                {
                    if (view.DisplayRotation)
                    {
                        if (view.Visual.Renderer.Dispatcher == null)
                        {
                            view.Visual.Renderer.Dispatcher = view.Dispatcher;
                        }
                        view.Visual.Renderer.Refresh();
                        view.LayoutTransform = view.Visual.Renderer.Transform;
                    }
                    else
                    {
                        view.LayoutTransform = null;
                    }
                    view.UpdateChildren();
                    view.Visual.Children.CollectionChanged += view.VisualChildren_CollectionChanged;
                    view.Visual.DisplayUpdate += view.Visual_DisplayUpdate;
                    view.Visual.Resized       += view.Visual_ResizeMove;
                    view.Visual.Moved         += view.Visual_ResizeMove;
                    view.Visual.HiddenChanged += view.Visual_HiddenChanged;

                    if (!view.IgnoreHidden)
                    {
                        view.Visibility = view.Visual.IsHidden ? Visibility.Hidden : Visibility.Visible;
                    }
                }
            }
        }
        public override void SetBindingFocus(HeliosObject bindingFoucsObject)
        {
            HeliosVisual visual = bindingFoucsObject as HeliosVisual;

            if (visual != null && Panel.Children.Contains(visual))
            {
                PanelEditor.SelectedItems.Clear();

                HeliosVisualView view = PanelEditor.GetViewerForVisual(visual);
                if (view != null)
                {
                    PanelEditor.UpdateLayout();
                    PanelEditor.SelectedItems.Add((HeliosVisual)bindingFoucsObject);
                    Dispatcher.BeginInvoke(new Action(view.BringIntoView));
                }
            }
        }
        private void ScaleControl(HeliosVisual visual, double scale)
        {
            if (visual.Left > 0)
            {
                double locXDif = visual.Left;
                visual.Left += (locXDif * scale) - locXDif;
            }

            if (visual.Top > 0)
            {
                double locYDif = visual.Top;
                visual.Top += (locYDif * scale) - locYDif;
            }

            visual.Width  = Math.Max(visual.Width * scale, 1d);
            visual.Height = Math.Max(visual.Height * scale, 1d);

            visual.ScaleChildren(scale, scale);
        }
Exemple #27
0
        private HeliosVisual ControlAt(HeliosVisual visual, Point location)
        {
            if (!visual.IsHidden)
            {
                Point localLocation = location;
                switch (visual.Rotation)
                {
                case HeliosVisualRotation.CW:
                    localLocation.X = location.Y;
                    localLocation.Y = visual.Height - location.X;
                    break;

                case HeliosVisualRotation.CCW:
                    localLocation.X = visual.Width - location.Y;
                    localLocation.Y = location.X;
                    break;
                }

                foreach (HeliosVisual child in visual.Children.Reverse())
                {
                    if (!child.IsHidden && child.DisplayRectangle.Contains(localLocation))
                    {
                        localLocation.X -= child.Left;
                        localLocation.Y -= child.Top;
                        HeliosVisual childHit = ControlAt(child, localLocation);
                        if (childHit != null)
                        {
                            return(childHit);
                        }
                    }
                }

                if (visual.HitTest(localLocation))
                {
                    return(visual);
                }
            }
            return(null);
        }
Exemple #28
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);
                        }
                    }
                }
            }
        }
Exemple #29
0
        private string UpdateControl(Monitor monitor, HeliosVisual visual, double scale, Point translation, string commentPrefix = "")
        {
            switch (ScalingMode)
            {
            case ResetMonitorsScalingMode.None:
                CheckBounds(visual, monitor);
                return($"{commentPrefix}checked bounds of {visual.TypeIdentifier} {visual.Name}");

            case ResetMonitorsScalingMode.ScaleMonitor:
                TransformControl(visual, scale, translation);
                return($"{commentPrefix}scaled {visual.TypeIdentifier} {visual.Name}");

            case ResetMonitorsScalingMode.ScaleToFit:
                TransformControl(visual, scale, translation);
                return($"{commentPrefix}scaled {visual.TypeIdentifier} {visual.Name} to fit");

            case ResetMonitorsScalingMode.ScaleToTopRightQuarter:
                TransformControl(visual, scale, translation);
                return($"{commentPrefix}scaled {visual.TypeIdentifier} {visual.Name} for demo");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #30
0
 public VisualsListItem(HeliosVisual control, bool isSelected)
 {
     _control = control;
     _selected = isSelected;
 }
Exemple #31
0
 private void LoadVisual(HeliosVisual visual)
 {
     Dispatcher.Invoke(DispatcherPriority.Background, new Action<HeliosVisual, Dispatcher>(PreLoadrenderer), visual, Dispatcher);
     foreach (HeliosVisual control in visual.Children)
     {
         LoadVisual(control);
     }
 }
Exemple #32
0
        private void CheckBounds(HeliosVisual visual, Monitor monitor)
        {
            if (visual.DisplayRectangle.Right > monitor.Width)
            {
                visual.Left = Math.Max(0d, monitor.Width - visual.DisplayRectangle.Width);
            }

            if (visual.DisplayRectangle.Bottom > monitor.Height)
            {
                visual.Top = Math.Max(0d, monitor.Height - visual.DisplayRectangle.Height);
            }
        }
Exemple #33
0
        private void ScaleControl(HeliosVisual visual, double scale)
        {
            if (visual.Left > 0)
            {
                double locXDif = visual.Left;
                visual.Left += (locXDif * scale) - locXDif;
            }

            if (visual.Top > 0)
            {
                double locYDif = visual.Top;
                visual.Top += (locYDif * scale) - locYDif;
            }

            visual.Width = Math.Max(visual.Width * scale, 1d);
            visual.Height = Math.Max(visual.Height * scale, 1d);

            visual.ScaleChildren(scale, scale);
        }
Exemple #34
0
 private void PreLoadrenderer(HeliosVisual visual, Dispatcher dispatcher)
 {
     visual.Renderer.Dispatcher = dispatcher;
     visual.Renderer.Refresh();
 }
Exemple #35
0
 public static Rect VisualToRect(HeliosVisual visual) =>
 new Rect(visual.Left, visual.Top, visual.Width, visual.Height);
Exemple #36
0
 public abstract void ConfigureIcon(HeliosVisual control);
 public DisplayOrderUndoItem(HeliosVisualContainer container, HeliosVisual control, bool up)
 {
     _container = container;
     _control = control;
     _up = up;
 }
Exemple #38
0
        private Point GetLocationForControl(HeliosVisual visual, Point location)
        {
            Point startLocation;

            HeliosVisual parent = visual.Parent;
            if (parent != null && !(parent is Monitor))
            {
                startLocation = GetLocationForControl(parent, location);
            }
            else
            {
                startLocation = location;
            }

            Point controlLocation = startLocation;
            switch (visual.Rotation)
            {
                case HeliosVisualRotation.CW:
                    controlLocation.X = controlLocation.Y;
                    controlLocation.Y = visual.Height - controlLocation.X;
                    break;

                case HeliosVisualRotation.CCW:
                    controlLocation.X = visual.Width - controlLocation.Y;
                    controlLocation.Y = location.X;
                    break;
            }

            controlLocation.X -= visual.Left;
            controlLocation.Y -= visual.Top;

            return controlLocation;
        }
Exemple #39
0
        private HeliosVisual ControlAt(HeliosVisual visual, Point location)
        {
            if (!visual.IsHidden)
            {
                Point localLocation = location;
                switch (visual.Rotation)
                {
                    case HeliosVisualRotation.CW:
                        localLocation.X = location.Y;
                        localLocation.Y = visual.Height - location.X;
                        break;

                    case HeliosVisualRotation.CCW:
                        localLocation.X = visual.Width - location.Y;
                        localLocation.Y = location.X;
                        break;
                }

                foreach (HeliosVisual child in visual.Children.Reverse())
                {
                    if (!child.IsHidden && child.DisplayRectangle.Contains(localLocation))
                    {
                        localLocation.X -= child.Left;
                        localLocation.Y -= child.Top;
                        HeliosVisual childHit = ControlAt(child, localLocation);
                        if (childHit != null)
                        {
                            return childHit;
                        }
                    }
                }

                if (visual.HitTest(localLocation))
                {
                    return visual;
                }
            }
            return null;
        }
 private static void SerializeBindings(HeliosSerializer serializer, HeliosVisual control, XmlWriter xmlWriter, HeliosBindingCollection serializedBindings)
 {
     serializer.SerializeBindings(control.InputBindings, xmlWriter, serializedBindings);
     serializer.SerializeBindings(control.OutputBindings, xmlWriter, serializedBindings);
     foreach (HeliosVisual child in control.Children)
     {
         SerializeBindings(serializer, child, xmlWriter, serializedBindings);
     }
 }
 public HeliosVisualView GetViewerForVisual(HeliosVisual visual)
 {
     return _view.GetViewerForVisual(visual);
 }
Exemple #42
0
 public HeliosVisualView GetViewerForVisual(HeliosVisual visual)
 {
     foreach (HeliosVisualView view in Children)
     {
         if (view.Visual == visual)
         {
             return view;
         }
     }
     return null;
 }
 public override void ConfigureIcon(HeliosVisual control)
 {
     // No-Op
 }
        private ProfileExplorerTreeItem(HeliosVisual visual, ProfileExplorerTreeItem parent, ProfileExplorerTreeItemType includeTypes)
            : this(visual.Name, "", parent, includeTypes)
        {
            if (visual.GetType() == typeof(Monitor))
            {
                _itemType = ProfileExplorerTreeItemType.Monitor;
            }
            else if (visual.GetType() == typeof(HeliosPanel))
            {
                _itemType = ProfileExplorerTreeItemType.Panel;
            }
            else
            {
                _itemType = ProfileExplorerTreeItemType.Visual;
            }
            _item = visual;

            AddChild(visual, includeTypes);

            foreach (HeliosVisual child in visual.Children)
            {
                if ((child is HeliosPanel && _includeTypes.HasFlag(ProfileExplorerTreeItemType.Panel)) ||
                    (child is HeliosVisual && _includeTypes.HasFlag(ProfileExplorerTreeItemType.Visual)))
                {
                    Children.Add(new ProfileExplorerTreeItem(child, this, _includeTypes));
                }
            }

            visual.Children.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(VisualChildren_CollectionChanged);
        }
 private static void CloseDoucments(HeliosVisual visual, HeliosVisualContainerEditor editor)
 {
     ProfileEditorCommands.CloseProfileItem.Execute(visual, editor);
     foreach (HeliosVisual child in visual.Children)
     {
         CloseDoucments(child, editor);
     }
 }
 public ControlAddUndoEvent(HeliosVisualContainer container, HeliosVisual control)
 {
     _container = container;
     _control = control;
 }
 public override void ConfigureIcon(HeliosVisual control)
 {
     control.ConfigureIconInstance();
 }
Exemple #48
0
 private int IndexOfChildView(HeliosVisual visual)
 {
     for (int i = 0; i < Children.Count; i++)
     {
         HeliosVisualView view = Children[i] as HeliosVisualView;
         if (view != null && view.Visual == visual)
         {
             return i;
         }
     }
     return -1;
 }