private void UpdateChkList(CheckedListBox chkLst, Shape shape)
 {
     chkLst.Items.Clear();
     int intCount = shape.GDIPropertyCount;
     for (short i = 0; i < intCount; i++)
     {
         chkLst.Items.Add(shape.GetPropertyName(i));
         chkLst.SetItemChecked(i,
             (bool)shape.GetGDIValue(i));
     }
 }
 private void UpdateShape(CheckedListBox chkLst, Shape shape)
 {
     int intCount = shape.GDIPropertyCount;
     for (short i = 0; i < intCount; i++)
     {
        shape.SetGDIValue(i, chkLst.GetItemChecked(i));
     }
 }
Esempio n. 3
0
        public bool AddShape(Shape s)
        {
            invalidationList.Clear();
            if (blnClipRectIsOn)
                shapes.Insert(shapes.Count - 1, s);
            else
                shapes.Add(s);
            //wire up events
            s.EditorRequested += new EventHandler(shape_EditorRequested);

            if (intCurIndex != -1)
            {
                shapes[intCurIndex].isSelected = false;
                invalidationList.Add(intCurIndex);
            }
            if (blnClipRectIsOn)
            {
                intCurIndex = (short)(shapes.Count - 2);
                shapes[intCurIndex].zOrder = (short)(intCurIndex);
                shapes[intCurIndex].isSelected = true;
                shapeClipRect.zOrder++;
                invalidationList.Add(intCurIndex);
            }
            else
            {
                intCurIndex = (short)(shapes.Count - 1);
                shapes[intCurIndex].zOrder = (short)intCurIndex;
                shapes[intCurIndex].isSelected = true;
                invalidationList.Add(intCurIndex);
            }

            if (s is ShapePolygon)
            {
                if (((ShapePolygon)s).IsInitializing)
                    shapes[intCurIndex].EditingOn = true;
                _isAddingShape = true;
            }
            else
                _isAddingShape = false;

            string strCurSearchName = shapes[intCurIndex].ShapeType + "1";
            int intCount = shapes.Count;
            short shapeNum = 1;
            for (short i =0;i<intCount;i++)
            {
                //shapeNum = 1;
                if (shapes[i].GetType() == shapes[intCurIndex].GetType())
                {
                    if (shapes[i].Name == strCurSearchName)
                    {
                        strCurSearchName = shapes[intCurIndex].ShapeType + (++shapeNum);
                        i = -1; //reset the loop
                    }
                }
            }
            shapes[intCurIndex].Name = strCurSearchName;
            DoInvalidation();
            isDirty = true;
            return true;
        }
        public string SetShapeBounds(Shape shape)
        {
            Rectangle rect = shape.GetShapeBounds(true);
            string str =
             "//Sets the original shape bounds\r\n" +
             "shapeBoundsOld = new Rectangle(" +
                 (rect.X - AreaBounds.X) + ", " +
                 (rect.Y - AreaBounds.Y) + ", " +
                 (rect.Width) + ", " +
                 (rect.Height) + ");\r\n";

            if ((bool)shape.GetGDIValue(sGDIProperty.EditBounds))
            {
                str += "shapeBoundsNew = dBounds[eShapeBounds." + shape.Name + "];\r\n";
            }
            else
                str += "shapeBoundsNew = shapeBoundsOld;\r\n";
            //-------
            if ((bool)shape.GetGDIValue(sGDIProperty.AllowScaling))
            {
                str += "//Scale the demensions\r\n" +
                 "shapeBoundsNew = GetScaledBounds(shapeBoundsNew);\r\n";
            }

            return str;
        }
        public string GeneratePaintToolInit(Shape shape, string lgbBounds, bool initShapeBounds)
        {
            string str = "";
            if (initShapeBounds)
               str += SetShapeBounds(shape);

               if (shape.painter.PaintBorder)
               {
               if ((bool)shape.GetGDIValue(sGDIProperty.EditColor))
                str += "Pen " + shape.Name +
                            "Pen = new Pen(dColors[eShapeColor." + shape.Name + "BorderColor],"+
                            shape.painter.BorderThickness.ToString("F")+"f);\r\n";
               else
                str += "Pen " + shape.Name +
                            "Pen = new Pen(Color.FromArgb(" +
                            shape.painter.BorderColor.A +", " +
                            shape.painter.BorderColor.R + ", " +
                            shape.painter.BorderColor.G + ", " +
                            shape.painter.BorderColor.B + "), " +
                            shape.painter.BorderThickness.ToString("F") + "f);\r\n";
               }
            if (shape.painter.PaintFill)
            {
                if ((bool)shape.GetGDIValue(sGDIProperty.EditColor))
                {
                    if (shape.painter.ColorCount == 1)
                    {  //paint with a solid brush
                        str += "SolidBrush " + shape.Name +
                            "Brush = new SolidBrush(dColors[eShapeColor." + shape.Name + "FillColor]);\r\n";
                    }
                    else
                    { //Paint with a linear gradient brush

                        str += "LinearGradientBrush " + shape.Name +
                            "Brush = new LinearGradientBrush(" + lgbBounds + ",\r\n" +
                            "dColors[eShapeColor." + shape.Name + "FillColor1]," +
                            "dColors[eShapeColor." + shape.Name + "FillColor2],\r\n" +
                            shape.painter.LinearModeString + ");\r\n";
                    }
                }
                else
                {
                    if (shape.painter.ColorCount == 1)
                    {
                        Color color = shape.painter.GetColor(0);
                        //paint with a solid brush
                        str += "SolidBrush " + shape.Name +
                            "Brush = new SolidBrush(Color.FromArgb(" +
                                         color.A + ", "+
                                         color.R + ", "+
                                         color.G + ", "+
                                         color.B + "));\r\n";
                    }
                    else
                    {
                        Color color1 = shape.painter.GetColor(0);
                        Color color2 = shape.painter.GetColor(1);
                        //Paint with a linear gradient brush
                        str += "LinearGradientBrush " + shape.Name +
                            "Brush = new LinearGradientBrush("+lgbBounds+",\r\n" +
                                  "Color.FromArgb(" + color1.A + ", " +
                                       color1.R + ", " +
                                       color1.G + ", " +
                                       color1.B + "), " +
                                  "Color.FromArgb(" + color2.A + ", " +
                                       color2.R + ", " +
                                       color2.G + ", " +
                                       color2.B + ")," + shape.painter.LinearModeString + ");\r\n";
                    }
                }
                if (shape.painter.ColorCount > 1)
                {
                    if ((bool)shape.GetGDIValue(sGDIProperty.EditBlend))
                    {
                        str += shape.Name + "Brush.Blend = GetBlend(\r\n" +
                            "dBlend[eShapeBlend." + shape.Name + "].Coverage," +
                            "dBlend[eShapeBlend." + shape.Name + "].BlendSmoothness" + ");\r\n";
                    }
                    else
                    {
                        str += shape.Name + "Brush.Blend = GetBlend(" + shape.painter.Coverage +
                             "," + shape.painter.BlendSmoothness + ");\r\n";
                    }
                }
            }
            return str;
        }
 public string GeneratePaintToolInit(Shape shape)
 {
     return GeneratePaintToolInit(shape, "shapeBoundsNew",true);
 }
        public string GeneratePaintToolCleanup(Shape shape)
        {
            string str = "//Cleanup paint tools\r\n";
            if (shape.painter.PaintFill)
                str += shape.Name + "Brush.Dispose();\r\n";
            if (shape.painter.PaintBorder)
                str += shape.Name + "Pen.Dispose();\r\n";

            return str + "//\r\n";
        }