コード例 #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
1
ファイル: EDocument.cs プロジェクト: vnkolt/NetOffice
		public EDocument_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
コード例 #3
0
		/// <summary>
		/// Cleans up the COM object references.
		/// </summary>
		/// <param name="disposing">
		/// <see langword="true"/> if this was called from the
		/// <see cref="IDisposable"/> interface.
		/// </param>
		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				_owner = null;
				_unmappedEventKeys = null;
				
				if (null != _events)
				{
					_events.Dispose();
					_events = null;
				}
			}
			
			if (null != _connectionPoint)
			{
				if (0 != _connectionCookie)
				{
					_connectionPoint.Unadvise(_connectionCookie);
					_connectionCookie = 0;
				}
				
				while( Marshal.ReleaseComObject(_connectionPoint) > 0 );
				_connectionPoint = null;
			}
		}
コード例 #4
0
 private void Advise(object rcw)
 {
     IConnectionPoint point;
     ((IConnectionPointContainer) rcw).FindConnectionPoint(ref this._iidSourceItf, out point);
     object pUnkSink = this;
     point.Advise(pUnkSink, out this._cookie);
     this._connectionPoint = point;
 }
コード例 #5
0
        public void Dispose() {
            if ((null != _connectionPoint) && (0 != _connectionCookie)) {
                _connectionPoint.Unadvise(_connectionCookie);
            }
            _connectionCookie = 0;
            _connectionPoint = null;

            _buffer = null;
            _fileId = null;
        }
コード例 #6
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);
 }
コード例 #7
0
        public new void Dispose() {
            lock (this) {
                if (_connectionPoint == null)
                    return;

                for (SinkItem node = _sinkHead; node != null; node = node.Next)
                    _connectionPoint.Unadvise(node.Cookie);

                Marshal.ReleaseComObject(_connectionPoint);
                _connectionPoint = null;
                _sinkHead = null;
            }
            GC.SuppressFinalize(this);
        }
コード例 #8
0
        public void Dispose()
        {
            if (_connectionPoint != null && _connectionCookie != 0)
            {
                _connectionPoint.Unadvise(_connectionCookie);
                Debug.WriteLine("\n\tUnadvised from TextLinesEvents\n");
            }

            _connectionCookie = 0;
            _connectionPoint  = null;

            _buffer = null;
            _fileId = null;
        }
コード例 #9
0
ファイル: SinkHelper.cs プロジェクト: swatt6400/NetOffice
        /// <summary>
        /// try to find connection point by EnumConnectionPoints
        /// </summary>
        /// <param name="connectionPointContainer"></param>
        /// <param name="point"></param>
        /// <param name="sinkIds"></param>
        /// <returns></returns>
        private static string EnumConnectionPoint(IConnectionPointContainer connectionPointContainer, ref IConnectionPoint point, params string[] sinkIds)
        {
            IConnectionPoint[] points = new IConnectionPoint[1];
            IEnumConnectionPoints enumPoints = null;
            try
            {
                connectionPointContainer.EnumConnectionPoints(out enumPoints);
                while (enumPoints.Next(1, points, IntPtr.Zero) == 0) // S_OK = 0 , S_FALSE = 1
                {
                    if (null == points[0])
                        break;

                    Guid interfaceGuid;
                    points[0].GetConnectionInterface(out interfaceGuid);

                    for (int i = sinkIds.Length; i > 0; i--)
                    {
                        string id = interfaceGuid.ToString().Replace("{", "").Replace("}", "");
                        if (true == sinkIds[i - 1].Equals(id, StringComparison.InvariantCultureIgnoreCase))
                        {
                            Marshal.ReleaseComObject(enumPoints);
                            enumPoints = null;
                            point = points[0];
                            return id;
                        }
                    }
                }
                return null;
            }
            catch (Exception throwedException)
            {
                DebugConsole.WriteException(throwedException);
                return null;
            }
            finally
            {
                if (null != enumPoints)
                    Marshal.ReleaseComObject(enumPoints);
            }
        }
