Beispiel #1
0
 /// <summary>
 /// Event handler when changes in elements occur
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="completeDrawing">update complete drawing</param>
 private void element_OnUpdateDrawing(object sender, bool completeDrawing)
 {
     if (InvokeRequired)
     {
         //handle thread safety
         UpdateDrawingEvent d = new UpdateDrawingEvent(element_OnUpdateDrawing);
         Invoke(d, new object[] { sender, completeDrawing });
         return;
     }
     if (completeDrawing)
     {
         UpdateDrawing();
         Invalidate();
     }
     else
     {
         // only update particular object
         GraphicBaseElement element = sender as GraphicBaseElement;
         if (element != null)
         {
             Graphics g = Graphics.FromImage(m_Drawing);
             element.Paint(g);
             Graphics control = this.CreateGraphics();
             control.DrawImage(m_Drawing, 0, 0);
         }
     }
 }
        ///// <summary>
        ///// Updates the background drawing
        ///// </summary>
        //protected virtual void UpdateBackground()
        //{
        //    if (Width == 0 || Height == 0)
        //    {
        //        return;
        //    }
        //    m_Background = new Bitmap(Width, Height);
        //    Graphics g = Graphics.FromImage(m_Background);
        //    g.FillRectangle(new SolidBrush(BackColor), 0, 0, Width, Height);
        //    if (GridSize.X > 0 && GridSize.Y > 0)
        //    {
        //        for (int i = m_GridSize.X; i < Width; i += m_GridSize.X)
        //        {
        //            for (int j = m_GridSize.X; j < Height; j += m_GridSize.Y)
        //            {
        //                (m_Background as Bitmap).SetPixel(i, j, m_GridColor);
        //            }
        //        }
        //    }
        //    g.DrawLine(new Pen(m_GridColor), 0, m_Offset.Y, Width, m_Offset.Y);
        //    g.DrawLine(new Pen(m_GridColor), m_Offset.X, 0, m_Offset.X, Height);
        //}

        /// <summary>
        /// Updates the symbol drawing
        /// </summary>
        protected virtual void UpdateDrawing()
        {
            if (Width == 0 || Height == 0)
            {
                return;
            }
            m_Drawing = new Bitmap(Width, Height);
            Graphics g = Graphics.FromImage(m_Drawing);

            g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, Width, Height);
            if (m_Element != null)
            {
                m_Element.Paint(g);
            }
            else
            {
                if (m_Path != null)
                {
                    GraphicsPath path        = (GraphicsPath)m_Path.Clone();
                    Matrix       translation = ComputeTranslationMatrix();
                    path.Transform(translation);
                    g.DrawPath(Pens.Black, path);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Updates the circuit drawing
        /// </summary>
        public virtual void UpdateDrawing()
        {
            if (Width == 0 || Height == 0)
            {
                return;
            }
            m_Drawing = new Bitmap(Width, Height);
            Graphics g = Graphics.FromImage(m_Drawing);

            g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, Width, Height);
            foreach (BaseElement logic in m_Circuit)
            {
                GraphicBaseElement element = logic.LinkedObject as GraphicBaseElement;
                element.Paint(g);
            }
        }
Beispiel #4
0
        private void GenerateItems()
        {
            MacroCache    macroCache = MacroCache.Instance;
            List <string> macroNames = macroCache.GetMacroNames();

            macroNames.Sort(String.Compare);
            foreach (string name in macroNames)
            {
                //Symbol symbol = macroCache.GetSymbol(name);
                GraphicBaseElement element =
                    GraphicObjectFactory.CreateInstance(typeof(Macro), MacroCache.Instance.GetMacro(name));
                element.Location = new PointF(element.Bounds.X * -1, element.Bounds.Y * -1);
                int width  = (int)element.Bounds.Width + 1;
                int height = (int)element.Bounds.Height + 1;
                if (width < 48)
                {
                    width = 48;
                }
                if (height < 48)
                {
                    height = 48;
                }
                if (width > 48 && height <= 48)
                {
                    element.Location = new PointF(element.Location.X, element.Location.Y + (width - height));
                    height           = width;
                }
                if (height > 48 && width <= 48)
                {
                    element.Location = new PointF(element.Location.X + (height - width), element.Location.Y);
                    width            = height;
                }
                Image img = new Bitmap(width, height);
                element.Paint(Graphics.FromImage(img));

                imageList_Symbols.Images.Add(name, img);

                ListViewItem item = listView_Macros.Items.Add(name, imageList_Symbols.Images.IndexOfKey(name));
            }
        }