예제 #1
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.LineColor = Color.FromArgb(tb_color_r.IntValue(), tb_color_g.IntValue(), tb_color_b.IntValue());

            // Reload all inputs and display the color
            LoadColor();
        }
예제 #2
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);
        }
예제 #3
0
        private void Btn_remove_lang_Click(object sender, EventArgs e)
        {
            if (languagesTable.SelectedCells.Count > 0)
            {
                int langID = Funcs.ToInt(languagesTable[grid_id.Index, languagesTable.SelectedCells[0].RowIndex].Value);

                if (langID == 0)
                {
                    Funcs.Information("You can't delete the default entry, it is the default text value used when no languages are avaible.");
                    return;
                }

                if (Funcs.Question("Are you sure you want to delete this language code ?\nNote that all label objects will lose this language code text value !  ") == DialogResult.Yes)
                {
                    Objects.RemoveLanguage(Languages.UsedLanguages[langID]);
                    Languages.UsedLanguages.Remove(Languages.UsedLanguages[langID]);
                    LoadLanguages();
                }
            }
        }
예제 #4
0
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            if (AllowWheel && UsedFilter == Filter.Digits)
            {
                float newValue = ParseFloatValue(lastGoodText) + (WheelStepValue * Funcs.Force(Funcs.ToInt(e.Delta)));

                if (!IgnoreClamping)
                {
                    this.Text = (newValue < Minimum ? Minimum : (newValue > Maximum ? Maximum : newValue)).ToString();
                }

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

            base.OnMouseWheel(e);
        }
예제 #5
0
        public override void RenderObject()
        {
            Point anchor = new Point(0, 0);

            Font font = Fonts.GetFont(FontID, Zoom.GetFontSize(FontSize), (FontStyle)FontStyle);

            Graphics g = Graphics.FromHwnd(IntPtr.Zero);

            g.ApplyGraphicsQuality();

            // Measure label size
            SizeF s = g.MeasureString(ContentTable[Languages.UsedLanguages[0]], font);

            s = new SizeF((float)Math.Ceiling(s.Width), (float)Math.Ceiling(s.Height));

            g.Dispose();

            // Is Object Vertical
            if (IsVertical)
            {
                s.Flip();
            }

            Bitmap b = new Bitmap((int)s.Width, (int)s.Height);

            g = Graphics.FromImage(b);
            g.ApplyGraphicsQuality();

            Point trans = Point.Empty;
            int   angle = 0;

            if (IsVertical)
            {
                if (!IsTurned180)
                {
                    trans.X = (int)s.Width;
                }
                angle += 90;
            }

            if (IsTurned180)
            {
                if (!IsVertical)
                {
                    trans = new Point((int)s.Width, (int)s.Height);
                }
                else
                {
                    trans.Y = Funcs.ToInt(s.Height);
                }

                angle += 180;
            }

            // Apply transformation when label is rotated
            g.TranslateTransform(trans.X, trans.Y);
            g.RotateTransform(angle);

            // Draw the string
            g.DrawString(ContentTable[Languages.UsedLanguages[0]],
                         font,
                         new SolidBrush(TextColor),
                         Point.Empty);

            // Remove the transformation for next drawing methods
            g.ResetTransform();

            // Draw the anchor point for this label
            if (Config.ShowAnchorPoints)
            {
                if (IsCenter())
                {
                    anchor.X = (int)(s.Width * 0.5F);
                }
                if (IsRight())
                {
                    anchor.X = (int)s.Width - 1;
                }

                if (IsMiddle())
                {
                    anchor.Y = (int)(s.Height * 0.5F);
                }
                if (IsDown())
                {
                    anchor.Y = (int)s.Height - 1;
                }

                g.DrawLine(Config.AnchorPen, anchor.X - Config.ANCHOR_SIZE, anchor.Y, anchor.X + Config.ANCHOR_SIZE, anchor.Y);
                g.DrawLine(Config.AnchorPen, anchor.X, anchor.Y - Config.ANCHOR_SIZE, anchor.X, anchor.Y + Config.ANCHOR_SIZE);
            }

            // Release previous rendered bitmap (A lil bit of memore'h :3)
            if (Holder.Image != null)
            {
                Holder.Image.Dispose();
            }

            // Set Canvas Image
            Holder.Image = b;
            Holder.Size  = Holder.Image.Size;

            base.RenderObject();
        }