예제 #1
1
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectReference"/> class.
 /// </summary>
 /// <param name="creationTime">The creation time.</param>
 /// <param name="comObject">The com object to track.</param>
 /// <param name="stackTrace">The stack trace.</param>
 public ObjectReference(DateTime creationTime, ComObject comObject, string stackTrace)
 {
     CreationTime = creationTime;
     // Creates a long week reference to the ComObject
     Object = new WeakReference(comObject, true);
     StackTrace = stackTrace;
 }
예제 #2
0
        /// <summary>
        /// Parses the specified item id.
        /// </summary>
        /// <param name="server">The COM server that provided the item id.</param>
        /// <param name="configuration">The COM wrapper configuration.</param>
        /// <param name="itemId">The item id to parse.</param>
        /// <param name="browseName">The name of the item.</param>
        /// <returns>True if the item id could be parsed.</returns>
        public bool Parse(ComObject server, ComClientConfiguration configuration, string itemId, out string browseName)
        {
            browseName = null;

            if (configuration == null || itemId == null)
            {
                return false;
            }

            if (String.IsNullOrEmpty(configuration.SeperatorChars))
            {                
                return false;
            }

            for (int ii = 0; ii < configuration.SeperatorChars.Length; ii++)
            {
                int index = itemId.LastIndexOf(configuration.SeperatorChars[ii]);

                if (index >= 0)
                {
                    browseName = itemId.Substring(index + 1);
                    return true;
                }
            }

            return false;
        }
예제 #3
0
		/// <summary>
		/// Creates a new device object that can be used to create other Microsoft DirectComposition objects.
		/// </summary>
		/// <param name="renderingDevice">An optional reference to a DirectX device to be used to create DirectComposition surface objects. Must be a reference to an object implementing the <strong><see cref="SharpDX.DXGI.Device"/></strong> or <strong><see cref="SharpDX.Direct2D1.Device"/></strong> interfaces.</param>
		public DesktopDevice(ComObject renderingDevice)
			: base(IntPtr.Zero)
		{
			IntPtr temp;
			DComp.CreateDevice2(renderingDevice, Utilities.GetGuidFromType(typeof(DesktopDevice)), out temp);
			NativePointer = temp;
		}
예제 #4
0
        protected DxgiSwapChain(ComObject device, Factory factory, IntPtr hWnd, int width, int height)
        {
            m_device = device;
            m_factory = factory;
            m_hWnd = hWnd;
            m_width = width;
            m_height = height;

            InitializeResources();
        }
예제 #5
0
 /// <summary>	
 /// The application implemented rendering callback (<see cref="TextRenderer.DrawInlineObject"/>) can use this to draw the inline object without needing to cast or query the object type. The text layout does not call this method directly. 	
 /// </summary>	
 /// <param name="clientDrawingContext">The drawing context passed to <see cref="SharpDX.DirectWrite.TextLayout.Draw_"/>.  This parameter may be NULL. </param>
 /// <param name="renderer">The same renderer passed to <see cref="SharpDX.DirectWrite.TextLayout.Draw_"/> as the object's containing parent.  This is useful if the inline object is recursive such as a nested layout. </param>
 /// <param name="originX">The x-coordinate at the upper-left corner of the inline object. </param>
 /// <param name="originY">The y-coordinate at the upper-left corner of the inline object. </param>
 /// <param name="isSideways">A Boolean flag that indicates whether the object's baseline runs alongside the baseline axis of the line. </param>
 /// <param name="isRightToLeft">A Boolean flag that indicates whether the object is in a right-to-left context and should be drawn flipped. </param>
 /// <param name="clientDrawingEffect">The drawing effect set in <see cref="SharpDX.DirectWrite.TextLayout.SetDrawingEffect"/>.  Usually this effect is a foreground brush that  is used in glyph drawing. </param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. </returns>
 /// <unmanaged>HRESULT IDWriteInlineObject::Draw([None] void* clientDrawingContext,[None] IDWriteTextRenderer* renderer,[None] float originX,[None] float originY,[None] BOOL isSideways,[None] BOOL isRightToLeft,[None] IUnknown* clientDrawingEffect)</unmanaged>
 public void Draw(object clientDrawingContext, TextRenderer renderer, float originX, float originY, bool isSideways, bool isRightToLeft, ComObject clientDrawingEffect)
 {
     var handle = GCHandle.Alloc(clientDrawingContext);
     IntPtr clientDrawingEffectPtr = Utilities.GetIUnknownForObject(clientDrawingEffect);
     try
     {
         this.Draw__(GCHandle.ToIntPtr(handle), TextRendererShadow.ToIntPtr(renderer), originX, originY, isSideways, isRightToLeft,
                     clientDrawingEffectPtr);
     } finally
     {
         if (handle.IsAllocated) handle.Free();
         if (clientDrawingEffectPtr != IntPtr.Zero) Marshal.Release(clientDrawingEffectPtr);
     }
 }