コード例 #10
0
ファイル: SinkHelper.cs プロジェクト: swatt6400/NetOffice
        /// <summary>
        /// try to find connection point by FindConnectionPoint
        /// </summary>
        /// <param name="connectionPointContainer"></param>
        /// <param name="point"></param>
        /// <param name="sinkIds"></param>
        /// <returns></returns>
        private static string FindConnectionPoint(IConnectionPointContainer connectionPointContainer, ref IConnectionPoint point, params string[] sinkIds)
        {
            try
            {
                for (int i = sinkIds.Length; i > 0; i--)
                {
                    Guid refGuid = new Guid(sinkIds[i - 1]);
                    IConnectionPoint refPoint = null;
                    connectionPointContainer.FindConnectionPoint(ref refGuid, out refPoint);
                    if (null != refPoint)
                    {
                        point = refPoint;
                        return sinkIds[i - 1];
                    }
                }

                return null;
            }
            catch (Exception throwedException)
            {
                DebugConsole.WriteException(throwedException);
                return null;
            }
        }
コード例 #11
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
            }
コード例 #12
0
 internal VirtualConnection(IConnectionPoint source)
 {
     StartPoint = source;
     EndPoint   = null;
     Router     = new DirectLineRouter();
 }
コード例 #13
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass"></param>
 /// <param name="connectPoint"></param>
 public InspectorEvents_10_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #14
0
        public SafeConnectionPointCookie(IConnectionPointContainer target, object sink, Guid eventId)
            : base(true)
        {
            Verify.IsNotNull(target, "target");
            Verify.IsNotNull(sink, "sink");
            Verify.IsNotDefault(eventId, "eventId");

            handle = IntPtr.Zero;

            IConnectionPoint cp = null;
            try
            {
                int dwCookie;
                target.FindConnectionPoint(ref eventId, out cp);
                cp.Advise(sink, out dwCookie);
                if (dwCookie == 0)
                {
                    throw new InvalidOperationException("IConnectionPoint::Advise returned an invalid cookie.");
                }
                handle = new IntPtr(dwCookie);
                _cp = cp;
                cp = null;
            }
            finally
            {
                Utility.SafeRelease(ref cp);
            }
        }
コード例 #15
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);
     }
 }
コード例 #16
0
		public HTMLInputImageEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
コード例 #17
0
		/// <summary>
		/// Cleans up the COM object references.
		/// </summary>
		/// <param name="disposing">
		/// <see langword="true"/> if this was called from the
		/// <see cref="IDisposable"/> interface.
		/// </param>
		private void Dispose(bool disposing)
		{
			lock(this)
			{
				if (null != _eventSink)
				{
					_eventSink.Dispose();
					_eventSink = null;
				}
				
				if (null != _connectionPoint)
				{
					while( Marshal.ReleaseComObject(_connectionPoint) > 0 );
					_connectionPoint = null;
				}
				
				if (null != _connectionPointContainer)
				{
					while( Marshal.ReleaseComObject(_connectionPointContainer) > 0 );
					_connectionPointContainer = null;
				}
			}
		}
コード例 #18
0
 public OutlookBarGroupsEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #19
0
 public _DDocSiteControlEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #20
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass"></param>
 /// <param name="connectPoint"></param>
 /// <exception cref="NetOfficeCOMException">Unexpected error</exception>
 public DispCommandButtonEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #21
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass"></param>
 /// <param name="connectPoint"></param>
 /// <exception cref="NetOfficeCOMException">Unexpected error</exception>
 public _CustomXMLPartEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #22
