コード例 #1
1
        /// <summary>
        /// Creates a connection point to of the given interface type
        /// which will call on a managed code sink that implements that interface.
        /// </summary>
        public ConnectionPointCookie(object source, object sink, Type eventInterface, bool throwException) {
            Exception ex = null;

            if (source is IConnectionPointContainer) {
                _connectionPointContainer = (IConnectionPointContainer)source;

                try {
                    Guid tmp = eventInterface.GUID;
                    _connectionPointContainer.FindConnectionPoint(ref tmp, out _connectionPoint);
                } catch {
                    _connectionPoint = null;
                }

                if (_connectionPoint == null) {
                    ex = new NotSupportedException();
                } else if (sink == null || !eventInterface.IsInstanceOfType(sink)) {
                    ex = new InvalidCastException();
                } else {
                    try {
                        _connectionPoint.Advise(sink, out _cookie);
                    } catch {
                        _cookie = 0;
                        _connectionPoint = null;
                        ex = new Exception();
                    }
                }
            } else {
                ex = new InvalidCastException();
            }

            if (throwException && (_connectionPoint == null || _cookie == 0)) {
                Dispose();

                if (ex == null) {
                    throw new ArgumentException("Exception null, but cookie was zero or the connection point was null");
                } else {
                    throw ex;
                }
            }

#if DEBUG
            //_callStack = Environment.StackTrace;
            //this._eventInterface = eventInterface;
#endif
        }
コード例 #2
0
        // Establish the connection point to receive events.
        private void RegisterForSBEGlobalEvents()
        {
            IConnectionPoint spConnectionPoint = (IConnectionPoint)spBroadcastEvent;

            spConnectionPoint.Advise((IBroadcastEventEx)(this),
                                     out dwBroadcastEventCookie);
        }
コード例 #3
0
        /// <summary>
        /// Establishes a connection between a connection point object and the client's sink.
        /// </summary>
        /// <param name="source">An event source that implements IConnectionPointContainer.</param>
        public void Connect(object source)
        {
            bool lockTaken = false;
            IConnectionPointContainer container = null;

            try
            {
                Monitor.Enter(this, ref lockTaken);

                // If previous call was made, disconnect existing connection.
                if (container != null)
                {
                    Disconnect();
                }

                // QueryInterface for IConnectionPointContainer.
                container = (IConnectionPointContainer)source;

                // Find the connection point by the GUID of type T.
                container.FindConnectionPoint(typeof(T).GUID, out _connectionPoint);

                if (_connectionPoint != null)
                {
                    // Establish the sink connection.
                    _connectionPoint.Advise(this, out _cookie);
                }
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(this);
                }
            }
        }
コード例 #4
0
ファイル: LanguagePreferences.cs プロジェクト: int19h/PTVS
        public LanguagePreferences(IServiceProvider site, Guid languageGuid)
        {
            site.AssertShellIsInitialized();

            _textMgr = (IVsTextManager)site.GetService(typeof(SVsTextManager));
            if (_textMgr == null)
            {
                throw new NotSupportedException("");
            }

            var langPrefs = new LANGPREFERENCES[1];

            langPrefs[0].guidLang = languageGuid;
            ErrorHandler.ThrowOnFailure(_textMgr.GetUserPreferences(null, null, langPrefs, null));
            _preferences = langPrefs[0];

            var guid = typeof(IVsTextManagerEvents2).GUID;
            IConnectionPoint connectionPoint = null;

            (_textMgr as IConnectionPointContainer)?.FindConnectionPoint(ref guid, out connectionPoint);
            if (connectionPoint != null)
            {
                connectionPoint.Advise(this, out _cookie);
            }
        }
コード例 #5
0
        public SafeConnectionPointCookie(IConnectionPointContainer target, object sink, Guid eventId) : base(true)
        {
            int num;

            Verify.IsNotNull <IConnectionPointContainer>(target, "target");
            Verify.IsNotNull <object>(sink, "sink");
            Verify.IsNotDefault <Guid>(eventId, "eventId");
            this.handle = IntPtr.Zero;
            IConnectionPoint connectionPoint = null;

            try
            {
                target.FindConnectionPoint(ref eventId, out connectionPoint);
                connectionPoint.Advise(sink, out num);
                if (num == 0)
                {
                    throw new InvalidOperationException("IConnectionPoint::Advise returned an invalid cookie.");
                }
                this.handle     = new IntPtr(num);
                this._cp        = connectionPoint;
                connectionPoint = null;
            }
            finally
            {
                Utility.SafeRelease <IConnectionPoint>(ref connectionPoint);
            }
        }
