Exemplo n.º 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
        }
Exemplo n.º 2
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="target">
		/// The target COM object
		/// </param>
		/// <param name="interceptType">
		/// The intercepted type.
		/// </param>
		/// <param name="owner">
		/// The owner <see cref="COMWrapper"/>
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="target"/> is <see langword="null"/></para>
		/// <para>-or-</para>
		/// <para><paramref name="interceptType"/> is <see langword="null"/></para>
		/// </exception>
		/// <exception cref="NotImplementedException">
		/// <paramref name="interceptType"/> does not define the
		/// <see cref="ComEventsAttribute"/> attribute.
		/// </exception>
		public ComEventProvider(object target, Type interceptType, COMWrapper owner)
		{
			if (null == target) throw new ArgumentNullException("target");
			if (null == interceptType) throw new ArgumentNullException("interceptType");
			
			ComEventsAttribute value = ComEventsAttribute.GetAttribute(interceptType);
			if (null == value) throw new NotImplementedException("Event provider attribute not found.");
			
			_connectionPointContainer = (IConnectionPointContainer)target;
			_eventSinkType = value.EventSinkType;
			_connectionPointGuid = value.EventsGuid;
			
			if (null != owner) _owner = new WeakReference(owner);
		}
Exemplo n.º 3
0
        /// <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);
            }
        }
Exemplo n.º 4
0
        public NetworkWatcher()
        {
            _buffer = new Timer(BufferCallback);

            _manager = new NetworkListManager();

            // init current connections
            _connections = GetCurrentConnections();

            // prep for networkevents
            _container = (IConnectionPointContainer)_manager;
            _container.FindConnectionPoint(ref IID_INetworkEvents, out _connectionPoint);

            // wire up sink object
            _sink.Added += NetworkAdded;
            _sink.ConnectivityChanged += NetworkConnectivityChanged;
            _sink.Deleted += NetworkDeleted;
            _sink.PropertyChanged += NetworkPropertyChanged;

            // enable raising events
            _connectionPoint.Advise(_sink, out _cookie);
        }
Exemplo n.º 5
0
        private void InitReqIOInterfaces()
        {
            try
            {
                //Query interface for async calls on group object
                pIOPCAsyncIO2      = (IOPCAsyncIO2)pobjGroup1;
                pIOPCSyncIO        = (IOPCSyncIO)pobjGroup1;
                pIOPCGroupStateMgt = (IOPCGroupStateMgt)pobjGroup1;

                // Query interface for callbacks on group object
                pIConnectionPointContainer = (IConnectionPointContainer)pobjGroup1;

                // Establish Callback for all async operations
                Guid iid = typeof(IOPCDataCallback).GUID;
                pIConnectionPointContainer.FindConnectionPoint(ref iid, out pIConnectionPoint);

                // Creates a connection between the OPC servers's connection point and
                // this client's sink (the callback object).
                pIConnectionPoint.Advise(this, out dwCookie);
            }
            catch (System.Exception error) // catch for group adding
            {
            }
        }
Exemplo n.º 6
0
        /// <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;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Try to find connection point by FindConnectionPoint
        /// </summary>
        private static string FindConnectionPoint(ICOMObject comInstance, 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)
            {
                comInstance.Console.WriteException(throwedException);
                return(null);
            }
        }