0
 public PinEventsSink(OnEnterCompleteHandler callback, IConnectionPoint connectionPoint)
 {
     m_Callback        = new WeakReference <OnEnterCompleteHandler>(callback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
コード例 #23
0
 public void FindConnectionPoint(ref Guid riid, out IConnectionPoint ppCP)
 {
     ppCP = new ConnectionPointMock(this);
 }
コード例 #24
0
ファイル: SinkHelper.cs プロジェクト: swatt6400/NetOffice
        public static string GetConnectionPoint2(COMObject comInstance, ref IConnectionPoint point, params string[] sinkIds)
        {
            if (null == sinkIds)
                return null;

            IConnectionPointContainer connectionPointContainer = comInstance.UnderlyingObject as IConnectionPointContainer;
            if (null == connectionPointContainer)
            {
                if (comInstance.Settings.EnableEventDebugOutput)
                    comInstance.Console.WriteLine("Unable to cast IConnectionPointContainer.");
                return null;
            }

            if (comInstance.Settings.EnableEventDebugOutput)
                comInstance.Console.WriteLine(comInstance.UnderlyingTypeName + " -> Call EnumConnectionPoint");

            string id = EnumConnectionPoint(comInstance, connectionPointContainer, ref point, sinkIds);

            if (comInstance.Settings.EnableEventDebugOutput)
                comInstance.Console.WriteLine(comInstance.UnderlyingTypeName + " -> Call EnumConnectionPoint passed");

            if (null == id)
            {
                if (comInstance.Settings.EnableEventDebugOutput)
                    comInstance.Console.WriteLine(comInstance.UnderlyingTypeName + " -> Call FindConnectionPoint");
                id = FindConnectionPoint(comInstance, connectionPointContainer, ref point, sinkIds);
                if (comInstance.Settings.EnableEventDebugOutput)
                    comInstance.Console.WriteLine(comInstance.UnderlyingTypeName + " -> Call FindConnectionPoint passed");
            }

            if (null != id)
                return id;
            else
                throw new COMException("Specified instance doesnt implement the target event interface.");
        }
コード例 #25
0
 public void StopParsing()
 {
     try
     {
         //UnAdvice and clean up
         if ((m_WBConnectionPoint != null) && (m_dwCookie > 0))
             m_WBConnectionPoint.Unadvise(m_dwCookie);
         if (m_WBOleObject != null)
         {
             m_WBOleObject.Close((uint)OLEDOVERB.OLECLOSE_NOSAVE);
             m_WBOleObject.SetClientSite(null);
         }
         if (m_pMSHTML != null)
         {
             Marshal.ReleaseComObject(m_pMSHTML);
             m_pMSHTML = null;
         }
         if (m_WBConnectionPoint != null)
         {
             Marshal.ReleaseComObject(m_WBConnectionPoint);
             m_WBConnectionPoint = null;
         }
         if (m_WBOleControl != null)
         {
             Marshal.ReleaseComObject(m_WBOleControl);
             m_WBOleControl = null;
         }
         if (m_WBOleObject != null)
         {
             Marshal.ReleaseComObject(m_WBOleObject);
             m_WBOleObject = null;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #26
0
 void Microsoft.VisualStudio.OLE.Interop.IConnectionPointContainer.FindConnectionPoint(ref Guid riid, out IConnectionPoint ppCP)
 {
     if (riid.Equals(typeof(IDebugPortEvents2).GUID))
     {
         ppCP = _cpDebugPortEvents2;
     }
     else
     {
         ppCP = null;
         Marshal.ThrowExceptionForHR(COM_HResults.CONNECT_E_NOCONNECTION);
     }
 }
コード例 #27
0
		public _DPageWrapCtrlEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
コード例 #28
0
 public _PageHdrFtrInReportEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
コード例 #29
0
		public DispTextBoxEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
コード例 #30
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass"></param>
 /// <param name="connectPoint"></param>
 public DImageComboEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #31
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass"></param>
 /// <param name="connectPoint"></param>
 /// <exception cref="NetOfficeCOMException">Unexpected error</exception>
 public _DispControlInReportEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #32
0
 public DocumentEvents2_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #33
0
 private VsTextBufferDataEventsSink(IConnectionPoint connectionPoint, Action action)
 {
     _connectionPoint = connectionPoint;
     _action          = action;
 }
コード例 #34
0
 void Microsoft.VisualStudio.OLE.Interop.IConnectionPointContainer.FindConnectionPoint(ref Guid riid, out IConnectionPoint ppCP)
 {
     if (riid.Equals(typeof(IDebugPortEvents2).GUID))
     {
         ppCP = m_cpDebugPortEvents2;
     }
     else
     {
         ppCP = null;
         Marshal.ThrowExceptionForHR(Utility.COM_HResults.CONNECT_E_NOCONNECTION);
     }
 }
 void IConnectionPointContainer.FindConnectionPoint(ref Guid riid, out IConnectionPoint ppCP)
 {
     ppCP = connectionPoints[riid];
 }
コード例 #36
0
 public HTMLButtonElementEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #37
0
		public ApplicationEvents_10_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
コード例 #38
0
ファイル: EMaster.cs プロジェクト: xianjiaodahe91/NetOffice
		public EMaster_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			SetupEventBinding(connectPoint);
		}
コード例 #39
0
		public IProgressBarEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
コード例 #40
0
 public HTMLControlElementEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
コード例 #41
0
ファイル: NativeMethods.cs プロジェクト: modulexcite/openwrap
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         try
         {
             if (connectionPoint != null && cookie != 0)
             {
                 connectionPoint.Unadvise(cookie);
             }
         }
         finally
         {
             cookie = 0;
             connectionPoint = null;
             cpc = null;
         }
     }
 }
コード例 #42
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass"></param>
 /// <param name="connectPoint"></param>
 public ApplicationEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #43
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);
     }
 }