コード例 #6
0
ファイル: Manipulable.cs プロジェクト: basavarajum2010/dotnet
        public Manipulable()
        {
            _iprocessor = new InertiaProcessor();
            _mprocessor = new ManipulationProcessor();
            _pts        = new Dictionary <int, Point>();

            Guid manipulationEventsId = new Guid(IIDGuid.IManipulationEvents);

            _mprocessor.FindConnectionPoint(ref manipulationEventsId, out _meventsconnectionpoint);
            _meventsconnectionpoint.Advise(this, out _cookie);
            _iprocessor.FindConnectionPoint(ref manipulationEventsId, out _ieventsconnectionpoint);
            _ieventsconnectionpoint.Advise(this, out _cookie);

            OnPivotPointChanged(this, new DependencyPropertyChangedEventArgs());
            OnPivotRadiusChanged(this, new DependencyPropertyChangedEventArgs());
            OnSupportedManipulationsChanged(this, new DependencyPropertyChangedEventArgs());
            OnMinimumScaleRotateRadiusChanged(this, new DependencyPropertyChangedEventArgs());

            _matrotate    = new RotateTransform();
            _matscale     = new ScaleTransform();
            _mattranslate = new TranslateTransform();
            _mattransform = new TransformGroup();

            _mattransform.Children.Add(_matrotate);
            _mattransform.Children.Add(_matscale);
            _mattransform.Children.Add(_mattranslate);
        }
コード例 #7
0
        /// <summary>
        /// Constructs the IVsCodeWindow and attaches an IVsTextBuffer
        /// </summary>
        /// <returns>S_OK if success</returns>
        private int CreateVsCodeWindow()
        {
            InitializeEditor();

            int hr = VSConstants.S_OK;

            //create the codewindow as the size of the snippetExplorerForm its in
            hr = ((IVsWindowPane)viewAdapter).CreatePaneWindow(Handle, 0, 0, Parent.Size.Width, Parent.Size.Height, out hWndCodeWindow);

            //we are only getting events if the codewindowhost is the snippet editor)
            if (snippetEditor != null)
            {
                // sink IVsTextViewEvents, so we can determine when a VsCodeWindow object actually has the focus.
                var  connptCntr = (IConnectionPointContainer)viewAdapter;
                Guid riid       = typeof(IVsTextViewEvents).GUID;

                //find the desired connection point
                connptCntr.FindConnectionPoint(ref riid, out textViewEventsConnectionPoint);
                //connect to this connection point to be advised of changes
                textViewEventsConnectionPoint.Advise(snippetEditor, out cookieTextViewEvents);


                // sink IVsTextLineEvents, so we can determine when the buffer is changed
                connptCntr = (IConnectionPointContainer)bufferAdapter;
                riid       = typeof(IVsTextLinesEvents).GUID;

                //find the desired connection point
                connptCntr.FindConnectionPoint(ref riid, out textLinesEventsConnectionPoint);
                //connect to this connection point to be advised of changes
                textLinesEventsConnectionPoint.Advise(snippetEditor, out cookieTextLineEvents);
            }


            return(hr);
        }
コード例 #8
0
        public TextBufferInitializationTracker(
            string documentName,
            IVsHierarchy hierarchy,
            VSConstants.VSITEMID itemid,
            IVsTextLines textLines,
            Guid languageServiceId,
            List <TextBufferInitializationTracker> trackers)
        {
            VsAppShell.Current.CompositionService.SatisfyImportsOnce(this);

            _documentName        = documentName;
            _hierarchy           = hierarchy;
            _itemid              = itemid;
            _textLines           = textLines;
            _languageServiceGuid = languageServiceId;
            _trackers            = trackers;

            IConnectionPointContainer cpc = textLines as IConnectionPointContainer;
            Guid g = typeof(IVsTextBufferDataEvents).GUID;

            cpc.FindConnectionPoint(g, out cp);
            cp.Advise(this, out cookie);

            _trackers.Add(this);
        }
