Esempio n. 1
0
 public void AddStroke( PenStroke stroke )
 {
     RedoHistory.Clear();
     DoAddStroke(stroke);
 }
Esempio n. 2
0
        protected override void OnPaint( PaintEventArgs e )
        {
            var fx = e.Graphics;

            var stroke = SMM.NextStroke;
            while ( stroke != null && stroke.Completed ) {
                SMM.RemoveStroke();

                switch ( stroke.MouseButtons ) {
                case MouseButtons.Left:
                    var ps = new PenStroke() { Points = stroke.Points.Select(p=>ToCanvasCoordinate(p)).ToList() };
                    Book.OpenPage.AddStroke(ps);
                    save = true;
                    ps.DrawTo(fx);
                    break;
                }
                stroke = SMM.NextStroke;
            }

            Book.OpenPage.DrawTo( fx, ClientSize.Width, ClientSize.Height );
            if (save) {
                //var a = DateTime.Now;
                Book.BackgroundSaveToDisk();
                //var b = DateTime.Now;
                //Profiling_LastSaveTook = b-a;
            }
            fx.TranslateTransform( ClientSize.Width/2f, ClientSize.Height/2f );
            if ( stroke != null && stroke.MouseButtons == MouseButtons.Left ) {
                Debug.Assert(!stroke.Completed);
                new PenStroke() { Points = stroke.Points.Select(p=>ToCanvasCoordinate(p)).ToList() }.DrawTo(fx);
            }

            int y = 10;
            Action<string> writeln = s => {
                TextRenderer.DrawText( fx, s, Font, new Point(10,y), ForeColor, BackColor );
                y += TextRenderer.MeasureText( s, Font ).Height;
            };
            writeln(string.Format("SMM     Mouse: {0}    Stylus: {1}", SMM.Debug_MouseStrokes, SMM.Debug_StylusStrokes));
            writeln(string.Format("Book    Pages: {0}    Size: {1}", Book.Pages.Count, Pretty.Bytes(Book.SizeInBytes) ));
            if ( Book.OpenPage!=null ) writeln(string.Format("Page    Strokes: {0}", Book.OpenPage._DebugStats_StrokesCount ));
            writeln(string.Format("Timing  Save: {0}s",Profiling_LastSaveTook.TotalSeconds.ToString("F2")));
            fx.ResetTransform();

            if ( !SMM.Enabled )
            using ( var font = new Font("Arial Black",24f) )
            {
                TextRenderer.DrawText( fx, "Enabling stylus, please wait...", font, ClientRectangle, Color.Black, BackColor, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter );
            }
            base.OnPaint(e);
        }
Esempio n. 3
0
 void DoAddStroke( PenStroke stroke )
 {
     Strokes.Add( stroke );
     if ( Cache != null ) using ( var fx = Graphics.FromImage(Cache) ) {
         fx.TranslateTransform( Cache.Width/2f, Cache.Height/2f );
         stroke.DrawTo(fx);
     }
 }