Beispiel #1
0
        public void Run()
        {
            //FileStream r = new FileStream(this.mycgmpath, 3, 1);
            FileStream r = new FileStream(this.mycgmpath, FileMode.Open, FileAccess.Read);

            try
            {
                this.currentFileSize = r.Length;
                this._handler        = new CGM2SVGhandler();
                this.@ref            = new Reference(this.options);
                try
                {
                    this._handler.@ref        = this.@ref;
                    this._handler.elementlist = this.elementlist;
                    CGMScanner.ReadFile(r, this._handler);
                    this._handler = null;
                }
                finally
                {
                    [email protected]();
                }
            }
            finally
            {
                r.Close();
            }
            if (this.ConvertCompleteEvent != null)
            {
                this.ConvertCompleteEvent(this.mycgmpath);
            }
        }
Beispiel #2
0
        //// 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();
            }
        }