Ejemplo n.º 1
0
        public PeriodChoiceControl()
        {
            Model = new PeriodChoiceControlModel();
            InitializeComponent();

            ControlGrid.DataContext = this;
        }
 public static void ResetFlags(this PeriodChoiceControlModel model)
 {
     model.BtnFromIsHolded        = false;
     model.BtnToIsHolded          = false;
     model.CentralPartIsHolded    = false;
     model.CentralPartDoubleClick = false;
 }
 public static void SetPositions(this PeriodChoiceControlModel model, double btnFromMarginLeft, double centerPartWidth)
 {
     model.BtnFromMargin    = new Thickness(btnFromMarginLeft, 0, 0, 0);
     model.LeftPartWidth    = btnFromMarginLeft + 4;
     model.CenterPartMargin = new Thickness(model.LeftPartWidth, 0, 0, 0);
     model.CenterPartWidth  = centerPartWidth;
     model.BtnToMargin      = new Thickness(btnFromMarginLeft + centerPartWidth - 1, 0, -4, 0);
     model.RightPartMargin  = new Thickness(model.LeftPartWidth + model.CenterPartWidth - 1, 0, 0, 0);
 }
Ejemplo n.º 4
0
 public static void ReactCentralPartDoubleClick(this PeriodChoiceControlModel model, double x, double controlActualWidth)
 {
     if (model.CentralPartDoubleClick)
     {
         model.ShrinkAroundX(x, controlActualWidth);
     }
     else
     {
         model.SetPositions(-4, controlActualWidth); // expand central part all over control
     }
     model.CentralPartDoubleClick = !model.CentralPartDoubleClick;
 }
Ejemplo n.º 5
0
        private static void ShrinkAroundX(this PeriodChoiceControlModel model, double x, double controlActualWidth)
        {
            double left = x - PeriodChoiceControlModel.MinCenterPartWidth / 2;

            if (left < -4)
            {
                left = -4;
            }
            if (left > controlActualWidth - PeriodChoiceControlModel.MinCenterPartWidth - 4)
            {
                left = controlActualWidth - PeriodChoiceControlModel.MinCenterPartWidth - 4;
            }
            model.SetPositions(left, PeriodChoiceControlModel.MinCenterPartWidth);
        }
Ejemplo n.º 6
0
        public static void ReactBtnToPreviewMouseMove(this PeriodChoiceControlModel model, double x, double rightPartWidth)
        {
            var delta = x - model.BtnToStartX;

            model.BtnToStartX = x;
            if (model.CenterPartWidth - PeriodChoiceControlModel.MinCenterPartWidth + delta < 0)
            {
                return;
            }
            if (rightPartWidth - delta <= 0)
            {
                return;
            }

            model.BtnToMargin      = new Thickness(model.BtnToMargin.Left + delta, 0, -4, 0);
            model.CenterPartWidth += delta;
        }
        public static void ReactBtnFromPreviewMouseMove(this PeriodChoiceControlModel model, double x)
        {
            var delta = x - model.BtnFromStartX;

            model.BtnFromStartX = x;
            if (delta > model.CenterPartWidth - PeriodChoiceControlModel.MinCenterPartWidth)
            {
                return;
            }
            if (model.BtnFromMargin.Left + delta < -4)
            {
                delta = -model.BtnFromMargin.Left - 4;
            }

            model.BtnFromMargin    = new Thickness(model.BtnFromMargin.Left + delta, 0, 0, 0);
            model.LeftPartWidth    = model.BtnFromMargin.Left + 4;
            model.CenterPartMargin = new Thickness(model.LeftPartWidth, 0, 0, 0);
            model.CenterPartWidth -= delta;
        }
Ejemplo n.º 8
0
        public static void ReactCentralPartPreviewMouseMove(this PeriodChoiceControlModel model, double x, double rightPartWidth)
        {
            var delta = x - model.CentralPartStartX;

            model.CentralPartStartX = x;

            if (model.BtnFromMargin.Left + delta < -4)
            {
                delta = -model.BtnFromMargin.Left - 4;
            }
            if (rightPartWidth - delta <= 0)
            {
                return;
            }

            model.BtnFromMargin    = new Thickness(model.BtnFromMargin.Left + delta, 0, 0, 0);
            model.LeftPartWidth    = model.BtnFromMargin.Left + 4;
            model.CenterPartMargin = new Thickness(model.LeftPartWidth, 0, 0, 0);
            model.BtnToMargin      = new Thickness(model.BtnToMargin.Left + delta, 0, -4, 0);
        }
 public static void ReactBtnFromPreviewMouseDown(this PeriodChoiceControlModel model, double x)
 {
     model.BtnFromIsHolded = true;
     model.BtnFromStartX   = x;
 }
Ejemplo n.º 10
0
 public static void ReactCentralPartPreviewMouseDown(this PeriodChoiceControlModel model, double x)
 {
     model.CentralPartIsHolded = true;
     model.CentralPartStartX   = x;
 }