public SvgEditor() { this.doc = new SvgDoc(); this.root = this.doc.CreateNewDocument(); this.CreateArrowStart(); this.CreateArrowEnd(); }
public SvgEditor(String name) { this.Name = name; this.doc = new SvgDoc(); this.root = this.doc.CreateNewDocument(); this.CreateArrowStart(); this.CreateArrowEnd(); }
private void ResetTree() { m_sFileName = ""; m_lvstate = new Hashtable(); txtXML.Text = ""; tv.Nodes.Clear(); m_svg = new SvgDoc(); }
public override SvgBasicShape ToSVGLibShape(SvgDoc doc) { var res = new SvgCircle(doc, center.X.ToString() + "px", center.X.ToString() + "px", r.ToString() + "px" ); res.Fill = System.Drawing.Color.FromArgb(fill.A, fill.R, fill.G, fill.B); res.Stroke = System.Drawing.Color.FromArgb(stroke.A, stroke.R, stroke.G, stroke.B); res.StrokeWidth = w.ToString() + "px"; return(res); }
//static List<SVGShape> Import(string filename) { //} public static void export(List <SVGShape> shapes, string filename, int width, int height) { SvgDoc doc = new SvgDoc(); SvgRoot root = doc.CreateNewDocument(); root.Width = width.ToString() + "px"; root.Height = height.ToString() + "px"; foreach (var shape in shapes) { var figure = shape.ToSVGLibShape(doc); doc.AddElement(root, figure); } doc.SaveToFile(filename); }
public override SvgBasicShape ToSVGLibShape(SvgDoc doc) { var res = new SvgRect(doc, rx.ToString() + "px", ry.ToString() + "px", width.ToString() + "px", height.ToString() + "px", w.ToString() + "px", System.Drawing.Color.FromArgb(fill.A, fill.R, fill.G, fill.B), System.Drawing.Color.FromArgb(stroke.A, stroke.R, stroke.G, stroke.B) ); return(res); }
public override SvgBasicShape ToSVGLibShape(SvgDoc doc) { String pointsStr = ""; foreach (var point in points) { pointsStr += point.X + "," + point.Y + " "; } var res = new SvgPolygon(doc, pointsStr ); res.Fill = System.Drawing.Color.FromArgb(fill.A, fill.R, fill.G, fill.B); res.Stroke = System.Drawing.Color.FromArgb(stroke.A, stroke.R, stroke.G, stroke.B); res.StrokeWidth = w.ToString() + "px"; return(res); }
public void errIsSvgFile(string pathToSvg) { SvgDoc checkDoc = new SvgDoc(); if (checkDoc.LoadFromFile(pathToSvg)) { // can proceed is valid svg Document hasError = false; currentError = @"<p><strong>Ooops! - Incorrect File Format</strong></p><p>I'm sorry, but we do not accept this file format.</p><p>Please resave your work as an .svg file and resubmit your file.</p>"; helpUrl = @"<p>Click <a href=""\help\?helipid=""here</a> to find out how to save your files in the correct format.</p>"; } else { hasError = false; currentError = ""; } checkDoc = null; }
public static Tuple <List <SVGShape>, int, int> import(string filename) { List <SVGShape> shapes = new List <SVGShape>() { new SVGEllipse(new Point(50.0, 50.0), 20.0, 10.0, new Color(100, 255, 56, 0), new Color(0, 0, 0, 0), 2) }; SvgDoc doc = new SvgDoc(); doc.LoadFromFile(filename); SvgRoot root = doc.GetSvgRoot(); int width, height = 1; Int32.TryParse(root.Width.ToString().Substring(0, root.Width.Length - 2), out width); Int32.TryParse(root.Height.ToString().Substring(0, root.Height.Length - 2), out height); Console.WriteLine(width); Console.WriteLine(height); int i = 2; SvgElement el; while ((el = doc.GetSvgElement(i)) != null) { el = doc.GetSvgElement(i); Console.WriteLine(el.getElementName()); ++i; } Console.WriteLine(i); //foreach (var shape in shapes) //{ // var figure = shape.ToSVGLibShape(doc); // doc.AddElement(root, figure); //} //doc.SaveToFile(filename); return(Tuple.Create(shapes, width, height)); }
public bool LoadFromXml(XmlTextReader reader) { ErrH.Log("DrawArea", "LoadFromXML", "", ErrH._LogPriority.Info); _graphicsList.Clear(); var svg = new SvgDoc(); if (!svg.LoadFromFile(reader)) { return(false); } SvgRoot root = svg.GetSvgRoot(); if (root == null) { return(false); } try { SizePicture = new Point((int)XnaDrawObject.ParseSize(root.Width, XnaDrawObject.Dpi.X), (int)XnaDrawObject.ParseSize(root.Height, XnaDrawObject.Dpi.Y)); } catch { } _mOriginalSize = SizePicture; SvgElement ele = root.getChild(); _mScale = new Point(1, 1); if (ele != null) { _graphicsList.AddFromSvg(ele); } Description = _graphicsList.Description; return(true); }
} // stroke width public abstract SvgBasicShape ToSVGLibShape(SvgDoc doc);
protected void Button1_Click(object sender, EventArgs e) { string testPath = HttpContext.Current.Server.MapPath(TextBox2.Text); SvgDoc myDoc = new SvgDoc(); bool fileOk = myDoc.LoadFromFile(testPath); //look for <g id="Your_Designs"> SVGLib.SvgElement elYourDesigns = myDoc.GetSvgElement("Your_Designs"); List <shapePrice> priceArray = AddFromSvg(elYourDesigns); zapQuote newQuote = new zapQuote(zapConstants.mAcrylic3mm, 1, 1); // StringBuilder myString = new StringBuilder(); foreach (shapePrice i in priceArray) { // myString.Append("zap type: " + i.zapType + ", area: " + Convert.ToString( i.area) + ", length: " + Convert.ToString(i.length) + ", x: " + Convert.ToString(i.xpos) + ", y: " + Convert.ToString(i.ypos) + ",\r\n other: " + i.otherInfo + "\r\n"); newQuote.appendShapeData(i.length, i.area, i.zapType, i.height, 0, 0); //myString.Append("\r\n" + i.otherInfo); } newQuote.calcTotalTime(zapConstants.mAcrylic3mm, 1, 1); lblareafill.Text = newQuote.totalAreaFill.ToString(); lblblightfillcount.Text = newQuote.lightFillCount.ToString(); lblbtotalengravelength.Text = newQuote.totalLengthEngrave.ToString(); lblbtotalheavyengrave.Text = newQuote.totalHeavyEngrave.ToString(); lblcutcount.Text = newQuote.cutCount.ToString(); lblcuttime.Text = newQuote.cutTime.ToString(); lblengravetime.Text = newQuote.engraveTime.ToString(); lblfilltime.Text = newQuote.fillTime.ToString(); lblheavyengravecount.Text = newQuote.heavyEngraveCount.ToString(); lblheavyfillarea.Text = newQuote.totalHeavyFill.ToString(); lblheavyfillcount.Text = newQuote.heavyFillCount.ToString(); lbllightengravecount.Text = newQuote.lightEngraveCount.ToString(); lbllightfillarea.Text = newQuote.totalLightFill.ToString(); lblmedengravecount.Text = newQuote.medEngraveCount.ToString(); lblmedfillarea.Text = newQuote.totalMedFill.ToString(); lblmedfillcount.Text = newQuote.medFillCount.ToString(); lbltotalCutLength.Text = newQuote.totalCutLength.ToString(); lbltotallightengrave.Text = newQuote.totalLengthEngrave.ToString(); lbltotalmedengrave.Text = newQuote.totalMedEngrave.ToString(); lbltotaltime.Text = newQuote.totalTime.ToString(); //TextBox1.Text = myString.ToString(); //errors //errors myHandler = new errors(); //myHandler.errFileSize(testPath); // TextBox1.Text = myHandler.currentError; //string gPath = @"<path d=""M 100 100 L 300 100 L 200 300 z"" fill=""red"" stroke=""blue"" stroke-width=""3"" />"; }
public static Tuple <List <SVGShape>, int, int> import(string filename) { var shapes = new List <SVGShape>(); SvgDoc doc = new SvgDoc(); doc.LoadFromFile(filename); SvgRoot root = doc.GetSvgRoot(); int width, height = 1; Int32.TryParse(root.Width.ToString().Substring(0, root.Width.Length - 2), out width); Int32.TryParse(root.Height.ToString().Substring(0, root.Height.Length - 2), out height); int i = 2; SvgElement el; double x, y, r, rx, ry, rectw, recth; int w; while ((el = doc.GetSvgElement(i)) != null) { el = doc.GetSvgElement(i); el.GetAttribute("RX"); switch (el.getElementName()) { case "circle": Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_CX).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_CX).Length - 2), out x); Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_CY).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_CY).Length - 2), out y); Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_R).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_R).Length - 2), out r); Int32.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrPaint_StrokeWidth).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrPaint_StrokeWidth).Length - 2), out w); var colorf = el.GetAttributeColorValue(SvgAttribute._SvgAttribute.attrPaint_Fill); var colors = el.GetAttributeColorValue(SvgAttribute._SvgAttribute.attrPaint_Stroke); var circle = new SVGCircle( new Point(x, y), r, new Color(colorf.R, colorf.G, colorf.B, colorf.A), new Color(colors.R, colors.G, colors.B, colors.A), w ); shapes.Add(circle); break; case "ellipse": Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_CX).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_CX).Length - 2), out x); Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_CY).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_CY).Length - 2), out y); Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_RX).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_RX).Length - 2), out rx); Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_RY).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_RY).Length - 2), out ry); Int32.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrPaint_StrokeWidth).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrPaint_StrokeWidth).Length - 2), out w); colorf = el.GetAttributeColorValue(SvgAttribute._SvgAttribute.attrPaint_Fill); colors = el.GetAttributeColorValue(SvgAttribute._SvgAttribute.attrPaint_Stroke); var ellipse = new SVGEllipse( new Point(x, y), rx, ry, new Color(colorf.R, colorf.G, colorf.B, colorf.A), new Color(colors.R, colors.G, colors.B, colors.A), w ); shapes.Add(ellipse); break; case "rect": Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_Width).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_Width).Length - 2), out rectw); Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_Height).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_Height).Length - 2), out recth); Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_X).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_X).Length - 2), out x); Double.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_Y).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_Y).Length - 2), out y); Int32.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrPaint_StrokeWidth).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrPaint_StrokeWidth).Length - 2), out w); colorf = el.GetAttributeColorValue(SvgAttribute._SvgAttribute.attrPaint_Fill); colors = el.GetAttributeColorValue(SvgAttribute._SvgAttribute.attrPaint_Stroke); var rect = new SVGRect( x, y, rectw, recth, new Color(colorf.R, colorf.G, colorf.B, colorf.A), new Color(colors.R, colors.G, colors.B, colors.A), w ); shapes.Add(rect); break; case "polygon": String pointsStr = ""; var points = new List <Point>(); pointsStr = el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrSpecific_Points); string[] value = pointsStr.Split(' ', ','); for (int k = 0; k < value.Length; k = k + 2) { if (value[k].Trim() != "" && value[k + 1].Trim() != "") { points.Add(new Point(Convert.ToDouble(value[k]), Convert.ToDouble(value[k + 1]))); } } ; Int32.TryParse(el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrPaint_StrokeWidth).Substring(0, el.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrPaint_StrokeWidth).Length - 2), out w); colorf = el.GetAttributeColorValue(SvgAttribute._SvgAttribute.attrPaint_Fill); colors = el.GetAttributeColorValue(SvgAttribute._SvgAttribute.attrPaint_Stroke); var polygon = new SVGPolygon( points, new Color(colorf.R, colorf.G, colorf.B, colorf.A), new Color(colors.R, colors.G, colors.B, colors.A), w ); shapes.Add(polygon); break; } ++i; } //foreach (var shape in shapes) //{ // var figure = shape.ToSVGLibShape(doc); // doc.AddElement(root, figure); //} //doc.SaveToFile(filename); return(Tuple.Create(shapes, width, height)); }
protected void btnCalc_Click(object sender, EventArgs e) { // clear error messages dialog.InnerHtml = ""; // FORM ITEMS ================================================================ //file info: fileName.InnerHtml = HttpUtility.HtmlEncode(Context.Request.Form["cFileName"]); string fPath = Context.Server.MapPath(@"imgLibrary"); string fullPath = fPath + @"\" + Context.Request.Form["cFileName"]; string fName = Context.Request.Form["cFileName"]; // user selected options: int materialId = Convert.ToInt32(svgMaterial.SelectedValue); int quantity = Convert.ToInt32(svgQuantity.Text); int mmId = Convert.ToInt32(svgMm.SelectedValue); // END FORM ================================================================== //get the template size id from the uloaded file templateSize myTemp = new templateSize(); int templateSizeId = myTemp.detectTemplate(fullPath); if (templateSizeId == 0) { // is not a valid template - show error errors errType = new errors(); errType.errTemplate(); openError(errType.currentError + errType.helpUrl); errType = null; return; } //show template size on screen lblSvgTemplateSize.Text = "Template size " + myTemp.txtTemplateSize; myTemp = null; //load the svg doc into the svg library SvgDoc myDoc = new SvgDoc(); myDoc.LoadFromFile(fullPath); SVGLib.SvgElement elYourDesigns = myDoc.GetSvgElement("Your_Designs"); if (elYourDesigns.getChild() != null) { AddFromSvg2(elYourDesigns); } else { //check inkscape added group labled "Your Designs" // get the id by searching for the label then us the ID with getSvgElement inkscapeGroupFix gf = new inkscapeGroupFix(); string groupId = gf.getgroupId("Your Designs", fullPath, "Your Designs"); if (groupId == "") { //throw error, no design detected errors errType = new errors(); errType.errDesign(); openError(errType.currentError + errType.helpUrl); errType = null; return; } else { elYourDesigns = myDoc.GetSvgElement(groupId); AddFromSvg2(elYourDesigns); } gf = null; } myDoc = null; List <shapePrice> priceArray = allShapes; zapQuote newQuote = new zapQuote(materialId, templateSizeId, mmId); //check if error returned from AddFromSvg if (isValidSvgDesign == false) { //show error and halt progress openError(svgError); return; } foreach (shapePrice i in priceArray) { newQuote.appendShapeData(i.length, i.area, i.zapType, i.height, i.xpos, i.ypos); // raster line area from objects rasterExtraArea += i.rasterArea; } //calculate extra raster area from coordinates if (rasterPoints.Count > 0) { //find 4 outer points and calculate area as a rectangle double lX = rasterPoints.Min(c => c.X); double rX = rasterPoints.Max(c => c.X); double tY = rasterPoints.Min(c => c.Y); double bY = rasterPoints.Max(c => c.Y); rasterExtraArea = Common.rasterAreaFromPoints(lX, rX, tY, bY); extraHeight = Common.rasterHeight(tY, bY); } newQuote.calcTotalTime(materialId, templateSizeId, mmId, rasterExtraArea, extraHeight); materialPrice mPrice = new materialPrice(); mPrice.getMaterialPrices(materialId, templateSizeId, mmId); //cut lines price decimal cutPrice = Convert.ToDecimal(newQuote.cutTime * mPrice.costCutSec); // engrave lines decimal engravePrice = Convert.ToDecimal(newQuote.engraveTime * mPrice.costVectorSec); // raster engrave //decimal rasterPrice = Convert.ToDecimal((newQuote.totalAreaFill / 100) * mPrice.costRasterPerSqCm); decimal rasterPrice = Convert.ToDecimal(newQuote.fillTime * mPrice.costRasterPerSec); decimal totalLaserPrice = cutPrice + engravePrice + rasterPrice; decimal materialCost = Convert.ToDecimal(mPrice.pricePerUnit); decimal unitPrice = totalLaserPrice + materialCost; decimal totalPrice = unitPrice * quantity; //populate labels / session values StringBuilder quoteInfo = new StringBuilder(); quoteInfo.Append("<ul>"); quoteInfo.Append("<li><b>File Cost</b>"); quoteInfo.Append("<div class='formInfo'>- " + fName + " = <span class='formBlue'>" + string.Format(CultureInfo.CreateSpecificCulture("en-GB"), "{0:C}", totalLaserPrice) + "</span></div>"); quoteInfo.Append("<div class='formInfo'>- Quantity = <span class='formBlue'>x" + quantity + "</span></div>"); quoteInfo.Append("<div class='formBlue'>Total File Cost = " + string.Format(CultureInfo.CreateSpecificCulture("en-GB"), "{0:C}", totalLaserPrice * quantity) + "</div>"); quoteInfo.Append("</li>"); quoteInfo.Append("<li><b>Material Cost</b>"); quoteInfo.Append("<div class='formInfo'>- " + svgMaterial.SelectedItem.Text + "</div>"); quoteInfo.Append("<div class='formInfo'>- " + svgMm.SelectedItem.Text + "</div>"); quoteInfo.Append("<div class='formInfo'>- " + materialColour.SelectedItem.Text + "</div>"); quoteInfo.Append("<div class='formInfo'>- = <span class='formBlue'>" + string.Format(CultureInfo.CreateSpecificCulture("en-GB"), "{0:C}", materialCost) + "</span></div>"); quoteInfo.Append("<div class='formInfo'>- Quantity = <span class='formBlue'>x" + quantity + "</span></div>"); quoteInfo.Append("<div class='formInfo'>- Total material cost= <span class='formBlue'>" + string.Format(CultureInfo.CreateSpecificCulture("en-GB"), "{0:C}", materialCost * quantity) + "</span></div>"); quoteInfo.Append("</li>"); quoteInfo.Append("<li><b>Total Cost</b> <span class='formBlue'>" + string.Format(CultureInfo.CreateSpecificCulture("en-GB"), "{0:C}", totalPrice) + "</span>"); quoteInfo.Append("</li>"); quoteInfo.Append("</ul>"); divQuote.InnerHtml = quoteInfo.ToString(); quoteInfo = null; StringBuilder debugInfo = new StringBuilder(); debugInfo.Append("<p>Cut price:" + cutPrice + "</p>"); debugInfo.Append("<p>Cut time:" + newQuote.cutTime + "</p>"); debugInfo.Append("<p>Cut length mm:" + newQuote.totalCutLength + "</p>"); debugInfo.Append("<p>Cut cost per sec:" + mPrice.costCutSec + "</p>"); debugInfo.Append("<p>Number of cuts:" + newQuote.cutCount + "</p>"); debugInfo.Append("<p>Cut area:" + newQuote.totalCutArea + "</p>"); debugInfo.Append("<p>Vector engrave price:" + engravePrice + "</p>"); debugInfo.Append("<p>Vector engrave time:" + newQuote.engraveTime + "</p>"); debugInfo.Append("<p>Vector engrave cost per sec:" + mPrice.costVectorSec + "</p>"); debugInfo.Append("<p>Vector engrave light length:" + newQuote.totalLightEngrave + "</p>"); debugInfo.Append("<p>Vector engrave med length:" + newQuote.totalMedEngrave + "</p>"); debugInfo.Append("<p>Vector engrave heavy length:" + newQuote.totalHeavyEngrave + "</p>"); debugInfo.Append("<p>Raster price:" + rasterPrice + "</p>"); debugInfo.Append("<p>Raster time:" + newQuote.fillTime + "</p>"); debugInfo.Append("<p>Raster cost per sec:" + mPrice.costRasterPerSec + "</p>"); debugInfo.Append("<p>Raster area:" + newQuote.rasterArea + "</p>"); litErr.Text = debugInfo.ToString(); debugInfo = null; }
public int detectTemplate(string docPath) { // XDocument test = XDocument.Load(docPath); // IEnumerable<XElement> users = (from el in test.Root.Descendants() where (string)el.Attribute("id") == "Your_Designs" select el); // XElement element = users.First(); // string mc = element.Attribute("class").Value.ToString(); // another change 15 june 2012 now using fill value from nested path in group with id = borders string pathFill = ""; SvgDoc myDoc = new SvgDoc(); myDoc.LoadFromFile(docPath); SVGLib.SvgElement elBorders = myDoc.GetSvgElement("Borders"); if (elBorders != null) { if (elBorders.getChild() != null) { SvgElement pathBorder = elBorders.getChild(); pathData myPath = new pathData((SvgPath)pathBorder); pathFill = myPath.fillColor; pathBorder = null; myPath = null; } } else { // check if is an inkscape //check inkscape added group labled "Borders" // get the id by searching for the label then us the ID with getSvgElement inkscapeGroupFix gf = new inkscapeGroupFix(); string groupId = gf.getgroupId("Borders", docPath, "Borders"); if (groupId == "") { //show template error - not recognised } else { //get the fill colour elBorders = myDoc.GetSvgElement(groupId); SvgElement pathBorder = elBorders.getChild(); pathData myPath = new pathData((SvgPath)pathBorder); string pathStyle = myPath.style; extractStyle rStyle = new extractStyle(); rStyle.getStyle(pathStyle); pathFill = rStyle.fillColour; //convert to RGB values Color htmlPath = ColorTranslator.FromHtml(pathFill); pathFill = Convert.ToString(htmlPath.R) + Convert.ToString(htmlPath.G) + Convert.ToString(htmlPath.B); rStyle = null; pathBorder = null; myPath = null; } myDoc = null; } //IEnumerable<XElement> users = test.Root.Descendants(); //string viewBox = svgTree.Attribute("viewBox").Value.ToString(); // chang to get the fill colour from the borders child path element TODO // pathData myPath = new pathData((SvgPath)elBorders.getChild()); // myShapes shapeData = new myShapes(); //string pathData = myPath.shapeData; //double length = shapeData.getPathLength(pathData); //int absLength = Convert.ToInt32(Math.Round(length)); //myDoc = null; // elBorders = null; //myPath = null; //shapeData = null; //svgTree = null; SqlConnection myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["zapCartDb"].ConnectionString); myConn.Open(); //SqlCommand myCmd = new SqlCommand("SELECT * FROM tbl_templateSizes where viewBox = @viewBox"); //SqlCommand myCmd = new SqlCommand("SELECT * FROM tbl_templateSizes where templateSizeText = @viewBox"); SqlCommand myCmd = new SqlCommand("SELECT * FROM tbl_templateSizes where borders = @borders"); myCmd.Connection = myConn; SqlParameter myParam = new SqlParameter(); myParam.ParameterName = "@borders"; //myParam.Value = viewBox; myParam.Value = pathFill; myCmd.Parameters.Add(myParam); SqlDataReader myReader = null; myReader = myCmd.ExecuteReader(); int templateSizeId = 0; while (myReader.Read()) { templateSizeId = (int)myReader["templateSizeId"]; txtTemplateSize = (string)myReader["templateSizeText"]; } myReader = null; myConn.Close(); myCmd = null; myConn = null; return(templateSizeId); }