Esempio n. 1
0
        void RepaintSnappoint(ISnapPoint snappoint)
        {
            if (snappoint == null)
            {
                return;
            }
            CanvasWrapper dc = new CanvasWrapper(this, Graphics.FromHwnd(Handle), ClientRectangle);

            snappoint.Draw(dc);
            dc.Graphics.Dispose();
            dc.Dispose();
        }
Esempio n. 2
0
        /*
         * public void DoInvalidate(bool dostatic, RectangleF rect)
         * {
         *  if (dostatic)
         *      m_staticDirty = true;
         *  Invalidate(ScreenUtils.ConvertRect(rect));
         * }*/

        void RepaintObject(IDrawObject obj)
        {
            if (obj == null)
            {
                return;
            }
            CanvasWrapper dc             = new CanvasWrapper(this, Graphics.FromHwnd(Handle), ClientRectangle);
            RectangleF    invalidaterect = ScreenUtils.ConvertRect(ScreenUtils.ToScreenNormalized(dc, obj.GetBoundingRect(dc)));

            obj.Draw(dc, invalidaterect);
            dc.Graphics.Dispose();
            dc.Dispose();
        }
Esempio n. 3
0
        //djl
        public void Draw(CanvasWrapper canvas, RectangleF unitrect, int start, int end, int line, int strong)
        {
            if (Enabled == false)
            {
                return;
            }

            float gridX = m_spacing.Width;
            float gridY = m_spacing.Height;
            //Console.WriteLine("gridX=" + gridX + " ; Y=" + gridY);
            float gridscreensizeX = canvas.ToScreen(gridX);
            float gridscreensizeY = canvas.ToScreen(gridY);

            //Console.WriteLine("gridscreensizeX=" + gridscreensizeX + " ; Y=" + gridscreensizeY);
            if (gridscreensizeX < m_minSize || gridscreensizeY < m_minSize)
            {
                return;
            }

            PointF leftpoint  = unitrect.Location;
            PointF rightpoint = ScreenUtils.RightPoint(canvas, unitrect);

            float left   = (float)Math.Round(leftpoint.X / gridX) * gridX;
            float top    = unitrect.Height + unitrect.Y;
            float right  = rightpoint.X;
            float bottom = (float)Math.Round(leftpoint.Y / gridY) * gridY;

            GraphicsPath path = new GraphicsPath();
            PointF       p1;
            PointF       p2;

            if (true)
            {
                Console.WriteLine("left=" + left + " ; top=" + top + " ; right=" + right + " ; bottom=" + bottom
                                  + "; start=" + start + ";end=" + end + ";line=" + line);
                p1 = canvas.ToScreen(new UnitPoint(leftpoint.X + start, top - line * gridY));
                p2 = canvas.ToScreen(new UnitPoint(leftpoint.X + end, top - line * gridY));
            }
            try
            {
                Line l = new Line(p1, p2, strong);
                CanvasCtrl.M_canvas.List.Add(l);
                canvas.Graphics.DrawLine(new Pen(l.Color, 2), p1, p2);
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
        }
Esempio n. 4
0
        public void Draw(CanvasWrapper canvas, RectangleF unitrect, int start, int end, int time, int strong)
        {
            if (Enabled == false)
            {
                return;
            }

            float gridX = Spacing.Width;
            float gridY = Spacing.Height;
            //Console.WriteLine("gridX=" + gridX + " ; Y=" + gridY);
            float gridscreensizeX = canvas.ToScreen(gridX);
            float gridscreensizeY = canvas.ToScreen(gridY);

            //Console.WriteLine("gridscreensizeX=" + gridscreensizeX + " ; Y=" + gridscreensizeY);
            if (gridscreensizeX < MinSize || gridscreensizeY < MinSize)
            {
                return;
            }

            PointF leftpoint  = unitrect.Location;
            PointF rightpoint = ScreenUtils.RightPoint(canvas, unitrect);

            float left   = (float)Math.Round(leftpoint.X / gridX) * gridX;
            float top    = unitrect.Height + unitrect.Y;
            float right  = rightpoint.X;
            float bottom = (float)Math.Round(leftpoint.Y / gridY) * gridY;


            //Console.WriteLine("left=" + left + " ; top=" + top + " ; right=" + right + " ; bottom=" + bottom);

            Pen          pen  = new Pen(d_color);
            GraphicsPath path = new GraphicsPath();

            while (bottom < top)
            {
                PointF p1 = canvas.ToScreen(new UnitPoint(leftpoint.X, bottom));
                PointF p2 = canvas.ToScreen(new UnitPoint(rightpoint.X, bottom));
                path.AddLine(p1, p2);
                path.CloseFigure();
                bottom += gridY;
            }

            if (canvas.Graphics != null)
            {
                canvas.Graphics.DrawPath(pen, path);
            }
        }
Esempio n. 5
0
        public CanvasCtrl(ICanvasOwner owner, IModel datamodel)
        {
            M_canvas = this;

            m_canvaswrapper = new CanvasWrapper(this);
            m_model         = datamodel;

            ((DataModel)m_model).AddDrawTool("Pen", new DrawTools.LineEdit(false));
            //////////////////////////////////////////
            //??????????????????????????????????
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            InitializeComponent();
            m_commandType = eCommandType.select;

            BorderStyle = BorderStyle.None;
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            m_nodeMoveHelper = new NodeMoveHelper(m_canvaswrapper);
            lines            = new List <Line>();
            orlines          = new List <Line>();
        }
Esempio n. 6
0
 void RepaintSnappoint(ISnapPoint snappoint)
 {
     if (snappoint == null)
         return;
     CanvasWrapper dc = new CanvasWrapper(this, Graphics.FromHwnd(Handle), ClientRectangle);
     snappoint.Draw(dc);
     dc.Graphics.Dispose();
     dc.Dispose();
 }
Esempio n. 7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //CommonTools.Tracing.StartTrack(Program.TracePaint);
            //ClearPens();
            
            e.Graphics.SmoothingMode = m_smoothingMode;
            CanvasWrapper dc = new CanvasWrapper(this, e.Graphics, ClientRectangle);
            Rectangle cliprectangle = e.ClipRectangle;
            if (m_staticImage == null)
            {
                cliprectangle = ClientRectangle;
                m_staticImage = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
                m_staticDirty = true;
            }
            RectangleF r = ScreenUtils.ToUnitNormalized(dc, cliprectangle);
            if (float.IsNaN(r.Width) || float.IsInfinity(r.Width))
            {
                r = ScreenUtils.ToUnitNormalized(dc, cliprectangle);
            }
            if (m_staticDirty)
            {
                m_staticDirty = false;
                CanvasWrapper dcStatic = new CanvasWrapper(this, Graphics.FromImage(m_staticImage), ClientRectangle);
                dcStatic.Graphics.SmoothingMode = m_smoothingMode;
                m_model.BackgroundLayer.Draw(dcStatic, r);
                //九线谱底谱
                if (m_model.GridLayer.Enabled)
                    m_model.GridLayer.Draw(dcStatic, r);

                //djl
                dcanvaswrapper = dcStatic;
                
                drf = r;
                /*
                PointF nullPoint = ToScreen(new UnitPoint(0, 0));
                dcStatic.Graphics.DrawLine(Pens.Blue, nullPoint.X - 10, nullPoint.Y, nullPoint.X + 10, nullPoint.Y);
                dcStatic.Graphics.DrawLine(Pens.Blue, nullPoint.X, nullPoint.Y - 10, nullPoint.X, nullPoint.Y + 10);
                */
                ICanvasLayer[] layers = m_model.Layers;
                for (int layerindex = layers.Length - 1; layerindex >= 0; layerindex--)
                {
                    if (layers[layerindex] != m_model.ActiveLayer && layers[layerindex].Visible)
                        layers[layerindex].Draw(dcStatic, r);
                }
                if (m_model.ActiveLayer != null)
                    m_model.ActiveLayer.Draw(dcStatic, r);
                
                dcStatic.Dispose();
            }
            e.Graphics.DrawImage(m_staticImage, cliprectangle, cliprectangle, GraphicsUnit.Pixel);
            /*
            foreach (IDrawObject drawobject in m_model.SelectedObjects)
                drawobject.Draw(dc, r);

            if (m_newObject != null)
                m_newObject.Draw(dc, r);

            if (m_snappoint != null)
                m_snappoint.Draw(dc);

            if (m_selection != null)
            {
                m_selection.Reset();
                m_selection.SetMousePoint(e.Graphics, this.PointToClient(Control.MousePosition));
            }
            if (m_moveHelper.IsEmpty == false)
                m_moveHelper.DrawObjects(dc, r);

            if (m_nodeMoveHelper.IsEmpty == false)
                m_nodeMoveHelper.DrawObjects(dc, r);
            dc.Dispose();
            ClearPens();
            CommonTools.Tracing.EndTrack(Program.TracePaint, "OnPaint complete");*/
            //重绘线
            if (CanvasCtrl.M_canvas.List.Count != 0) {

                List<Line> l=CanvasCtrl.M_canvas.List;
                for (int i = 0; i < l.Count;i++ )
                {
                    e.Graphics.DrawLine(new Pen(l[i].Color, 2), l[i].P1, l[i].P2);

                }
            }
            //重绘小节线和拍线
            if (CanvasCtrl.M_canvas.OrList.Count != 0)
            {

                List<Line> l = CanvasCtrl.M_canvas.OrList;
                for (int i = 0; i < l.Count; i++)
                {
                    e.Graphics.DrawLine(new Pen(l[i].Color2, l[i].S), l[i].P1, l[i].P2);

                }
            }
            //绘制移动中的选定区域
            if (moving)
            {
                mr.drawRegion(e.Graphics);
            }
            if (ispaste) {
                if(pr!=null)
                pr.drawRegion(e.Graphics);
            }
        }