コード例 #9
0
        protected override void Initialize()
        {
            base.Initialize();

            //绑定textView事件
            IVsMonitorSelection monitorSelection = (IVsMonitorSelection)GetService(typeof(SVsShellMonitorSelection));

            ErrorHandler.ThrowOnFailure(monitorSelection.AdviseSelectionEvents(textViewEvent, out selectionEventCookie));

            //绑定RunningDocTable事件
            IVsRunningDocumentTable DocTables = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));

            DocTables.AdviseRunningDocTableEvents(docTableEvent, out runningDocEventCookie);

            // And we can query for the text manager service as we're surely running in
            // interactive mode. So this is the right time to register for text manager events.
            IConnectionPointContainer textManager = (IConnectionPointContainer)GetService(typeof(SVsTextManager));
            Guid interfaceGuid = typeof(IVsTextManagerEvents).GUID;

            textManager.FindConnectionPoint(ref interfaceGuid, out tmConnectionPoint);
            tmConnectionPoint.Advise(TextManagerEventSink, out tmConnectionCookie);

            //todo:通过win32形式检测键盘输入
            hookVs.InitHook();
        }
コード例 #10
0
        private void HookEvents(object source, Guid eventGuid)
        {
            IConnectionPointContainer connectionPointContainer = null;
            IConnectionPoint          connectionPoint          = null;
            int cookie = 0;

            connectionPointContainer = source as IConnectionPointContainer;
            if (connectionPointContainer != null)
            {
                connectionPointContainer.FindConnectionPoint(eventGuid, out connectionPoint);
                if (connectionPoint != null)
                {
                    connectionPoint.Advise(this, out cookie);
                    if (cookie != 0)
                    {
                        _connectionPoints.Add(connectionPoint, cookie);
                    }
                    else
                    {
                        throw new System.Exception("Advisory connection between the connection point and the caller's sink object failed.");
                    }
                }
                else
                {
                    throw new System.Exception(String.Format("Connection point '{0}' not found.", eventGuid));
                }
            }
            else
            {
                throw new System.Exception("Source does not implement IConnectionPointContainer.");
            }
        }
コード例 #11
0
        public NameSpaceWrapper(object obj)
        {
            Utility.LogNameSpaceEvent(LogType.Diagnostic, (string.Format("{0}{1}", new StackTrace().GetFrame(0).GetMethod().Name, System.Environment.NewLine)));

            this._myObject             = obj;
            _pConnectionPointContainer = _myObject as IConnectionPointContainer;
            if (_pConnectionPointContainer != null)
            {
                _pConnectionPoint = null;
                _pConnectionPointContainer.FindConnectionPoint(_sourceIntfGuid, out _pConnectionPoint);
                if (_pConnectionPoint != null)
                {
                    _pConnectionPoint.Advise(this, out _cookie);

                    nameSpace           = _myObject as Outlook.NameSpace;
                    inboxMAPIFolder     = nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);    // inboxMAPIFolder is released within the wrapper
                    outboxMAPIFolder    = nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);   // outboxMAPIFolder is released within the wrapper
                    sentItemsMAPIFolder = nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail); // sentItemsMAPIFolder is released within the wrapper
                    if (ControlPanel.TrackInboxEnabled)
                    {
                        new FolderWrapper(inboxMAPIFolder);
                    }
                    if (ControlPanel.TrackOutboxEnabled)
                    {
                        new FolderWrapper(outboxMAPIFolder);
                    }
                    if (ControlPanel.TrackSentItemsEnabled)
                    {
                        new FolderWrapper(sentItemsMAPIFolder);
                    }
                }
            }
        }
コード例 #12
0
        public void AttachEvents()
        {
            lock (_lock)
            {
                if (IsWrappingNullReference)
                {
                    return;
                }

                if (_cookie != NotAdvising)
                {
                    return;
                }

                // Call QueryInterface for IConnectionPointContainer
                var icpc = (IConnectionPointContainer)Target;

                // Find the connection point for the source interface
                var g = typeof(TEventInterface).GUID;
                icpc.FindConnectionPoint(ref g, out _icp);

                var sink = this as TEventInterface;

                if (sink == null)
                {
                    throw new InvalidOperationException($"The class {this.GetType()} does not implement the required event interface {typeof(TEventInterface)}");
                }

                _icp.Advise(sink, out _cookie);
            }
        }
