Пример #1
0
        public static bool StartTrackingComponent(IOleComponent me)
        {
            if (ActiveComponent != me)
            {
                // Make sure there isn't somebody already registered
                IOleComponent activeComponent;
                OleComponentManager.FGetActiveComponent(
                    //(uint)FGetActiveComponentType.olegacTracking, // f: changed
                    1,
                    out activeComponent,
                    null,
                    0);

                if (activeComponent == null)
                {
                    // Save ourselves as the currently active component (prevents reentrancy)
                    ActiveComponent = me;

                    // Tell the shell we are the active component
                    OleComponentManager.FSetTrackingComponent(RegisterComponent(me), 1);
                    return(true);
                }
                else if (Marshal.IsComObject(activeComponent))
                {
                    Marshal.ReleaseComObject(activeComponent);
                }
            }
            return(false);
        }
Пример #2
0
 public void OnActivationChange(IOleComponent pic,
                                int fSameComponent,
                                OLECRINFO[] pcrinfo,
                                int fHostIsActivating,
                                OLECHOSTINFO[] pchostinfo,
                                uint dwReserved)
 {
 }
Пример #3
0
 public int FRegisterComponent(IOleComponent piComponent, OLECRINFO[] pcrinfo, out uint pdwComponentID) {
     var flags = (_OLECRF)pcrinfo[0].grfcrf;
     if (flags.HasFlag(_OLECRF.olecrfNeedIdleTime)) {
         _idleComponents[++_idleCount] = piComponent;
         pdwComponentID = _idleCount;
     } else {
         throw new NotImplementedException();
     }
     return VSConstants.S_OK;
 }
Пример #4
0
        public static bool StopTrackingComponent(IOleComponent me)
        {
            OleComponentManager.FSetTrackingComponent(RegisterComponent(me), 0);

            if (ActiveComponent == me)
            {
                ActiveComponent = null;
            }

            return(true);
        }
Пример #5
0
        public int FRegisterComponent(IOleComponent piComponent, OLECRINFO[] pcrinfo, out uint pdwComponentID)
        {
            var flags = (_OLECRF)pcrinfo[0].grfcrf;

            if (flags.HasFlag(_OLECRF.olecrfNeedIdleTime))
            {
                _idleComponents[++_idleCount] = piComponent;
                pdwComponentID = _idleCount;
            }
            else
            {
                throw new NotImplementedException();
            }
            return(VSConstants.S_OK);
        }