Esempio n. 8
0
        public CanvasCtrl(ICanvasOwner owner, IModel datamodel)
        {
            M_canvas = this;

            m_canvaswrapper = new CanvasWrapper(this);
            m_model = datamodel;

            ((DataModel)m_model).AddDrawTool("Pen", new DrawTools.LineEdit(false));
            //////////////////////////////////////////
            //??????????????????????????????????
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            InitializeComponent();
            m_commandType = eCommandType.select;

            BorderStyle = BorderStyle.None;
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            m_nodeMoveHelper = new NodeMoveHelper(m_canvaswrapper);
            lines = new List<Line>();
            orlines = new List<Line>();
        }
Esempio n. 9
0
 public void Draw(CanvasWrapper canvas, RectangleF unitrect,int start ,int end ,int time,int strong)
 { 
 }
Esempio n. 10
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            m_mousedownPoint = new PointF(e.X, e.Y); // used when panning
            m_dragOffset     = new PointF(0, 0);

            //移动音符放下
            if (moving)
            {
                moving = false;
                lines.AddRange(mr.getLines());
            }
            if (ispaste)
            {
                ispaste = false;
                List <Line> l = pr.getLines();
                for (int i = 0; i < l.Count; i++)
                {
                    Line l1 = new Line(l[i].P1, l[i].P2, l[i].S, l[i].isRed, l[i].Color);
                    lines.Add(l1);
                }
            }
            if (m_drawObjectId.Equals("StartPoint"))
            {
                TestForm.setStartPoint(e.X, e.Y);
            }
            UnitPoint mousepoint = ToUnit(m_mousedownPoint);

            if (m_snappoint != null)
            {
                mousepoint = m_snappoint.SnapPoint;
            }

            if (m_commandType == eCommandType.select)
            {
                bool handled = false;
                if (m_nodeMoveHelper.HandleMouseDown(mousepoint, ref handled))
                {
                    m_commandType = eCommandType.editNode;
                    m_snappoint   = null;
                    base.OnMouseDown(e);
                    return;
                }
                m_selection = new SelectionRectangle(m_mousedownPoint);
            }

            /*
             * if (m_commandType == eCommandType.move)
             * {
             *  m_moveHelper.HandleMouseDownForMove(mousepoint, m_snappoint);
             * }
             * */
            if (m_commandType == eCommandType.draw)
            {
                HandleMouseDownWhenDrawing(mousepoint, null);
                DoInvalidate(true);
            }

            else if (m_commandType == eCommandType.symbol)
            {
                System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TestForm));
                CanvasWrapper canvastest = new CanvasWrapper(this, Graphics.FromImage(m_staticImage), ClientRectangle);
                canvastest.Graphics.SmoothingMode = m_smoothingMode;
                if (m_drawObjectId == "clef1" || m_drawObjectId == "clef2" || m_drawObjectId == "clef3" || m_drawObjectId == "clef4" || m_drawObjectId == "clef6" || m_drawObjectId == "N2" ||
                    m_drawObjectId == "N3" || m_drawObjectId == "N4" || m_drawObjectId == "N5" || m_drawObjectId == "N6" || m_drawObjectId == "N7" || m_drawObjectId == "N8" || m_drawObjectId == "N9" ||
                    m_drawObjectId == "N10" || m_drawObjectId == "N11" || m_drawObjectId == "N12" || m_drawObjectId == "s10" || m_drawObjectId == "s11" || m_drawObjectId == "s12" ||
                    m_drawObjectId == "N12" || m_drawObjectId == "N13")
                {
                    //  MessageBox.Show("test  test " + m_drawObjectId);

                    DrawSymbol(canvastest, e.X, e.Y, ((System.Drawing.Image)(resources.GetObject("ribbonButton_" + m_drawObjectId + ".Image"))), 1);
                }
                else if (m_drawObjectId == "bm1" || m_drawObjectId == "bm2" || m_drawObjectId == "bm3" || m_drawObjectId == "bm4" ||
                         m_drawObjectId == "bm5" || m_drawObjectId == "bm6" || m_drawObjectId == "bm7" || m_drawObjectId == "bm8" ||
                         m_drawObjectId == "bm18" || m_drawObjectId == "o11")
                {
                    DrawSymbol(canvastest, e.X, e.Y, ((System.Drawing.Image)(resources.GetObject("ribbonButton_" + m_drawObjectId + ".Image"))), 0.7);
                }
                else
                {
                    //  MessageBox.Show("test  test " + m_drawObjectId);
                    DrawSymbol(canvastest, e.X, e.Y, ((System.Drawing.Image)(resources.GetObject("ribbonButton_" + m_drawObjectId + ".Image"))), 0.4);
                }
                canvastest.CanvasCtrl.Refresh();
            }

            /*
             * if (m_commandType == eCommandType.edit)
             * {
             *  if (m_editTool == null)
             *      m_editTool = m_model.GetEditTool(m_editToolId);
             *  if (m_editTool != null)
             *  {
             *      if (m_editTool.SupportSelection)
             *          m_selection = new SelectionRectangle(m_mousedownPoint);
             *
             *      eDrawObjectMouseDown mouseresult = m_editTool.OnMouseDown(m_canvaswrapper, mousepoint, m_snappoint);
             * //                    /*
             * //                    if (mouseresult == eDrawObjectMouseDown.Continue)
             * //                    {
             * //                        if (m_editTool.SupportSelection)
             * //                            m_selection = new SelectionRectangle(m_mousedownPoint);
             * //                    }
             * //                     * * /
             * //
             *      if (mouseresult == eDrawObjectMouseDown.Done)
             *      {
             *          m_editTool.Finished();
             *          m_editTool = m_model.GetEditTool(m_editToolId); // continue with new tool
             *          //m_editTool = null;
             *
             *          if (m_editTool.SupportSelection)
             *              m_selection = new SelectionRectangle(m_mousedownPoint);
             *      }
             *  }
             *  DoInvalidate(true);
             *  UpdateCursor();
             * }
             */
            base.OnMouseDown(e);
        }
