示例#1
0
        private static void OnRectoSizeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            ColorControl colorControl = sender as ColorControl;

            colorControl.ReverseAutoSize = colorControl.ElementSize - Convert.ToInt32(e.NewValue);
        }
示例#2
0
 private void EmpiringColorControl(bool increases)
 {
     try
     {
         ColorControl col = this.colorControl;
         int          indexOfColorControl = this.Instrument_ToolBar.Items.IndexOf(col);
         double       currentHeight       = this.Instrument_ToolBar.PointToScreen(new Point(0, this.Instrument_ToolBar.ActualHeight)).Y;
         for (int i = 0; i < this.Instrument_ToolBar.Items.Count && currentHeight > this.Instrument_ToolBar.PointToScreen(new Point(0, 27)).Y; i++)
         {
             if (this.Instrument_ToolBar.Items[i].GetType() == typeof(RadioButton))
             {
                 RadioButton rBut          = this.Instrument_ToolBar.Items[i] as RadioButton;
                 double      thisButHeight = rBut.PointToScreen(new Point(0, 0)).Y;
                 if (thisButHeight + 2 * rBut.ActualHeight > currentHeight - 14 && thisButHeight + col.ActualHeight < currentHeight - 14)
                 {
                     if (col.Margin.Top != 0)
                     {
                         col.Margin = new Thickness(0);
                     }
                     if (increases)
                     {
                         RadioButton buff = new RadioButton();
                         buff.Height = buff.Width = 29;
                         this.Instrument_ToolBar.Items[i] = buff;
                         Instrument_ToolBar.Items[indexOfColorControl] = rBut;
                         Instrument_ToolBar.Items[i] = col;
                         if (i == this.Instrument_ToolBar.Items.Count - 1)
                         {
                             double screenHeight = this.drawingAreaCell.PointToScreen(new Point(0, this.drawingAreaCell.ActualHeight)).Y;
                             if (screenHeight - currentHeight < 50)
                             {
                                 col.Margin = new Thickness(0, (screenHeight - currentHeight) / 2 + 1, 0, 0);
                             }
                             else
                             {
                                 col.Margin = new Thickness(0, 25, 0, 0);
                             }
                         }
                     }
                     else
                     {
                         Instrument_ToolBar.Items.Remove(col);
                         Instrument_ToolBar.Items[i] = col;
                         Instrument_ToolBar.Items.Add(rBut);
                     }
                     break;
                 }
             }
             else if (this.Instrument_ToolBar.Items[i].GetType() == typeof(ColorControl))
             {
                 if (increases)
                 {
                     if (i == this.Instrument_ToolBar.Items.Count - 1)
                     {
                         double screenHeight = this.drawingAreaCell.PointToScreen(new Point(0, this.drawingAreaCell.ActualHeight)).Y;
                         if (screenHeight - currentHeight < 50)
                         {
                             col.Margin = new Thickness(0, (screenHeight - currentHeight) / 2 + 1, 0, 0);
                         }
                         else
                         {
                             col.Margin = new Thickness(0, 25, 0, 0);
                         }
                     }
                     if (col.PointToScreen(new Point(0, col.ActualHeight)).Y + 31 > currentHeight)
                     {
                         break;
                     }
                 }
                 else
                 {
                     if (i != 0)
                     {
                         double screenHeight = this.drawingAreaCell.PointToScreen(new Point(0, this.drawingAreaCell.ActualHeight)).Y;
                         if (currentHeight + col.Margin.Top >= screenHeight)
                         {
                             col.Margin = new Thickness(0, screenHeight - currentHeight, 0, 0);
                         }
                     }
                     break;
                 }
             }
         }
     }
     catch (Exception excp)
     {
         MessageBox.Show(excp.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
         this.InvalidateVisual();
     }
 }
示例#3
0
        private static void OnSizeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            ColorControl colorControl = sender as ColorControl;

            colorControl.ColorRectSize = Convert.ToInt32(e.NewValue) * 3 / 4;
        }