Exemplo n.º 8
0
        protected override void Initialize()
        {
            PlvsLogger.log("plvsPackage.Initialize() - enter");
            base.Initialize();

            if (InCommandLineMode)
            {
                return;
            }

            installCrashHandler();

            ProxyListener.Instance.init();

            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // toggle tool window command
                CommandID      menuCommandId = new CommandID(GuidList.guidplvsCmdSet, (int)PkgCmdIDList.cmdidToggleToolWindow);
                OleMenuCommand menuItem      = new OleMenuCommand(toggleToolWindowMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += toggleToolWindow_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                // find issue command
                menuCommandId = new CommandID(GuidList.guidplvsCmdSet, (int)PkgCmdIDList.cmdidFindIssue);
                menuItem      = new OleMenuCommand(findIssueMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += toolWindowCommand_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                // create issue command
                menuCommandId = new CommandID(GuidList.guidplvsCmdSet, (int)PkgCmdIDList.cmdidCreateIssue);
                menuItem      = new OleMenuCommand(createIssueMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += toolWindowCommand_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                // project properties command
                menuCommandId = new CommandID(GuidList.guidplvsCmdSet, (int)PkgCmdIDList.cmdidProjectProperties);
                menuItem      = new OleMenuCommand(projectPropertiesMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += toolWindowCommand_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                // global properties command
                menuCommandId = new CommandID(GuidList.guidplvsCmdSet, (int)PkgCmdIDList.cmdidGlobalProperties);
                menuItem      = new OleMenuCommand(globalPropertiesMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += toolWindowCommand_BeforeQueryStatus;
                mcs.AddCommand(menuItem);
            }

            SolutionEventSink solutionEventSink = new SolutionEventSink(this, createAtlassianWindow, createIssueDetailsWindow, createBuildDetailsWindow);
            IVsSolution       solution          = (IVsSolution)GetService(typeof(SVsSolution));

            ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(solutionEventSink, out solutionEventCookie));

#if !VS2010
            JiraLinkMarkerTypeProvider markerTypeProvider = new JiraLinkMarkerTypeProvider();
            ((IServiceContainer)this).AddService(markerTypeProvider.GetType(), markerTypeProvider, true);

            // Now it's time to initialize our copies of the marker IDs. We need them to be
            // able to create marker instances.
            JiraLinkMarkerTypeProvider.InitializeMarkerIds(this);

            RunningDocTableEventSink runningDocTableEventSink = new RunningDocTableEventSink();
            TextManagerEventSink     textManagerEventSink     = new TextManagerEventSink();

            IConnectionPointContainer textManager = (IConnectionPointContainer)GetService(typeof(SVsTextManager));
            Guid interfaceGuid = typeof(IVsTextManagerEvents).GUID;

            try {
                textManager.FindConnectionPoint(ref interfaceGuid, out tmConnectionPoint);
                tmConnectionPoint.Advise(textManagerEventSink, out tmConnectionCookie);
// ReSharper disable EmptyGeneralCatchClause
            }
            catch {}
            // ReSharper restore EmptyGeneralCatchClause

            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));
            ErrorHandler.ThrowOnFailure(rdt.AdviseRunningDocTableEvents(runningDocTableEventSink, out rdtEventCookie));

            // Since we register custom text markers we have to ensure the font and color
            // cache is up-to-date.
            ValidateFontAndColorCacheManagerIsUpToDate();
#endif
            ((IServiceContainer)this).AddService(typeof(AnkhSvnJiraConnector), new ServiceCreatorCallback(CreateAnkhSvnConnector), true);
        }
 // Aletnative to destructor
 void IDisposable.Dispose()
 {
   Disconnect();
   ConnectionPointContainer = null;
   System.GC.SuppressFinalize(this);
 }
Exemplo n.º 10
0
        public void Init()
        {
            using (Settings xmlreader = new MPSettings())
            {
                _controlEnabled       = xmlreader.GetValueAsBool("remote", "X10", false);
                _x10Medion            = xmlreader.GetValueAsBool("remote", "X10Medion", false);
                _x10Ati               = xmlreader.GetValueAsBool("remote", "X10ATI", false);
                _x10Firefly           = xmlreader.GetValueAsBool("remote", "X10Firefly", false);
                _logVerbose           = xmlreader.GetValueAsBool("remote", "X10VerboseLog", false);
                _x10UseChannelControl = xmlreader.GetValueAsBool("remote", "X10UseChannelControl", false);
                _x10Channel           = xmlreader.GetValueAsInt("remote", "X10Channel", 0);
            }

            //Setup the X10 Remote
            try
            {
                if (X10Inter == null)
                {
                    try
                    {
                        X10Inter = new X10Interface();
                    }
                    catch (COMException)
                    {
                        Log.Info("X10 debug: Could not get interface");
                        _remotefound = false;
                        return;
                    }
                    _remotefound = true;

                    //Bind the interface using a connection point

                    icpc = (IConnectionPointContainer)X10Inter;
                    Guid IID_InterfaceEvents = typeof(_DIX10InterfaceEvents).GUID;
                    icpc.FindConnectionPoint(ref IID_InterfaceEvents, out icp);
                    icp.Advise(this, out cookie);
                }
            }
            catch (COMException cex)
            {
                Log.Info("X10 Debug: Com error - " + cex.ToString());
            }

            if (_inputHandler == null)
            {
                if (_controlEnabled)
                {
                    if (_x10Medion)
                    {
                        _inputHandler = new InputHandler("Medion X10");
                    }
                    else if (_x10Ati)
                    {
                        _inputHandler = new InputHandler("ATI X10");
                    }
                    else if (_x10Firefly)
                    {
                        _inputHandler = new InputHandler("Firefly X10");
                    }
                    else
                    {
                        _inputHandler = new InputHandler("Other X10");
                    }
                }
                else
                {
                    return;
                }

                if (!_inputHandler.IsLoaded)
                {
                    _controlEnabled = false;
                    Log.Info("X10: Error loading default mapping file - please reinstall MediaPortal");
                    return;
                }

                if (_logVerbose)
                {
                    if (_x10Medion)
                    {
                        Log.Info("X10Remote: Start Medion");
                    }
                    else if (_x10Ati)
                    {
                        Log.Info("X10Remote: Start ATI");
                    }
                    else if (_x10Firefly)
                    {
                        Log.Info("X10Remote: Start Firefly");
                    }
                    else
                    {
                        Log.Info("X10Remote: Start Other");
                    }
                }
            }
        }
Exemplo n.º 11
0
 public void GetConnectionPointContainer(out IConnectionPointContainer ppCPC)
 {
     ppCPC = this.container;
 }
Exemplo n.º 12
0
 //------------------------------------------------------------
 public HTMLDocument2Events2Sink(int procId, IHTMLDocument2 doc, DocumentCompleteEventHandler h)
 {
     this.procId = procId;
     this.doc = doc;
     docCompletedHandler = h;
     handler = new Handler(this);
     connPointContainer = (IConnectionPointContainer)doc;
     connPointContainer.FindConnectionPoint(ref IID_HTMLDocumentEvents2, out connPoint);
     connPoint.Advise(handler, out cookie);
 }
Exemplo n.º 13
0
    void Interop.IElementBehavior.Init(Interop.IElementBehaviorSite site)
    {
        Dictionary <string, int> dictionary1;
        string text2;
        string text3;
        string text4;
        int    num1;

        this.behaviorSite = site;
        if (4 == 0)
        {
            goto Label_01AE;
        }
        this.attachedElement = (Interop.IHTMLElement2)site.GetElement();
        this.paintSite       = (Interop.IHTMLPaintSite) this.behaviorSite;
        IConnectionPointContainer container1 = (IConnectionPointContainer)this.attachedElement;
        Guid   guid1 = Guid.Empty;
        string text1 = container1.GetType().Name;

        if (text1.EndsWith("Class"))
        {
            text2 = container1.GetType().Name.Substring(0, text1.Length - 5) + "Events2";
            if (text1 == "HTMLInputElementClass")
            {
                goto Label_03D4;
            }
            if ((((uint)num1) + ((uint)num1)) <= uint.MaxValue)
            {
                goto Label_022E;
            }
            if ((((uint)num1) <= uint.MaxValue) && ((((uint)num1) | uint.MaxValue) == 0))
            {
                goto Label_012B;
            }
            goto Label_024A;
        }
        return;

Label_00D9:
        if ((0 == 0) && ((((uint)num1) & 0) == 0))
        {
            goto Label_0107;
        }
Label_00DC:
        //if (<PrivateImplementationDetails>{FDFC6380-7665-4920-BE96-D8D7777662F6}.$$method0x6000139-1.TryGetValue(text4, out num1))
        {
            switch (num1)
            {
            case 0:
                text2 = "HTMLInputTextElementEvents2";
                if (4 != 0)
                {
                    if ((((uint)num1) - ((uint)num1)) >= 0)
                    {
                    }
                    goto Label_0107;
                }
                if (0 == 0)
                {
                    goto Label_02C9;
                }
                if (-2147483648 != 0)
                {
                    goto Label_03D4;
                }
                goto Label_0360;

            case 1:
                text2 = "HTMLOptionButtonElementEvents2";
                goto Label_0107;

            case 2:
                text2 = "HTMLButtonElementEvents2";
                goto Label_0107;

            case 3:
                goto Label_02C9;

            case 4:
                text2 = "HTMLElementEvents2";
                goto Label_0107;

            case 5:
                throw new NotImplementedException("dunno correct class");

            case 6:
                text2 = "HTMLInputTextElementEvents2";
                goto Label_0107;
            }
        }
Label_0107:
        text3 = "mshtml." + text2 + ", Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
        if (((((uint)num1) + ((uint)num1)) <= uint.MaxValue) && ((((uint)num1) + ((uint)num1)) < 0))
        {
            goto Label_016C;
        }
        Type type1 = Type.GetType(text3);

        try
        {
            guid1 = type1.GUID;
            container1.FindConnectionPoint(ref guid1, out this.x09a9fe7720941e5b);
            this.x09a9fe7720941e5b.Advise(this.myEvents, out this.xc151a99213d76447);
            this.myEvents.ElementEvent += new ElementEventHandler(this.eventHandler);
        }
        catch
        {
            MessageBox.Show("Could not attach events for " + ((Interop.IHTMLElement) this.attachedElement).outerHTML);
        }
        return;

Label_011E:
        if (text1 == "HTMLDivElementClass")
        {
            goto Label_016C;
        }
Label_012B:
        if (text1 != "HTMLSpanElementClass")
        {
            goto Label_0107;
        }
        text2 = "HTMLElementEvents2";
        goto Label_00D9;
Label_016C:
        text2 = "HTMLElementEvents2";
        goto Label_0107;
Label_0177:
        if (text1 == "HTMLAnchorElementClass")
        {
            text2 = "HTMLAnchorEvents2";
            if (((uint)num1) >= 0)
            {
                goto Label_0107;
            }
            if ((((uint)num1) - ((uint)num1)) < 0)
            {
                goto Label_00D9;
            }
            if ((((uint)num1) | 1) != 0)
            {
                goto Label_01AE;
            }
            goto Label_022E;
        }
        if ((((uint)num1) + ((uint)num1)) > uint.MaxValue)
        {
            if (0 != 0)
            {
                goto Label_0177;
            }
            goto Label_011E;
        }
        if (((uint)num1) <= uint.MaxValue)
        {
            goto Label_011E;
        }
        goto Label_016C;
Label_01AE:
        if ((((uint)num1) | 15) == 0)
        {
            goto Label_022E;
        }
        if (0xff != 0)
        {
            goto Label_0177;
        }
Label_01CD:
        if ((((uint)num1) & 0) != 0)
        {
            goto Label_01AE;
        }
        goto Label_0177;
Label_022E:
        if (text1 != "HTMLGenericElementClass")
        {
            if (-1 != 0)
            {
                goto Label_01CD;
            }
            goto Label_0107;
        }
Label_024A:
        text2 = "HTMLElementEvents2";
        goto Label_0107;
Label_02C9:
        text2 = "HTMLElementEvents2";
        goto Label_0107;
Label_0360:
        dictionary1 = new Dictionary <string, int>(7);
        dictionary1.Add("text", 0);
        dictionary1.Add("option", 1);
        dictionary1.Add("button", 2);
        dictionary1.Add("submit", 3);
        dictionary1.Add("radio", 4);
        dictionary1.Add("image", 5);
        dictionary1.Add("hidden", 6);
        //<PrivateImplementationDetails>{FDFC6380-7665-4920-BE96-D8D7777662F6}.$$method0x6000139-1 = dictionary1;
        goto Label_00DC;
Label_03D4:
        if ((text4 = ((HTMLInputElementClass)container1).type) == null)
        {
            goto Label_0107;
        }
        //if (<PrivateImplementationDetails>{FDFC6380-7665-4920-BE96-D8D7777662F6}.$$method0x6000139-1 == null)
        {
            goto Label_0360;
        }
        goto Label_00DC;
    }
Exemplo n.º 14
0
        /// <summary>
        /// 添加组和标签异步读取
        /// </summary>
        /// <param name="name"></param>
        public static void OPCServerADDgroup(string name, string itemname)
        {
            Int32 dwRequestedUpdateRate = 1000;
            Int32 hClientGroup          = 1;
            Int32 pRevUpdateRate;


            float    deadband = 0;
            int      TimeBias = 0;
            GCHandle hTimeBias, hDeadband;

            hTimeBias = GCHandle.Alloc(TimeBias, GCHandleType.Pinned);
            hDeadband = GCHandle.Alloc(deadband, GCHandleType.Pinned);
            Guid iidRequiredInterface = typeof(IOPCItemMgt).GUID;

            if (connectedOK == false)
            {
                MessageBox.Show("OPC服务器没有连接,读取数据失败");
                return;
            }
            IntPtr pResults = IntPtr.Zero;                                                  /* 保存AddItems函数的执行结果 */
            IntPtr pErrors  = IntPtr.Zero;                                                  /* 保存AddItems函数的执行错误 */

            /* 执行结果信息 */
            try
            {
                Serverobj.AddGroup(name,
                                   0, dwRequestedUpdateRate,
                                   hClientGroup,
                                   hTimeBias.AddrOfPinnedObject(),
                                   hDeadband.AddrOfPinnedObject(),
                                   LOCALE_ID,
                                   out pSvrGroupHandle,
                                   out pRevUpdateRate,
                                   ref iidRequiredInterface,
                                   out MyobjGroup1);                                 //增加相应的组
                IOPCAsyncIO2Obj            = (IOPCAsyncIO2)MyobjGroup1;              //为组同步读写定义句柄
                IOPCGroupStateMgtObj       = (IOPCGroupStateMgt)MyobjGroup1;         //组管理对象
                pIConnectionPointContainer = (IConnectionPointContainer)MyobjGroup1; //增加特定组的异步调用连接

                Guid iid = typeof(IOPCDataCallback).GUID;                            //为所有的异步调用创建回调
                pIConnectionPointContainer.FindConnectionPoint(ref iid, out pIConnectionPoint);
                //为OPC server 的连接点与客户端接收点之间建立连接
                //  pIConnectionPoint.Advise(this, out dwCookie);
                tItemSvrHandleArray = new  int[1];
                OPCITEMDEF[] itemarray = new OPCITEMDEF[4];
                itemarray[0].szAccessPath        = "";       /* 访问路径"" */
                itemarray[0].szItemID            = itemname; /* OPC标签名称 */
                itemarray[0].hClient             = 1;
                tItemSvrHandleArray[0]           = 1;        /* 客户机的标签索引 */
                itemarray[0].dwBlobSize          = 0;
                itemarray[0].pBlob               = IntPtr.Zero;
                itemarray[0].vtRequestedDataType = 2;
                ItemSvrHandleArray               = new int[1, 1];
                ((IOPCItemMgt)MyobjGroup1).AddItems(1, itemarray, out pResults, out pErrors); //将标签加入到组中
                int[]  errors = new int[1];                                                   /* 每个标签的错误信息 */
                IntPtr pos    = pResults;
                Marshal.Copy(pErrors, errors, 0, 1);                                          /* pErrors->errors */
                for (int i = 0; i < 1; i++)                                                   /* 检查每个标签的error */
                {
                    if (errors[i] == 0)                                                       /* 如果无错误=0 */
                    {
                        if (i != 0)                                                           /* 如果不是第一个标签则指针移动一个OPCITEMRESULT */
                        {
                            pos = new IntPtr(pos.ToInt32() + Marshal.SizeOf(typeof(OPCITEMRESULT)));
                        }
                        OPCITEMRESULT result = (OPCITEMRESULT)Marshal.PtrToStructure(pos, typeof(OPCITEMRESULT)); /* IntPtr->OPCITEMRESULT */
                        ItemSvrHandleArray[0, 0] = result.hServer;                                                /* 保存该标签在服务器中的句柄,以后读写标签数值时要用到 */
                    }
                    else
                    {                                                                       /* 如果有错误(向服务器添加标签失败) */
                        connectedOK = false;                                                /* 连接失败 */
                        // String strError;
                        //  Serverobj.GetErrorString(errors[i], LOCALE_ID, out strError);   /* 获取错误信息 */
                        // OutputExceptionToDatabase(.......)                               /* 将异常信息输出到数据库 */
                        throw new Exception("添加标签:" + itemarray[i].szItemID + " 错误!" //+ strError
                                            );                                       /* 抛出异常 */
                    }
                }
            }
            catch (System.Exception error)
            {
                MessageBox.Show("group组添加失败失败\n" + error.Message);
            }
            finally
            {
                if (pResults != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pResults);
                    pErrors = IntPtr.Zero;
                }
                if (pErrors != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pErrors);
                    pErrors = IntPtr.Zero;
                }
            }
        }
 public IOmniRigXEvents_EventProvider([In] object obj0)
 {
     this.m_ConnectionPointContainer = (IConnectionPointContainer)obj0;
 }
