private void _handler_ElementProcessed(CGMElement el) { if (this.ProgressChangeEvent != null) { this.ProgressChangeEvent((int)Math.Round((((double)(el.Offset + el.Data.Length)) / ((double)this.currentFileSize)) * 100.0)); } }
// Methods public static bool class7(CGMElement element, SVGContext mycontext, XmlTextWriter myxml) { switch (element.ElementId) { case 1: { int num = mycontext.Reader.ReadE(); string str = mycontext.Reader.ReadS(); myxml.WriteStartElement("qsvg:string"); myxml.WriteAttributeString("identifier", num.ToString()); myxml.WriteAttributeString("value", str); myxml.WriteEndElement(); break; } case 2: { int num2 = mycontext.Reader.ReadI(); byte[] buffer = mycontext.Reader.ReadD(); myxml.WriteStartElement("qsvg:data"); myxml.WriteAttributeString("identifier", num2.ToString()); myxml.WriteAttributeString("value", Convert.ToBase64String(buffer)); myxml.WriteEndElement(); break; } default: return(false); } return(true); }
//// Events //public event ElementProcessedEventHandler ElementProcessed { // [MethodImpl(MethodImplOptions.Synchronized)] // add { // this.ElementProcessedEvent = Delegate.Combine(this.ElementProcessedEvent, obj); // } // [MethodImpl(MethodImplOptions.Synchronized)] // remove { // this.ElementProcessedEvent = Delegate.Remove(this.ElementProcessedEvent, obj); // } //} //public event ExceptionOccuredEventHandler ExceptionOccured { // [MethodImpl(MethodImplOptions.Synchronized)] // add { // this.ExceptionOccuredEvent = Delegate.Combine(this.ExceptionOccuredEvent, obj); // } // [MethodImpl(MethodImplOptions.Synchronized)] // remove { // this.ExceptionOccuredEvent = Delegate.Remove(this.ExceptionOccuredEvent, obj); // } //} // Methods protected override void OnElement(CGMElement el) { try { if ((el.ElementClass == 1) && (el.ElementId == 12)) { MemoryStream r = new MemoryStream(el.Data, false); CGMScanner.ReadFile(r, this); } else { using (CGMBinaryReader reader = this.GetReader(el)) { [email protected] = reader; [email protected](el); this.elementlist.Add(ElementDictionary.GetInstance().FindElement(el.ElementClass, el.ElementId) + " " + el.ElementId.ToString() + " : " + el.ElementClass.ToString()); if (this.ElementProcessedEvent != null) { this.ElementProcessedEvent(el); } } } } catch (Exception exception1) { //ProjectData.SetProjectError(exception1); Exception ex = exception1; if (this.ExceptionOccuredEvent != null) { this.ExceptionOccuredEvent(el, ex); } //ProjectData.ClearProjectError(); } }
public void ElementWrite(CGMElement element) { bool flag = false; try { switch (element.ElementClass) { case 0: flag = EClass0.class0(element, this.mycontext, this.myxml); return; case 1: flag = EClass1.class1(element, this.mycontext, this.myxml); return; case 2: flag = EClass2.class2(element, this.mycontext, this.myxml); return; case 3: flag = EClass3.class3(element, this.mycontext, this.myxml); return; case 4: flag = EClass4.class4(element, this.mycontext, this.myxml); return; case 5: flag = EClass5.class5(element, this.mycontext, this.myxml); return; case 6: case 8: return; case 7: flag = EClass6.class7(element, this.mycontext, this.myxml); return; case 9: break; default: return; } flag = EClass6.class9(element, this.mycontext, this.myxml); } catch (Exception exception1) { //ProjectData.SetProjectError(exception1); Exception exception = exception1; if (exception.Message == "Invalid Use.")//if (StringType.StrCmp(exception.Message, "Invalid Use.", false) == 0) { throw new Exception("This conversion is being called from an invalid source, Please contract Docsoft Inc. if the probem continues."); } throw new Exception(element.ElementClass.ToString() + " " + element.ElementId.ToString() + " - " + ElementDictionary.GetInstance().FindElement(element.ElementClass, element.ElementId) + " - " + exception.ToString()); } }
private void _handler_ExceptionOccured(CGMElement el, Exception ex) { if (this.options.StrictMode) { throw new CGM2SVGException("CGM2SVG conversion exception at " + (int)el.Offset + " --> " + ex.Message, (long)el.Offset, ex); } Trace.WriteLine("Error at " + el.Offset.ToString("X8")); Trace.WriteLine(ex); }
public static bool class9(CGMElement element, SVGContext mycontext, XmlTextWriter myxml) { if (element.ElementId == 1) { string str = mycontext.Reader.ReadS(); SDR sdr = mycontext.Reader.ReadSDR(); myxml.WriteStartElement("qsvg:sdrData"); myxml.WriteAttributeString("type", str); WriteSDR(myxml, sdr); myxml.WriteEndElement(); return(true); } return(false); }
// Methods public static bool class1(CGMElement element, SVGContext mycontext, XmlTextWriter myxml) { switch (element.ElementId) { case 1: mycontext.version = mycontext.Reader.ReadI(); myxml.WriteComment("Version: " + mycontext.version.ToString().Trim()); break; case 2: myxml.WriteComment("MetaFile Description: " + mycontext.Reader.ReadS().Trim()); break; case 9: mycontext.MaxColourIndex = Convert.ToInt32(mycontext.Reader.ReadCI()); break; case 10: mycontext.mincolor = mycontext.Reader.ReadCD(); mycontext.maxcolor = mycontext.Reader.ReadCD(); break; case 12: break; case 13: { ArrayList list = new ArrayList(); while (!mycontext.Reader.EOF) { list.Add(mycontext.Reader.ReadS()); } mycontext.Fonts = (string[])list.ToArray(typeof(string)); mycontext.Font = mycontext.Fonts[0]; break; } case 0x12: mycontext.SegPriExtMin = mycontext.Reader.ReadI(); mycontext.segPriExtMax = mycontext.Reader.ReadI(); break; default: return(false); } return(true); }
public static bool class3(CGMElement element, SVGContext mycontext, XmlTextWriter myxml) { switch (element.ElementId) { case 3: mycontext.AuxColorC = RuntimeHelpers.GetObjectValue(mycontext.Reader.ReadCO()); break; case 4: mycontext.transparent = mycontext.Reader.ReadE() > 0; break; case 5: { CGMClip clip = new CGMClip { ClipPoint1 = mycontext.Reader.ReadP(), ClipPoint2 = mycontext.Reader.ReadP() }; clip.UpdateSVG(myxml, mycontext); mycontext.CurrClipID = clip.ClipID; break; } case 6: { int num = mycontext.Reader.ReadE(); mycontext.isClip = num == 0 ? false : true; break; } case 10: mycontext.newregion = true; break; case 0x13: mycontext.MetreLimit = mycontext.Reader.ReadR(); break; default: return(false); } return(true); }
// Methods public static bool class4(CGMElement element, SVGContext mycontext, XmlTextWriter myxml) { CGM.Scanner.Point[] pointArray; switch (element.ElementId) { case 1: { ArrayList list = new ArrayList(); while (!mycontext.Reader.EOF) { list.Add(mycontext.Reader.ReadP()); } CGMPolyLine line = new CGMPolyLine { points = (CGM.Scanner.Point[])list.ToArray(typeof(CGM.Scanner.Point)) }; if (mycontext.CurrFigure == null) { line.UpdateSVG(myxml, mycontext); } else { mycontext.figline = true; mycontext.CurrFigure.AddPath(line.GetPath(mycontext), mycontext); } break; } case 2: { ArrayList list2 = new ArrayList(); while (!mycontext.Reader.EOF) { list2.Add(mycontext.Reader.ReadP()); } CGMDisjoint disjoint = new CGMDisjoint { points = (CGM.Scanner.Point[])list2.ToArray(typeof(CGM.Scanner.Point)) }; if (mycontext.CurrFigure == null) { disjoint.UpdateSVG(myxml, mycontext); } else { mycontext.figline = true; mycontext.CurrFigure.AddPath(disjoint.GetPath(mycontext), mycontext); } break; } case 4: { CGM4Text text = new CGM4Text { Position = mycontext.Reader.ReadP() }; int num = mycontext.Reader.ReadE(); text.Text = mycontext.Reader.ReadS(); if (num != 0) { mycontext.Final = true; text.UpdateSVG(myxml, mycontext); } else { mycontext.Final = false; SVGContext context = (SVGContext)mycontext.Clone(); text.appendcontext.Add(context); mycontext.AppendTxt4 = text; mycontext.Appfour = true; } break; } case 5: { CGMText text2 = new CGMText(); SizeF ef = new SizeF((float)mycontext.Reader.ReadVDC(), (float)mycontext.Reader.ReadVDC()); text2.TextSize = ef; text2.Position = mycontext.Reader.ReadP(); int num2 = mycontext.Reader.ReadE(); text2.Text = mycontext.Reader.ReadS(); if (num2 != 1) { mycontext.Final = false; SVGContext context2 = (SVGContext)mycontext.Clone(); text2.appendcontext.Add(context2); mycontext.AppendTxt = text2; mycontext.Appfour = false; } else { text2.UpdateSVG(myxml, mycontext); } break; } case 6: if (mycontext.Final) { mycontext.Final = false; } else { int num3 = mycontext.Reader.ReadE(); string str = mycontext.Reader.ReadS(); if (num3 != 1) { if (mycontext.Appfour) { CGM4Text text5 = mycontext.AppendTxt4; text5.appendtext.Add(str); SVGContext context3 = (SVGContext)mycontext.Clone(); text5.appendcontext.Add(context3); mycontext.Appfour = true; } else { CGMText appendTxt = mycontext.AppendTxt; appendTxt.appendtext.Add(str); SVGContext context4 = (SVGContext)mycontext.Clone(); appendTxt.appendcontext.Add(context4); mycontext.Appfour = false; } } else if (!mycontext.Appfour) { CGMText text4 = mycontext.AppendTxt; text4.appendtext.Add(str); text4.UpdateSVGwContext(myxml, mycontext); mycontext.Final = true; mycontext.AppendTxt = null; } else { CGM4Text text3 = mycontext.AppendTxt4; text3.appendtext.Add(str); text3.UpdateSVGwContext(myxml, mycontext); mycontext.Final = true; mycontext.AppendTxt4 = null; } } break; case 7: { ArrayList list3 = new ArrayList(); while (!mycontext.Reader.EOF) { list3.Add(mycontext.Reader.ReadP()); } list3.Add(RuntimeHelpers.GetObjectValue(list3[0])); CGMPoly poly = new CGMPoly { points = (CGM.Scanner.Point[])list3.ToArray(typeof(CGM.Scanner.Point)) }; if (mycontext.CurrFigure == null) { if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateBeginSVGLink(ref myxml, mycontext); } poly.UpdateSVG(myxml, mycontext); if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateEndSVGLink(ref myxml, mycontext); } } else { mycontext.newregion = true; mycontext.CurrFigure.AddPath(poly.GetPath(mycontext), mycontext); } break; } case 8: { ArrayList list4 = new ArrayList(); ArrayList list5 = new ArrayList(); while (!mycontext.Reader.EOF) { list4.Add(mycontext.Reader.ReadP()); list5.Add(mycontext.Reader.ReadE()); } CGMPolySet set = new CGMPolySet { points = (CGM.Scanner.Point[])list4.ToArray(typeof(CGM.Scanner.Point)), flags = (int[])list5.ToArray(typeof(int)) }; if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateBeginSVGLink(ref myxml, mycontext); } set.UpdateSVG(myxml, mycontext); if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateEndSVGLink(ref myxml, mycontext); } break; } case 9: { MakeCellArray array = new MakeCellArray(mycontext) { p = mycontext.Reader.ReadP(), q = mycontext.Reader.ReadP(), r = mycontext.Reader.ReadP(), nx = mycontext.Reader.ReadI(), ny = mycontext.Reader.ReadI(), LCP = mycontext.Reader.ReadI(), cellmode = mycontext.Reader.ReadE(), data = mycontext.Reader.ReadBS(-1) }; array.MakeArray(); array.updatesvg(myxml); break; } case 11: { CGMRect rect = new CGMRect { topleft = mycontext.Reader.ReadP(), bottomright = mycontext.Reader.ReadP() }; if (mycontext.CurrFigure != null) { mycontext.newregion = true; mycontext.CurrFigure.AddPath(rect.GetPath(mycontext), mycontext); } else { if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateBeginSVGLink(ref myxml, mycontext); } rect.UpdateSVG(myxml, mycontext); if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateEndSVGLink(ref myxml, mycontext); } } break; } case 12: { CGMCircle circle = new CGMCircle { center = mycontext.Reader.ReadP(), radius = Convert.ToInt32(mycontext.Reader.ReadVDC()) }; if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateBeginSVGLink(ref myxml, mycontext); } if (mycontext.CurrFigure != null) { mycontext.newregion = true; mycontext.CurrFigure.AddPath(circle.GetPath(mycontext), mycontext); } else { if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateBeginSVGLink(ref myxml, mycontext); } circle.UpdateSVG(myxml, mycontext); if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateEndSVGLink(ref myxml, mycontext); } } break; } case 13: { CGMArc arc = new CGMArc(); pointArray = new CGM.Scanner.Point[] { mycontext.Reader.ReadP(), mycontext.Reader.ReadP(), mycontext.Reader.ReadP() }; arc.SetCircle3Points(pointArray); if (mycontext.CurrFigure != null) { mycontext.CurrFigure.AddPath(arc.GetPath(mycontext), mycontext); } else { arc.UpdateSVG(myxml, mycontext); } break; } case 14: { CGMArc arc2 = new CGMArc(); pointArray = new CGM.Scanner.Point[] { mycontext.Reader.ReadP(), mycontext.Reader.ReadP(), mycontext.Reader.ReadP() }; arc2.SetCircle3Points(pointArray); arc2.closingType = mycontext.Reader.ReadE(); if (mycontext.CurrFigure != null) { mycontext.newregion = true; mycontext.CurrFigure.AddPath(arc2.GetPath(mycontext), mycontext); } else { if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateBeginSVGLink(ref myxml, mycontext); } arc2.UpdateSVG(myxml, mycontext); if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateEndSVGLink(ref myxml, mycontext); } } break; } case 15: { CGMArc arc3 = new CGMArc { center = mycontext.Reader.ReadP(), v1 = { X = Convert.ToDecimal(mycontext.Reader.ReadVDC()), Y = Convert.ToDecimal(mycontext.Reader.ReadVDC()) }, v2 = { X = Convert.ToDecimal(mycontext.Reader.ReadVDC()), Y = Convert.ToDecimal(mycontext.Reader.ReadVDC()) } }; double r = Convert.ToDouble(mycontext.Reader.ReadVDC()); arc3.SetCircleDiameters(r, false); if (mycontext.CurrFigure != null) { mycontext.CurrFigure.AddPath(arc3.GetPath(mycontext), mycontext); } else { arc3.UpdateSVG(myxml, mycontext); } break; } case 0x10: { CGMArc arc4 = new CGMArc { center = mycontext.Reader.ReadP(), v1 = { X = Convert.ToDecimal(mycontext.Reader.ReadVDC()), Y = Convert.ToDecimal(mycontext.Reader.ReadVDC()) }, v2 = { X = Convert.ToDecimal(mycontext.Reader.ReadVDC()), Y = Convert.ToDecimal(mycontext.Reader.ReadVDC()) } }; double num5 = Convert.ToDouble(mycontext.Reader.ReadVDC()); arc4.SetCircleDiameters(num5, false); arc4.closingType = mycontext.Reader.ReadE(); if (mycontext.CurrFigure != null) { mycontext.newregion = true; mycontext.CurrFigure.AddPath(arc4.GetPath(mycontext), mycontext); } else { if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateBeginSVGLink(ref myxml, mycontext); } arc4.UpdateSVG(myxml, mycontext); if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateEndSVGLink(ref myxml, mycontext); } } break; } case 0x11: { CGMEllipse ellipse = new CGMEllipse { center = mycontext.Reader.ReadP(), cd1 = mycontext.Reader.ReadP(), cd2 = mycontext.Reader.ReadP() }; if (mycontext.CurrFigure != null) { mycontext.newregion = true; mycontext.CurrFigure.AddPath(ellipse.GetPath(mycontext), mycontext); } else { if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateBeginSVGLink(ref myxml, mycontext); } ellipse.UpdateSVG(myxml, mycontext); if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateEndSVGLink(ref myxml, mycontext); } } break; } case 0x12: new CGMArc { center = mycontext.Reader.ReadP(), cd1 = mycontext.Reader.ReadP(), cd2 = mycontext.Reader.ReadP(), v1 = { X = Convert.ToDecimal(mycontext.Reader.ReadVDC()), Y = Convert.ToDecimal(mycontext.Reader.ReadVDC()) }, v2 = { X = Convert.ToDecimal(mycontext.Reader.ReadVDC()), Y = Convert.ToDecimal(mycontext.Reader.ReadVDC()) } }.UpdateSVG(myxml, mycontext); break; case 0x13: new CGMArc { center = mycontext.Reader.ReadP(), cd1 = mycontext.Reader.ReadP(), cd2 = mycontext.Reader.ReadP(), v1 = { X = Convert.ToDecimal(mycontext.Reader.ReadVDC()), Y = Convert.ToDecimal(mycontext.Reader.ReadVDC()) }, v2 = { X = Convert.ToDecimal(mycontext.Reader.ReadVDC()), Y = Convert.ToDecimal(mycontext.Reader.ReadVDC()) }, closingType = mycontext.Reader.ReadE() }.UpdateSVG(myxml, mycontext); break; case 0x15: mycontext.connectingedge = true; break; case 0x1a: { CGMPolyBez bez = new CGMPolyBez { Continue = mycontext.Reader.ReadIX() == 1 ? false : true }; ArrayList list6 = new ArrayList(); while (!mycontext.Reader.EOF) { list6.Add(mycontext.Reader.ReadP()); } bez.Points = (CGM.Scanner.Point[])list6.ToArray(typeof(CGM.Scanner.Point)); if (mycontext.CurrFigure == null) { bez.UpdateSVG(myxml, mycontext); } else { mycontext.CurrFigure.AddPath(bez.GetPath(mycontext), mycontext); } break; } case 0x1c: { mycontext.Reader.ReadIX(); mycontext.Reader.ReadI(); mycontext.Reader.ReadCO(); mycontext.Reader.ReadCO(); mycontext.Reader.ReadSDR(); byte[] buffer = mycontext.Reader.ReadBS(-1); mycontext.prevtiles.Tiles.Add(buffer); mycontext.prevtiles.isBitonal = true; break; } case 0x1d: { mycontext.Reader.ReadIX(); mycontext.Reader.ReadI(); mycontext.Reader.ReadI(); mycontext.Reader.ReadSDR(); byte[] buffer2 = mycontext.Reader.ReadBS(-1); mycontext.prevtiles.Tiles.Add(buffer2); mycontext.prevtiles.Tiles.Add(buffer2); mycontext.prevtiles.isBitonal = false; break; } default: return(false); } return(true); }
// Methods public static bool class2(CGMElement element, SVGContext mycontext, XmlTextWriter myxml) { switch (element.ElementId) { case 3: mycontext.linewidthmode = mycontext.Reader.ReadE(); break; case 5: mycontext.edgewidthmode = mycontext.Reader.ReadE(); break; case 6: { mycontext.vdclb = mycontext.Reader.ReadP(); mycontext.vdcrt = mycontext.Reader.ReadP(); mycontext.ow = Convert.ToDouble(Math.Abs(decimal.Subtract(mycontext.vdclb.X, mycontext.vdcrt.X))); mycontext.oh = Convert.ToDouble(Math.Abs(decimal.Subtract(mycontext.vdclb.Y, mycontext.vdcrt.Y))); CGM.Scanner.Point point = new CGM.Scanner.Point(new decimal(mycontext.options.ViewBox.Location.X), new decimal(mycontext.options.ViewBox.Location.Y)); mycontext.rtl = point; mycontext.rw = Convert.ToInt32(Math.Round(mycontext.ow)); mycontext.rh = Convert.ToInt32(Math.Round(mycontext.oh)); mycontext.scale = 1.0; if (mycontext.options.FitInBox || mycontext.options.EnlargeInBox) { double num2 = mycontext.ow / ((double)mycontext.options.ViewBox.Width); double num = mycontext.oh / ((double)mycontext.options.ViewBox.Height); if (num2 < num) { if (((num > 1.0) && mycontext.options.FitInBox) || ((num < 1.0) && mycontext.options.EnlargeInBox)) { mycontext.scale = num; mycontext.rw = Convert.ToInt32(Math.Round(mycontext.ow / num)); mycontext.rh = Convert.ToInt32(Math.Round((double)mycontext.options.ViewBox.Width)); } } else if (((num2 > 1.0) && mycontext.options.FitInBox) || ((num2 < 1.0) && mycontext.options.EnlargeInBox)) { mycontext.scale = num2; mycontext.rw = Convert.ToInt32(Math.Round((double)mycontext.options.ViewBox.Width)); mycontext.rh = Convert.ToInt32(Math.Round(mycontext.oh / num2)); } } break; } case 7: mycontext.BackColor = mycontext.convertColor(mycontext.Reader.ReadCD()); break; case 11: { SVGContext.linebundlestruct linebundlestruct; int index = mycontext.Reader.ReadIX(); linebundlestruct.type = mycontext.Reader.ReadIX(); linebundlestruct.width = Convert.ToDouble(mycontext.Reader.ReadSS(true)); linebundlestruct.color = (Color)mycontext.Reader.ReadCO(); if ((mycontext.linebundle.Length - 1) < index) { mycontext.linebundle = mycontext.linebundle.Concat(new SVGContext.linebundlestruct[(index - 1) + 1]).ToArray();//mycontext.linebundle = Utils.CopyArray((Array)mycontext.linebundle, new SVGContext.linebundlestruct[(index - 1) + 1]); } mycontext.linebundle[index] = linebundlestruct; break; } case 13: { SVGContext.textbundlestruct textbundlestruct; int num4 = mycontext.Reader.ReadIX(); textbundlestruct.fontindex = mycontext.Reader.ReadIX().ToString(); textbundlestruct.precision = mycontext.Reader.ReadE(); textbundlestruct.spacing = mycontext.Reader.ReadR(); textbundlestruct.expansion = mycontext.Reader.ReadR(); textbundlestruct.color = (Color)mycontext.Reader.ReadCO(); if ((mycontext.textbundle.Length - 1) < num4) { //mycontext.textbundle = Utils.CopyArray((Array)mycontext.textbundle, new SVGContext.textbundlestruct[(num4 - 1) + 1]); mycontext.textbundle = mycontext.textbundle.Concat(new SVGContext.textbundlestruct[(num4 - 1) + 1]).ToArray(); } mycontext.textbundle[num4] = textbundlestruct; break; } case 14: { SVGContext.fillbundlestruct fillbundlestruct; int num5 = mycontext.Reader.ReadIX(); fillbundlestruct.style = mycontext.Reader.ReadE(); fillbundlestruct.color = (Color)mycontext.Reader.ReadCO(); fillbundlestruct.hatch = mycontext.Reader.ReadIX(); fillbundlestruct.pattern = mycontext.Reader.ReadIX(); if ((mycontext.fillbundle.Length - 1) < num5) { //mycontext.fillbundle = Utils.CopyArray((Array)mycontext.fillbundle, new SVGContext.fillbundlestruct[(num5 - 1) + 1]); mycontext.fillbundle = mycontext.fillbundle.Concat(new SVGContext.fillbundlestruct[(num5 - 1) + 1]).ToArray(); } mycontext.fillbundle[num5] = fillbundlestruct; break; } case 15: { SVGContext.edgebundlestruct edgebundlestruct; int num6 = mycontext.Reader.ReadIX(); edgebundlestruct.type = mycontext.Reader.ReadIX(); edgebundlestruct.width = Convert.ToDouble(mycontext.Reader.ReadSS(true)); edgebundlestruct.color = (Color)mycontext.Reader.ReadCO(); if ((mycontext.edgebundle.Length - 1) < num6) { //mycontext.edgebundle = Utils.CopyArray((Array)mycontext.edgebundle, new SVGContext.edgebundlestruct[(num6 - 1) + 1]); mycontext.edgebundle = mycontext.edgebundle.Concat(new SVGContext.edgebundlestruct[(num6 - 1) + 1]).ToArray(); } mycontext.edgebundle[num6] = edgebundlestruct; break; } default: return(false); } return(true); }
// Methods public static bool class5(CGMElement element, SVGContext mycontext, XmlTextWriter myxml) { switch (element.ElementId) { case 1: mycontext.linebundleindex = mycontext.Reader.ReadIX(); break; case 2: mycontext.Linetype = mycontext.Reader.ReadIX(); break; case 3: if (mycontext.linewidthmode != 0) { mycontext.Linewidth = mycontext.Reader.ReadR(); } else { mycontext.Linewidth = Convert.ToDouble(mycontext.Reader.ReadVDC()); } break; case 4: mycontext.LineColorC = RuntimeHelpers.GetObjectValue(mycontext.Reader.ReadCO()); break; case 9: mycontext.textbundleindex = mycontext.Reader.ReadIX(); break; case 10: { int index = mycontext.Reader.ReadIX() - 1; if (mycontext.Fonts == null || (index >= mycontext.Fonts.Length)) { mycontext.Font = "Arial"; } else { mycontext.Font = mycontext.Fonts[index]; } break; } case 13: mycontext.TextSpacing = mycontext.Reader.ReadR(); break; case 14: mycontext.TextColorC = RuntimeHelpers.GetObjectValue(mycontext.Reader.ReadCO()); break; case 15: mycontext.FontSize = Convert.ToDouble(mycontext.Reader.ReadVDC()); break; case 0x10: { double num3 = 0; double num6 = 0; double num8 = 0; double num10 = 0; double num12 = 0; double num13 = 0; int num7 = Convert.ToInt32(mycontext.Reader.ReadVDC()); int num11 = Convert.ToInt32(mycontext.Reader.ReadVDC()); int num5 = Convert.ToInt32(mycontext.Reader.ReadVDC()); int num9 = Convert.ToInt32(mycontext.Reader.ReadVDC()); double num4 = Math.Sqrt((double)((num7 * num7) + (num11 * num11))); double num2 = Math.Sqrt((double)((num5 * num5) + (num9 * num9))); if (num4 != 0.0) { num8 = ((double)num7) / num4; num12 = ((double)num11) / num4; } if (num2 != 0.0) { num6 = ((double)num5) / num2; num10 = ((double)num9) / num2; } if (mycontext.GetInversion() == 3) { num3 = -1.0; num13 = 0.0; } else if (mycontext.GetInversion() == 4) { num3 = -1.0; num13 = 0.0; num10 = -num10; } else { num3 = 1.0; num13 = 0.0; } if ((num6 != 0.0) | (num10 != 0.0)) { mycontext.TextRotateAngle = (Math.Acos(((num3 * num6) + (num13 * num10)) / (Math.Sqrt(1.0) * Math.Sqrt(Math.Pow(num10, 2.0) + Math.Pow(num6, 2.0)))) * 180.0) / 3.1415926535897931; if (num10 < 0.0) { mycontext.TextRotateAngle = -mycontext.TextRotateAngle; } } else { mycontext.TextRotateAngle = 0.0; } if ((((Math.Acos(((num8 * num6) + (num12 * num10)) / (Math.Sqrt(1.0) * Math.Sqrt(Math.Pow(num10, 2.0) + Math.Pow(num6, 2.0)))) * 180.0) / 3.1415926535897931) < 89.0) | (((Math.Acos(((num8 * num6) + (num12 * num10)) / (Math.Sqrt(1.0) * Math.Sqrt(Math.Pow(num10, 2.0) + Math.Pow(num6, 2.0)))) * 180.0) / 3.1415926535897931) > 91.0)) { mycontext.TextAngle = Math.Acos(((num8 * num6) + (num12 * num10)) / (Math.Sqrt(1.0) * Math.Sqrt(Math.Pow(num10, 2.0) + Math.Pow(num6, 2.0)))); } break; } case 0x11: mycontext.TextPath = mycontext.Reader.ReadE(); break; case 0x12: mycontext.TextAlignment = mycontext.Reader.ReadE(); mycontext.TextAlignmentVert = mycontext.Reader.ReadE(); mycontext.TextHContinuous = mycontext.Reader.ReadR(); mycontext.TextVContinuous = mycontext.Reader.ReadR(); break; case 0x15: mycontext.fillbundleindex = mycontext.Reader.ReadIX(); break; case 0x16: mycontext.interiorstyle = mycontext.Reader.ReadE(); if (mycontext.interiorstyle == 3) { mycontext.getHatch(myxml); } break; case 0x17: mycontext.FillColorC = RuntimeHelpers.GetObjectValue(mycontext.Reader.ReadCO()); break; case 0x18: mycontext.HatchIndex = mycontext.Reader.ReadIX(); break; case 0x1a: mycontext.edgebundleindex = mycontext.Reader.ReadIX(); break; case 0x1b: mycontext.edgetype = mycontext.Reader.ReadIX(); break; case 0x1c: if (mycontext.edgewidthmode != 0) { mycontext.edgewidth = mycontext.Reader.ReadR(); } else { mycontext.edgewidth = Convert.ToDouble(mycontext.Reader.ReadVDC()); } break; case 0x1d: mycontext.EdgeColorC = RuntimeHelpers.GetObjectValue(mycontext.Reader.ReadCO()); break; case 30: mycontext.edgevis = mycontext.Reader.ReadE(); break; case 0x22: { mycontext.startcolorindex = Convert.ToInt32(mycontext.Reader.ReadCI()); ArrayList list = new ArrayList(); while (!mycontext.Reader.EOF) { list.Add(mycontext.convertColor(mycontext.Reader.ReadCD())); } int num14 = list.Count; if (mycontext.colortable.Length < (mycontext.startcolorindex + num14)) { mycontext.colortable = mycontext.colortable.Concat(new Color[((mycontext.startcolorindex + num14) - 1) + 1]).ToArray();//mycontext.colortable = Utils.CopyArray((Array)mycontext.colortable, new Color[((mycontext.startcolorindex + num14) - 1) + 1]); } Array.Copy(list.ToArray(typeof(Color)), 0, mycontext.colortable, mycontext.startcolorindex, list.Count); if (mycontext.startcolorindex == 0) { mycontext.BackColor = Color.Empty; } break; } case 0x23: while (!mycontext.Reader.EOF) { int num15 = mycontext.Reader.ReadE(); mycontext.ASF[num15] = mycontext.Reader.ReadE(); } break; case 0x25: mycontext.linecap = mycontext.Reader.ReadIX(); break; case 0x26: mycontext.linejoin = mycontext.Reader.ReadIX(); break; case 0x2c: mycontext.edgecap = mycontext.Reader.ReadIX(); break; case 0x2d: mycontext.edgejoin = mycontext.Reader.ReadIX(); break; default: return(false); } return(true); }
// Methods public static bool class0(CGMElement element, SVGContext mycontext, XmlTextWriter myxml) { switch (element.ElementId) { case 1: //myxml.WriteComment("Begin MetaFile: " + mycontext.Reader.ReadS().Trim()); //foreach (Assembly assembly in AppDomain.get_CurrentDomain().GetAssemblies()) //{ // if (string.Compare(Path.GetExtension(assembly.get_Location()), ".exe", true) == 0) // { // object[] customAttributes = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true); // for (int i = 0; i < customAttributes.Length; i++) // { // AssemblyCompanyAttribute attribute = customAttributes[i]; // if (attribute.get_Company().StartsWith("DocSoft")) // { // break; // } // } // } //} //throw new Exception("Invalid Use."); case 3: { string str2 = mycontext.Reader.ReadS(); myxml.WriteStartElement("g"); myxml.WriteAttributeString("qsvg:picture", str2.Trim()); break; } case 4: if (!mycontext.BackColor.IsEmpty) { new CGMBackGround().WriteBackground(myxml, mycontext); } break; case 5: myxml.WriteFullEndElement(); break; case 8: mycontext.CurrFigure = new CGMFigure(); mycontext.fingureOn = true; break; case 9: if (mycontext.CurrFigure != null) { if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateBeginSVGLink(ref myxml, mycontext); } mycontext.CurrFigure.UpdateSVG(myxml, mycontext); if (Dynamic.Instance.Linked) { Dynamic.Instance.CreateEndSVGLink(ref myxml, mycontext); } mycontext.CurrFigure = null; } mycontext.fingureOn = false; mycontext.connectingedge = false; break; case 0x13: { mycontext.prevtiles = new CGMTiles(); mycontext.prevtiles.Position = mycontext.Reader.ReadP(); mycontext.Reader.ReadE(); mycontext.Reader.ReadE(); Size size = new Size(mycontext.Reader.ReadI(), mycontext.Reader.ReadI()); mycontext.prevtiles.NumberTiles = size; size = new Size(mycontext.Reader.ReadI(), mycontext.Reader.ReadI()); mycontext.prevtiles.TileSize = size; SizeF ef = new SizeF((float)mycontext.Reader.ReadR(), (float)mycontext.Reader.ReadR()); mycontext.prevtiles.PointSize = ef; CGM.Scanner.Point point = new CGM.Scanner.Point(mycontext.Reader.ReadI(), mycontext.Reader.ReadI()); mycontext.prevtiles.Offset = point; size = new Size(mycontext.Reader.ReadI(), mycontext.Reader.ReadI()); mycontext.prevtiles.ImageSize = size; break; } case 20: mycontext.prevtiles.UpdateSVG(myxml, mycontext); break; case 0x15: { string s = mycontext.Reader.ReadS(); string str4 = mycontext.Reader.ReadS(); mycontext.Reader.ReadE(); myxml.WriteStartElement("g"); myxml.WriteAttributeString("id", MakeId(s)); myxml.WriteAttributeString("qsvg:aps", s); myxml.WriteAttributeString("qsvg:type", str4); break; } case 0x16: myxml.WriteComment("aps body"); break; case 0x17: myxml.WriteFullEndElement(); break; default: return(false); } return(true); }