コード例 #44
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass"></param>
 /// <param name="connectPoint"></param>
 /// <exception cref="NetOfficeCOMException">Unexpected error</exception>
 public DispEmptyCellEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #45
0
		/// <summary>
		/// Initialize the event sink.
		/// </summary>
		private void Initialize()
		{
			if (null == _connectionPointContainer)
				throw new ObjectDisposedException("ComEventProvider");
			
			IConnectionPoint connectionPoint;
			Guid pointGuid = _connectionPointGuid;
			_connectionPointContainer.FindConnectionPoint(ref pointGuid, out connectionPoint);
			_connectionPoint = connectionPoint;
			
			_eventSink = (ComEventSink)Activator.CreateInstance(_eventSinkType);
			_eventSink.Connect(_connectionPoint);
			_eventSink.Owner = _owner;
		}
コード例 #46
0
 public OlkBusinessCardControlEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #47
0
		public OlkTimeControlEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
コード例 #48
0
 public _DataSourceControlEvent_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
コード例 #49
0
		public ISpreadsheetEventSink_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
コード例 #50
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass"></param>
 /// <param name="connectPoint"></param>
 public MAPIFolderEvents_12_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #51
0
		public DispPageHdrFtrInReportEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
コード例 #52
0
 public _OptionGroupEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
コード例 #53
0
ファイル: SinkHelper.cs プロジェクト: swatt6400/NetOffice
        public static string GetConnectionPoint(COMObject comProxy, ref IConnectionPoint point, params string[] sinkIds)
        {
            if (null == sinkIds)
                return null;

            IConnectionPointContainer connectionPointContainer = (IConnectionPointContainer)comProxy.UnderlyingObject;

            if (Settings.EnableDebugOutput)
                DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".GetConnectionPoint");

            if (Settings.EnableDebugOutput)
                DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".FindConnectionPoint");

            string id = FindConnectionPoint(connectionPointContainer, ref point, sinkIds);

            if (Settings.EnableDebugOutput)
                DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".FindConnectionPoint sucseed");

            if (null == id)
            {
                if (Settings.EnableDebugOutput)
                    DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".EnumConnectionPoint");
                id = EnumConnectionPoint(connectionPointContainer, ref point, sinkIds);
                if (Settings.EnableDebugOutput)
                    DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".EnumConnectionPoint sucseed");
            }

            if (Settings.EnableDebugOutput)
                DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".GetConnectionPoint passed.");

            if (null != id)
                return id;
            else
                throw new COMException("Specified instance doesnt implement the target event interface.");
        }