Exemplo n.º 16
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="FeatureProgress" /> class.
 /// </summary>
 /// <param name="connectionPointContainer">The connection point container.</param>
 /// <exception cref="ArgumentException">An feature progress connection point could not be found.</exception>
 protected FeatureProgress(IConnectionPointContainer connectionPointContainer)
 {
     Advise(connectionPointContainer);
 }
Exemplo n.º 17
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the 
        // runtime from inside the finalizer and you should not reference 
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed 
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                    this._connectionPointContainer = null;
                }

                // Call the appropriate methods to clean up 
                // unmanaged resources here.
                // If disposing is false, 
                // only the following code is executed.
                try
                {
                    if (this._connectionPoint != null)
                    {
                        this._connectionPoint.Unadvise(this._eventSinkHelper.m_dwCookie);
                        Marshal.ReleaseComObject(this._connectionPoint);
                        this._connectionPoint = null;
                        this._eventSinkHelper = null;
                    }

                    if (this._drvCtx != null)
                    {
                        Marshal.ReleaseComObject(this._drvCtx);
                        this._drvCtx = null;
                    }
                }
                catch (Exception)
                {
                }
                finally
                {
                }
            }
            disposed = true;
        }
Exemplo n.º 18
0
 /// <summary>
 /// Retrieves the IConnectionPointContainer interface pointer for the parent connectable object. (http://msdn.microsoft.com/en-us/library/ms679669.aspx)
 /// </summary>
 /// <param name="ppCPC"> An IConnectionPointContainer object. </param>
 public void GetConnectionPointContainer(out IConnectionPointContainer ppCPC)
 {
     ppCPC = this;
 }
