private Size SetExtent(int width, int height) {
     NativeMethods.tagSIZEL sz = new NativeMethods.tagSIZEL();
     sz.cx = width;
     sz.cy = height;
     bool resetExtents = DesignMode;
     try {
         Pixel2hiMetric(sz, sz);
         this.axOleObject.SetExtent(NativeMethods.ActiveX.DVASPECT_CONTENT, sz);
     }
     catch (COMException) {
         resetExtents = true;
     }
     if (resetExtents) {
         this.axOleObject.GetExtent(NativeMethods.ActiveX.DVASPECT_CONTENT, sz);
         try {
             this.axOleObject.SetExtent(NativeMethods.ActiveX.DVASPECT_CONTENT, sz);
         }
         catch (COMException e) {
             Debug.Fail(e.ToString());
         }
     }
     return GetExtent();        
 }
 private Size GetExtent() {
     NativeMethods.tagSIZEL sz = new NativeMethods.tagSIZEL();
     this.axOleObject.GetExtent(NativeMethods.ActiveX.DVASPECT_CONTENT, sz);
     HiMetric2Pixel(sz, sz);
     return new Size(sz.cx, sz.cy);
 }
Esempio n. 3
0
 private Size SetExtent(int width, int height) {
     Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "setting extent to "+width.ToString(CultureInfo.InvariantCulture)+" "+height.ToString(CultureInfo.InvariantCulture));
     NativeMethods.tagSIZEL sz = new NativeMethods.tagSIZEL();
     sz.cx = width;
     sz.cy = height;
     bool resetExtents = !IsUserMode();
     try {
         Pixel2hiMetric(sz, sz);
         GetOleObject().SetExtent(NativeMethods.ActiveX.DVASPECT_CONTENT, sz);
     }
     catch (COMException) {
         resetExtents = true;
     }
     if (resetExtents) {
         GetOleObject().GetExtent(NativeMethods.ActiveX.DVASPECT_CONTENT, sz);
         try {
             GetOleObject().SetExtent(NativeMethods.ActiveX.DVASPECT_CONTENT, sz);
         }
         catch (COMException e) {
             Debug.Fail(e.ToString());
         }
     }
     return GetExtent();        
 }