Exemple #1
0
 public MonitorAdorner(HeliosVisualView adornedElement, string monitorLabel, Monitor monitor)
     : base(adornedElement)
 {
     _textFormat.VerticalAlignment = TextVerticalAlignment.Center;
     _label = monitorLabel;
     _monitor = monitor;
 }
Exemple #2
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);
 }
Exemple #3
0
        private void UpdateChildren()
        {
            if (Visual != null)
            {
                int i = 0;
                for (i = Children.Count - 1; i >= 0; i--)
                {
                    HeliosVisualView view = Children[i] as HeliosVisualView;
                    if (!Visual.Children.Contains(view.Visual))
                    {
                        RemoveVisualChild(view);
                        Children.RemoveAt(i);
                    }
                }

                for (i = 0; i < Visual.Children.Count; i++)
                {
                    int viewIndex = IndexOfChildView(Visual.Children[i]);
                    HeliosVisualView view;
                    if (viewIndex == -1)
                    {
                        view        = new HeliosVisualView();
                        view.Visual = Visual.Children[i];
                        Children.Add(view);
                        AddVisualChild(view);
                    }
                    else
                    {
                        view = Children[viewIndex];
                        RemoveVisualChild(view);
                        if (viewIndex != i)
                        {
                            Children.RemoveAt(viewIndex);
                            if (i >= Children.Count)
                            {
                                Children.Add(view);
                            }
                            else
                            {
                                Children.Insert(i, view);
                            }
                        }
                        AddVisualChild(view);
                    }
                }
            }

            InvalidateMeasure();
            InvalidateArrange();
            InvalidateVisual();
        }
Exemple #4
0
        private static void OnIgnoreHidden(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HeliosVisualView view = d as HeliosVisualView;

            if (view != null)
            {
                if (view.IgnoreHidden)
                {
                    view.Visibility = Visibility.Visible;
                }
                else
                {
                    view.SetHidden();
                }
            }
        }
Exemple #5
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;
                    }
                }
            }
        }
Exemple #6
0
        protected static void OnDisplayRotationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HeliosVisualView view = d as HeliosVisualView;

            if (view != null)
            {
                if (view.DisplayRotation)
                {
                    view.Visual.Renderer.Refresh();
                    view.LayoutTransform = view.Visual.Renderer.Transform;
                    view.InvalidateVisual();
                }
                else
                {
                    view.LayoutTransform = null;
                }
            }
        }
Exemple #7
0
        public MonitorWindow(Monitor monitor, bool autoInvalidate)
        {
            _viewer = new HeliosVisualView();
            _viewer.Visual = monitor;
            Content = _viewer;

            _display = monitor;
            _autoInvalidate = autoInvalidate;
            _needsDisplay = true;

            Top = _display.Top;
            Left = _display.Left;
            Width = _display.Width;
            Height = _display.Height;

            ShowInTaskbar = false;
            WindowStyle = System.Windows.WindowStyle.None;
            (Monitor.Renderer as MonitorRenderer).SkipFill = true;

            if (!Monitor.FillBackground)
            {
                ConfigManager.LogManager.LogDebug("Setting " + monitor.Name + " to transparent.");
                AllowsTransparency = true;
                Background = Brushes.Transparent;
            }
            else
            {
                if (Monitor.BackgroundColor.A != 255)
                {
                    ConfigManager.LogManager.LogDebug("Setting " + monitor.Name + " to transparent.");
                    AllowsTransparency = true;
                }
                Background = new SolidColorBrush(Monitor.BackgroundColor);
            }

            Focusable = false;

            if (Monitor.AlwaysOnTop)
            {
                Topmost = true;
            }

            ResizeMode = System.Windows.ResizeMode.NoResize;
        }
        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;            
        }
        public HeliosVisualContainerEditor()
        {
            Focusable = true;

            _view = new HeliosVisualView();
            _view.IgnoreHidden = true;
            _view.DisplayRotation = false;
            AddVisualChild(_view);

            SelectedItems = new HeliosVisualCollection();
            _zoomCalibration = new CalibrationPointCollectionDouble(-4d, 0.25d, 4d, 4d);
            _zoomCalibration.Add(new CalibrationPointDouble(0d, 1d));
            SelectedItems.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedItems_CollectionChanged);

            DrawingGroup checkerGroup = new DrawingGroup();
            checkerGroup.Children.Add(new GeometryDrawing(Brushes.White, null, new RectangleGeometry(new Rect(0, 0, 100, 100))));

            DrawingGroup grayGroup = new DrawingGroup();
            grayGroup.Children.Add(new GeometryDrawing(Brushes.LightGray, null, new RectangleGeometry(new Rect(0, 0, 50, 50))));
            grayGroup.Children.Add(new GeometryDrawing(Brushes.LightGray, null, new RectangleGeometry(new Rect(50, 50, 50, 50))));

            checkerGroup.Children.Add(grayGroup);
            checkerGroup.Freeze();

            _checkerBrush = new DrawingBrush(checkerGroup);
            _checkerBrush.Viewport = new Rect(0, 0, 10, 10);
            _checkerBrush.ViewportUnits = BrushMappingMode.Absolute;
            _checkerBrush.TileMode = TileMode.Tile;
            _checkerBrush.Freeze();
        }
Exemple #10
0
        private void UpdateChildren()
        {
            if (Visual != null)
            {
                int i = 0;
                for (i = Children.Count-1; i >= 0; i--)
                {
                    HeliosVisualView view = Children[i] as HeliosVisualView;
                    if (!Visual.Children.Contains(view.Visual))
                    {
                        RemoveVisualChild(view);
                        Children.RemoveAt(i);
                    }
                }

                for (i = 0; i < Visual.Children.Count; i++)
                {
                    int viewIndex = IndexOfChildView(Visual.Children[i]);
                    HeliosVisualView view;
                    if (viewIndex == -1)
                    {
                        view = new HeliosVisualView();
                        view.Visual = Visual.Children[i];
                        Children.Add(view);
                        AddVisualChild(view);
                    }
                    else
                    {
                        view = Children[viewIndex];                        
                        RemoveVisualChild(view);
                        if (viewIndex != i)
                        {
                            Children.RemoveAt(viewIndex);
                            if (i >= Children.Count)
                            {
                                Children.Add(view);
                            }
                            else
                            {
                                Children.Insert(i, view);
                            }
                        }
                        AddVisualChild(view);
                    }
                }
            }

            InvalidateMeasure();
            InvalidateArrange();
            InvalidateVisual();
        }