Exemplo n.º 19
0
        // Methods
        public DrvCtxWrap(IDrvCtx ctx)
        {
            try
            {
                this._drvCtx = ctx;
                this._connectionPointContainer = (IConnectionPointContainer)ctx;

                IConnectionPoint ppCP = null;
                byte[] b = new byte[] { 0xe5, 0x26, 0xd6, 0x63, 0x58, 0x20, 0x18, 0x4d, 0xa2, 190, 0x52, 0x3f, 0xf5, 0x3d, 0x44, 0x34 };
                Guid riid = new Guid(b);

                this._connectionPointContainer.FindConnectionPoint(ref riid, out ppCP);
                this._connectionPoint = (IConnectionPoint)ppCP;

                this._eventSinkHelper = new DrvCtxEventSinkHelper();
                this._eventSinkHelper.m_OnAsyncDataDelegate = new _IDrvCtxEvents_OnAsyncDataEventHandler(this.OnAsyncData);
                this._eventSinkHelper.m_OnNotifyDelegate = new _IDrvCtxEvents_OnNotifyEventHandler(this.OnNotify);
                this._eventSinkHelper.m_OnStatusDelegate = new _IDrvCtxEvents_OnStatusEventHandler(this.OnStatus);
                this._eventSinkHelper.m_OnSyncDataDelegate = new _IDrvCtxEvents_OnSyncDataEventHandler(this.OnSyncData);


                int pdwCookie = 0;
                this._connectionPoint.Advise((object)this._eventSinkHelper, out pdwCookie);
                this._eventSinkHelper.m_dwCookie = pdwCookie;
            }
            catch (Exception theException)
            {
                String errorMessage;
                errorMessage = "Error: ";
                errorMessage = String.Concat(errorMessage, theException.Message);
                errorMessage = String.Concat(errorMessage, " Line: ");
                errorMessage = String.Concat(errorMessage, theException.Source);

                //MessageBox.Show(errorMessage, "Error");

                throw theException;
            }
        }
 protected MSScriptControl_EventProvider(object connectionPoint) {
     _connectionPointContainer = (IConnectionPointContainer)connectionPoint;
     _riid = typeof(IMSScriptControl_EventSink).GUID;
 }
Exemplo n.º 21
0
 void IConnectionPoint.GetConnectionPointContainer(out IConnectionPointContainer connectionPointContainer)
 {
     connectionPointContainer = this;
 }