コード例 #13
0
ファイル: OPCDriver.cs プロジェクト: godlovefeng/SharpSCADA
        public bool Connect()
        {
            if (_opcServerObj != null)
            {
                Dispose();
            }
            Guid cid;
            Type svrComponenttype = Guid.TryParse(_clsidOPCserver, out cid) ? Type.GetTypeFromCLSID(cid, _serverIP, false)
                : Type.GetTypeFromProgID(_clsidOPCserver, _serverIP, false);

            if (svrComponenttype == null)
            {
                return(false);
            }
            try
            {
                _opcServerObj = Activator.CreateInstance(svrComponenttype);
            }
            catch (Exception err)
            {
                if (err.Message != null)
                {
                }
                return(false);
            }
            _opcServer  = (IOPCServer)_opcServerObj;
            _opcProp    = (IOPCItemProperties)_opcServerObj;
            _opcBrowser = (IOPCBrowseServerAddressSpace)_opcServerObj;
            Guid sinkguid = typeof(IOPCShutdown).GUID;

            ((IConnectionPointContainer)_opcServerObj).FindConnectionPoint(ref sinkguid, out _shutDownPoint);
            if (_shutDownPoint == null)
            {
                return(false);
            }
            try
            {
                _shutDownPoint.Advise(this, out _shutDownCookie);
            }
            catch (COMException err)
            {
                _opcServerObj  = null;
                _opcServer     = null;
                _shutDownPoint = null;
                return(false);
            }
            if (_metaGroups.Count > 0 && _groups.Count == 0)
            {
                foreach (var metagrp in _metaGroups)
                {
                    var grp = AddGroup(metagrp.Name, metagrp.ID, metagrp.UpdateRate, metagrp.DeadBand, metagrp.Active);
                    if (grp != null)
                    {
                        grp.AddItems(_dataServer.MetaDataList);
                    }
                }
            }
            return(true);
        }
コード例 #14
0
ファイル: OpcGroup.cs プロジェクト: tkouba/OPCdotNET
        /// <summary>
        /// Create OPC Group
        /// </summary>
        /// <param name="opcServer">If server link</param>
        /// <param name="isPublic">Is public</param>
        /// <param name="groupName">Group name</param>
        /// <param name="setActive">Set active</param>
        /// <param name="requestedUpdateRate">Requested update rate</param>
        /// <param name="biasTime">Bias time</param>
        /// <param name="percentDeadband">Percent deadband</param>
        /// <param name="localeID">Locale ID</param>
        internal OpcGroup(IOPCServer opcServer, bool isPublic, string groupName, bool setActive, int requestedUpdateRate,
                          int?biasTime, float?percentDeadband, int localeID)
        {
            IsDisposed = false;

            parentServer = opcServer;

            stateName            = groupName;
            statePublic          = isPublic;
            stateUpdateRate      = requestedUpdateRate;
            stateActive          = setActive;
            stateTimeBias        = 0;
            statePercentDeadband = 0.0f;
            stateLocaleID        = 0;
            stateHandleClient    = this.GetHashCode();
            stateHandleServer    = 0;

            Type typGrpMgt  = typeof(IOPCGroupStateMgt);
            Guid guidGrpTst = typGrpMgt.GUID;

            if (statePublic)
            {
                IOPCServerPublicGroups ifPubGrps = null;
                ifPubGrps = (IOPCServerPublicGroups)parentServer;
                if (ifPubGrps == null)
                {
                    Marshal.ThrowExceptionForHR(HRESULTS.E_NOINTERFACE);
                }

                ifPubGrps.GetPublicGroupByName(stateName, ref guidGrpTst, out opcGroupObject);
                ifPubGrps = null;
            }
            else
            {
                int[] biasTimeArray = biasTime == null ? null : new int[1] {
                    biasTime.Value
                };
                float[] percentDeadbandArray = percentDeadband == null ? null : new float[1] {
                    percentDeadband.Value
                };
                parentServer.AddGroup(stateName, stateActive, stateUpdateRate, stateHandleClient, biasTimeArray,
                                      percentDeadbandArray, stateLocaleID, out stateHandleServer, out stateUpdateRate, ref guidGrpTst, out opcGroupObject);
            }
            if (opcGroupObject == null)
            {
                Marshal.ThrowExceptionForHR(HRESULTS.E_NOINTERFACE);
            }

            RefreshState();

            // Advise callback
            Guid sinkGuid = typeof(IOPCDataCallback).GUID;

            connectionPointContainer.FindConnectionPoint(ref sinkGuid, out callbackConnectionPoint);
            if (callbackConnectionPoint != null)
            {
                callbackConnectionPoint.Advise(this, out callbackCookie);
            }
        }
