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); }
private void write_BlendEnumeration() { sbBeginCode.Append("public enum eShapeBlend\r\n{\r\n"); int intResult = 0; int intCount = manager.ShapeCount; bool isFirstEnum = true; for (short i = 0; i < intCount; i++) { Shape shape = manager.GetShape(i); if (shape.GetShapeBounds(true).IntersectsWith(AreaBounds)) { if ((bool)shape.GetGDIValue(sGDIProperty.EditBounds)) { if (isFirstEnum) { isFirstEnum = false; } else { sbBeginCode.Append(", "); } blendEnumCount++; sbBeginCode.Append(shape.Name); Math.DivRem(blendEnumCount, 4, out intResult); if (intResult == 0) { sbBeginCode.Append("\r\n"); } } } } sbBeginCode.Append("}\r\n\r\n"); }
private void write_BoundsDictionary() { sbEndCode.Append( "private void fillBoundsDictionary(bool isInit)\r\n{\r\n" + "if (isInit)\r\n" + "dBounds = new Dictionary<eShapeBounds, Rectangle>(" + boundsEnumCount + ");\r\n" + "dBounds.Clear();\r\n"); for (short i = 0; i < manager.ShapeCount; i++) { Shape shape = manager.GetShape(i); if (shape.GetShapeBounds(true).IntersectsWith(AreaBounds)) { if ((bool)shape.GetGDIValue(sGDIProperty.EditBounds)) { Rectangle r = shape.GetShapeBounds(true); sbEndCode.Append("dBounds.Add(eShapeBounds." + shape.Name + ", new Rectangle(" + (r.X - AreaBounds.X) + ", " + (r.Y - AreaBounds.Y) + ", " + r.Width + ", " + r.Height + "));\r\n"); } } } sbEndCode.Append("}\r\n\r\n"); }
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 write_ColorDictionary() { sbEndCode.Append( "private void fillColorDictionary(bool isInit)\r\n{\r\n" + "if (isInit)\r\n" + " dColors = new Dictionary<eShapeColor, Color>(" + colorEnumCount + ");\r\n" + "dColors.Clear();\r\n"); for (short i = 0; i < manager.ShapeCount; i++) { Shape shape = manager.GetShape(i); if (shape.GetShapeBounds(true).IntersectsWith(AreaBounds)) { if ((bool)shape.GetGDIValue(sGDIProperty.EditColor)) { if (shape.painter.PaintFill) { if (shape.painter.ColorCount == 1) { Color col1 = shape.painter.GetColor(0); sbEndCode.Append("dColors.Add(eShapeColor." + shape.Name + "FillColor, Color.FromArgb(" + col1.A + ", " + col1.R + ", " + col1.G + ", " + col1.B + "));\r\n"); } else { Color col1 = shape.painter.GetColor(0); Color col2 = shape.painter.GetColor(1); sbEndCode.Append("dColors.Add(eShapeColor." + shape.Name + "FillColor1, Color.FromArgb(" + col1.A + ", " + col1.R + ", " + col1.G + ", " + col1.B + "));\r\n" + "dColors.Add(eShapeColor." + shape.Name + "FillColor2, Color.FromArgb(" + col2.A + ", " + col2.R + ", " + col2.G + ", " + col2.B + "));\r\n"); blnHasGradientBrush = true; } } if (shape.painter.PaintBorder) { Color col1 = shape.painter.BorderColor; sbEndCode.Append("dColors.Add(eShapeColor." + shape.Name + "BorderColor, Color.FromArgb(" + col1.A + ", " + col1.R + ", " + col1.G + ", " + col1.B + "));\r\n"); } } } } sbEndCode.Append("\r\n}\r\n\r\n"); }
private void write_TextDictionary() { sbEndCode.Append( "private void fillTextDictionary(bool isInit)\r\n{\r\n" + "if (isInit)\r\n" + "dText = new Dictionary<eShapeText, string>(" + textEnumCount + ");\r\n" + "dText.Clear();\r\n"); for (short i = 0; i < manager.ShapeCount; i++) { Shape shape = manager.GetShape(i); if (shape is ShapeText && shape.GetShapeBounds(true).IntersectsWith(AreaBounds)) { if ((bool)shape.GetGDIValue("Edit Text")) { sbEndCode.Append("dText.Add(eShapeText." + shape.Name + ", " + FormatText(((ShapeText)shape).Text) + ");\r\n"); } } } sbEndCode.Append("}\r\n\r\n"); }
private void write_BlendDictionary() { sbEndCode.Append( "private void fillBlendDictionary(bool isInit)\r\n{\r\n" + "if (isInit)\r\n" + "dBlend = new Dictionary<eShapeBlend, BlendArgs>(" + blendEnumCount + ");\r\n" + "dBlend.Clear();\r\n"); for (short i = 0; i < manager.ShapeCount; i++) { Shape shape = manager.GetShape(i); if (shape.GetShapeBounds(true).IntersectsWith(AreaBounds)) { if ((bool)shape.GetGDIValue(sGDIProperty.EditBlend)) { sbEndCode.Append("dBlend.Add(eShapeBlend." + shape.Name + ", new BlendArgs(" + shape.painter.Coverage + ", " + shape.painter.BlendSmoothness + "));\r\n"); } } } sbEndCode.Append("}\r\n\r\n"); }
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); }
private void write_ColorEnumeration() { sbBeginCode.Append("public enum eShapeColor\r\n{\r\n"); int intResult = 0; int intCount = manager.ShapeCount; bool isFirstEnum = true; for (short i = 0; i < intCount; i++) { Shape shape = manager.GetShape(i); if (shape.GetShapeBounds(true).IntersectsWith(AreaBounds)) { if ((bool)shape.GetGDIValue(sGDIProperty.EditColor)) { if (shape.painter.PaintFill) { if (shape.painter.ColorCount == 1) { colorEnumCount++; if (isFirstEnum) { isFirstEnum = false; } else { sbBeginCode.Append(", "); } sbBeginCode.Append(shape.Name + "FillColor"); Math.DivRem(colorEnumCount, 4, out intResult); if (intResult == 0) { sbBeginCode.Append("\r\n"); } } else { colorEnumCount++; if (isFirstEnum) { isFirstEnum = false; } else { sbBeginCode.Append(", "); } sbBeginCode.Append(shape.Name + "FillColor1"); Math.DivRem(colorEnumCount, 4, out intResult); if (intResult == 0) { sbBeginCode.Append("\r\n"); } colorEnumCount++; sbBeginCode.Append(", " + shape.Name + "FillColor2"); Math.DivRem(colorEnumCount, 4, out intResult); if (intResult == 0) { sbBeginCode.Append("\r\n"); } } } if (shape.painter.PaintBorder) { colorEnumCount++; if (isFirstEnum) { isFirstEnum = false; } else { sbBeginCode.Append(", "); } sbBeginCode.Append(shape.Name + "BorderColor"); Math.DivRem(colorEnumCount, 4, out intResult); if (intResult == 0) { sbBeginCode.Append("\r\n"); } } } } } sbBeginCode.Append("}\r\n"); }
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; }