Exemplo n.º 22
0
        public void Execute()
        {
            Package2 dtsPackage = new Package2();

            try
            {
                LoggerHandler(ExecutionLoggerEventType.Information, "Будем загружать DTS-пакет из файла '" + _packageFilePath + "'");
                object pVarPersistStgOfHost = "";
                dtsPackage.LoadFromStorageFile(_packageFilePath, "", "", "", "", ref pVarPersistStgOfHost);
                LoggerHandler(ExecutionLoggerEventType.Information, "Пакет загружен");
                LoggerHandler(ExecutionLoggerEventType.Information, "Готовы задать " + _parameters.Count + " параметров");
                foreach (var parameter in _parameters)
                {
                    dtsPackage.GlobalVariables.Remove(parameter.Key);
                    dtsPackage.GlobalVariables.AddGlobalVariable(parameter.Key, parameter.Value);
                    LoggerHandler(ExecutionLoggerEventType.Information, "Параметр " + parameter.Key + " добавлен к пакету");
                }

                dtsPackage.FailOnError = true;
                if (_logFilePath != null)
                {
                    dtsPackage.LogFileName = _logFilePath;
                }

                IConnectionPointContainer cnnctPtCont = (IConnectionPointContainer)dtsPackage;
                IConnectionPoint          cnnctPt;
                PackageEventsSink         pes = new PackageEventsSink();
                Guid guid = new Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5");  // UUID of PackageEvents Interface
                cnnctPtCont.FindConnectionPoint(ref guid, out cnnctPt);
                int iCookie;
                cnnctPt.Advise(pes, out iCookie);



                _stepsCount = dtsPackage.Steps.Count;
                LoggerHandler(ExecutionLoggerEventType.Information, "Пакет содержит " + _stepsCount + " шагов. Начинаем выполнять пакет.");
                dtsPackage.Execute();
                LoggerHandler(ExecutionLoggerEventType.Information, "Пакет выполнен");
                dtsPackage.UnInitialize();
                cnnctPt.Unadvise(iCookie);

                LoggerHandler(ExecutionLoggerEventType.Information, "Пакет Uninitialized");
                if (_logFilePath != null && File.Exists(_logFilePath))
                {
                    string dtsLog = Gin.Util.IOUtil.ReadFile(_logFilePath);
                    LoggerHandler(ExecutionLoggerEventType.Information, dtsLog);
                    LoggerHandler(ExecutionLoggerEventType.Information, "Слили файл DTS-лога в основной лог");
                }
            }
            catch (Exception ex)
            {
                LoggerHandler(ExecutionLoggerEventType.Error, ex.Message + " at: " + ex.StackTrace);
                if (_logFilePath != null && File.Exists(_logFilePath))
                {
                    string dtsLog = Gin.Util.IOUtil.ReadFile(_logFilePath);
                    LoggerHandler(ExecutionLoggerEventType.Error, dtsLog);
                }
                ProgressHandler(TOTAL_PROGRESS_COST);
                if (!_supressErrors)
                {
                    throw;
                }
            }
            finally
            {
                if (_logFilePath != null && File.Exists(_logFilePath))
                {
                    File.Delete(_logFilePath);
                }
            }
        }
Exemplo n.º 23
0
 public XboxEvents_EventProvider(object _param1)
 {
     this.m_ConnectionPointContainer = (IConnectionPointContainer)_param1;
 }
Exemplo n.º 24
0
 // Methods
 public _CustomTaskPaneEvents_EventProvider(object obj1)
 {
     _disposed = false;
     this.m_ConnectionPointContainer = (IConnectionPointContainer)obj1;
 }
Exemplo n.º 25
0
 // Constructor: remember ConnectionPointContainer
 EventProvider(object CPContainer)
 {
     ConnectionPointContainer = (IConnectionPointContainer)CPContainer;
 }
Exemplo n.º 26
0
            /// <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
            }
Exemplo n.º 27
0
 // Aletnative to destructor
 void IDisposable.Dispose()
 {
     Disconnect();
     ConnectionPointContainer = null;
     GC.SuppressFinalize(this);
 }
Exemplo n.º 28
0
 void IConnectionPoint.GetConnectionPointContainer(out IConnectionPointContainer connectionPointContainer)
 {
     connectionPointContainer = this;
 }
 public ConnectionPoint(IConnectionPointContainer container, Guid iid)
 {
     m_container   = container;
     m_iid         = iid;
     m_connections = new Connections();
 }
Exemplo n.º 30
0
 public void GetConnectionPointContainer(out IConnectionPointContainer ppCPC)
 {
     ppCPC = m_container;
 }
Exemplo n.º 31
0
    /// <summary>
    /// Start the IR Server plugin.
    /// </summary>
    public override void Start()
    {
      LoadSettings();
      X10Inter = new X10Interface();
      if (X10Inter == null)
        throw new InvalidOperationException("Failed to start X10 interface");

      // Bind the interface using a connection point
      icpc = (IConnectionPointContainer)X10Inter;
      Guid IID_InterfaceEvents = typeof(_DIX10InterfaceEvents).GUID;
      icpc.FindConnectionPoint(ref IID_InterfaceEvents, out icp);
      icp.Advise(this, out cookie);
    }
 // Constructor: remember ConnectionPointContainer
 _IShockwaveFlashEvents_EventProvider(object CPContainer) : base()
 {
   ConnectionPointContainer = (IConnectionPointContainer)CPContainer;
 }
Exemplo n.º 33
0
 /// <summary>
 /// Stop the IR Server plugin.
 /// </summary>
 public override void Stop()
 {
   if (X10Inter != null)
   {
     icp.Unadvise(cookie);
     icpc = null;
     X10Inter = null;
   }
 }
Exemplo n.º 34
0
 void IConnectionPoint.GetConnectionPointContainer(out IConnectionPointContainer ppCPC)
 {
     ppCPC = null;
 }
Exemplo n.º 35
0
 public _IShockwaveFlashEvents_EventProvider(object obj1)
 {
     this.m_ConnectionPointContainer = (IConnectionPointContainer)obj1;
 }
 public void GetConnectionPointContainer(out IConnectionPointContainer ppCPC)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 37
0
        /*------------------------------------------------------
        *  Add OPC Group
        *
        *  (ret)   True    OK
        *                  False   NG
        *  ------------------------------------------------------*/
        public bool AddGroup(string sGrpName, int iUpdateRate)
        {
            if (m_OPCServer == null)
            {
                return(false);
            }
            if (m_OPCGroup != null || m_iServerGroup != 0)
            {
                return(false);
            }

            object group = null;

            bool   bActive      = true;
            int    iClientGroup = 0;         //1234;
            IntPtr ptrTimeBias  = IntPtr.Zero;
            IntPtr ptrDeadBand  = IntPtr.Zero;
            int    iLCID        = 0;

            Guid guidGroupStateMgt;
            Guid guidDataCallback;
            int  iRevisedUpdateRate;
            int  iKeepAliveTime = 10000;

            try
            {
                switch (m_OpcdaVer)
                {
                case DEF_OPCDA.VER_30:
                    guidGroupStateMgt = Marshal.GenerateGuidForType(typeof(IOPCGroupStateMgt2));
                    m_OPCServer.AddGroup(sGrpName,
                                         (bActive) ? 1 : 0,
                                         iUpdateRate,
                                         iClientGroup,
                                         ptrTimeBias,
                                         ptrDeadBand,
                                         iLCID,
                                         out m_iServerGroup,
                                         out iRevisedUpdateRate,
                                         ref guidGroupStateMgt,
                                         out group);
                    m_OPCGroup2 = (IOPCGroupStateMgt2)group;
                    m_OPCGroup2.SetKeepAlive(iKeepAliveTime, out iKeepAliveTime);

                    m_OPCConnPointCntnr = (IConnectionPointContainer)m_OPCGroup2;
                    guidDataCallback    = Marshal.GenerateGuidForType(typeof(IOPCDataCallback));
                    m_OPCConnPointCntnr.FindConnectionPoint(ref guidDataCallback, out m_OPCConnPoint);
                    break;

                case DEF_OPCDA.VER_10:
                case DEF_OPCDA.VER_20:
                default:
                    guidGroupStateMgt = Marshal.GenerateGuidForType(typeof(IOPCGroupStateMgt));
                    m_OPCServer.AddGroup(sGrpName,
                                         (bActive) ? 1 : 0,
                                         iUpdateRate,
                                         iClientGroup,
                                         ptrTimeBias,
                                         ptrDeadBand,
                                         iLCID,
                                         out m_iServerGroup,
                                         out iRevisedUpdateRate,
                                         ref guidGroupStateMgt,
                                         out group);
                    m_OPCGroup = (IOPCGroupStateMgt)group;

                    m_OPCConnPointCntnr = (IConnectionPointContainer)m_OPCGroup;
                    guidDataCallback    = Marshal.GenerateGuidForType(typeof(IOPCDataCallback));
                    m_OPCConnPointCntnr.FindConnectionPoint(ref guidDataCallback, out m_OPCConnPoint);
                    break;
                }
                return(true);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString(), "AddGroup");
                return(false);
            }
        }
Exemplo n.º 38
0
    public void Init()
    {
      using (Settings xmlreader = new MPSettings())
      {
        _controlEnabled = xmlreader.GetValueAsBool("remote", "X10", false);
        _x10Medion = xmlreader.GetValueAsBool("remote", "X10Medion", false);
        _x10Ati = xmlreader.GetValueAsBool("remote", "X10ATI", false);
        _x10Firefly = xmlreader.GetValueAsBool("remote", "X10Firefly", false);
        _logVerbose = xmlreader.GetValueAsBool("remote", "X10VerboseLog", false);
        _x10UseChannelControl = xmlreader.GetValueAsBool("remote", "X10UseChannelControl", false);
        _x10Channel = xmlreader.GetValueAsInt("remote", "X10Channel", 0);
      }

      //Setup the X10 Remote
      try
      {
        if (X10Inter == null)
        {
          try
          {
            X10Inter = new X10Interface();
          }
          catch (COMException)
          {
            Log.Info("X10 debug: Could not get interface");
            _remotefound = false;
            return;
          }
          _remotefound = true;

          //Bind the interface using a connection point

          icpc = (IConnectionPointContainer)X10Inter;
          Guid IID_InterfaceEvents = typeof (_DIX10InterfaceEvents).GUID;
          icpc.FindConnectionPoint(ref IID_InterfaceEvents, out icp);
          icp.Advise(this, out cookie);
        }
      }
      catch (COMException cex)
      {
        Log.Info("X10 Debug: Com error - " + cex.ToString());
      }

      if (_inputHandler == null)
      {
        if (_controlEnabled)
        {
          if (_x10Medion)
          {
            _inputHandler = new InputHandler("Medion X10");
          }
          else if (_x10Ati)
          {
            _inputHandler = new InputHandler("ATI X10");
          }
          else if (_x10Firefly)
          {
            _inputHandler = new InputHandler("Firefly X10");
          }
          else
          {
            _inputHandler = new InputHandler("Other X10");
          }
        }
        else
        {
          return;
        }

        if (!_inputHandler.IsLoaded)
        {
          _controlEnabled = false;
          Log.Info("X10: Error loading default mapping file - please reinstall MediaPortal");
          return;
        }

        if (_logVerbose)
        {
          if (_x10Medion)
          {
            Log.Info("X10Remote: Start Medion");
          }
          else if (_x10Ati)
          {
            Log.Info("X10Remote: Start ATI");
          }
          else if (_x10Firefly)
          {
            Log.Info("X10Remote: Start Firefly");
          }
          else
          {
            Log.Info("X10Remote: Start Other");
          }
        }
      }
    }
Exemplo n.º 39
0
 protected MSScriptControl_EventProvider(object connectionPoint)
 {
     _connectionPointContainer = (IConnectionPointContainer)connectionPoint;
     _riid = typeof(IMSScriptControl_EventSink).GUID;
 }
Exemplo n.º 40
0
        public void Dispose() {
            try {
                if (_connectionPoint != null && _cookie != 0) {
                    _connectionPoint.Unadvise(_cookie);
                }
            } finally {
                _cookie = 0;
                _connectionPoint = null;
                _connectionPointContainer = null;
            }

            GC.SuppressFinalize(this);
        }
Exemplo n.º 41
0
 void IConnectionPoint.GetConnectionPointContainer(out IConnectionPointContainer ppCPC)
 {
     ppCPC = this;
 }
Exemplo n.º 42
0
 // Methods
 public HTMLWindowEvents2_EventProvider(object obj1)
 {
     this.m_ConnectionPointContainer = (IConnectionPointContainer)obj1;
 }
Exemplo n.º 43
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage:\n{0} {1} {2}", "Cs_FoldersMonitorClient.exe", "dir_1", "dir_2");
                return;
            }

            string directoryName1 = args[0];
            string directoryName2 = args[1];

            try
            {
                // early binding
                Console.WriteLine("Early binding");

                // Run the following command in console:
                // > tlbimp FoldersMonitorServer.tlb /out:FoldersMonitorServer.dll
                //
                // Add FoldersMonitorServer.dll as a reference to this project.

                FoldersMonitorServer.CoFoldersMonitor fm = new FoldersMonitorServer.CoFoldersMonitor();
                fm.Start(10000);

                // notifications filter: FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE
                string taskId = fm.CreateTask(directoryName1, 0x00000001 | 0x00000010);
                Console.WriteLine("task id : {0}", taskId);

                int error = 0;
                fm.StartTask(taskId, out error);

                //
                FoldersMonitorEventHandler handler = new FoldersMonitorEventHandler();
                fm.OnChanged += handler.OnChanged;

                Console.WriteLine("Working ...");
                Console.ReadKey();

                //
                fm.StopTask(taskId, out error);
                fm.Stop();
            }
            catch (Exception e)
            {
                String errorMessage;
                errorMessage = "Error: ";
                errorMessage = String.Concat(errorMessage, e.Message);
                errorMessage = String.Concat(errorMessage, " Line: ");
                errorMessage = String.Concat(errorMessage, e.Source);

                Console.WriteLine(errorMessage);
                return;
            }

            try
            {
                // late binding
                Console.WriteLine("Late binding");

                Type   objClass = Type.GetTypeFromProgID("CoFoldersMonitor.1");
                object objFM    = Activator.CreateInstance(objClass);

                object[] arguments = null;

                arguments    = new object[1];
                arguments[0] = 10000;
                objFM.GetType().InvokeMember("Start", BindingFlags.InvokeMethod, null, objFM, arguments);

                arguments    = new object[2];
                arguments[0] = directoryName2;
                arguments[1] = 0x00000001 | 0x00000010;

                //
                int  cookie = -1;
                Guid IID_IFoldersMonitorEvents = new Guid("231A27E0-55B9-44A2-9025-F82B8ED5F40F");

                IConnectionPointContainer cpc = objFM as IConnectionPointContainer;

                IConnectionPoint cp;
                cpc.FindConnectionPoint(IID_IFoldersMonitorEvents, out cp);

                IFoldersMonitorEvents sink = new FoldersMonitorEvents_Sink();

                cp.Advise(sink, out cookie);

                //
                string taskId = (objFM.GetType().InvokeMember("CreateTask", BindingFlags.InvokeMethod,
                                                              null, objFM, arguments)) as string;

                Console.WriteLine("task {0}", taskId);

                arguments    = new object[2];
                arguments[0] = taskId;
                arguments[1] = 0;

                ParameterModifier parametersOut = new ParameterModifier(2);
                parametersOut[0] = false;
                parametersOut[1] = true;    // the second argument is passed on by reference !!!!

                objFM.GetType().InvokeMember("StartTask", BindingFlags.InvokeMethod,
                                             null, objFM, arguments,
                                             new ParameterModifier[] { parametersOut }, null, null);

                Console.WriteLine("Working ...");
                Console.ReadKey();

                objFM.GetType().InvokeMember("StopTask", BindingFlags.InvokeMethod,
                                             null, objFM, arguments,
                                             new ParameterModifier[] { parametersOut }, null, null);

                objFM.GetType().InvokeMember("Stop", BindingFlags.InvokeMethod,
                                             null, objFM, null);

                //
                cp.Unadvise(cookie);
            }
            catch (Exception e)
            {
                String errorMessage;
                errorMessage = "Error: ";
                errorMessage = String.Concat(errorMessage, e.Message);
                errorMessage = String.Concat(errorMessage, " Line: ");
                errorMessage = String.Concat(errorMessage, e.Source);

                Console.WriteLine(errorMessage);
                Console.WriteLine(e.InnerException.ToString());
            }

            Console.WriteLine("Bye ...");
        }
Exemplo n.º 44
0
 public void GetConnectionPointContainer(out IConnectionPointContainer ppCPC)
 {
     ppCPC = null;
 }
Exemplo n.º 45
0
Arquivo: EPG.cs Projeto: dgis/CodeTV
 public void RegisterEvent(IConnectionPointContainer bdaTIFConnectionPointContainer)
 {
     //http://msdn.microsoft.com/en-us/library/ms779696
     try
     {
         Guid IID_IGuideDataEvent = typeof(IGuideDataEvent).GUID;
         bdaTIFConnectionPointContainer.FindConnectionPoint(ref IID_IGuideDataEvent, out this.guideDataEventConnectionPoint);
         if (this.guideDataEventConnectionPoint != null)
         {
             guideDataEventConnectionPoint.Advise(this, out this.guideDataEventCookie);
         }
     }
     catch (Exception ex)
     {
         // CONNECT_E_CANNOTCONNECT = 0x80040200
         Trace.WriteLineIf(trace.TraceError, ex.ToString());
     }
 }
Exemplo n.º 46
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         try
         {
             if (connectionPoint != null && cookie != 0)
             {
                 connectionPoint.Unadvise(cookie);
             }
         }
         finally
         {
             cookie = 0;
             connectionPoint = null;
             cpc = null;
         }
     }
 }
Exemplo n.º 47
0
        private void CreateVsCodeWindow()
        {
            int  hr = VSConstants.S_OK;
            Guid clsidVsCodeWindow = typeof(VsCodeWindowClass).GUID;
            Guid iidVsCodeWindow   = typeof(IVsCodeWindow).GUID;
            Guid clsidVsTextBuffer = typeof(VsTextBufferClass).GUID;
            Guid iidVsTextLines    = typeof(IVsTextLines).GUID;

            // create/site a VsTextBuffer object
            _vsTextBuffer = (IVsTextBuffer)NuoDbVSPackagePackage.Instance.CreateInstance(ref clsidVsTextBuffer, ref iidVsTextLines, typeof(IVsTextBuffer));
            IObjectWithSite ows = (IObjectWithSite)_vsTextBuffer;

            ows.SetSite(_editor);
            //string strSQL = "select * from sometable";
            //hr = _vsTextBuffer.InitializeContent(strSQL, strSQL.Length);
            switch (NuoDbVSPackagePackage.Instance.GetMajorVStudioVersion())
            {
            case 10:
                hr = _vsTextBuffer.SetLanguageServiceID(ref GuidList.guidSQLLangSvc_VS2010);
                break;

            case 11:
                hr = _vsTextBuffer.SetLanguageServiceID(ref GuidList.guidSQLLangSvc_VS2012);
                break;
            }

            // create/initialize/site a VsCodeWindow object
            _vsCodeWindow = (IVsCodeWindow)NuoDbVSPackagePackage.Instance.CreateInstance(ref clsidVsCodeWindow, ref iidVsCodeWindow, typeof(IVsCodeWindow));

            INITVIEW[] initView = new INITVIEW[1];
            initView[0].fSelectionMargin = 0;
            initView[0].fWidgetMargin    = 0;
            initView[0].fVirtualSpace    = 0;
            initView[0].fDragDropMove    = 1;
            initView[0].fVirtualSpace    = 0;
            IVsCodeWindowEx vsCodeWindowEx = (IVsCodeWindowEx)_vsCodeWindow;

            hr = vsCodeWindowEx.Initialize((uint)_codewindowbehaviorflags.CWB_DISABLEDROPDOWNBAR | (uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER,
                                           0, null, null,
                                           (uint)TextViewInitFlags.VIF_SET_WIDGET_MARGIN |
                                           (uint)TextViewInitFlags.VIF_SET_SELECTION_MARGIN |
                                           (uint)TextViewInitFlags.VIF_SET_VIRTUAL_SPACE |
                                           (uint)TextViewInitFlags.VIF_SET_DRAGDROPMOVE |
                                           (uint)TextViewInitFlags2.VIF_SUPPRESS_STATUS_BAR_UPDATE |
                                           (uint)TextViewInitFlags2.VIF_SUPPRESSBORDER |
                                           (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKCHANGES |
                                           (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKGOBACK,
                                           initView);

            hr = _vsCodeWindow.SetBuffer((IVsTextLines)_vsTextBuffer);
            IVsWindowPane vsWindowPane = (IVsWindowPane)_vsCodeWindow;

            hr = vsWindowPane.SetSite(_editor);
            hr = vsWindowPane.CreatePaneWindow(this.Handle, 0, 0, this.Parent.Size.Width, this.Parent.Size.Height, out _hWndCodeWindow);

            IVsTextView vsTextView;

            hr = _vsCodeWindow.GetPrimaryView(out vsTextView);

            // sink IVsTextViewEvents, so we can determine when a VsCodeWindow object actually has the focus.
            IConnectionPointContainer connptCntr = (IConnectionPointContainer)vsTextView;
            Guid             riid = typeof(IVsTextViewEvents).GUID;
            IConnectionPoint cp;

            connptCntr.FindConnectionPoint(ref riid, out cp);
            cp.Advise(_editor, out cookie);

            // sink IVsTextLinesEvents, so we can determine when a VsCodeWindow text has been changed.
            connptCntr = (IConnectionPointContainer)_vsTextBuffer;
            riid       = typeof(IVsTextLinesEvents).GUID;
            connptCntr.FindConnectionPoint(ref riid, out cp);
            cp.Advise(_editor, out cookie);
        }
Exemplo n.º 48
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;
				}
			}
		}