Esempio n. 11
0
 public NodeMoveHelper(CanvasWrapper canvas)
 {
     m_canvas = canvas;
 }
Esempio n. 12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //CommonTools.Tracing.StartTrack(Program.TracePaint);
            //ClearPens();

            e.Graphics.SmoothingMode = m_smoothingMode;
            CanvasWrapper dc            = new CanvasWrapper(this, e.Graphics, ClientRectangle);
            Rectangle     cliprectangle = e.ClipRectangle;

            if (m_staticImage == null)
            {
                cliprectangle = ClientRectangle;
                m_staticImage = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
                m_staticDirty = true;
            }
            RectangleF r = ScreenUtils.ToUnitNormalized(dc, cliprectangle);

            if (float.IsNaN(r.Width) || float.IsInfinity(r.Width))
            {
                r = ScreenUtils.ToUnitNormalized(dc, cliprectangle);
            }
            if (m_staticDirty)
            {
                m_staticDirty = false;
                CanvasWrapper dcStatic = new CanvasWrapper(this, Graphics.FromImage(m_staticImage), ClientRectangle);
                dcStatic.Graphics.SmoothingMode = m_smoothingMode;
                m_model.BackgroundLayer.Draw(dcStatic, r);
                //九线谱底谱
                if (m_model.GridLayer.Enabled)
                {
                    m_model.GridLayer.Draw(dcStatic, r);
                }

                //djl
                dcanvaswrapper = dcStatic;

                drf = r;

                /*
                 * PointF nullPoint = ToScreen(new UnitPoint(0, 0));
                 * dcStatic.Graphics.DrawLine(Pens.Blue, nullPoint.X - 10, nullPoint.Y, nullPoint.X + 10, nullPoint.Y);
                 * dcStatic.Graphics.DrawLine(Pens.Blue, nullPoint.X, nullPoint.Y - 10, nullPoint.X, nullPoint.Y + 10);
                 */
                ICanvasLayer[] layers = m_model.Layers;
                for (int layerindex = layers.Length - 1; layerindex >= 0; layerindex--)
                {
                    if (layers[layerindex] != m_model.ActiveLayer && layers[layerindex].Visible)
                    {
                        layers[layerindex].Draw(dcStatic, r);
                    }
                }
                if (m_model.ActiveLayer != null)
                {
                    m_model.ActiveLayer.Draw(dcStatic, r);
                }

                dcStatic.Dispose();
            }
            e.Graphics.DrawImage(m_staticImage, cliprectangle, cliprectangle, GraphicsUnit.Pixel);

            /*
             * foreach (IDrawObject drawobject in m_model.SelectedObjects)
             *  drawobject.Draw(dc, r);
             *
             * if (m_newObject != null)
             *  m_newObject.Draw(dc, r);
             *
             * if (m_snappoint != null)
             *  m_snappoint.Draw(dc);
             *
             * if (m_selection != null)
             * {
             *  m_selection.Reset();
             *  m_selection.SetMousePoint(e.Graphics, this.PointToClient(Control.MousePosition));
             * }
             * if (m_moveHelper.IsEmpty == false)
             *  m_moveHelper.DrawObjects(dc, r);
             *
             * if (m_nodeMoveHelper.IsEmpty == false)
             *  m_nodeMoveHelper.DrawObjects(dc, r);
             * dc.Dispose();
             * ClearPens();
             * CommonTools.Tracing.EndTrack(Program.TracePaint, "OnPaint complete");*/
            //重绘线
            if (CanvasCtrl.M_canvas.List.Count != 0)
            {
                List <Line> l = CanvasCtrl.M_canvas.List;
                for (int i = 0; i < l.Count; i++)
                {
                    e.Graphics.DrawLine(new Pen(l[i].Color, 2), l[i].P1, l[i].P2);
                }
            }
            //重绘小节线和拍线
            if (CanvasCtrl.M_canvas.OrList.Count != 0)
            {
                List <Line> l = CanvasCtrl.M_canvas.OrList;
                for (int i = 0; i < l.Count; i++)
                {
                    e.Graphics.DrawLine(new Pen(l[i].Color2, l[i].S), l[i].P1, l[i].P2);
                }
            }
            //绘制移动中的选定区域
            if (moving)
            {
                mr.drawRegion(e.Graphics);
            }
            if (ispaste)
            {
                if (pr != null)
                {
                    pr.drawRegion(e.Graphics);
                }
            }
        }