コード例 #54
0
 public HTMLXMLHttpRequestEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }
コード例 #55
0
ファイル: SinkHelper.cs プロジェクト: swatt6400/NetOffice
        /// <summary>
        /// release event binding
        /// </summary>
        private void RemoveEventBinding(bool removeFromList)
        {
            if (_connectionCookie != 0)
            {
                try
                {
                    _connectionPoint.Unadvise(_connectionCookie);
                    Marshal.ReleaseComObject(_connectionPoint);
                }
                catch (System.Runtime.InteropServices.COMException throwedException)
                {
                    DebugConsole.WriteException(throwedException);
                    ; // RPC server is disconnected or dead
                }
                catch (Exception throwedException)
                {
                    DebugConsole.WriteException(throwedException);
                    throw new COMException("An error occured.", throwedException);
                }

                _connectionPoint = null;
                _connectionCookie = 0;

                if (removeFromList)
                    _pointList.Remove(this);
            }
        }
コード例 #56
0
 public _CommandBarComboBoxEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #57
0
 public DispNavigationControlEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #58
0
ファイル: Connections.cs プロジェクト: up2038292/dwsim6
        void CreateAndAddRow(string direction, IConnectionPoint connector, IEnumerable <String> options)
        {
            DynamicLayout cont1 = new DynamicLayout();

            var cbConnection = s.CreateAndAddEditableDropDownRow(cont1, connector.ConnectorName, options.ToList(), 0, null);

            if (connector.IsAttached)
            {
                if (connector.AttachedConnector != null)
                {
                    if (direction == "In" && (connector.Type == ConType.ConIn | connector.Type == ConType.ConEn))
                    {
                        if (connector.IsEnergyConnector)
                        {
                            if (options.Contains(connector.AttachedConnector.AttachedTo.Tag))
                            {
                                cbConnection.SelectedIndex = Array.IndexOf(options.ToArray(), connector.AttachedConnector.AttachedTo.Tag);
                            }
                        }
                        else
                        {
                            if (options.Contains(connector.AttachedConnector.AttachedFrom.Tag))
                            {
                                cbConnection.SelectedIndex = Array.IndexOf(options.ToArray(), connector.AttachedConnector.AttachedFrom.Tag);
                            }
                        }
                    }
                    else if (connector.Type == ConType.ConOut | connector.Type == ConType.ConEn)
                    {
                        if (options.Contains(connector.AttachedConnector.AttachedTo.Tag))
                        {
                            cbConnection.SelectedIndex = Array.IndexOf(options.ToArray(), connector.AttachedConnector.AttachedTo.Tag);
                        }
                    }
                }
            }
            else
            {
                cbConnection.SelectedIndex = 0;
            }

            cbConnection.Tag = false;

            Action <object, EventArgs> schangedaction = (sender, e) =>
            {
                if (cbConnection.SelectedIndex == -1)
                {
                    return;
                }

                var fgui = (Interfaces.IFlowsheet)SimObject.GetFlowsheet();

                if ((bool)cbConnection.Tag)
                {
                    var sel = options.ElementAt(cbConnection.SelectedIndex);

                    var gobj      = SimObject.GraphicObject;
                    var flowsheet = SimObject.GetFlowsheet();

                    if (connector.IsAttached && sel == "")
                    {
                        if (direction == "In" && (connector.Type == ConType.ConIn | connector.Type == ConType.ConEn))
                        {
                            try
                            {
                                var objfrom = connector.AttachedConnector.AttachedFrom;
                                flowsheet.DisconnectObjects(objfrom, gobj);
                                flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}.", objfrom.Tag, gobj.Tag), IFlowsheet.MessageType.Information);
                            }
                            catch (Exception ex)
                            {
                                flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                            }
                            fgui.UpdateInterface();
                            fgui.UpdateOpenEditForms();
                            return;
                        }
                        else if (connector.Type == ConType.ConOut | connector.Type == ConType.ConEn)
                        {
                            try
                            {
                                var objto = connector.AttachedConnector.AttachedTo;
                                flowsheet.DisconnectObjects(gobj, objto);
                                flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}.", gobj.Tag, objto.Tag), IFlowsheet.MessageType.Information);
                            }
                            catch (Exception ex)
                            {
                                flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);;
                            }
                            fgui.UpdateInterface();
                            fgui.UpdateOpenEditForms();
                            return;
                        }
                    }

                    if (sel != "")
                    {
                        var gobj2 = flowsheet.GetFlowsheetSimulationObject(sel)?.GraphicObject;

                        if (gobj2 == null)
                        {
                            return;
                        }

                        if (direction == "In" && (connector.Type == ConType.ConIn | connector.Type == ConType.ConEn))
                        {
                            if (connector.IsAttached)
                            {
                                try
                                {
                                    var objfrom = connector.AttachedConnector.AttachedFrom;
                                    flowsheet.DisconnectObjects(objfrom, gobj);
                                    flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}.", objfrom.Tag, gobj.Tag), IFlowsheet.MessageType.Information);
                                }
                                catch (Exception ex)
                                {
                                    flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                                }
                            }
                            if (connector.IsEnergyConnector)
                            {
                                if (gobj2.InputConnectors[0].IsAttached)
                                {
                                    flowsheet.ShowMessage("Selected object already connected to another object.", IFlowsheet.MessageType.GeneralError);
                                    cbConnection.SelectedIndex = 0;
                                    return;
                                }
                                try
                                {
                                    flowsheet.ConnectObjects(gobj, gobj2, 0, 0);
                                    flowsheet.ShowMessage(String.Format("Connected {0} to {1}.", gobj.Tag, gobj2.Tag), IFlowsheet.MessageType.Information);
                                }
                                catch (Exception ex)
                                {
                                    flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                                }
                            }
                            else
                            {
                                if (gobj2.OutputConnectors[0].IsAttached)
                                {
                                    flowsheet.ShowMessage("Selected object already connected to another object.", IFlowsheet.MessageType.GeneralError);
                                    cbConnection.SelectedIndex = 0;
                                    return;
                                }
                                try
                                {
                                    flowsheet.ConnectObjects(gobj2, gobj, 0, gobj.InputConnectors.IndexOf(connector));
                                    flowsheet.ShowMessage(String.Format("Connected {0} to {1}.", gobj2.Tag, gobj.Tag), IFlowsheet.MessageType.Information);
                                }
                                catch (Exception ex)
                                {
                                    flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                                }
                            }
                        }
                        else if (connector.Type == ConType.ConOut | connector.Type == ConType.ConEn)
                        {
                            if (gobj2.InputConnectors[0].IsAttached)
                            {
                                flowsheet.ShowMessage("Selected object already connected to another object.", IFlowsheet.MessageType.GeneralError);
                                cbConnection.SelectedIndex = 0;
                                return;
                            }
                            try
                            {
                                if (connector.IsAttached)
                                {
                                    var objto = connector.AttachedConnector.AttachedTo;
                                    flowsheet.DisconnectObjects(gobj, objto);
                                    flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}.", gobj.Tag, objto.Tag), IFlowsheet.MessageType.Information);
                                }
                                flowsheet.ConnectObjects(gobj, gobj2, gobj.OutputConnectors.IndexOf(connector), 0);
                                flowsheet.ShowMessage(String.Format("Connected {0} to {1}.", gobj.Tag, gobj2.Tag), IFlowsheet.MessageType.Information);
                            }
                            catch (Exception ex)
                            {
                                flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                            }
                        }

                        fgui.UpdateInterface();
                        fgui.UpdateOpenEditForms();
                    }
                }
            };

            cbConnection.KeyUp += (sender, e) =>
            {
                if (e.Key == Keys.Enter)
                {
                    var items = cbConnection.Items.Select((x) => x.Text).ToList();
                    if (!items.Contains(cbConnection.Text))
                    {
                        var   gobj = SimObject.GraphicObject;
                        var   flowsheet = SimObject.GetFlowsheet();
                        float posx, posy;
                        if (direction == "In")
                        {
                            posx = gobj.X - 100;
                            posy = gobj.Y + gobj.Height / 2;
                        }
                        else
                        {
                            posx = gobj.X + gobj.Width + 100;
                            posy = gobj.Y + gobj.Height / 2;
                        }
                        ISimulationObject stream = flowsheet.GetFlowsheetSimulationObject(cbConnection.Text);
                        if (stream == null)
                        {
                            if (connector.Type == ConType.ConEn)
                            {
                                stream = flowsheet.AddObject(ObjectType.EnergyStream, (int)posx, (int)posy, cbConnection.Text);
                            }
                            else
                            {
                                stream = flowsheet.AddObject(ObjectType.MaterialStream, (int)posx, (int)posy, cbConnection.Text);
                            }
                        }
                        ((Drawing.SkiaSharp.GraphicObjects.GraphicObject)stream.GraphicObject).CreateConnectors(0, 0);
                        if (direction == "In")
                        {
                            try
                            {
                                if (connector.IsAttached)
                                {
                                    var objfrom = connector.AttachedConnector.AttachedFrom;
                                    flowsheet.DisconnectObjects(objfrom, gobj);
                                    flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}.", objfrom.Tag, gobj.Tag), IFlowsheet.MessageType.Information);
                                }
                                flowsheet.ConnectObjects(stream.GraphicObject, gobj, 0, gobj.InputConnectors.IndexOf(connector));
                                flowsheet.ShowMessage(String.Format("Connected {0} to {1}.", stream.GraphicObject.Tag, gobj.Tag), IFlowsheet.MessageType.Information);
                                cbConnection.Items.Add(cbConnection.Text);
                                var list = new List <string>(options);
                                list.Add(cbConnection.Text);
                                options = list;
                            }
                            catch (Exception ex)
                            {
                                flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                            }
                        }
                        else
                        {
                            try
                            {
                                if (connector.IsAttached)
                                {
                                    var objto = connector.AttachedConnector.AttachedTo;
                                    flowsheet.DisconnectObjects(gobj, objto);
                                    flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}", gobj.Tag, objto.Tag), IFlowsheet.MessageType.Information);
                                }
                                if (connector.IsEnergyConnector)
                                {
                                    flowsheet.ConnectObjects(gobj, stream.GraphicObject, 0, 0);
                                }
                                else
                                {
                                    flowsheet.ConnectObjects(gobj, stream.GraphicObject, gobj.OutputConnectors.IndexOf(connector), 0);
                                }
                                flowsheet.ShowMessage(String.Format("Connected {0} to {1}.", gobj.Tag, stream.GraphicObject.Tag), IFlowsheet.MessageType.Information);
                                cbConnection.Items.Add(cbConnection.Text);
                                var list = new List <string>(options);
                                list.Add(cbConnection.Text);
                                options = list;
                            }
                            catch (Exception ex)
                            {
                                flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                            }
                        }
                    }
                    else
                    {
                        schangedaction.Invoke(cbConnection, e);
                    }
                }
            };

            cbConnection.SelectedValueChanged += (sender, e) => schangedaction.Invoke(sender, e);

            cbConnection.Tag = true;

            container.Rows.Add(new TableRow(cont1));

            return;
        }
コード例 #59
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="eventClass"></param>
 /// <param name="connectPoint"></param>
 /// <exception cref="NetOfficeCOMException">Unexpected error</exception>
 public HTMLTextContainerEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     SetupEventBinding(connectPoint);
 }
コード例 #60
0
 public MAPIFolderEvents_12_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint) : base(eventClass)
 {
     _eventClass   = eventClass;
     _eventBinding = (IEventBinding)eventClass;
     SetupEventBinding(connectPoint);
 }