예제 #6
0
파일: ByteStream.cs 프로젝트: nkast/SharpDX
 /// <summary>
 /// Instantiates a new instance <see cref="ByteStream"/> from a <see cref="Stream"/>.
 /// </summary>
 /// <msdn-id>hh162754</msdn-id>	
 /// <unmanaged>HRESULT MFCreateMFByteStreamOnStreamEx([In] IUnknown* punkStream,[Out] IMFByteStream** ppByteStream)</unmanaged>	
 /// <unmanaged-short>MFCreateMFByteStreamOnStreamEx</unmanaged-short>	
 public ByteStream(Stream sourceStream)
 {
     this.sourceStream = sourceStream;
     #if WIN8METRO
     var randomAccessStream = sourceStream.AsRandomAccessStream();
     randomAccessStreamCom = new ComObject(Marshal.GetIUnknownForObject(randomAccessStream));
     MediaFactory.CreateMFByteStreamOnStreamEx(randomAccessStreamCom, this);
     #else
     streamProxy = new ComStreamProxy(sourceStream);
     IByteStream localStream;
     MediaFactory.CreateMFByteStreamOnStream(ComStream.ToIntPtr(streamProxy), out localStream);
     NativePointer = ((ByteStream) localStream).NativePointer;
     #endif
 }
예제 #7
0
        /// <summary>
        /// Tracks the specified COM object.
        /// </summary>
        /// <param name="comObject">The COM object.</param>
        public static void Track(ComObject comObject)
        {
            if (comObject == null || comObject.NativePointer == IntPtr.Zero)
                return;
            lock (ObjectReferences)
            {
                List<ObjectReference> referenceList;
                // Object is already tracked
                if (!ObjectReferences.TryGetValue(comObject.NativePointer, out referenceList))
                {
                    referenceList = new List<ObjectReference>();
                    ObjectReferences.Add(comObject.NativePointer, referenceList);
                }
#if W8CORE
                referenceList.Add(new ObjectReference(DateTime.Now, comObject));
#else
                referenceList.Add(new ObjectReference(DateTime.Now, comObject, new StackTrace(3, true)));
#endif
            }
        }
예제 #8
0
파일: Engine.cs 프로젝트: ericrrichards/fps
 protected void ReleaseCom(ComObject p)
 {
     if (p != null && !p.Disposed) p.Dispose();
     p = null;
 }
예제 #9
0
 public int GetId()
 {
     return(ComObject.GetId());
 }
예제 #10
0
        private SwapChain CreateSwapChainForWinRT()
        {
            var coreWindow = Description.DeviceWindowHandle as CoreWindow;
            var swapChainBackgroundPanel = Description.DeviceWindowHandle as SwapChainBackgroundPanel;

            bufferCount = 2;
            var description = new SwapChainDescription1
            {
                // Automatic sizing
                Width = Description.BackBufferWidth,
                Height = Description.BackBufferHeight,
                Format = SharpDX.DXGI.Format.B8G8R8A8_UNorm, // TODO: Check if we can use the Description.BackBufferFormat
                Stereo = false,
                SampleDescription = new SharpDX.DXGI.SampleDescription((int)Description.MultiSampleCount, 0),
                Usage = Description.RenderTargetUsage,
                // Use two buffers to enable flip effect.
                BufferCount = bufferCount,
                Scaling = SharpDX.DXGI.Scaling.Stretch,
                SwapEffect = SharpDX.DXGI.SwapEffect.FlipSequential,
            };

            if (coreWindow != null)
            {
                // Creates a SwapChain from a CoreWindow pointer
                using (var comWindow = new ComObject(coreWindow))
                    return new SwapChain1((DXGI.Factory2)GraphicsAdapter.Factory, (Direct3D11.Device)GraphicsDevice, comWindow, ref description);
            }
            else if (swapChainBackgroundPanel != null)
            {
                var nativePanel = ComObject.As<ISwapChainBackgroundPanelNative>(swapChainBackgroundPanel);
                // Creates the swap chain for XAML composition
                var swapChain = new SwapChain1((DXGI.Factory2)GraphicsAdapter.Factory, (Direct3D11.Device)GraphicsDevice, ref description);

                // Associate the SwapChainBackgroundPanel with the swap chain
                nativePanel.SwapChain = swapChain;
                return swapChain;
            }
            else
            {
#if DIRECTX11_2
                using (var comObject = new ComObject(Description.DeviceWindowHandle))
                {
                    var swapChainPanel = comObject.QueryInterfaceOrNull<ISwapChainPanelNative>();
                    if (swapChainPanel != null)
                    {
                        var swapChain = new SwapChain1((DXGI.Factory2)GraphicsAdapter.Factory, (Direct3D11.Device)GraphicsDevice, ref description);
                        swapChainPanel.SwapChain = swapChain;
                        return swapChain;
                    }
                }
#endif
                throw new NotSupportedException();
            }
        }