Esempio n. 13
0
        //djl
         public void Draw(CanvasWrapper canvas, RectangleF unitrect,int start,int end,int line,int strong){
             if (Enabled == false)
                 return;

             float gridX = m_spacing.Width;
             float gridY = m_spacing.Height;
             //Console.WriteLine("gridX=" + gridX + " ; Y=" + gridY);
             float gridscreensizeX = canvas.ToScreen(gridX);
             float gridscreensizeY = canvas.ToScreen(gridY);
             //Console.WriteLine("gridscreensizeX=" + gridscreensizeX + " ; Y=" + gridscreensizeY);
             if (gridscreensizeX < m_minSize || gridscreensizeY < m_minSize)
                 return;

             PointF leftpoint = unitrect.Location;
             PointF rightpoint = ScreenUtils.RightPoint(canvas, unitrect);

             float left = (float)Math.Round(leftpoint.X / gridX) * gridX;
             float top = unitrect.Height + unitrect.Y;
             float right = rightpoint.X;
             float bottom = (float)Math.Round(leftpoint.Y / gridY) * gridY;
       
             GraphicsPath path = new GraphicsPath();
             PointF p1;
             PointF p2;
             if(true)
             {
                 Console.WriteLine("left=" + left + " ; top=" + top + " ; right=" + right + " ; bottom=" + bottom
                     +"; start="+start+";end="+end+";line="+line);
                  p1= canvas.ToScreen(new UnitPoint(leftpoint.X+start,top-line*gridY));
                  p2= canvas.ToScreen(new UnitPoint(leftpoint.X+end, top-line*gridY));
                 
             }
             try
             {
                 Line l = new Line(p1, p2, strong);
                 CanvasCtrl.M_canvas.List.Add(l);
                 canvas.Graphics.DrawLine(new Pen(l.Color,2), p1, p2);
                
             }
             catch (Exception e)
             {

                 Console.Write(e.Message);
             }
             
            
         }