コード例 #15
0
        private void ConnectToNetworkListManagerEvents()
        {
            IConnectionPointContainer icpc = (IConnectionPointContainer)m_networkListManager;
            Guid typeGuid = typeof(INetworkListManagerEvents).GUID;

            icpc.FindConnectionPoint(ref typeGuid, out m_connectionPoint);
            m_connectionPoint.Advise(this, out m_cookie);
        }
コード例 #16
0
        public void AdviseforNetworklistManager()
        {
            IConnectionPointContainer icpc = (IConnectionPointContainer)m_nlm;
            Guid tempGuid = typeof(INetworkListManagerEvents).GUID;

            icpc.FindConnectionPoint(ref tempGuid, out m_icp);
            m_icp.Advise(this, out m_cookie);
        }
コード例 #17
0
        public ScrollWithSelectionFocus()
        {
            Guid manipulationEventsId = new Guid(IIDGuid.IManipulationEvents);

            _iprocessor = new InertiaProcessor();
            _iprocessor.FindConnectionPoint(ref manipulationEventsId, out _conpt);
            _conpt.Advise(this, out _cookie);
        }
コード例 #18
0
        //=====================================================================
        // IConnectionPoint

        /// <summary>
        /// Establishes a connection, if necessary and increments the reference count.
        /// </summary>
        public int Advise(object callback)
        {
            if (m_refs++ == 0)
            {
                m_server.Advise(callback, out m_cookie);
            }
            return(m_refs);
        }
コード例 #19
0
        //=====================================================================
        // IConnectionPoint

        /// <summary>
        /// Establishes a connection, if necessary and increments the reference count.
        /// </summary>
        public int Advise(object callback)
        {
            if (refs_++ == 0)
            {
                server_.Advise(callback, out cookie_);
            }
            return(refs_);
        }
コード例 #20
0
            public TextBufferEventListener(IVsTextLines textLines) {
                _textLines = textLines;

                var cpc = textLines as IConnectionPointContainer;
                var bufferEventsGuid = typeof(IVsTextBufferDataEvents).GUID;
                cpc.FindConnectionPoint(ref bufferEventsGuid, out _cp);
                _cp.Advise(this, out _cookie);
            }
コード例 #21
0
 /*------------------------------------------------------
 *  Valid DataChange event
 *
 *  ------------------------------------------------------*/
 public void Advise()
 {
     if (!m_bAdvise)
     {
         m_OPCConnPoint.Advise(this, out m_iCallBackConnection);
     }
     m_bAdvise = true;
 }
コード例 #22
0
ファイル: ConnectionPoint.cs プロジェクト: Fooway/RTVS
        /// <summary>
        /// Creates a connection point to of the given interface type
        /// which will call on a managed code sink that implements that interface.
        /// </summary>
        public ConnectionPointCookie(object source, object sink, Type eventInterface, bool throwException)
        {
            Exception ex = null;

            if (source is IConnectionPointContainer)
            {
                _connectionPointContainer = (IConnectionPointContainer)source;

                try {
                    Guid tmp = eventInterface.GUID;
                    _connectionPointContainer.FindConnectionPoint(ref tmp, out _connectionPoint);
                } catch {
                    _connectionPoint = null;
                }

                if (_connectionPoint == null)
                {
                    ex = new NotSupportedException();
                }
                else if (sink == null || !eventInterface.IsInstanceOfType(sink))
                {
                    ex = new InvalidCastException();
                }
                else
                {
                    try {
                        _connectionPoint.Advise(sink, out _cookie);
                    } catch {
                        _cookie          = 0;
                        _connectionPoint = null;
                        ex = new Exception();
                    }
                }
            }
            else
            {
                ex = new InvalidCastException();
            }

            if (throwException && (_connectionPoint == null || _cookie == 0))
            {
                Dispose();

                if (ex == null)
                {
                    throw new ArgumentException("Exception null, but cookie was zero or the connection point was null");
                }
                else
                {
                    throw ex;
                }
            }

#if DEBUG
            //_callStack = Environment.StackTrace;
            //this._eventInterface = eventInterface;
#endif
        }
