Пример #1
0
        private void PaperWrap_MouseWheel(object sender, MouseEventArgs e)
        {
            if (Control.ModifierKeys == Keys.Control)
            {
                if (PaperWrap.WheelDelta < 0)
                {
                    if (comboZoom.SelectedIndex + 1 < comboZoom.Items.Count)
                    {
                        comboZoom.SelectedIndex = comboZoom.SelectedIndex + 1;
                    }
                }
                else
                {
                    if (comboZoom.SelectedIndex - 1 >= 0)
                    {
                        comboZoom.SelectedIndex = comboZoom.SelectedIndex - 1;
                    }
                }
            }

            if (Control.ModifierKeys == Keys.Alt)
            {
                int newvalue = Funcs.Clamp((PaperWrap.HorizontalScroll.Value - PaperWrap.WheelDelta),
                                           PaperWrap.HorizontalScroll.Minimum, PaperWrap.HorizontalScroll.Maximum);

                // Don't ask me but if you don't set the value twice the H Scroll seems
                // To not register the value at first call (debugged for f'ing 5 hours)
                //
                PaperWrap.HorizontalScroll.Value = newvalue;
                PaperWrap.HorizontalScroll.Value = newvalue;
                //
            }

            PaperWrap.Update();
        }
Пример #2
0
        public void MoveTo(int x, int y)
        {
            Holder.Location = new Point(Funcs.Clamp(x, 0, Zoom.paperSize.Width - Holder.Width),
                                        Funcs.Clamp(y, 0, Zoom.paperSize.Height - Holder.Height));

            RecalculateRealPosition();
        }
Пример #3
0
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            if (UsedFilter == Filter.DigitsOnly)
            {
                int newValue = Funcs.ToInt(this.Text) + (Wheel_StepValue * Funcs.Force(Funcs.ToInt(e.Delta)));

                if (!IgnoreClampig)
                {
                    this.Text = Funcs.Clamp(newValue, MinimumValue, MaximumValue).ToString();
                }

                this.Select(this.Text.Length, 0);
            }

            base.OnMouseWheel(e);
        }
Пример #4
0
        private void OnValidatingColorInput(object sender, CancelEventArgs e)
        {
            TextBox tb         = sender as TextBox;
            int     colorValue = Funcs.ToInt(tb.Text);

            if (colorValue < 0 || colorValue > 255)
            {
                e.Cancel = true;
            }

            // To prevent any exception I'm using a special Clamp method :3
            Target.TextColor = Color.FromArgb(Funcs.Clamp(tb_color_r.Text, 0, 255),
                                              Funcs.Clamp(tb_color_g.Text, 0, 255),
                                              Funcs.Clamp(tb_color_b.Text, 0, 255));

            // Reload all inputs and display the color
            LoadColor();
        }
Пример #5
0
        public virtual void RenderObject()
        {
            Point p = Zoom.Calculate(RealLocation);

            if (IsCenter())
            {
                p.X -= (int)((float)Holder.Width * 0.5);
            }
            if (IsRight())
            {
                p.X -= (int)((float)Holder.Width);
            }

            if (IsMiddle())
            {
                p.Y -= (int)((float)Holder.Height * 0.5);
            }
            if (IsDown())
            {
                p.Y -= (int)((float)Holder.Height);
            }

            // Clamp Position to inside the document
            p.X = Funcs.Clamp(p.X, 0, Zoom.paperSize.Width - Holder.Width);
            p.Y = Funcs.Clamp(p.Y, 0, Zoom.paperSize.Height - Holder.Height);

            // Finally set theposition clamped and with zoom applied
            Holder.Location = p;
            RecalculateRealPosition();

            // Set the BackColor
            Holder.BackColor = BackColor;

#if DEBUG
            Console.WriteLine("Rendering : " + Name);
#endif
        }
Пример #6
0
        private void Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            //Point s = new Point(200, 200);
            Point s;

            if (isMouseDown)
            {
                //X = X - mouseLastLocation.X + e.X;
                //Y = Y - mouseLastLocation.Y + e.Y;

                /*
                 * // Calcualte the Canvas's new location
                 * Point newLocation = new Point(RealLocation.X - mouseLastLocation.X + e.X,
                 *                            RealLocation.Y - mouseLastLocation.Y + e.Y);
                 *
                 * Size halfCanvas = new Size((int)((float)Canvas.Width / 2.0f),
                 *                         (int)((float)Canvas.Height / 2.0f));
                 *
                 * Point canvasLocation = Point.Empty;
                 *
                 * if(IsLeft())
                 * {
                 *  newLocation.X = Funcs.Clamp(newLocation.X, 0, Zoom.paperSize.Width - Canvas.Width);
                 *  canvasLocation.X = newLocation.X;
                 * }
                 * else if(IsCenter())
                 * {
                 *  newLocation.X = Funcs.Clamp(newLocation.X, halfCanvas.Width, Zoom.paperSize.Width - halfCanvas.Width);
                 *  canvasLocation.X = newLocation.X - halfCanvas.Width;
                 * }
                 * else if(IsRight())
                 * {
                 *  newLocation.X = Funcs.Clamp(newLocation.X, Canvas.Width, Zoom.paperSize.Width);
                 *  canvasLocation.X = newLocation.X - Canvas.Width;
                 * }
                 *
                 * if (IsUp())
                 * {
                 *  newLocation.Y = Funcs.Clamp(newLocation.Y, 0, Zoom.paperSize.Height - Canvas.Height);
                 *  canvasLocation.Y = newLocation.Y;
                 * }
                 * else if (IsMiddle())
                 * {
                 *  newLocation.Y = Funcs.Clamp(newLocation.Y, halfCanvas.Height, Zoom.paperSize.Height - halfCanvas.Height);
                 *  canvasLocation.Y = newLocation.Y - halfCanvas.Height;
                 * }
                 * else if (IsDown())
                 * {
                 *  newLocation.Y = Funcs.Clamp(newLocation.Y, Canvas.Height, Zoom.paperSize.Height);
                 *  canvasLocation.Y = newLocation.Y - Canvas.Height;
                 * }
                 *
                 *
                 * RealLocation = newLocation;
                 *
                 * Canvas.Location = Zoom.Calculate(canvasLocation);
                 * Canvas.Update();
                 *
                 */


                // Calcualte the Canvas's new location
                Point p = new Point(Holder.Location.X - mouseLastLocation.X + e.X,
                                    Holder.Location.Y - mouseLastLocation.Y + e.Y);

                // Ignore snapping and alignment if control is pressed
                if (Control.ModifierKeys != Keys.Control && e.Button != MouseButtons.Right)
                {
                    // A Basic snapping Algorithm
                    foreach (DocumentObject obj in Objects.objectList)
                    {
                        if (obj == this || !obj.Visible)
                        {
                            continue;
                        }

                        s = obj.Holder.Location;

                        if (p.X >= s.X - 10 && p.X < s.X + 10)
                        {
                            p.X = s.X;
                        }

                        if (p.Y >= s.Y - 10 && p.Y < s.Y + 10)
                        {
                            p.Y = s.Y;
                        }
                    }
                }

                // Always clamp Position to inside the document
                p.X = Funcs.Clamp(p.X, 0, Zoom.paperSize.Width - Holder.Width);
                p.Y = Funcs.Clamp(p.Y, 0, Zoom.paperSize.Height - Holder.Height);

                Holder.Location = p;
                Holder.Update();

                RecalculateRealPosition();

                // Update position labels on the main form
                LivePreview.mainForm.UpdateObjectPosition();
            }
        }