protected override void Dispose(bool disposing)
        {
            if (myOptimizedTexture != null)
            {
                myOptimizedTexture.Dispose();                 // first stop this one because it does the updating
            }
            myOptimizedTexture = null;

            if (myRenderWindow != null)
            {
                myRenderWindow.Kill();
            }
            myRenderWindow = null;

            if (myAdjustMetricForm != null)
            {
                myAdjustMetricForm.Dispose();
            }
            myAdjustMetricForm = null;

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
 // this cannot be part of the deserializing constructor
 internal void SetEditor(ContourEditor editor, AdjustMetricForm form, RenderWindow window)
 {
     myEditor           = editor;
     myAdjustMetricForm = form;
     myAdjustMetricForm.LoadValues(anglePositionValue, allIntersectionsValue);
     myRenderWindow = window;
     myRenderWindow.SetBaseTexture(optimizedArrayWork, HiresImage);
 }
        public ContourEditor()
        {
            InitializeComponent();
            SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

            Assembly assem = Assembly.GetAssembly(typeof(ContourEditor));
            Stream   st    = assem.GetManifestResourceStream("BilievelTextureMagnification.Curvy.jpg");

            myOptimizedTexture = new OptimizedTexture(st, getDownsampling());
            st.Close();
            st = null;

            myAdjustMetricForm = new AdjustMetricForm();
            myRenderWindow     = RenderWindow.Create();
            myOptimizedTexture.SetEditor(this, myAdjustMetricForm, myRenderWindow);
            AutoScrollMinSize = myOptimizedTexture.GetSize(getZoom());
            Dirty();
        }