示例#1
0
        /// <summary>
        /// 切换工作模式 ink、rect、eraser等
        /// </summary>
        /// <param name="mode"></param>
        public void SwitchInkMode(InkMode mode)
        {
            string name = mode.ToString();

            this._inkMode = mode;

            // 系统的几个Mode
            if (AppConsts.InkCanvasEditingModeNames.Contains(name))
            {
                if (Enum.TryParse(name, true, out InkCanvasEditingMode editMode))
                {
                    this.EditingMode = editMode;
                }

                this.DynamicRenderer = _dynamicRenderers[(int)mode];
            }
            // 自定义的几个Mode 比如Rect、Circle
            else
            {
                this.EditingMode = InkCanvasEditingMode.Ink;

                if (mode == InkMode.Rectangle)
                {
                    this.DynamicRenderer = new RectangleDynamicRenderer();
                }
            }
        }
示例#2
0
    public InkSelector()
    {
        mode = InkMode.Ink;

        // Use an InkPresenter to display the strokes on the custom control.
        presenter    = new InkPresenter();
        this.Content = presenter;

        //<Snippet4>
        // In the constructor.
        // Selection drawing attributes use dark gray ink.
        selectDA       = new DrawingAttributes();
        selectDA.Color = Colors.DarkGray;

        // ink drawing attributes use default attributes
        inkDA        = new DrawingAttributes();
        inkDA.Width  = 5;
        inkDA.Height = 5;

        inkDA.AttributeChanged    += new PropertyDataChangedEventHandler(DrawingAttributesChanged);
        selectDA.AttributeChanged += new PropertyDataChangedEventHandler(DrawingAttributesChanged);
        //</Snippet4>

        // Add a DynmaicRenderer to the control so ink appears
        // to "flow" from the tablet pen.
        renderer = new DynamicRenderer();
        renderer.DrawingAttributes = inkDA;
        this.StylusPlugIns.Add(renderer);
        presenter.AttachVisuals(renderer.RootVisual,
                                renderer.DrawingAttributes);
    }
示例#3
0
        private void CustomInitialization()
        {
            InkMode mode = InkMode.Ink;

            _inkModeSets = AppUtil.GetEnumSets(mode);
        }
示例#4
0
 private void SwitchInkMode(InkMode mode)
 {
     AppUtil.SendMessage(mode, AppConsts.MSG_SwitchInkMode);
 }
示例#5
0
        public PenMenu(InkControl control)
        {
            InitializeComponent();
            this.control = control;
            this.Mode    = control.InkMode;

            this.Font = new Font(this.Font.FontFamily, this.Font.Size * Util.GetScaleFactor());
            int guiSize = Util.GetGUISize();

            this.Width         = guiSize * Configuration.PenSizeNum;
            panelBottom.Height = guiSize;
            BackColor          = Style.Default.MenuBackground;
            ForeColor          = Style.Default.MenuForeground;
            panel1.BackColor   = Style.Default.MenuForeground;

            foreach (Control cltr in Controls)
            {
                if (cltr is Button)
                {
                    cltr.Height = Util.GetGUISize();
                    cltr.Text   = Language.GetText(cltr.Text);
                }
            }

            if (bmpEraser == null)
            {
                bmpEraser = ResManager.LoadIcon("eraserAll.svg", Util.GetGUISize());
            }
            int btnSize = Util.GetGUISize();

            btnLine.Image     = Forms.LinearLine.BitmapLL;
            btnRect.Image     = Forms.Rect.BitmapRect;
            btnCircle.Image   = Forms.Arc.BitmapArc;
            btnArc2.Image     = Forms.Arc2.BitmapArc2;
            btnStroke.Image   = Line.BitmapStrk;
            btnRuler.Image    = Ruler.Icon;
            btnCompass.Image  = Compass.Icon;
            btnTextBox.Image  = Forms.TextBox.BitmapTB;
            btnAddImage.Image = Forms.ImageObject.IconPhoto;
            if (control.EraserColor == Color.Transparent)
            {
                btnEraser.Image = bmpEraser;
            }
            else
            {
                btnEraser.Image = Dialogues.BrushList.CreateIcon(control.EraserColor);
            }

            for (int i = 0; i < Configuration.PenSizeNum; i++)
            {
                float    size = Configuration.PenSizeMin + i * (Configuration.PenSizeMax - Configuration.PenSizeMin) / (float)(Configuration.PenSizeNum - 1);
                Button   btn  = new Button();
                Bitmap   bmp  = new Bitmap(guiSize, guiSize);
                Graphics g    = Graphics.FromImage(bmp);
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                g.FillEllipse(Brushes.Black, new RectangleF(guiSize / 2 - size, guiSize / 2 - size, size * 2, size * 2));
                g.Dispose();
                btn.BackgroundImage = bmp;
                btn.Bounds          = new Rectangle(i * guiSize, 0, guiSize, guiSize);
                panelBottom.Controls.Add(btn);
                btn.Tag       = size;
                btn.Click    += Btn_Click;
                btn.FlatStyle = FlatStyle.Flat;
                btn.FlatAppearance.BorderSize = 0;

                if (control.Thicknes == size)
                {
                    btn.BackColor = Style.Default.Selection;
                }
            }

            hasRuler   = false;
            hasCompass = false;
            foreach (var obj in control.ScreenObjects)
            {
                if (obj is Ruler)
                {
                    hasRuler = true;
                }
                if (obj is Compass)
                {
                    hasCompass = true;
                }
            }
            if (hasRuler)
            {
                btnRuler.BackColor = Style.Default.MenuContrast;
            }
            if (hasCompass)
            {
                btnCompass.BackColor = Style.Default.MenuContrast;
            }

            this.Dock = DockStyle.Right;
        }
 public void SwitchInkMode(InkMode mode)
 {
     CustomInkCanvas.SwitchInkMode(mode);
 }
示例#7
0
 private void button1_Click(object sender, EventArgs e)
 {
     Mode = InkMode.Text;
     OnClose?.Invoke();
 }
示例#8
0
 private void btnArc2_Click(object sender, EventArgs e)
 {
     Mode = InkMode.Arc2;
     OnClose?.Invoke();
 }
示例#9
0
 private void btnRect_Click(object sender, EventArgs e)
 {
     Mode = InkMode.Rect;
     OnClose?.Invoke();
 }
示例#10
0
 private void btnLine_Click(object sender, EventArgs e)
 {
     Mode = InkMode.Line;
     OnClose?.Invoke();
 }
示例#11
0
 private void btnStroke_Click(object sender, EventArgs e)
 {
     Mode = InkMode.Pen;
     OnClose?.Invoke();
 }