コード例 #23
0
        /// <summary>
        /// Creates a connection point to of the given interface type,
        /// which will call on a managed code sink that implements that interface.
        /// </summary>
        /// <param name='source'>
        /// The object that exposes the events. This object must implement IConnectionPointContainer or an InvalidCastException will be thrown.
        /// </param>
        /// <param name='sink'>
        /// The object to sink the events. This object must implement the interface eventInterface, or an InvalidCastException is thrown.
        /// </param>
        /// <param name='iid'>
        /// The GUID of the event interface to sink. The sink object must support this interface and the source object must expose it through it's ConnectionPointContainer.
        /// </param>
        /// <param name='throwException'>
        /// If true, exceptions described will be thrown, otherwise object will silently fail to connect.
        /// </param>
        public ConnectionPointCookie(object source, object sink, Guid iid, bool throwException)
        {
            Exception ex = null;

            if (source is IConnectionPointContainer)
            {
                IConnectionPointContainer cpc = (IConnectionPointContainer)source;
                IEnumConnectionPoints     checkPoints;
                cpc.EnumConnectionPoints(out checkPoints);
                try
                {
                    Guid tmp = iid;
                    cpc.FindConnectionPoint(ref tmp, out connectionPoint);
                }
                catch (Exception)
                {
                    connectionPoint = null;
                }

                if (connectionPoint == null)
                {
                    ex = new ArgumentException("The source object does not expose the " + iid + " event interface");
                }
//                else if (!Type.GetTypeFromCLSID(iid).IsInstanceOfType(sink) && !(iid.Equals(typeof(Interop.IPropertyNotifySink).GUID)))
//                {
//                    ex = new InvalidCastException("The sink object does not implement the eventInterface");
//                }
                else
                {
                    try
                    {
                        connectionPoint.Advise(sink, out cookie);
                    }
                    catch (Exception)
                    {
                        cookie          = 0;
                        connectionPoint = null;
                        ex = new Exception("IConnectionPoint::Advise failed for event interface '" + iid + "'");
                    }
                }
            }
            else
            {
                ex = new InvalidCastException("The source object does not expost IConnectionPointContainer");
            }

            if (throwException && (connectionPoint == null || cookie == 0))
            {
                if (ex == null)
                {
                    throw new ArgumentException("Could not create connection point for event interface '" + iid + "'");
                }
                else
                {
                    throw ex;
                }
            }
        }
コード例 #24
0
    public Foo()
    {
        nlm = new NetworkListManager();
        IConnectionPointContainer icpc = (IConnectionPointContainer)nlm;
        Guid tempGuid = typeof(INetworkListManagerEvents).GUID;

        icpc.FindConnectionPoint(ref tempGuid, out icp);
        icp.Advise(this, out cookie);
    }
コード例 #25
0
        protected override void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);
            var main = Windows;

            var m = main[0] as MainWindow;

            icp.Advise(m.Terminal, out cookie);
        }
コード例 #26
0
ファイル: XingSessionCtrl.cs プロジェクト: phs008/ebest
        public XingSessionCtrl()
        {
            m_session = new XASession();
            m_icpc    = (IConnectionPointContainer)m_session;
            Guid IID_SessionEvents = typeof(_IXASessionEvents).GUID;

            m_icpc.FindConnectionPoint(ref IID_SessionEvents, out m_icp);
            m_icp.Advise(this, out m_dwCookie);
        }
