Example #1
0
        public void BrushTest1()
        {
            InkCanvas    MyCanvas = new InkCanvas();
            GlyphChanged glyph    = new GlyphChanged(MyCanvas);

            //Изначальная кисть должна быть Ink и Ellipse
            Assert.AreEqual(MyCanvas.EditingMode, InkCanvasEditingMode.Ink);
            Assert.AreEqual(MyCanvas.DefaultDrawingAttributes.StylusTip, StylusTip.Ellipse);

            // При выборе различных кисте (от 0й до 4й) меняются значения СтилусТип и СтилусТипТрансформейшн
            glyph.BrushesSelect(0);
            Assert.AreEqual(MyCanvas.EditingMode, InkCanvasEditingMode.Ink);
            Assert.AreEqual(MyCanvas.DefaultDrawingAttributes.StylusTip, StylusTip.Ellipse);
            Assert.AreEqual(MyCanvas.DefaultDrawingAttributes.StylusTipTransform, new Matrix(1, 0, 0, 1, 0, 0));

            glyph.BrushesSelect(1);
            Assert.AreEqual(MyCanvas.EditingMode, InkCanvasEditingMode.Ink);
            Assert.AreEqual(MyCanvas.DefaultDrawingAttributes.StylusTip, StylusTip.Rectangle);
            Assert.AreEqual(MyCanvas.DefaultDrawingAttributes.StylusTipTransform, new Matrix(1, 0, 0, 1, 0, 0));

            glyph.BrushesSelect(2);
            Assert.AreEqual(MyCanvas.EditingMode, InkCanvasEditingMode.Ink);
            Assert.AreEqual(MyCanvas.DefaultDrawingAttributes.StylusTip, StylusTip.Rectangle);
            Assert.AreEqual(MyCanvas.DefaultDrawingAttributes.StylusTipTransform, new Matrix(1, 2, 3, 3, 0, 0));

            glyph.BrushesSelect(3);
            Assert.AreEqual(MyCanvas.EditingMode, InkCanvasEditingMode.Select);

            glyph.BrushesSelect(4);
            Assert.AreEqual(MyCanvas.EditingMode, InkCanvasEditingMode.None);
        }
Example #2
0
        public void StrokeTest()
        {
            InkCanvas    MyCanvas = new InkCanvas();
            GlyphChanged glyph    = new GlyphChanged(MyCanvas);

            Assert.AreEqual(MyCanvas.GetSelectedStrokes().Count, 0);
        }
Example #3
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        private void OnGlyphChanged(EventArgs e)
        {
            if (GlyphChanged != null)
            {
                GlyphChanged.Invoke(this, e);
            }
        }
Example #4
0
        public Controller(InkCanvas canvas)
        {
            this.canvas = canvas;

            workImg = new SaveAndOpen(canvas);
            glyph   = new GlyphChanged(canvas);
            draw    = new Draw_Color(canvas);
        }
Example #5
0
        public void SlideTest1()
        {
            InkCanvas    MyCanvas = new InkCanvas();
            GlyphChanged glyph    = new GlyphChanged(MyCanvas);

            var drawingAttributes = MyCanvas.DefaultDrawingAttributes;

            drawingAttributes.Width  = 3; //ширина кисти
            drawingAttributes.Height = 4; //высота кисти

            Assert.That(drawingAttributes.Width, Is.EqualTo(3));
            Assert.That(drawingAttributes.Height, Is.EqualTo(4));
            for (int i = 1; i < 100; ++i)
            {
                glyph.GlyphSize(i);
                Assert.That(drawingAttributes.Width, Is.EqualTo(i));
                Assert.That(drawingAttributes.Height, Is.EqualTo(i));
            }
        }
Example #6
0
        public GlyphNameListUserControl()
        {
            InitializeComponent();
            this.listBox1.SelectedIndexChanged += (s, e) =>
            {
                if (listBox1.SelectedItem != null)
                {
                    SelectedGlyphIndex    = (ushort)this.listBox1.SelectedIndex;
                    this.textBox1.Text    =
                        SelectedGlyphName = ((GlyphNameMapInfo)listBox1.SelectedItem)._glyphNameMap.glyphName;
                }

                if (chkRenderGlyph.Checked)
                {
                    //render ...
                    GlyphChanged?.Invoke(null, EventArgs.Empty);
                }
            };

            this.txtHexUnicode.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    //find user name first
                    string unicode_hexForm = this.txtHexUnicode.Text;
                    int    unicode         = Convert.ToInt32(unicode_hexForm, 16);
                    ushort glyphIndex      = _selectedTypeface.GetGlyphIndex(unicode);

                    if (glyphIndex > 0)
                    {
                        Glyph foundGlyph = _selectedTypeface.GetGlyph(glyphIndex);

                        //display
                        this.listBox1.SelectedIndex = glyphIndex;
                    }
                }
                ;
            };

            lstUnicodes.SelectedIndexChanged += (s, e) =>
            {
                this.txtHexUnicode.Text = (string)lstUnicodes.SelectedItem;
            };


            this.textBox1.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    //find user name first
                    string userSupplyGlyphName = this.textBox1.Text;
                    if (userSupplyGlyphName == "")
                    {
                        //show all
                        ShowGlyphNameList(_allGlyphNameMapList);
                    }
                    else
                    {
                        //show
                        Glyph found = _selectedTypeface.GetGlyphByName(userSupplyGlyphName);
                        if (found != null && found.GlyphIndex != 0)
                        {
                            ShowGlyphNameList(_allGlyphNameMapList);

                            int  index  = 0;
                            bool found1 = false;
                            foreach (GlyphNameMapInfo mapInfo in _allGlyphNameMapList)
                            {
                                if (mapInfo._glyphNameMap.glyphName == userSupplyGlyphName)
                                {
                                    found1 = true;
                                    break;
                                }
                                else
                                {
                                    index++;
                                }
                            }

                            if (found1)
                            {
                                listBox1.SelectedIndex = index;
                            }
                        }
                        else
                        {
                            //not found => find glyph that contains the 'name'
                            int    index          = 0;
                            string user_upperCase = userSupplyGlyphName.ToUpper();

                            List <GlyphNameMapInfo> similarList = new List <GlyphNameMapInfo>();
                            foreach (GlyphNameMapInfo mapInfo in _allGlyphNameMapList)
                            {
                                if (mapInfo._glyphNameMap.glyphName.ToUpper().Contains(user_upperCase))
                                {
                                    similarList.Add(mapInfo);
                                }
                                index++;
                            }
                            ShowGlyphNameList(similarList);
                        }
                    }
                }
            };
        }