예제 #1
0
 private MonitorRectangle FindClosestMonitor(MonitorRectangle inSelectedMonitorRectangle)
 {
     if (MonitorRectanglesList != null && MonitorRectanglesList.Count > 1 && inSelectedMonitorRectangle != null)
     {
         MonitorRectangle toRetMonitor = MonitorRectanglesList[0];
         if (toRetMonitor == inSelectedMonitorRectangle)
         {
             toRetMonitor = MonitorRectanglesList[1];
         }
         double currentLowestDistance = Calculations.GetDistanceBetween2Points(inSelectedMonitorRectangle.CenterPointOfRectangle, toRetMonitor.CenterPointOfRectangle);
         foreach (var monitor in MonitorRectanglesList)
         {
             if (monitor != inSelectedMonitorRectangle && monitor != toRetMonitor)
             {
                 if (currentLowestDistance > Calculations.GetDistanceBetween2Points(inSelectedMonitorRectangle.CenterPointOfRectangle, monitor.CenterPointOfRectangle))
                 {
                     currentLowestDistance = Calculations.GetDistanceBetween2Points(inSelectedMonitorRectangle.CenterPointOfRectangle, monitor.CenterPointOfRectangle);
                     toRetMonitor          = monitor;
                 }
             }
         }
         return(toRetMonitor);
     }
     return(null);
 }
예제 #2
0
        private void LokForRectangleDistanceAligment(MonitorRectangle inDraggingRectangle)  //LOOK FOR INTERSECT WITH VIRTUAL AROUNDING RECT
        {
            var distanceValue = 8;

            if (MonitorRectanglesList != null && MonitorRectanglesList.Count > 1 && inDraggingRectangle.draggingStarted)
            {
                foreach (var monitor in MonitorRectanglesList)
                {
                    if (monitor != inDraggingRectangle && monitor.VirtualAroundRegionRect.IntersectsWith(inDraggingRectangle.TmpRectangle) && !monitor.TmpRectangle.IntersectsWith(inDraggingRectangle.TmpRectangle))
                    {
                        if (Math.Abs(inDraggingRectangle.Right - monitor.Left) < distanceValue && inDraggingRectangle.Right <= monitor.Left)
                        {
                            inDraggingRectangle.SetRight(monitor.Left - distanceValue);
                        }
                        else if (Math.Abs(inDraggingRectangle.Left - monitor.Right) < distanceValue && inDraggingRectangle.Left >= monitor.Right)
                        {
                            inDraggingRectangle.SetLeft(monitor.Right + distanceValue);
                        }
                        else if (Math.Abs(inDraggingRectangle.Bottom - monitor.Top) < distanceValue && inDraggingRectangle.Bottom <= monitor.Top)
                        {
                            inDraggingRectangle.SetBottom(monitor.Top - distanceValue);
                        }
                        else if (Math.Abs(inDraggingRectangle.Top - monitor.Bottom) < distanceValue && inDraggingRectangle.Top >= monitor.Bottom)
                        {
                            inDraggingRectangle.SetTop(monitor.Bottom + distanceValue);
                        }
                    }
                }
            }
        }