コード例 #27
0
        // Public Methods (2) 

        /// <summary>
        /// Begins advising the linked <see cref="Org.Edgerunner.Dynamics.Nav.CSide.Client"/> of new events from the source.
        /// </summary>
        /// <param name="source">The source.</param>
        public void Advise(ref IObjectDesigner source)
        {
            //   Late bind connection point subscription
            //   Subscribe for connection point event
            IConnectionPointContainer container = source as IConnectionPointContainer;

            container.FindConnectionPoint(ref _IID, out _ConnectionPoint);
            _ConnectionPoint.Advise(this, out _Cookie);
        }
コード例 #28
0
        public ManipulationEvents(IConnectionPointContainer connectionPointContainer, IManipulationEvents callBack)
        {
            _callBack = callBack;

            Guid manipulationEventsId = new Guid(IIDGuid.IManipulationEvents);

            connectionPointContainer.FindConnectionPoint(ref manipulationEventsId, out _connectionPoint);
            _connectionPoint.Advise(this, out _cookie);
        }
コード例 #29
0
        public NativeWebBrowserEventHandler(WebBrowser webBrowser)
        {
            var connectionPointContainer = (IConnectionPointContainer)
                                           ActiveXInstanceProperty.GetValue(webBrowser);
            var riid = typeof(SHDocVw.DWebBrowserEvents2).GUID;

            connectionPointContainer.FindConnectionPoint(ref riid, out connectionPoint);
            connectionPoint.Advise(this, out connectionCookie);
        }