예제 #11
0
 public int GetTextIds(ref object ids, int txttyp = 0, string search_string = "")
 {
     return(ComObject.GetTextIds(ref ids, txttyp, search_string));
 }
        private SwapChain CreateSwapChainForUWP()
        {
            bufferCount = 2;
            var description = new SwapChainDescription1
            {
                // Automatic sizing
                Width             = Description.BackBufferWidth,
                Height            = Description.BackBufferHeight,
                Format            = (SharpDX.DXGI.Format)Description.BackBufferFormat.ToNonSRgb(),
                Stereo            = false,
                SampleDescription = new SharpDX.DXGI.SampleDescription((int)Description.MultisampleCount, 0),
                Usage             = Usage.BackBuffer | Usage.RenderTargetOutput,
                // Use two buffers to enable flip effect.
                BufferCount = bufferCount,
                Scaling     = SharpDX.DXGI.Scaling.Stretch,
                SwapEffect  = SharpDX.DXGI.SwapEffect.FlipSequential,
            };

            SwapChain swapChain = null;

            switch (Description.DeviceWindowHandle.Context)
            {
            case Games.AppContextType.UWPXaml:
            {
                var nativePanel = ComObject.As <ISwapChainPanelNative>(Description.DeviceWindowHandle.NativeWindow);

                // Creates the swap chain for XAML composition
                swapChain = new SwapChain1(GraphicsAdapterFactory.NativeFactory, GraphicsDevice.NativeDevice, ref description);

                // Associate the SwapChainPanel with the swap chain
                nativePanel.SwapChain = swapChain;

                break;
            }

            case Games.AppContextType.UWPCoreWindow:
            {
                using (var dxgiDevice = GraphicsDevice.NativeDevice.QueryInterface <SharpDX.DXGI.Device2>())
                {
                    // Ensure that DXGI does not queue more than one frame at a time. This both reduces
                    // latency and ensures that the application will only render after each VSync, minimizing
                    // power consumption.
                    dxgiDevice.MaximumFrameLatency = 1;

                    // Next, get the parent factory from the DXGI Device.
                    using (var dxgiAdapter = dxgiDevice.Adapter)
                        using (var dxgiFactory = dxgiAdapter.GetParent <SharpDX.DXGI.Factory2>())
                            // Finally, create the swap chain.
                            using (var coreWindow = new SharpDX.ComObject(Description.DeviceWindowHandle.NativeWindow))
                            {
                                swapChain = new SharpDX.DXGI.SwapChain1(dxgiFactory
                                                                        , GraphicsDevice.NativeDevice, coreWindow, ref description);
                            }
                }

                break;
            }

            default:
                throw new NotSupportedException(string.Format("Window context [{0}] not supported while creating SwapChain", Description.DeviceWindowHandle.Context));
            }

            return(swapChain);
        }
예제 #13
0
 /// <summary>
 /// Finds the object reference for a specific COM object.
 /// </summary>
 /// <param name="comObject">The COM object.</param>
 /// <returns>An object reference</returns>
 public static ObjectReference Find(ComObject comObject)
 {
     lock (ObjectReferences)
     {
         List<ObjectReference> referenceList;
         // Object is already tracked
         if (ObjectReferences.TryGetValue(comObject.NativePointer, out referenceList))
         {
             foreach (var objectReference in referenceList)
             {
                 if (ReferenceEquals(objectReference.Object.Target, comObject))
                     return objectReference;
             }
         }
     }            
     return null;
 }
예제 #14
0
 public int SetLockChangeable(int lockchangeable)
 {
     return(ComObject.SetLockChangeable(lockchangeable));
 }
예제 #15
0
 public int SetValue(string value)
 {
     return(ComObject.SetValue(value));
 }
예제 #16
0
 public int SetId(int id)
 {
     return(ComObject.SetId(id));
 }
예제 #17
0
 public int IsLockChangeable()
 {
     return(ComObject.IsLockChangeable());
 }
예제 #18
0
 public string GetValue()
 {
     return(ComObject.GetValue());
 }
예제 #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObjectReference"/> class.
        /// </summary>
        /// <param name="creationTime">The creation time.</param>
        /// <param name="comObject">The com object to track.</param>
        /// <param name="stackTrace">The stack trace.</param>
#if W8CORE
        public ObjectReference(DateTime creationTime, ComObject comObject)
        {
            CreationTime = creationTime;
            // Creates a long week reference to the ComObject
            Object = new WeakReference(comObject, true);
        }
예제 #20
0
        public override Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect)
        {
            SolidColorBrush sb = defaultBrush;

            if (clientDrawingEffect != null && clientDrawingEffect is SolidColorBrush)
            {
                sb = (SolidColorBrush)clientDrawingEffect;
            }

            try
            {
                this.renderTarget.DrawGlyphRun(new Vector2(baselineOriginX, baselineOriginY), glyphRun, sb, measuringMode);
                return(Result.Ok);
            }
            catch
            {
                return(Result.Fail);
            }
        }
예제 #21
0
        /// <summary>
        /// Tracks the specified COM object.
        /// </summary>
        /// <param name="comObject">The COM object.</param>
        public static void Track(ComObject comObject)
        {
            if (comObject == null || comObject.NativePointer == IntPtr.Zero)
                return;
            lock (ObjectReferences)
            {
                List<ObjectReference> referenceList;
                // Object is already tracked
                if (!ObjectReferences.TryGetValue(comObject.NativePointer, out referenceList))
                {
                    referenceList = new List<ObjectReference>();
                    ObjectReferences.Add(comObject.NativePointer, referenceList);
                }

#if STORE_APP
                var stacktrace = "Stacktrace is not available on this platform";

                // This code is a workaround to be able to get a full stacktrace on Windows Store App. 
                // This is an unsafe code, that should not run on production. Only at dev time!
                // Make sure we are on a 32bit process
                if(IntPtr.Size == 4)
                {
                    // Get an access to a restricted method
                    try
                    {
                        var stackTraceGetMethod = typeof(Environment).GetRuntimeProperty("StackTrace").GetMethod;
                        try
                        {
                            // First try to get the stacktrace
                            stacktrace = (string)stackTraceGetMethod.Invoke(null, null);
                        }
                        catch(Exception ex)
                        {
                            // If we have an exception, it means that the access to the method is not possible
                            // so we are going to patch the field RuntimeMethodInfo.m_invocationFlags that should contain
                            // 0x41 (initialized + security), and replace it by 0x1 (initialized)
                            // and then callback again the method
                            unsafe
                            {
                                // unsafe code, the RuntimeMethodInfo could be relocated (is it a real managed GC object?), 
                                // but we don't have much choice
                                var addr = *(int**)Interop.Fixed(ref stackTraceGetMethod);
                                // offset to RuntimeMethodInfo.m_invocationFlags
                                addr += 13;
                                // Check if we have the expecting value
                                if(*addr == 0x41)
                                {
                                    // if yes, change it to 0x1
                                    *addr = 0x1;
                                    try
                                    {
                                        // And try to callit again a second time
                                        // if it succeeds, first Invoke() should run on next call
                                        stacktrace = (string)stackTraceGetMethod.Invoke(null, null);
                                    }
                                    catch(Exception ex2)
                                    {
                                        // if it is still failing, we can't do anything
                                    }
                                }
                            }
                        }
                    }
                    catch(Exception ex)
                    {
                        // can't do anything
                    }
                }
                referenceList.Add(new ObjectReference(DateTime.Now, comObject, stacktrace));
#else
                // Another WTF: To get a stacktrace, we don't have other ways than throwing an exception on PCL. 
                try
                {
                    throw new GetStackTraceException();
                }
                catch (GetStackTraceException ex)
                {
                    referenceList.Add(new ObjectReference(DateTime.Now, comObject, ex.StackTrace));
                }
#endif
                // Fire Tracked event.
                OnTracked(comObject);
            }
        }
