void UnsafeNativeMethods.IOleControlSite.TransformCoords(NativeMethods._POINTL pPtlHimetric, NativeMethods.tagPOINTF pPtfContainer, NativeMethods.tagXFORMCOORDS dwFlags) { if ((dwFlags & NativeMethods.tagXFORMCOORDS.XFORMCOORDS_HIMETRICTOCONTAINER) != 0) { if ((dwFlags & NativeMethods.tagXFORMCOORDS.XFORMCOORDS_SIZE) != 0) { pPtfContainer.x = ActiveXHelper.HM2Pix(pPtlHimetric.x, ActiveXHelper.LogPixelsX); pPtfContainer.y = ActiveXHelper.HM2Pix(pPtlHimetric.y, ActiveXHelper.LogPixelsY); return; } if ((dwFlags & NativeMethods.tagXFORMCOORDS.XFORMCOORDS_POSITION) != 0) { pPtfContainer.x = ActiveXHelper.HM2Pix(pPtlHimetric.x, ActiveXHelper.LogPixelsX); pPtfContainer.y = ActiveXHelper.HM2Pix(pPtlHimetric.y, ActiveXHelper.LogPixelsY); return; } throw new COMException("IOleControlSite", (int)NativeMethods.HRESULT.E_INVALIDARG); } if ((dwFlags & NativeMethods.tagXFORMCOORDS.XFORMCOORDS_CONTAINERTOHIMETRIC) != 0) { if ((dwFlags & NativeMethods.tagXFORMCOORDS.XFORMCOORDS_SIZE) != 0) { pPtlHimetric.x = ActiveXHelper.Pix2HM((int)pPtfContainer.x, ActiveXHelper.LogPixelsX); pPtlHimetric.y = ActiveXHelper.Pix2HM((int)pPtfContainer.y, ActiveXHelper.LogPixelsY); return; } if ((dwFlags & NativeMethods.tagXFORMCOORDS.XFORMCOORDS_POSITION) != 0) { pPtlHimetric.x = ActiveXHelper.Pix2HM((int)pPtfContainer.x, ActiveXHelper.LogPixelsX); pPtlHimetric.y = ActiveXHelper.Pix2HM((int)pPtfContainer.y, ActiveXHelper.LogPixelsY); return; } } throw new COMException("IOleControlSite", (int)NativeMethods.HRESULT.E_INVALIDARG); }
private void OnNewSelection(object sender, EventArgs e) { if (base.DesignMode) { ISelectionService selectionService = ActiveXHelper.GetSelectionService(this); if (selectionService != null) { if (!selectionService.GetComponentSelected(this)) { if (this.activeXEditMode != ActiveXHelper.ActiveXEditMode.None) { this.GetParentContainer().OnExitEditMode(this); this.SetEditMode(ActiveXHelper.ActiveXEditMode.None); } this.SetSelectionStyle(ActiveXHelper.SelectionStyle.Selected); this.RemoveSelectionHandler(); } else { PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(this)["SelectionStyle"]; if ((propertyDescriptor != null) && (propertyDescriptor.PropertyType == typeof(int))) { int selectionStyle = (int)propertyDescriptor.GetValue(this); if (((ActiveXHelper.SelectionStyle)selectionStyle) != this.selectionStyle) { propertyDescriptor.SetValue(this, this.selectionStyle); } } } } } }
private void AddSelectionHandler() { if (!this.GetActiveXHostState(ActiveXHelper.AddedSelectionHandler)) { this.SetActiveXHostState(ActiveXHelper.AddedSelectionHandler, true); ISelectionService selectionService = ActiveXHelper.GetSelectionService(this); if (selectionService != null) { selectionService.SelectionChanging += this.SelectionChangeHandler; } } }
private bool RemoveSelectionHandler() { bool addedSelectionHandler = this.GetActiveXHostState(ActiveXHelper.AddedSelectionHandler); if (addedSelectionHandler) { this.SetActiveXHostState(ActiveXHelper.AddedSelectionHandler, false); ISelectionService selectionService = ActiveXHelper.GetSelectionService(this); if (selectionService != null) { selectionService.SelectionChanging -= this.SelectionChangeHandler; } } return(addedSelectionHandler); }
private void SetSelectionStyle(ActiveXHelper.SelectionStyle selectionStyle) { if (base.DesignMode) { ISelectionService selectionService = ActiveXHelper.GetSelectionService(this); this.selectionStyle = selectionStyle; if ((selectionService != null) && selectionService.GetComponentSelected(this)) { PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(this)["SelectionStyle"]; if ((propertyDescriptor != null) && (propertyDescriptor.PropertyType == typeof(int))) { propertyDescriptor.SetValue(this, (int)selectionStyle); } } } }
void UnsafeNativeMethods.IOleInPlaceSite.GetWindowContext(out UnsafeNativeMethods.IOleInPlaceFrame ppFrame, out UnsafeNativeMethods.IOleInPlaceUIWindow ppDoc, NativeMethods._RECT lprcPosRect, NativeMethods._RECT lprcClipRect, NativeMethods.tagOIFI lpFrameInfo) { ppDoc = null; ppFrame = this.Host.GetParentContainer(); lprcPosRect.left = this.Host.Bounds.X; lprcPosRect.top = this.Host.Bounds.Y; lprcPosRect.right = this.Host.Bounds.Width + this.Host.Bounds.X; lprcPosRect.bottom = this.Host.Bounds.Height + this.Host.Bounds.Y; lprcClipRect = ActiveXHelper.GetClipRect(); if (lpFrameInfo != null) { lpFrameInfo.cb = Marshal.SizeOf(typeof(NativeMethods.tagOIFI)); lpFrameInfo.fMDIApp = false; lpFrameInfo.hAccel = IntPtr.Zero; lpFrameInfo.cAccelEntries = 0; lpFrameInfo.hwndFrame = (this.Host.Parent == null) ? IntPtr.Zero : this.Host.Parent.Handle; } }
private int OnActiveXRectChange(NativeMethods._RECT lprcPosRect) { this.Host.activeXOleInPlaceObject.SetObjectRects(NativeMethods._RECT.FromXYWH(0, 0, lprcPosRect.right - lprcPosRect.left, lprcPosRect.bottom - lprcPosRect.top), ActiveXHelper.GetClipRect()); this.Host.MakeDirty(); return(0); }
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) { if (this.activeXState >= ActiveXHelper.ActiveXState.InPlaceActive && this.IsHandleCreated && (((this.Left != x) || (this.Top != y)) || ((this.Width != width) || (this.Height != height)))) { try { this.activeXBaseChangingSize.Width = width; this.activeXBaseChangingSize.Height = height; this.activeXOleInPlaceObject.SetObjectRects(new NativeMethods._RECT(new Rectangle(0, 0, width, height)), ActiveXHelper.GetClipRect()); } finally { this.activeXBaseChangingSize.Width = -1; } } base.SetBoundsCore(x, y, width, height, specified); }