예제 #3
0
        //Work with Rectangles aligment TEST functions   //po potrebi uraditi nove
        #region Look For Rectangle Side Aligment function
        private void LookForRectangleSideAligment(MonitorRectangle inDraggingRectangle, bool compareWithFarAwayRectangles = false)
        {
            var responseValue = 3;


            if (inDraggingRectangle.draggingStarted)
            {
                if (MonitorRectanglesList != null && MonitorRectanglesList.Count > 1)
                {
                    foreach (var monitor in MonitorRectanglesList)
                    {
                        if (monitor != inDraggingRectangle && (monitor.VirtualAroundRegionRect.IntersectsWith(inDraggingRectangle.TmpRectangle) || compareWithFarAwayRectangles))
                        {
                            if (Math.Abs(monitor.Left - inDraggingRectangle.Left) < responseValue) //Aligment stranica
                            {
                                inDraggingRectangle.SetLeft(monitor.Left);
                            }
                            else if (Math.Abs(monitor.Right - inDraggingRectangle.Right) < responseValue)
                            {
                                inDraggingRectangle.SetRight(monitor.Right);
                            }
                            else if (Math.Abs(monitor.Bottom - inDraggingRectangle.Bottom) < responseValue)
                            {
                                inDraggingRectangle.SetBottom(monitor.Bottom);
                            }
                            else if (Math.Abs(monitor.Top - inDraggingRectangle.Top) < responseValue)
                            {
                                inDraggingRectangle.SetTop(monitor.Top);
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
 //Work with MonitorRectangles list functions
 #region Generate Monitors Rectangles Dictonary
 public void GenerateMonitorRectanglesList()
 {
     if (MonitorRectanglesList == null)
     {
         MonitorRectanglesList = new ObservableCollection <MonitorRectangle>();
     }
     if (MonitorRectanglesList != null && SmartWall != null && SmartWall.MonitorsList != null && SmartWall.MonitorsList.Count > 0)
     {
         foreach (var monitor in SmartWall.MonitorsList)
         {
             MonitorRectangle tmpMonitor = new MonitorRectangle(canvas_Main, SmartWall, monitor);
             MonitorRectanglesList.Add(tmpMonitor);
             tmpMonitor.EizoActionCalled += TmpMonitor_EizoActionCalled;
         }
     }
 }
예제 #5
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (Profile != null)
            {
                Profile.Monitors.UpdateVirtualScreen();

                double scale = Math.Min(finalSize.Width / Profile.Monitors.VirtualScreenWidth, finalSize.Height / Profile.Monitors.VirtualScreenHeight);

                for (int i = 0; i < _monitorRectangles.Count; i++)
                {
                    MonitorRectangle monitorRect = _monitorRectangles[i];
                    monitorRect.DisplayRectangle = new Rect(((monitorRect.Monitor.Left - Profile.Monitors.VirtualScreenLeft) * scale),
                                                            ((monitorRect.Monitor.Top - Profile.Monitors.VirtualScreenTop) * scale),
                                                            monitorRect.Monitor.Width * scale,
                                                            monitorRect.Monitor.Height * scale);
                    monitorRect.View.Arrange(monitorRect.DisplayRectangle);
                }
            }

            return(finalSize);
        }
예제 #6
0
        private void UpdateMonitors()
        {
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(this);

            foreach (MonitorRectangle monitorRect in _monitorRectangles)
            {
                if (layer != null)
                {
                    layer.Remove(monitorRect.Adorner);
                }
                _children.Remove(monitorRect.View);
            }

            _monitorRectangles.Clear();

            if (Profile != null)
            {
                _setAdorners = true;

                int i = 1;
                foreach (Monitor monitor in Profile.Monitors)
                {
                    HeliosVisualView monitorView = new HeliosVisualView();
                    monitorView.Visual     = monitor;
                    monitorView.Visibility = ShowPanels ? Visibility.Visible : Visibility.Hidden;
                    _children.Add(monitorView);

                    MonitorAdorner adorner = new MonitorAdorner(monitorView, i++.ToString(), monitor);

                    MonitorRectangle monitorRect = new MonitorRectangle();
                    monitorRect.Monitor = monitor;
                    monitorRect.View    = monitorView;
                    monitorRect.Adorner = adorner;
                    _monitorRectangles.Add(monitorRect);
                }
            }
            InvalidateMeasure();
            InvalidateArrange();
            InvalidateVisual();
        }
예제 #7
0
        private void LokForRectangleDistanceAligment(MonitorRectangle inDraggingRectangle, MonitorRectangle inClosestRectangle) //GIVE CLOSEST MONITOR RECTANGLE FUNCTION WAY
        {
            var distanceValue = 6;

            if (inDraggingRectangle != null && inClosestRectangle != null)
            {
                if (Math.Abs(inDraggingRectangle.Right - inClosestRectangle.Left) < distanceValue && inDraggingRectangle.Right <= inClosestRectangle.Left)
                {
                    inDraggingRectangle.SetRight(inClosestRectangle.Left - distanceValue);
                }
                else if (Math.Abs(inDraggingRectangle.Left - inClosestRectangle.Right) < distanceValue && inDraggingRectangle.Left >= inClosestRectangle.Right)
                {
                    inDraggingRectangle.SetLeft(inClosestRectangle.Right + distanceValue);
                }
                else if (Math.Abs(inDraggingRectangle.Bottom - inClosestRectangle.Top) < distanceValue && inDraggingRectangle.Bottom <= inClosestRectangle.Top)
                {
                    inDraggingRectangle.SetBottom(inClosestRectangle.Top - distanceValue);
                }
                else if (Math.Abs(inDraggingRectangle.Top - inClosestRectangle.Bottom) < distanceValue && inDraggingRectangle.Top >= inClosestRectangle.Bottom)
                {
                    inDraggingRectangle.SetTop(inClosestRectangle.Bottom + distanceValue);
                }
            }
        }