Esempio n. 14
0
 public NodeMoveHelper(CanvasWrapper canvas)
 {
     m_canvas = canvas;
 }
Esempio n. 15
0
        public void Draw(CanvasWrapper canvas, RectangleF unitrect,int start ,int end ,int time,int strong)
        {

            if (Enabled == false)
                return;

            float gridX = Spacing.Width;
            float gridY = Spacing.Height;
            //Console.WriteLine("gridX=" + gridX + " ; Y=" + gridY);
            float gridscreensizeX = canvas.ToScreen(gridX);
            float gridscreensizeY = canvas.ToScreen(gridY);
            //Console.WriteLine("gridscreensizeX=" + gridscreensizeX + " ; Y=" + gridscreensizeY);
            if (gridscreensizeX < MinSize || gridscreensizeY < MinSize)
                return;

            PointF leftpoint = unitrect.Location;
            PointF rightpoint = ScreenUtils.RightPoint(canvas, unitrect);

            float left = (float)Math.Round(leftpoint.X / gridX) * gridX;
            float top = unitrect.Height + unitrect.Y;
            float right = rightpoint.X;
            float bottom = (float)Math.Round(leftpoint.Y / gridY) * gridY;


             //Console.WriteLine("left=" + left + " ; top=" + top + " ; right=" + right + " ; bottom=" + bottom);

            Pen pen = new Pen(d_color);
            GraphicsPath path = new GraphicsPath();
            while (bottom < top)
            {
                PointF p1 = canvas.ToScreen(new UnitPoint(leftpoint.X, bottom));
                PointF p2 = canvas.ToScreen(new UnitPoint(rightpoint.X, bottom));
                path.AddLine(p1, p2);
                path.CloseFigure();
                bottom += gridY;
            }
            
            if(canvas.Graphics!=null){canvas.Graphics.DrawPath(pen, path); }
        }
