示例#1
0
 /// <summary>
 /// Update the height to the newheight and the top location to newtop.
 /// </summary>
 /// <param name="newwidth"></param>
 /// <param name="newleft"></param>
 private void UpdateHeight(double newheight, double newtop)
 {
     // if within the min height and a location greater than or equal to zero then update the height and the top location
     if ((newheight >= mMinHeight) &&
         (newtop >= 0))
     {
         if (mWindow != null)
         {
             mWindow.Height = newheight;
             mWindow.Top    = newtop;
         }
         else
         {
             Canvas.SetTop(AdornedElement, newtop);
             AdornedElement.SetValue(AnalysisChild.HeightProperty, newheight);
         }
     }
     else // otherwise set the height the the min or max bound accordingly
     {
         if (mWindow != null)
         {
             double height = mWindow.Height;
             double top    = mWindow.Top;
             if (!(newtop >= 0))
             {
                 mWindow.Top    = 0;
                 mWindow.Height = top + height;
             }
             else
             {
                 mWindow.Top   += mWindow.Height - mMinHeight;
                 mWindow.Height = mMinHeight;
             }
         }
         else
         {
             double height = (double)AdornedElement.GetValue(HeightProperty);
             double top    = Canvas.GetTop(AdornedElement);
             if (!(newtop >= 0))
             {
                 Canvas.SetTop(AdornedElement, 0);
                 AdornedElement.SetValue(AnalysisChild.HeightProperty, top + height);
             }
             else
             {
                 Canvas.SetTop(AdornedElement, top + (height - mMinHeight));
                 AdornedElement.SetValue(AnalysisChild.HeightProperty, mMinHeight);
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// Update the width to the newwidth and the left location to newleft.
 /// </summary>
 /// <param name="newwidth"></param>
 /// <param name="newleft"></param>
 private void UpdateWidth(double newwidth, double newleft)
 {
     // if within the min width and a location greater than or equal to zero then update the width and the left location
     if ((newwidth >= mMinWidth) &&
         (newleft >= 0))
     {
         if (mWindow != null)
         {
             mWindow.SetValue(Window.WidthProperty, newwidth);
             mWindow.SetValue(Window.LeftProperty, newleft);
         }
         else
         {
             Canvas.SetLeft(AdornedElement, newleft);
             AdornedElement.SetValue(AnalysisChild.WidthProperty, newwidth);
         }
     }
     else // otherwise set the width the the min or max bound accordingly
     {
         if (mWindow != null)
         {
             double width = mWindow.Width;
             double left  = mWindow.Left;
             if (!(newleft >= 0))
             {
                 mWindow.Left  = 0;
                 mWindow.Width = left + width;
             }
             else
             {
                 mWindow.Left += (mWindow.Width - mMinWidth);
                 mWindow.Width = mMinWidth;
             }
         }
         else
         {
             double width = (double)AdornedElement.GetValue(WidthProperty);
             double left  = Canvas.GetLeft(AdornedElement);
             if (!(newleft >= 0))
             {
                 Canvas.SetLeft(AdornedElement, 0);
                 AdornedElement.SetValue(AnalysisChild.WidthProperty, left + width);
             }
             else
             {
                 Canvas.SetLeft(AdornedElement, left + (width - mMinWidth));
                 AdornedElement.SetValue(AnalysisChild.WidthProperty, mMinWidth);
             }
         }
     }
 }
示例#3
0
        public override void SetAdornedElement(DependencyObject adorner, FrameworkElement?adornedElement)
        {
            if (adorner is SettingsControl settingsControl)
            {
                if (adornedElement == null)
                {
                    disposable?.Dispose();
                    return;
                }
                else
                {
                    adornedElement.SetValue(Type.ShowDataContextProperty, true);
                    disposable = settingsControl
                                 .WhenAnyValue(a => a.SelectedDock)
                                 .Subscribe(dock =>
                    {
                        adornedElement.SetValue(Text.PositionProperty, dock);
                    });

                    settingsControl.Checked += SettingsControl_Checked;
                }
            }

            void SettingsControl_Checked(object sender, CheckedEventArgs e)
            {
                switch (e.CheckedType)
                {
                case CheckedType.DataContext:
                    AdornedElement.SetValue(Type.ShowDataContextProperty, e.IsChecked);
                    break;

                case CheckedType.Dimensions:
                    AdornedElement.SetValue(Type.ShowDimensionsProperty, e.IsChecked);
                    break;

                case CheckedType.HighlightArea:
                    controlColourer ??= new(adornedElement);
                    //AdornedElement.SetValue(Type.HighlightColourProperty, e.IsChecked);
                    if (e.IsChecked)
                    {
                        controlColourer.Apply();
                    }
                    else
                    {
                        controlColourer.Remove();
                    }
                    break;
                }
            }
        }
示例#4
0
        /// <summary>
        /// Update the height with the newheight based on the current mouse point.
        /// </summary>
        /// <param name="newheight"></param>
        /// <param name="p"></param>
        private void UpdateHeight(double newheight, Point p)
        {
            if (AdornedElement.GetType().Equals(typeof(AnalysisChild)))
            {
                mMaxHeight = ((AnalysisChild)AdornedElement).MwiParent.ActualHeight - 3 - Canvas.GetTop(AdornedElement);
            }

            // if within the min and max height then update the height to the new height
            if ((newheight >= mMinHeight && p.Y >= mMinHeight) &&
                (newheight <= mMaxHeight && p.Y <= mMaxHeight))
            {
                if (mWindow != null)
                {
                    mWindow.Height = newheight;
                }
                else
                {
                    AdornedElement.SetValue(AnalysisChild.HeightProperty, newheight);
                }
            }
            else // otherwise set the height to the min or max bound accordingly
            {
                if (mWindow != null)
                {
                    if (!(newheight <= mMaxHeight && p.Y <= mMaxHeight))
                    {
                        mWindow.Height = mMaxHeight;
                    }
                    else
                    {
                        mWindow.Height = mMinHeight;
                    }
                }
                else
                {
                    if (!(newheight <= mMaxHeight && p.Y <= mMaxHeight))
                    {
                        AdornedElement.SetValue(AnalysisChild.HeightProperty, mMaxHeight);
                    }
                    else
                    {
                        AdornedElement.SetValue(AnalysisChild.HeightProperty, mMinHeight);
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        /// Updates the width to the newwidth provided based on the current mouse point.
        /// </summary>
        /// <param name="newwidth"></param>
        /// <param name="p"></param>
        private void UpdateWidth(double newwidth, Point p)
        {
            if (AdornedElement.GetType().Equals(typeof(AnalysisChild)))
            {
                mMaxWidth = ((AnalysisChild)AdornedElement).MwiParent.ActualWidth - 3 - Canvas.GetLeft(AdornedElement);
            }

            // if within the min and max width then update the width to the new width
            if ((newwidth >= mMinWidth && p.X >= mMinWidth) &&
                (newwidth <= mMaxWidth && p.X <= mMaxWidth))
            {
                if (mWindow != null)
                {
                    mWindow.Width = newwidth;
                }
                else
                {
                    AdornedElement.SetValue(AnalysisChild.WidthProperty, newwidth);
                }
            }
            else // otherwise set the width to the min or max bound accordingly
            {
                if (mWindow != null)
                {
                    if (!(newwidth <= mMaxWidth && p.X <= mMaxWidth))
                    {
                        mWindow.Width = mMaxWidth;
                    }
                    else
                    {
                        mWindow.Width = mMinWidth;
                    }
                }
                else
                {
                    if (!(newwidth <= mMaxWidth && p.X <= mMaxWidth))
                    {
                        AdornedElement.SetValue(AnalysisChild.WidthProperty, mMaxWidth);
                    }
                    else
                    {
                        AdornedElement.SetValue(AnalysisChild.WidthProperty, mMinWidth);
                    }
                }
            }
        }