예제 #22
0
 public int GetNetSegmentIds(ref object ids)
 {
     return(ComObject.GetNetSegmentIds(ref ids));
 }
예제 #23
0
 private static void OnUnTracked(ComObject obj)
 {
     var handler = UnTracked;
     if (handler != null)
     {
         handler(null, new ComObjectEventArgs(obj));
     }
 }
예제 #24
0
 public int GetPinGroupCount(int num)
 {
     return(ComObject.GetPinGroupCount(num));
 }
예제 #25
0
 /// <summary>	
 /// <p><strong>Applies to: </strong>desktop apps | Metro style apps</p><p> Creates a media source from a byte stream. This method is synchronous. </p>	
 /// </summary>	
 /// <param name="stream"><dd> <p> Pointer to the byte stream's <strong><see cref="SharpDX.MediaFoundation.IByteStream"/></strong> interface. </p> </dd></param>	
 /// <param name="url"><dd> <p> Null-terminated string that contains the URL of the byte stream. The URL is optional and can be <strong><c>null</c></strong>. See Remarks for more information. </p> </dd></param>	
 /// <param name="flags"><dd> <p> Bitwise <strong>OR</strong> of flags. See <strong>Source Resolver Flags</strong>. </p> </dd></param>	
 /// <param name="propertyStore"><dd> <p> Pointer to the <strong><see cref="SharpDX.ComObject"/></strong> interface of a property store. The method passes the property store to the byte-stream handler. The byte-stream handler can use the property store to configure the media source. This parameter can be <strong><c>null</c></strong>. For more information, see Configuring a Media Source. </p> </dd></param>	
 /// <param name="objectType"><dd> <p> Receives a member of the <strong><see cref="SharpDX.MediaFoundation.ObjectType"/></strong> enumeration, specifying the type of object that was created. </p> </dd></param>	
 /// <returns>a reference to the media source's <strong><see cref="SharpDX.ComObject"/></strong> interface. The caller must release the interface.</returns>	
 /// <remarks>	
 /// <p>The <em>dwFlags</em> parameter must contain the <strong><see cref="SharpDX.MediaFoundation.SourceResolverFlags.MediaSource"/></strong> flag and should not contain the <strong><see cref="SharpDX.MediaFoundation.SourceResolverFlags.ByteStream"/></strong> flag.</p><p>The source resolver attempts to find one or more byte-stream handlers for the byte stream, based on the file name extension of the URL, or the MIME type of the byte stream (or both). The URL is specified in the optional <em>pwszURL</em> parameter, and the MIME type may be specified in the <strong><see cref="SharpDX.MediaFoundation.ByteStreamAttributeKeys.ContentType"/></strong> attribute on the byte stream. Byte-stream handlers are registered by file name extension or MIME type, or both, as described in Scheme Handlers and Byte-Stream Handlers. The caller should specify at least one of these values (both if possible):</p><ul> <li> Specify the URL in the <em>pwszURL</em> parameter. </li> <li> Specify the MIME type by setting the <strong><see cref="SharpDX.MediaFoundation.ByteStreamAttributeKeys.ContentType"/></strong> attribute on the byte stream. (This attribute might be set already when you create the byte stream, depending on how the byte stream was created.) </li> </ul><p><strong>Note</strong>??This method cannot be called remotely.</p>	
 /// </remarks>	
 /// <msdn-id>ms704671</msdn-id>	
 /// <unmanaged>HRESULT IMFSourceResolver::CreateObjectFromByteStream([In] IMFByteStream* pByteStream,[In] const wchar_t* pwszURL,[In] unsigned int dwFlags,[In] IPropertyStore* pProps,[Out] MF_OBJECT_TYPE* pObjectType,[Out] IUnknown** ppObject)</unmanaged>	
 /// <unmanaged-short>IMFSourceResolver::CreateObjectFromByteStream</unmanaged-short>	
 public SharpDX.ComObject CreateObjectFromStream(ByteStream stream,
     string url,
     SourceResolverFlags flags,
     ComObject propertyStore,
     out SharpDX.MediaFoundation.ObjectType objectType)
 {
     ComObject result;
     CreateObjectFromByteStream_(stream.NativePointer,
         url,
         (int)(flags | SourceResolverFlags.MediaSource),
         propertyStore,
         out objectType,
         out result);
     return result;
 }
예제 #26
0
 public int GetPinGroupIds(int num, ref object ids)
 {
     return(ComObject.GetPinGroupIds(num, ref ids));
 }
예제 #27
0
 /// <summary>	
 ///  IDWriteTextLayout::Draw calls this function to instruct the client to render a run of glyphs. 	
 /// </summary>	
 /// <remarks>	
 /// The <see cref="SharpDX.DirectWrite.TextLayout.Draw_"/> function calls this callback function with all the information about glyphs to render. The application implements this callback by mostly delegating the call to the underlying platform's graphics API such as {{Direct2D}} to draw glyphs on the drawing context. An application that uses GDI can implement this callback in terms of the <see cref="BitmapRenderTarget.DrawGlyphRun(float,float,MeasuringMode,SharpDX.DirectWrite.GlyphRun,SharpDX.DirectWrite.RenderingParams,SharpDX.Color4)"/> method.	
 /// </remarks>	
 /// <param name="clientDrawingContext">The application-defined drawing context passed to  <see cref="SharpDX.DirectWrite.TextLayout.Draw_"/>.</param>
 /// <param name="baselineOriginX">The pixel location (X-coordinate) at the baseline origin of the glyph run.</param>
 /// <param name="baselineOriginY">The pixel location (Y-coordinate) at the baseline origin of the glyph run.</param>
 /// <param name="measuringMode"> The measuring method for glyphs in the run, used with the other properties to determine the rendering mode.</param>
 /// <param name="glyphRun">Pointer to the glyph run instance to render. </param>
 /// <param name="glyphRunDescription">A pointer to the optional glyph run description instance which contains properties of the characters  associated with this run.</param>
 /// <param name="clientDrawingEffect">Application-defined drawing effects for the glyphs to render. Usually this argument represents effects such as the foreground brush filling the interior of text.</param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
 /// <unmanaged>HRESULT DrawGlyphRun([None] void* clientDrawingContext,[None] FLOAT baselineOriginX,[None] FLOAT baselineOriginY,[None] DWRITE_MEASURING_MODE measuringMode,[In] const DWRITE_GLYPH_RUN* glyphRun,[In] const DWRITE_GLYPH_RUN_DESCRIPTION* glyphRunDescription,[None] IUnknown* clientDrawingEffect)</unmanaged>
 public virtual Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect)
 {
     return Result.NotImplemented;
 }
예제 #28
0
 public int GetPinGroupsCount()
 {
     return(ComObject.GetPinGroupsCount());
 }
예제 #29
0
 public int GetLockChangeable()
 {
     return(ComObject.GetLockChangeable());
 }
예제 #30
0
 public int GetPinIds(ref object ids)
 {
     return(ComObject.GetPinIds(ref ids));
 }
예제 #31
0
 public string GetInternalValue()
 {
     return(ComObject.GetInternalValue());
 }
예제 #32
0
 public int GetReferenceSymbolCount()
 {
     return(ComObject.GetReferenceSymbolCount());
 }
예제 #33
0
        /// <summary>
        /// Tracks the specified COM object.
        /// </summary>
        /// <param name="comObject">The COM object.</param>
        public static void Track(ComObject comObject)
        {
            if (comObject == null || comObject.NativePointer == IntPtr.Zero)
                return;
            lock (ObjectReferences)
            {
                List<ObjectReference> referenceList;
                // Object is already tracked
                if (!ObjectReferences.TryGetValue(comObject.NativePointer, out referenceList))
                {
                    referenceList = new List<ObjectReference>();
                    ObjectReferences.Add(comObject.NativePointer, referenceList);
                }

            #if W8CORE
                var stacktrace = "Stacktrace is not available on this platform";

                // This code is a workaround to be able to get a full stacktrace on Windows Store App.
                // This is an unsafe code, that should not run on production. Only at dev time!
                // Make sure we are on a 32bit process
                if(IntPtr.Size == 4)
                {
                    // Get an access to a restricted method
                    try
                    {
                        var stackTraceGetMethod = typeof(Environment).GetRuntimeProperty("StackTrace").GetMethod;
                        try
                        {
                            // First try to get the stacktrace
                            stacktrace = (string)stackTraceGetMethod.Invoke(null, null);
                        }
                        catch(Exception ex)
                        {
                            // If we have an exception, it means that the access to the method is not possible
                            // so we are going to patch the field RuntimeMethodInfo.m_invocationFlags that should contain
                            // 0x41 (initialized + security), and replace it by 0x1 (initialized)
                            // and then callback again the method
                            unsafe
                            {
                                // unsafe code, the RuntimeMethodInfo could be relocated (is it a real managed GC object?),
                                // but we don't have much choice
                                var addr = *(int**)Interop.Fixed(ref stackTraceGetMethod);
                                // offset to RuntimeMethodInfo.m_invocationFlags
                                addr += 13;
                                // Check if we have the expecting value
                                if(*addr == 0x41)
                                {
                                    // if yes, change it to 0x1
                                    *addr = 0x1;
                                    try
                                    {
                                        // And try to callit again a second time
                                        // if it succeeds, first Invoke() should run on next call
                                        stacktrace = (string)stackTraceGetMethod.Invoke(null, null);
                                    }
                                    catch(Exception ex2)
                                    {
                                        // if it is still failing, we can't do anything
                                    }
                                }
                            }
                        }
                    }
                    catch(Exception ex)
                    {
                        // can't do anything
                    }
                }
                referenceList.Add(new ObjectReference(DateTime.Now, comObject, stacktrace));
            #else
                var stackTraceText = new StringBuilder();
                var stackTrace = new StackTrace(3, true);
                foreach (var stackFrame in stackTrace.GetFrames())
                {
                    // Skip system/generated frame
                    if (stackFrame.GetFileLineNumber() == 0)
                        continue;
                    stackTraceText.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "\t{0}({1},{2}) : {3}", stackFrame.GetFileName(), stackFrame.GetFileLineNumber(),
                                         stackFrame.GetFileColumnNumber(),
                                         stackFrame.GetMethod()).AppendLine();
                }

                referenceList.Add(new ObjectReference(DateTime.Now, comObject, stackTraceText.ToString()));
            #endif
                // Fire Tracked event.
                OnTracked(comObject);
            }
        }
예제 #34
0
 public int GetReferenceSymbolIds(ref object ids)
 {
     return(ComObject.GetReferenceSymbolIds(ref ids));
 }
예제 #35
0
		public SurfaceFactory(Device2 device, ComObject renderingDevice) : base(IntPtr.Zero)
		{
			device.CreateSurfaceFactory(renderingDevice, this);
		}
예제 #36
0
 public string GetSignalName()
 {
     return(ComObject.GetSignalName());
 }
예제 #37
0
        /// <summary>
        /// Tracks the specified COM object.
        /// </summary>
        /// <param name="comObject">The COM object.</param>
        public static void Track(ComObject comObject)
        {
            if (comObject == null || comObject.NativePointer == IntPtr.Zero)
                return;
            lock (ObjectReferences)
            {
                List<ObjectReference> referenceList;
                // Object is already tracked
                if (!ObjectReferences.TryGetValue(comObject.NativePointer, out referenceList))
                {
                    referenceList = new List<ObjectReference>();
                    ObjectReferences.Add(comObject.NativePointer, referenceList);
                }
#if W8CORE
                referenceList.Add(new ObjectReference(DateTime.Now, comObject, "Not Available on this platform"));
#else
                var stackTraceText = new StringBuilder();
                var stackTrace = new StackTrace(3, true);
                foreach (var stackFrame in stackTrace.GetFrames())
                {
                    // Skip system/generated frame
                    if (stackFrame.GetFileLineNumber() == 0)
                        continue;
                    stackTraceText.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "\t{0}({1},{2}) : {3}", stackFrame.GetFileName(), stackFrame.GetFileLineNumber(),
                                         stackFrame.GetFileColumnNumber(),
                                         stackFrame.GetMethod()).AppendLine();
                }

                referenceList.Add(new ObjectReference(DateTime.Now, comObject, stackTraceText.ToString()));
#endif
                // Fire Tracked event.
                OnTracked(comObject);
            }
        }
예제 #38
0
 public string GetTranslatedSignalName()
 {
     return(ComObject.GetTranslatedSignalName());
 }
예제 #39
0
        /// <summary>
        /// Tracks the specified COM object.
        /// </summary>
        /// <param name="comObject">The COM object.</param>
        public static void Track(ComObject comObject)
        {
            if (comObject == null || comObject.NativePointer == IntPtr.Zero)
                return;
            lock (ObjectReferences)
            {
                List<ObjectReference> referenceList;
                // Object is already tracked
                if (!ObjectReferences.TryGetValue(comObject.NativePointer, out referenceList))
                {
                    referenceList = new List<ObjectReference>();
                    ObjectReferences.Add(comObject.NativePointer, referenceList);
                }

                referenceList.Add(new ObjectReference(DateTime.Now, comObject, StackTraceProvider != null ? StackTraceProvider() : String.Empty));

                // Fire Tracked event.
                OnTracked(comObject);
            }
        }
예제 #40
0
 public int GetViewNumber()
 {
     return(ComObject.GetViewNumber());
 }
예제 #41
0
        /// <summary>
        /// Untracks the specified COM object.
        /// </summary>
        /// <param name="comObject">The COM object.</param>
        public static void UnTrack(ComObject comObject)
        {
            if (comObject == null || comObject.NativePointer == IntPtr.Zero)
                return;

            lock (ObjectReferences)
            {
                List<ObjectReference> referenceList;
                // Object is already tracked
                if (ObjectReferences.TryGetValue(comObject.NativePointer, out referenceList))
                {
                    for (int i = referenceList.Count-1; i >=0; i--)
                    {
                        var objectReference = referenceList[i];
                        if (ReferenceEquals(objectReference.Object.Target, comObject))
                            referenceList.RemoveAt(i);
                        else if (!objectReference.IsAlive)
                            referenceList.RemoveAt(i);
                    }
                    // Remove empty list
                    if (referenceList.Count == 0)
                        ObjectReferences.Remove(comObject.NativePointer);

                    // Fire UnTracked event
                    OnUnTracked(comObject);
                }
            }
        }
예제 #42
0
 /// <summary>
 /// Creates a swapchain associated to the specified HWND. This is applicable only for Desktop platform.
 /// </summary>
 /// <param name="factory">The DXGI Factory used to create the swapchain.</param>
 /// <param name="device">The associated device instance.</param>
 /// <param name="hwnd">The HWND of the window to which this swapchain is associated.</param>
 /// <param name="description">The swap chain description.</param>
 /// <param name="fullScreenDescription">The fullscreen description of the swap chain. Default is null.</param>
 /// <param name="restrictToOutput">The output to which this swap chain should be restricted. Default is null, meaning that there is no restriction.</param>
 public SwapChain1(Factory2 factory, ComObject device, IntPtr hwnd, ref SwapChainDescription1 description, SwapChainFullScreenDescription? fullScreenDescription = null, Output restrictToOutput = null)
     : base(IntPtr.Zero)
 {
     factory.CreateSwapChainForHwnd(device, hwnd, ref description, fullScreenDescription, restrictToOutput, this);
 }
예제 #43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComObjectEventArgs"/> class.
 /// </summary>
 /// <param name="o">The o.</param>
 public ComObjectEventArgs(ComObject o)
 {
     Object = o;
 }
예제 #44
0
 public int GetOwnerId()
 {
     return(ComObject.GetOwnerId());
 }
예제 #45
0
 /// <summary>	
 /// <p>[This documentation is preliminary and is subject to change.]</p><p><strong>Applies to: </strong>desktop apps | Metro style apps</p><p>Sets the Microsoft Direct3D device or notifies the device manager that the Direct3D device was reset.</p>	
 /// </summary>	
 /// <param name="direct3D11Device"><dd> <p>A reference to the <strong><see cref="SharpDX.ComObject"/></strong> interface of the DXGI device.</p> </dd></param>	
 /// <remarks>	
 /// <p>When you first create the DXGI Device Manager, call this method with a reference to the Direct3D device. (The device manager does not create the device; the caller must provide the device reference initially.) Also call this method if the Direct3D device becomes lost and you need to reset the device or create a new device. </p><p>The <em>resetToken</em> parameter ensures that only the component that originally created the device manager can invalidate the current device.</p><p>If this method succeeds, all open device handles become invalid.</p>	
 /// </remarks>	
 /// <msdn-id>hh447911</msdn-id>	
 /// <unmanaged>HRESULT IMFDXGIDeviceManager::ResetDevice([In] IUnknown* pUnkDevice,[In] unsigned int resetToken)</unmanaged>	
 /// <unmanaged-short>IMFDXGIDeviceManager::ResetDevice</unmanaged-short>	
 public void ResetDevice(ComObject direct3D11Device)
 {
     this.ResetDevice(direct3D11Device, ResetToken);
 }
예제 #46
0
 /// <summary>	
 ///  IDWriteTextLayout::Draw calls this function to instruct the client to draw a strikethrough. 	
 /// </summary>	
 /// <remarks>	
 ///  A single strikethrough can be broken into multiple calls, depending on how the formatting changes attributes. Strikethrough is not averaged across font sizes/styles changes. To get an appropriate starting pixel position, add strikethrough::offset to the baseline. Like underlines, the x coordinate will always be passed as the left side, regardless of text directionality. 	
 /// </remarks>	
 /// <param name="clientDrawingContext">The application-defined drawing context passed to  IDWriteTextLayout::Draw.</param>
 /// <param name="baselineOriginX">The pixel location (X-coordinate) at the baseline origin of the run where strikethrough applies.</param>
 /// <param name="baselineOriginY">The pixel location (Y-coordinate) at the baseline origin of the run where strikethrough applies.</param>
 /// <param name="strikethrough">Pointer to  a structure containing strikethrough logical information.</param>
 /// <param name="clientDrawingEffect">Application-defined effect to apply to the strikethrough.  Usually this argument represents effects such as the foreground brush filling the interior of a line.</param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
 /// <unmanaged>HRESULT DrawStrikethrough([None] void* clientDrawingContext,[None] FLOAT baselineOriginX,[None] FLOAT baselineOriginY,[In] const DWRITE_STRIKETHROUGH* strikethrough,[None] IUnknown* clientDrawingEffect)</unmanaged>
 public virtual Result DrawStrikethrough(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref Strikethrough strikethrough, ComObject clientDrawingEffect)
 {
     return Result.NotImplemented;
 }
예제 #47
0
 public int HasAttribute(string name)
 {
     return(ComObject.HasAttribute(name));
 }
예제 #48
0
 public int GetTextCount()
 {
     return(ComObject.GetTextCount());
 }
예제 #49
0
 /// <summary>
 /// Creates a swapchain for DirectComposition API or WinRT XAML framework. This is applicable only for WinRT platform.
 /// </summary>
 /// <param name="factory">The DXGI Factory used to create the swapchain.</param>
 /// <param name="device">The associated device instance.</param>
 /// <param name="description">The swap chain description.</param>
 /// <param name="restrictToOutput">The output to which this swap chain should be restricted. Default is null, meaning that there is no restriction.</param>
 public SwapChain1(Factory2 factory, ComObject device, ref SwapChainDescription1 description, Output restrictToOutput = null)
     : base(IntPtr.Zero)
 {
     factory.CreateSwapChainForComposition(device, ref description, restrictToOutput, this);
 }
예제 #50
0
 public int Highlight()
 {
     return(ComObject.Highlight());
 }
예제 #51
0
 /// <summary>	
 ///  IDWriteTextLayout::Draw calls this function to instruct the client to draw an underline. 	
 /// </summary>	
 /// <remarks>	
 ///  A single underline can be broken into multiple calls, depending on how the formatting changes attributes. If font sizes/styles change within an underline, the thickness and offset will be averaged weighted according to characters. To get an appropriate starting pixel position, add underline::offset to the baseline. Otherwise there will be no spacing between the text. The x coordinate will always be passed as the left side, regardless of text directionality. This simplifies drawing and reduces the problem of round-off that could potentially cause gaps or a double stamped alpha blend. To avoid alpha overlap, round the end points to the nearest device pixel. 	
 /// </remarks>	
 /// <param name="clientDrawingContext">The application-defined drawing context passed to  IDWriteTextLayout::Draw.</param>
 /// <param name="baselineOriginX">The pixel location (X-coordinate) at the baseline origin of the run where underline applies.</param>
 /// <param name="baselineOriginY">The pixel location (Y-coordinate) at the baseline origin of the run where underline applies.</param>
 /// <param name="underline">Pointer to  a structure containing underline logical information.</param>
 /// <param name="clientDrawingEffect"> Application-defined effect to apply to the underline. Usually this argument represents effects such as the foreground brush filling the interior of a line.</param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
 /// <unmanaged>HRESULT DrawUnderline([None] void* clientDrawingContext,[None] FLOAT baselineOriginX,[None] FLOAT baselineOriginY,[In] const DWRITE_UNDERLINE* underline,[None] IUnknown* clientDrawingEffect)</unmanaged>
 public virtual Result DrawUnderline(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref Underline underline, ComObject clientDrawingEffect)
 {
     return Result.NotImplemented;
 }
예제 #52
0
 public int IsValid()
 {
     return(ComObject.IsValid());
 }
예제 #53
0
 /// <summary>	
 ///  IDWriteTextLayout::Draw calls this application callback when it needs to draw an inline object. 	
 /// </summary>	
 /// <param name="clientDrawingContext">The application-defined drawing context passed to IDWriteTextLayout::Draw.</param>
 /// <param name="originX">X-coordinate at the top-left corner of the inline object.</param>
 /// <param name="originY">Y-coordinate at the top-left corner of the inline object.</param>
 /// <param name="inlineObject">The application-defined inline object set using IDWriteTextFormat::SetInlineObject.</param>
 /// <param name="isSideways">A Boolean flag that indicates whether the object's baseline runs alongside the baseline axis of the line.</param>
 /// <param name="isRightToLeft">A Boolean flag that indicates whether the object is in a right-to-left context, hinting that the drawing may want to mirror the normal image.</param>
 /// <param name="clientDrawingEffect">Application-defined drawing effects for the glyphs to render. Usually this argument represents effects such as the foreground brush filling the interior of a line.</param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
 /// <unmanaged>HRESULT DrawInlineObject([None] void* clientDrawingContext,[None] FLOAT originX,[None] FLOAT originY,[None] IDWriteInlineObject* inlineObject,[None] BOOL isSideways,[None] BOOL isRightToLeft,[None] IUnknown* clientDrawingEffect)</unmanaged>
 public virtual Result DrawInlineObject(object clientDrawingContext, float originX, float originY, InlineObject inlineObject, bool isSideways, bool isRightToLeft, ComObject clientDrawingEffect)
 {
     return Result.NotImplemented;
 }
예제 #54
0
 public int IsView()
 {
     return(ComObject.IsView());
 }
예제 #55
0
파일: ByteStream.cs 프로젝트: nkast/SharpDX
        protected unsafe override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (streamProxy != null)
            {
                streamProxy.Dispose();
                streamProxy = null;
            }

            if (randomAccessStreamCom != null)
            {
                randomAccessStreamCom.Dispose();
                randomAccessStreamCom = null;
            }
        }
예제 #56
0
 public int SetAttributeValue(string name, string value)
 {
     return(ComObject.SetAttributeValue(name, value));
 }
예제 #57
0
파일: ByteStream.cs 프로젝트: nkast/SharpDX
 /// <summary>
 /// Instantiates a new instance <see cref="ByteStream"/> from a <see cref="Stream"/>.
 /// </summary>
 /// <msdn-id>hh162754</msdn-id>	
 /// <unmanaged>HRESULT MFCreateMFByteStreamOnStreamEx([In] IUnknown* punkStream,[Out] IMFByteStream** ppByteStream)</unmanaged>	
 /// <unmanaged-short>MFCreateMFByteStreamOnStreamEx</unmanaged-short>	
 public ByteStream(IRandomAccessStream sourceStream)
 {
     var randomAccessStream = sourceStream;
     randomAccessStreamCom = new ComObject(Marshal.GetIUnknownForObject(randomAccessStream));
     MediaFactory.CreateMFByteStreamOnStreamEx(randomAccessStreamCom, this);
 }
예제 #58
0
 public int SetAttributeVisibility(string name, int onoff)
 {
     return(ComObject.SetAttributeVisibility(name, onoff));
 }
예제 #59
0
 /// <summary>
 /// Creates a MediaObject from any ComObjects which derives from MediaObject.
 /// </summary>
 /// <remarks>
 /// Internally they IUnknown::QueryInterface method of the passed COM Object gets called.
 /// </remarks>
 /// <param name="comObj">ComObjects which has to get casted to a MediaObject.</param>
 /// <returns>MediaObject</returns>
 public static MediaObject FromComObject(ComObject comObj)
 {
     if (comObj == null)
         throw new ArgumentNullException("comObj");
     return comObj.QueryInterface<MediaObject>();
 }
예제 #60
0
 public int Create(int shti, int pnts, ref object x, ref object y)
 {
     return(ComObject.Create(shti, pnts, ref x, ref y));
 }