Beispiel #1
0
            internal Oleaut32.IExtender GetProxyForControl(Control ctl)
            {
                Oleaut32.IExtender rval = null;
                if (proxyCache is null)
                {
                    proxyCache = new Hashtable();
                }
                else
                {
                    rval = (Oleaut32.IExtender)proxyCache[ctl];
                }

                if (rval is null)
                {
                    if (ctl != parent && !GetControlBelongs(ctl))
                    {
                        Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "!parent || !belongs NYI");
                        AxContainer c = FindContainerForControl(ctl);
                        if (c is not null)
                        {
                            rval = new ExtenderProxy(ctl, c);
                        }
                        else
                        {
                            Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "unable to find proxy, returning null");
                            return(null);
                        }
                    }
                    else
                    {
                        rval = new ExtenderProxy(ctl, this);
                    }

                    proxyCache.Add(ctl, rval);
                }

                Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "found proxy " + rval.ToString());
                return(rval);
            }
Beispiel #2
0
            internal Oleaut32.IExtender GetProxyForControl(Control ctl)
            {
                Oleaut32.IExtender rval = null;
                if (_proxyCache is null)
                {
                    _proxyCache = new();
                }
                else
                {
                    _proxyCache.TryGetValue(ctl, out rval);
                }

                if (rval is null)
                {
                    if (ctl != _parent && !GetControlBelongs(ctl))
                    {
                        Debug.WriteLineIf(s_axHTraceSwitch.TraceVerbose, "!parent || !belongs NYI");
                        AxContainer c = FindContainerForControl(ctl);
                        if (c is not null)
                        {
                            rval = new ExtenderProxy(ctl, c);
                        }
                        else
                        {
                            Debug.WriteLineIf(s_axHTraceSwitch.TraceVerbose, "unable to find proxy, returning null");
                            return(null);
                        }
                    }
                    else
                    {
                        rval = new ExtenderProxy(ctl, this);
                    }

                    _proxyCache.Add(ctl, rval);
                }

                Debug.WriteLineIf(s_axHTraceSwitch.TraceVerbose, $"found proxy {rval}");
                return(rval);
            }
            internal IEnumUnknown EnumControls(Control ctl, OLECONTF dwOleContF, GC_WCH dwWhich)
            {
                GetComponents();

                LockComponents();
                try
                {
                    ArrayList l        = null;
                    bool      selected = (dwWhich & GC_WCH.FSELECTED) != 0;
                    bool      reverse  = (dwWhich & GC_WCH.FREVERSEDIR) != 0;
                    // Note that visual basic actually ignores the next/prev flags... we will not
                    bool onlyNext = (dwWhich & GC_WCH.FONLYNEXT) != 0;
                    bool onlyPrev = (dwWhich & GC_WCH.FONLYPREV) != 0;
                    dwWhich &= ~(GC_WCH.FSELECTED | GC_WCH.FREVERSEDIR |
                                 GC_WCH.FONLYNEXT | GC_WCH.FONLYPREV);
                    if (onlyNext && onlyPrev)
                    {
                        Debug.Fail("onlyNext && onlyPrev are both set!");
                        throw E_INVALIDARG;
                    }
                    if (dwWhich == GC_WCH.CONTAINER || dwWhich == GC_WCH.CONTAINED)
                    {
                        if (onlyNext || onlyPrev)
                        {
                            Debug.Fail("GC_WCH_FONLYNEXT or FONLYPREV used with CONTANER or CONATINED");
                            throw E_INVALIDARG;
                        }
                    }
                    int       first = 0;
                    int       last  = -1; // meaning all
                    Control[] ctls  = null;
                    switch (dwWhich)
                    {
                    default:
                        Debug.Fail("Bad GC_WCH");
                        throw E_INVALIDARG;

                    case GC_WCH.CONTAINED:
                        ctls = ctl.GetChildControlsInTabOrder(false);
                        ctl  = null;
                        break;

                    case GC_WCH.SIBLING:
                        Control p = ctl.ParentInternal;
                        if (p != null)
                        {
                            ctls = p.GetChildControlsInTabOrder(false);
                            if (onlyPrev)
                            {
                                last = ctl.TabIndex;
                            }
                            else if (onlyNext)
                            {
                                first = ctl.TabIndex + 1;
                            }
                        }
                        else
                        {
                            ctls = Array.Empty <Control>();
                        }
                        ctl = null;
                        break;

                    case GC_WCH.CONTAINER:
                        l = new ArrayList();
                        MaybeAdd(l, ctl, selected, dwOleContF, false);
                        while (ctl != null)
                        {
                            AxContainer cont = FindContainerForControl(ctl);
                            if (cont != null)
                            {
                                MaybeAdd(l, cont.parent, selected, dwOleContF, true);
                                ctl = cont.parent;
                            }
                            else
                            {
                                break;
                            }
                        }
                        break;

                    case GC_WCH.ALL:
                        Hashtable htbl = GetComponents();
                        ctls = new Control[htbl.Keys.Count];
                        htbl.Keys.CopyTo(ctls, 0);
                        ctl = parent;
                        break;
                    }
                    if (l is null)
                    {
                        l = new ArrayList();
                        if (last == -1 && ctls != null)
                        {
                            last = ctls.Length;
                        }

                        if (ctl != null)
                        {
                            MaybeAdd(l, ctl, selected, dwOleContF, false);
                        }

                        for (int i = first; i < last; i++)
                        {
                            MaybeAdd(l, ctls[i], selected, dwOleContF, false);
                        }
                    }
                    object[] rval = new object[l.Count];
                    l.CopyTo(rval, 0);
                    if (reverse)
                    {
                        for (int i = 0, j = rval.Length - 1; i < j; i++, j--)
                        {
                            object temp = rval[i];
                            rval[i] = rval[j];
                            rval[j] = temp;
                        }
                    }
                    return(new EnumUnknown(rval));
                }
                finally
                {
                    UnlockComponents();
                }
            }
 private AxContainer GetParentContainer()
 {
     System.Windows.Forms.IntSecurity.GetParent.Demand();
     if (this.container == null)
     {
         this.container = AxContainer.FindContainerForControl(this);
     }
     if (this.container == null)
     {
         ContainerControl containingControl = this.ContainingControl;
         if (containingControl == null)
         {
             if (this.newParent == null)
             {
                 this.newParent = new ContainerControl();
                 this.axContainer = this.newParent.CreateAxContainer();
                 this.axContainer.AddControl(this);
             }
             return this.axContainer;
         }
         this.container = containingControl.CreateAxContainer();
         this.container.AddControl(this);
         this.containingControl = containingControl;
     }
     return this.container;
 }
Beispiel #5
0
 internal ExtenderProxy(Control principal, AxContainer container) {
     pRef = new WeakReference(principal);
     pContainer = new WeakReference(container);
 }
Beispiel #6
0
        private AxContainer GetParentContainer() {
            Debug.WriteLineIf(IntSecurity.SecurityDemand.TraceVerbose, "GetParent Demanded");
            IntSecurity.GetParent.Demand();

            if (container == null) {
                container = AxContainer.FindContainerForControl(this);
            }
            if (container == null) {
                ContainerControl f = ContainingControl;
                if (f == null) {
                    // ContainingCointrol can be null if the AxHost is still not parented to a containerControl
                    // In everett we used to return a parking window.
                    // now we just set the containingControl to a dummyValue.
                    if (newParent == null)
                    {
                        newParent = new ContainerControl();
                        axContainer = newParent.CreateAxContainer();
                        axContainer.AddControl(this);
                    }
                    return axContainer;
                }
                else {
                    Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "calling upon "+f.ToString()+" to create a container");
                    container = f.CreateAxContainer();
                    container.AddControl(this);
                    containingControl = f;
                }
            }
            return container;
        }