Пример #6
0
        private static uint RegisterComponent(IOleComponent me)
        {
            uint returnValue = 0;

            if (!_registeredComponents.TryGetValue(me, out returnValue))
            {
                // treat us as a modal component that takes care of all input
                OLECRINFO info = new OLECRINFO();
                info.cbSize   = (uint)Marshal.SizeOf(info);
                info.grfcadvf = (uint)_OLECADVF.olecadvfModal;
                info.grfcrf   = (uint)(_OLECRF.olecrfPreTranslateKeys | _OLECRF.olecrfPreTranslateAll | _OLECRF.olecrfNeedAllActiveNotifs | _OLECRF.olecrfExclusiveActivation);
                OLECRINFO[] array = new OLECRINFO[1];
                array[0] = info;
                OleComponentManager.FRegisterComponent(me, array, out returnValue);
                _registeredComponents.Add(me, returnValue);
            }

            return(returnValue);
        }
        private static uint RegisterIdleLoop(SVsServiceProvider serviceProvider, IOleComponent component)
        {
            var oleComponentManager = serviceProvider.GetService(typeof(SOleComponentManager)) as IOleComponentManager;

            if (oleComponentManager != null)
            {
                uint        pwdId;
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
                                   (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
                                     (uint)_OLECADVF.olecadvfRedrawOff |
                                     (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                oleComponentManager.FRegisterComponent(component, crinfo, out pwdId);

                return(pwdId);
            }
            return(uint.MinValue);
        }
 /// <summary>
 /// Notifies the component when a new object is being activated.
 /// </summary>
 /// <param name="dwReserved">Reserved for future use.</param>
 /// <param name="fHostIsActivating">TRUE (not zero) if the host is the object being activated, otherwise FALSE (zero).</param>
 /// <param name="fSameComponent">TRUE (not zero) if pic is the same component as the callee of this method, otherwise FALSE (zero).</param>
 /// <param name="pchostinfo">An OLECHOSTINFO that contains information about the host.</param>
 /// <param name="pcrinfo">An OLECRINFO that contains information about pic.</param>
 /// <param name="pic">The IOleComponent object to activate.</param>
 /// <remarks>
 /// If pic is non-NULL, then it is the component that is being activated.
 /// In this case, fSameComponent is true if pic is the same component as
 /// the callee of this method, and pcrinfo is the information about the pic.
 /// If pic is NULL and fHostIsActivating is true, then the host is the
 /// object being activated, and pchostinfo is its host info.
 /// If pic is NULL and fHostIsActivating is false, then there is no current
 /// active object.
 /// If pic is being activated and pcrinfo->grf has the olecrfExclusiveBorderSpace 
 /// bit set, the component should hide its border space tools (toolbars, 
 /// status bars, etc.), and it should also do this if the host is activating and 
 /// pchostinfo->grfchostf has the olechostfExclusiveBorderSpace bit set.
 /// In either of these cases, the component should unhide its border space
 /// tools the next time it is activated.
 /// If pic is being activated and pcrinfo->grf has the olecrfExclusiveActivation
 /// bit is set, then pic is being activated in 'ExclusiveActive' mode.  The
 /// component should retrieve the top frame window that is hosting pic
 /// (via pic->HwndGetWindow(olecWindowFrameToplevel, 0)).  
 /// If this window is different from the component's own top frame window, 
 /// the component should disable its windows and do the things it would do
 /// when receiving an OnEnterState(olecstateModal, true) notification. 
 /// Otherwise, if the component is top-level, it should refuse to have its window 
 /// activated by appropriately processing WM_MOUSEACTIVATE.
 /// The component should remain in one of these states until the 
 /// ExclusiveActive mode ends, indicated by a future call to OnActivationChange 
 /// with the ExclusiveActivation bit not set or with a NULL pcrinfo.
 /// </remarks>
 public void OnActivationChange(IOleComponent pic, int fSameComponent, OLECRINFO[] pcrinfo, int fHostIsActivating, OLECHOSTINFO[] pchostinfo, uint dwReserved)
 {
 }
Пример #9
0
 public int FGetActiveComponent(uint dwgac, out IOleComponent ppic, OLECRINFO[] pcrinfo, uint dwReserved)
 {
     throw new NotImplementedException();
 }
        private static uint RegisterIdleLoop(SVsServiceProvider serviceProvider, IOleComponent component)
        {
            var oleComponentManager = serviceProvider.GetService(typeof(SOleComponentManager)) as IOleComponentManager;
            if (oleComponentManager != null)
            {
                uint pwdId;
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
                                              (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
                                              (uint)_OLECADVF.olecadvfRedrawOff |
                                              (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                oleComponentManager.FRegisterComponent(component, crinfo, out pwdId);

                return pwdId;
            }
            return uint.MinValue;
        }
Пример #11
0
 public int FGetActiveComponent(uint dwgac, out IOleComponent ppic, OLECRINFO[] pcrinfo, uint dwReserved) {
     throw new NotImplementedException();
 }
Пример #12
0
 public int FRegisterComponent(IOleComponent piComponent, OLECRINFO[] pcrinfo, out uint pdwComponentID)
 {
     pdwComponentID = 0;
     return VSConstants.S_OK;
 }
Пример #13
0
 public int FRegisterComponent(IOleComponent piComponent, OLECRINFO[] pcrinfo, out uint pdwComponentID)
 {
     pdwComponentID = 0;
     return(VSConstants.S_OK);
 }