Esempio n. 16
0
        /*
        public void DoInvalidate(bool dostatic, RectangleF rect)
        {
            if (dostatic)
                m_staticDirty = true;
            Invalidate(ScreenUtils.ConvertRect(rect));
        }*/

        void RepaintObject(IDrawObject obj)
        {
            if (obj == null)
                return;
            CanvasWrapper dc = new CanvasWrapper(this, Graphics.FromHwnd(Handle), ClientRectangle);
            RectangleF invalidaterect = ScreenUtils.ConvertRect(ScreenUtils.ToScreenNormalized(dc, obj.GetBoundingRect(dc)));
            obj.Draw(dc, invalidaterect);
            dc.Graphics.Dispose();
            dc.Dispose();
        }
Esempio n. 17
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            m_mousedownPoint = new PointF(e.X, e.Y); // used when panning
            m_dragOffset = new PointF(0, 0);

            //移动音符放下
            if (moving)
            {
                moving = false;
                lines.AddRange(mr.getLines());
            }
            if (ispaste)
            {
                ispaste = false;
                List<Line> l=pr.getLines();
                for (int i = 0; i <l.Count; i++) {
                    Line l1 = new Line(l[i].P1, l[i].P2, l[i].S, l[i].isRed, l[i].Color);
                    lines.Add(l1);
                }
                  
            }
            if (m_drawObjectId.Equals("StartPoint")) {

                TestForm.setStartPoint(e.X,e.Y);
            }
            UnitPoint mousepoint = ToUnit(m_mousedownPoint);
            if (m_snappoint != null)
                mousepoint = m_snappoint.SnapPoint;

            if (m_commandType == eCommandType.select)
            {
                bool handled = false;
                if (m_nodeMoveHelper.HandleMouseDown(mousepoint, ref handled))
                {
                    m_commandType = eCommandType.editNode;
                    m_snappoint = null;
                    base.OnMouseDown(e);
                    return;
                }
                m_selection = new SelectionRectangle(m_mousedownPoint);
            }
            /*
            if (m_commandType == eCommandType.move)
            {
                m_moveHelper.HandleMouseDownForMove(mousepoint, m_snappoint);
            }
             * */
            if (m_commandType == eCommandType.draw)
            {
                HandleMouseDownWhenDrawing(mousepoint, null);
                DoInvalidate(true);
            }

            else if (m_commandType == eCommandType.symbol) {
                System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TestForm));
                CanvasWrapper canvastest = new CanvasWrapper(this, Graphics.FromImage(m_staticImage), ClientRectangle);
                canvastest.Graphics.SmoothingMode = m_smoothingMode;
                if (m_drawObjectId == "clef1" || m_drawObjectId == "clef2" || m_drawObjectId == "clef3" || m_drawObjectId == "clef4" || m_drawObjectId == "clef6" || m_drawObjectId == "N2"
                    || m_drawObjectId == "N3" || m_drawObjectId == "N4" || m_drawObjectId == "N5" || m_drawObjectId == "N6" || m_drawObjectId == "N7" || m_drawObjectId == "N8" || m_drawObjectId == "N9"
                    || m_drawObjectId == "N10" || m_drawObjectId == "N11" || m_drawObjectId == "N12" || m_drawObjectId == "s10" || m_drawObjectId == "s11" || m_drawObjectId == "s12" ||
                    m_drawObjectId == "N12" || m_drawObjectId == "N13" )
                {
                  //  MessageBox.Show("test  test " + m_drawObjectId);

                    DrawSymbol(canvastest, e.X, e.Y, ((System.Drawing.Image)(resources.GetObject("ribbonButton_" + m_drawObjectId + ".Image"))), 1);
                }
                else if (m_drawObjectId == "bm1" || m_drawObjectId == "bm2" || m_drawObjectId == "bm3" || m_drawObjectId == "bm4"
                   || m_drawObjectId == "bm5" || m_drawObjectId == "bm6" || m_drawObjectId == "bm7" || m_drawObjectId == "bm8" ||
                    m_drawObjectId == "bm18" || m_drawObjectId == "o11")
                {
                    DrawSymbol(canvastest, e.X, e.Y, ((System.Drawing.Image)(resources.GetObject("ribbonButton_" + m_drawObjectId + ".Image"))), 0.7);

                }
                else
                {
                    //  MessageBox.Show("test  test " + m_drawObjectId);
                    DrawSymbol(canvastest, e.X, e.Y, ((System.Drawing.Image)(resources.GetObject("ribbonButton_" + m_drawObjectId + ".Image"))), 0.4);
                }
                canvastest.CanvasCtrl.Refresh();
                
            }
            /*
            if (m_commandType == eCommandType.edit)
            {
                if (m_editTool == null)
                    m_editTool = m_model.GetEditTool(m_editToolId);
                if (m_editTool != null)
                {
                    if (m_editTool.SupportSelection)
                        m_selection = new SelectionRectangle(m_mousedownPoint);

                    eDrawObjectMouseDown mouseresult = m_editTool.OnMouseDown(m_canvaswrapper, mousepoint, m_snappoint);
//                    /*
//                    if (mouseresult == eDrawObjectMouseDown.Continue)
//                    {
//                        if (m_editTool.SupportSelection)
//                            m_selection = new SelectionRectangle(m_mousedownPoint);
//                    }
//                     * * /
//
                    if (mouseresult == eDrawObjectMouseDown.Done)
                    {
                        m_editTool.Finished();
                        m_editTool = m_model.GetEditTool(m_editToolId); // continue with new tool
                        //m_editTool = null;

                        if (m_editTool.SupportSelection)
                            m_selection = new SelectionRectangle(m_mousedownPoint);
                    }
                }
                DoInvalidate(true);
                UpdateCursor();
            }
           */
            base.OnMouseDown(e);
        }
Esempio n. 18
0
 public void Draw(CanvasWrapper canvas, RectangleF unitrect, int start, int end, int time, int strong)
 {
 }