Example #1
0
 private void drawPanel_MouseUp(object sender, MouseEventArgs e)
 {
     if (m_movingOrigin != null && m_selectionPoint != null)
     {
         var r = DrawingExtension.GetBoundingRectangle(m_movingOrigin.Value, m_selectionPoint.Value);
         foreach (var table in m_diagram.Tables)
         {
             if (!table.HorInterv.Intersection(r.GetHorInterv()).IsEmpty&&
                 !table.VerInterv.Intersection(r.GetVerInterv()).IsEmpty)
             {
                 if (!m_selectedTables.Contains(table))
                 {
                     m_selectedTables.Add(table);
                 }
             }
         }
         ShowCurrentEntityStyle();
     }
     m_movingOrigin   = null;
     m_selectionPoint = null;
     drawPanel.Invalidate();
 }
Example #2
0
        private void drawPanel_Paint(object sender, PaintEventArgs e)
        {
            if (m_denyDraw)
            {
                return;
            }

            //if (btnAntiAliasing.Checked)
            //{
            //    e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //    e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            //}

            //e.Graphics.ScaleTransform(ZoomFactor, ZoomFactor);
            //m_diagram.Draw(e.Graphics);

            if (Math.Abs(ZoomFactor - 1.0) > 0.01)
            {
                if (AntiAlias)
                {
                    using (Bitmap bmp = new Bitmap(m_diagram.Size.Width, m_diagram.Size.Height))
                    {
                        using (Graphics g = Graphics.FromImage(bmp))
                        {
                            m_diagram.Draw(g);
                        }
                        //e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                        e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                        e.Graphics.DrawImage(bmp, new RectangleF(0, 0, m_diagram.Size.Width * ZoomFactor, m_diagram.Size.Height * ZoomFactor));
                    }
                }
                else
                {
                    e.Graphics.ScaleTransform(ZoomFactor, ZoomFactor);
                    m_diagram.Draw(e.Graphics);
                }
            }
            else
            {
                m_diagram.Draw(e.Graphics);
            }

            e.Graphics.ResetTransform();
            e.Graphics.ScaleTransform(ZoomFactor, ZoomFactor);

            Size newsize = m_diagram.Size;

            newsize.Width  = (int)(newsize.Width * ZoomFactor);
            newsize.Height = (int)(newsize.Height * ZoomFactor);
            if (newsize.Height < 1)
            {
                newsize.Height = 1;
            }
            if (newsize.Width < 1)
            {
                newsize.Width = 1;
            }
            if (newsize != drawPanel.Size)
            {
                drawPanel.Size = newsize;
            }
            foreach (var seltbl in m_selectedTables)
            {
                using (Pen pen = new Pen(drawPanel.Focused ? Brushes.Blue : Brushes.Gray, 3))
                {
                    e.Graphics.DrawRectangle(pen, new Rectangle(seltbl.Location, seltbl.Size));
                }
            }

            if (m_movingOrigin != null && m_selectionPoint != null)
            {
                using (var pen = new Pen(Color.Black, 1))
                {
                    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    var r = DrawingExtension.GetBoundingRectangle(m_movingOrigin.Value, m_selectionPoint.Value);
                    e.Graphics.DrawRectangle(pen, r);
                }
            }

            bool wantRefresh = false;

            foreach (var t in m_diagram.Tables)
            {
                if (t.MustBePlaced)
                {
                    PlaceTable(t);
                    wantRefresh    = true;
                    t.MustBePlaced = false;
                }
            }
            if (wantRefresh)
            {
                drawPanel.Invalidate();
            }
        }