コード例 #30
0
 public ConnectionEventsSink(
     OnConnectCompleteHandler connectCallback,
     OnDisconnectCompleteHandler disconnectCallback,
     IConnectionPoint connectionPoint)
 {
     m_ConnectCallback    = new WeakReference <OnConnectCompleteHandler>(connectCallback);
     m_DisconnectCallback = new WeakReference <OnDisconnectCompleteHandler>(disconnectCallback);
     m_ConnectionPoint    = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
コード例 #31
0
ファイル: MBApiImplementation.cs プロジェクト: mbin/Win81App
 public InterfaceManagerEventsSink(
     OnInterfaceArrivalHandler arrivalCallback,
     OnInterfaceRemovalHandler removalCallback,
     IConnectionPoint connectionPoint)
 {
     m_ArrivalCallback = new WeakReference<OnInterfaceArrivalHandler>(arrivalCallback);
     m_RemovalCallback = new WeakReference<OnInterfaceRemovalHandler>(removalCallback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
        private int RegisterComEvent(IUICollection collection)
        {
            IConnectionPoint connectionPoint = GetConnectionPoint(collection);

            int cookie;

            connectionPoint.Advise(this, out cookie);

            return(cookie);
        }
コード例 #33
0
ファイル: SinkHelper.cs プロジェクト: swatt6400/NetOffice
 /// <summary>
 /// create event binding
 /// </summary>
 /// <param name="connectPoint"></param>
 public void SetupEventBinding(IConnectionPoint connectPoint)
 {
     try
     {
         if (true == Settings.Default.EnableEvents)
         {
             _connectionPoint = connectPoint;
             _connectionPoint.Advise(this, out _connectionCookie);
             _pointList.Add(this);
         }
     }
     catch (Exception throwedException)
     {
         _eventClass.Console.WriteException(throwedException);
         throw (throwedException);
     }
 }
コード例 #34
0
ファイル: NativeMethods.cs プロジェクト: modulexcite/openwrap
            /// <devdoc>
            /// Creates a connection point to of the given interface type.
            /// which will call on a managed code sink that implements that interface.
            /// </devdoc>
            public ConnectionPointCookie(object source, object sink, Type eventInterface, bool throwException)
            {
                Exception ex = null;
                if (source is IConnectionPointContainer)
                {
                    cpc = (IConnectionPointContainer)source;

                    try
                    {
                        Guid tmp = eventInterface.GUID;
                        cpc.FindConnectionPoint(ref tmp, out connectionPoint);
                    }
                    catch
                    {
                        connectionPoint = null;
                    }

                    if (connectionPoint == null)
                    {
                        ex = new ArgumentException( /* SR.GetString(SR.ConnectionPoint_SourceIF, eventInterface.Name)*/);
                    }
                    else if (sink == null || !eventInterface.IsInstanceOfType(sink))
                    {
                        ex = new InvalidCastException( /* SR.GetString(SR.ConnectionPoint_SinkIF)*/);
                    }
                    else
                    {
                        try
                        {
                            connectionPoint.Advise(sink, out cookie);
                        }
                        catch
                        {
                            cookie = 0;
                            connectionPoint = null;
                            ex = new Exception( /*SR.GetString(SR.ConnectionPoint_AdviseFailed, eventInterface.Name)*/);
                        }
                    }
                }
                else
                {
                    ex = new InvalidCastException( /*SR.ConnectionPoint_SourceNotICP)*/);
                }


                if (throwException && (connectionPoint == null || cookie == 0))
                {
                    if (ex == null)
                    {
                        throw new ArgumentException( /*SR.GetString(SR.ConnectionPoint_CouldNotCreate, eventInterface.Name)*/);
                    }
                    throw ex;
                }

#if DEBUG
                callStack = Environment.StackTrace;
                this.eventInterface = eventInterface;
#endif
            }
コード例 #35
0
 public PinManagerEventsSink(OnGetPinStateCompleteHandler callback, IConnectionPoint connectionPoint)
 {
     m_Callback = new WeakReference<OnGetPinStateCompleteHandler>(callback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviceCookie);
 }
コード例 #36
0
ファイル: MBApiImplementation.cs プロジェクト: mbin/Win81App
 public ConnectionEventsSink(
     OnConnectCompleteHandler connectCallback,
     OnDisconnectCompleteHandler disconnectCallback,
     IConnectionPoint connectionPoint)
 {
     m_ConnectCallback = new WeakReference<OnConnectCompleteHandler>(connectCallback);
     m_DisconnectCallback = new WeakReference<OnDisconnectCompleteHandler>(disconnectCallback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
コード例 #37
0
		/// <summary>
		/// Connects this event sink to a COM object.
		/// </summary>
		/// <param name="connectionPoint">
		/// The connection point to connect to.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="connectionPoint"/> is <see langword="null"/>.
		/// </exception>
		internal void Connect(IConnectionPoint connectionPoint)
		{
			if (null == connectionPoint) throw new ArgumentNullException("connectionPoint");
			
			if (0 == _connectionCookie)
			{
				int connectionCookie;
				connectionPoint.Advise(this, out connectionCookie);
				_connectionCookie = connectionCookie;
				_connectionPoint = connectionPoint;
			}
		}
コード例 #38
0
ファイル: MBApiImplementation.cs プロジェクト: mbin/Win81App
 public DeviceServicesEventsSink(
     OnOpenCommandSessionCompleteHandler onOpenDataSessionCallback,
     OnQueryCommandCompleteHandler onQueryCommandCallback,
     OnCloseCommandSessionCompleteHandler onCloseCommandCallback,
     IConnectionPoint connectionPoint)
 {
     m_OnOpenCommandSessionCallback = new WeakReference<OnOpenCommandSessionCompleteHandler>(onOpenDataSessionCallback);
     m_OnQueryCommandCallback = new WeakReference<OnQueryCommandCompleteHandler>(onQueryCommandCallback);
     m_OnCloseCommandCallback = new WeakReference<OnCloseCommandSessionCompleteHandler>(onCloseCommandCallback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
コード例 #39
0
ファイル: SinkHelper.cs プロジェクト: swatt6400/NetOffice
 /// <summary>
 /// create event binding
 /// </summary>
 /// <param name="connectPoint"></param>
 public void SetupEventBinding(IConnectionPoint connectPoint)
 {
     try
     {
         if (true == Settings.EnableEvents)
         {
             connectPoint.GetConnectionInterface(out _interfaceId);
             _connectionPoint = connectPoint;
             _connectionPoint.Advise(this, out _connectionCookie);
             _pointList.Add(this);
         }
     }
     catch (Exception throwedException)
     {
         DebugConsole.WriteException(throwedException);
         throw (throwedException);
     }
 }
コード例 #40
0
ファイル: MBApiImplementation.cs プロジェクト: mbin/Win81App
 public PinEventsSink(OnEnterCompleteHandler callback, IConnectionPoint connectionPoint)
 {
     m_Callback = new WeakReference<OnEnterCompleteHandler>(callback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }