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(); }
/* * 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(); }
/* 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(); }
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(); }
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); } }
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); } } }