Beispiel #1
0
        private void SymbolListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            Pen selectPen = Pens.Black;

            if (e.Item.Selected)
            {
                selectPen = Pens.Red;
            }
            Rectangle r = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);


            Graphics          g      = e.Graphics;
            ScadaSymbol_Shape symbol = (ScadaSymbol_Shape)e.Item.Tag;


            if (symbol.Paths != null && symbol.Paths.Count > 0 && symbol.Bmp == null)
            {
                symbol.Bmp = new Bitmap(e.Bounds.Width, e.Bounds.Height);
                RectangleF   mr           = new RectangleF(0, 0, e.Bounds.Width, e.Bounds.Height);
                Graphics     mg           = Graphics.FromImage(symbol.Bmp);
                GraphicsPath graphicsPath = new GraphicsPath();
                graphicsPath.AddRectangle(r);
                symbol.Paint("", mg, mr, 0, new SVG_Color(Color.Red), SVTFillType.Original, null);
                mg.Dispose();
                g.DrawImage(symbol.Bmp, e.Bounds.X, e.Bounds.Y);
            }
            else
            {
                g.DrawImage(symbol.Bmp, e.Bounds.X, e.Bounds.Y);
            }


            g.DrawRectangle(selectPen, r);
        }
Beispiel #2
0
        /// <summary>
        /// 用户选择某个
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SymbolListView_OnSelectSymbol(object sender, EventArgs e)
        {
            if (sender != null)
            {
                DataObject data = new DataObject("Scada.FlowGraphEngine.GraphicsMap.Shape.Draw", sender);

                ScadaSymbol_Shape selectShape = (ScadaSymbol_Shape)sender;
                this.Cursor = new Cursor(selectShape.GetCursor());
                if (this.mediator.ActiveWork != null)
                {
                    ((WorkForm)this.mediator.ActiveWork).GraphControl.Cursor = this.Cursor;
                    SVG_StaticShape shape = new SVG_StaticShape();
                    shape.SvgShape = data.GetData("Scada.FlowGraphEngine.GraphicsMap.Shape.Draw") as ScadaSymbol_Shape;
                    ((WorkForm)this.mediator.ActiveWork).GraphControl.selector = new CommonSelector(((WorkForm)this.mediator.ActiveWork).GraphControl, shape);
                }
            }
        }