Example #1
0
 private bool CanShrinkWidth(DesignerItem item, double amount)
 {
     if (item.Width - Math.Abs(amount) <= item.MinWidth)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #2
0
 private bool CanShrinkHeight(DesignerItem item, double amount)
 {
     if (item.Height - Math.Abs(amount) <= item.MinHeight)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #3
0
 private bool CanGrowDown(DesignerItem item, double amount)
 {
     if ((item.Height + Math.Abs(amount) >= item.MaxHeight) ||
         (item.Y + item.Height + Math.Abs(amount) > item.ParentDesigner.Height))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #4
0
 private bool CanGrowUp(DesignerItem item, double amount)
 {
     if ((item.Height + Math.Abs(amount) >= item.MaxHeight) ||
         (item.Y - Math.Abs(amount) < 0))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #5
0
 private bool CanGrowRight(DesignerItem item, double amount)
 {
     if ((item.Width + Math.Abs(amount) >= item.MaxWidth) ||
         (item.X + item.Width + Math.Abs(amount) > item.ParentDesigner.Width))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #6
0
 private bool CanGrowLeft(DesignerItem item, double amount)
 {
     if ((item.Width + Math.Abs(amount) >= item.MaxWidth) ||
         (item.X - Math.Abs(amount) < 0))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #7
0
        private void AdjustDown(DesignerItem item, double amount)
        {
            double delta = Math.Abs(amount);

            if (amount < 0 && CanShrinkHeight(item, delta))
            {
                item.Height -= delta;
            }
            if (amount > 0 && CanGrowDown(item, delta))
            {
                item.Height += delta;
            }
        }
Example #8
0
        private void AdjustRight(DesignerItem item, double amount)
        {
            double delta = Math.Abs(amount);

            if (amount < 0 && CanShrinkWidth(item, delta))
            {
                item.Width -= delta;
            }
            if (amount > 0 && CanGrowRight(item, delta))
            {
                item.Width += delta;
            }
        }
Example #9
0
        void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            // Set up the data sources we'll need to work with
            DesignerItem sourceItem = this.DataContext as DesignerItem;

            //DesignerVM vm = sourceItem.ParentForm;

            // Make sure something exists and is selected
            if (sourceItem != null && sourceItem.IsSelected)
            {
                // Set up the selected items
                //var selectedItems = vm.ActiveTab.SelectedItems;

                double minLeft = double.MaxValue;
                double minTop  = double.MaxValue;

                /*
                 * // if more than one item is selected, treat them as a group -
                 * // when one stops moving, they all do
                 * double TopmostItemTop = vm.Height;
                 * double LeftmostItemLeft = 0;
                 * double RightmostItemLeft = 0;
                 * double BottomMostItemTop = 0;
                 *
                 * if (vm.SelectedItems.Count > 1)
                 * {
                 *  foreach (DesignerItemBaseVM item in selectedItems.OfType<DesignerItemBaseVM>())
                 *  {
                 *
                 *      if (item.Top < TopmostItemTop) TopmostItemTop = item.Top;
                 *      if (item.Left < LeftmostItemLeft) LeftmostItemLeft = item.Left;
                 *      if (item.Top > BottomMostItemTop) BottomMostItemTop = item.Top;
                 *      if (item.Left < RightmostItemLeft) RightmostItemLeft = item.Left;
                 *
                 *  }
                 *  System.Console.WriteLine("Extreme edges: Top({0}), Left({1}), Right({2}), Bottom({3})", TopmostItemTop, LeftmostItemLeft, RightmostItemLeft, BottomMostItemTop);
                 * } */

                /*
                 * foreach (DesignerItem item in selectedItems.OfType<DesignerItem>())
                 * {
                 *  double maxItemLeft = vm.Width - item.Width;
                 *  double maxItemTop = vm.Height - item.Height;
                 *
                 *  minLeft = double.IsNaN(item.Left) ? 0 : Math.Min(item.Left, minLeft);
                 *  minTop = double.IsNaN(item.Top) ? 0 : Math.Min(item.Top, minTop);
                 *
                 *
                 *  double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
                 *  double deltaVertical = Math.Max(-minTop, e.VerticalChange);
                 *
                 *  double desiredLeft = item.Left + deltaHorizontal;
                 *  double desiredTop = item.Top + deltaVertical;
                 *
                 *
                 *  if (desiredLeft > maxItemLeft) item.Left = maxItemLeft;
                 *  else item.Left += deltaHorizontal;
                 *
                 *  if (desiredTop > maxItemTop) item.Top = maxItemTop;
                 *  else item.Top += deltaVertical;
                 * } */
                e.Handled = true;
            }
        }