示例#1
0
        /// <summary>
        /// Gets a value indicating whether Ink is available.
        /// </summary>
        /// <returns>true if Ink is available, or false if it is not</returns>
        /// <remarks>
        /// If ink is not available, then the other static methods or properties of this class will not
        /// be usable and will throw NotSupportedException.
        /// </remarks>
        public static bool IsAvailable()
        {
            if (!isInkAvailableInit)
            {
                // For debug builds we try to load the assembly. This enables us to work with ink
                // if we have the Tablet PC SDK installed.
                // For retail builds we only enable ink on true blue Tablet PC's. Calling GetSystemMetrics
                // is much faster than attempting to load an assembly.
#if NOINK
                isInkAvailable = false;
#elif DEBUG
    #if ENABLE_INK_IN_DEBUG_BUILDS
                try
                {
                    Assembly inkAssembly = Assembly.Load("Microsoft.Ink, Version=1.7.2600.2180, Culture=\"\", PublicKeyToken=31bf3856ad364e35");
                    isInkAvailable = true;
                }

                catch (Exception)
                {
                    isInkAvailable = false;
                }
    #else
                isInkAvailable = false;
    #endif
#else
                if (SafeNativeMethods.GetSystemMetrics(NativeConstants.SM_TABLETPC) != 0)
                {
                    // Only enable ink if the system states it is a Tablet PC.
                    // In other words, don't incur the performance penalty and a few other
                    // weird things for regular PC's that just happen to have the SDK
                    // installed, or that have something like Vista Ultimate.
                    try
                    {
                        Assembly inkAssembly = Assembly.Load("Microsoft.Ink, Version=1.7.2600.2180, Culture=\"\", PublicKeyToken=31bf3856ad364e35");
                        isInkAvailable = true;
                    }

                    catch (Exception)
                    {
                        isInkAvailable = false;
                    }
                }
                else
                {
                    isInkAvailable = false;
                }
#endif

                isInkAvailableInit = true;
            }

            return(isInkAvailable);
        }
示例#2
0
 /// <summary>
 /// Determines whether the user is running within a remoted session (Terminal Server, Remote Desktop).
 /// </summary>
 /// <returns>
 /// <b>true</b> if we're running in a remote session, <b>false</b> otherwise.
 /// </returns>
 /// <remarks>
 /// You can use this to optimize the presentation of visual elements. Remote sessions
 /// are often bandwidth limited and less suitable for complex drawing.
 /// Note to implementors: This may be implemented as a no op; in this case, always return false.
 /// </remarks>
 public static bool IsRemote()
 {
     return(0 != SafeNativeMethods.GetSystemMetrics(NativeConstants.SM_REMOTESESSION));
 }