Exemplo n.º 49
0
        /// <summary>
        /// Only public method which starts the parsing process
        /// When parsing is done, we receive a DISPID_READYSTATE dispid
        /// in IPropertyNotifySink.OnChanged implementation
        /// </summary>
        /// <param name="Url"></param>
        /// <param name="cookie"></param>
        public void StartParsing(string Url, string cookie)
        {
            IntPtr pUsername = IntPtr.Zero;
            IntPtr pPassword = IntPtr.Zero;

            try
            {
                if (string.IsNullOrEmpty(Url))
                {
                    throw new ApplicationException("Url must have a valid value!");
                }

                //Create a new MSHTML, throws exception if fails
                Type htmldoctype = Type.GetTypeFromCLSID(Iid_Clsids.CLSID_HTMLDocument, true);
                //Using Activator inplace of CoCreateInstance, returns IUnknown
                //which we cast to a IHtmlDocument2 interface
                m_pMSHTML = (IHTMLDocument2)System.Activator.CreateInstance(htmldoctype);

                //Get the IOleObject
                m_WBOleObject = (IOleObject)m_pMSHTML;
                //Set client site
                int iret = m_WBOleObject.SetClientSite(this);

                //Connect for IPropertyNotifySink
                m_WBOleControl = (IOleControl)m_pMSHTML;
                m_WBOleControl.OnAmbientPropertyChange(HTMLDispIDs.DISPID_AMBIENT_DLCONTROL);

                //Get connectionpointcontainer
                IConnectionPointContainer cpCont = (IConnectionPointContainer)m_pMSHTML;
                cpCont.FindConnectionPoint(ref Iid_Clsids.IID_IPropertyNotifySink, out m_WBConnectionPoint);
                //Advice
                m_WBConnectionPoint.Advise(this, out m_dwCookie);

                m_Done = false;
                m_Url  = Url;

                if (!string.IsNullOrEmpty(cookie))
                {
                    m_pMSHTML.cookie = cookie;
                }

                //Set up username and password if provided
                if (!string.IsNullOrEmpty(m_Username))
                {
                    pUsername = Marshal.StringToCoTaskMemAnsi(m_Username);
                    if (pUsername != IntPtr.Zero)
                    {
                        WinApis.InternetSetOption(IntPtr.Zero,
                                                  InternetSetOptionFlags.INTERNET_OPTION_USERNAME,
                                                  pUsername, m_Username.Length);
                    }
                }
                if (!string.IsNullOrEmpty(m_Password))
                {
                    pPassword = Marshal.StringToCoTaskMemAnsi(m_Password);
                    if (pPassword != IntPtr.Zero)
                    {
                        WinApis.InternetSetOption(IntPtr.Zero,
                                                  InternetSetOptionFlags.INTERNET_OPTION_PASSWORD,
                                                  pPassword, m_Password.Length);
                    }
                }
                //Load
                IPersistMoniker persistMoniker = (IPersistMoniker)m_pMSHTML;
                IMoniker        moniker        = null;
                WinApis.CreateURLMoniker(null, m_Url, out moniker);
                if (moniker == null)
                {
                    return;
                }
                IBindCtx bindContext = null;
                WinApis.CreateBindCtx((uint)0, out bindContext);
                if (bindContext == null)
                {
                    return;
                }
                persistMoniker.Load(1, moniker, bindContext, 0);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (pUsername != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pUsername);
                }
                if (pPassword != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pPassword);
                }
            }
        }
Exemplo n.º 50
0
 void IConnectionPoint.GetConnectionPointContainer(out IConnectionPointContainer ppCPC)
 {
     ppCPC = this;
 }
Exemplo n.º 51
0
 public ConnectionPointMock(IConnectionPointContainer container)
 {
     _container = container;
 }
Exemplo n.º 52
0
 public ConnectionPoint(IConnectionPointContainer container, Guid iid)
 {
     m_container = container;
     m_iid = iid;
     m_connections = new Connections();
 }
Exemplo n.º 53
0
 // Methods
 public _CustomTaskPaneEvents_EventProvider(object obj1)
 {
     _disposed = false;
     this.m_ConnectionPointContainer = (IConnectionPointContainer)obj1;
 }
 public void GetConnectionPointContainer(out IConnectionPointContainer ppCPC)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 55
0
 // Token: 0x06000205 RID: 517 RVA: 0x00007091 File Offset: 0x00005291
 public DebugPortEvents2ConnectionPoint(IConnectionPointContainer container)
 {
     this.container = container;
 }
        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);
            }
        }
        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);
        }