コード例 #1
0
ファイル: ContentReaders.cs プロジェクト: Cyral/MonoForce
        /// <returns>Returns the cursor object from the stream.</returns>
        /// <param name="existingInstance">Existing cursor object to read into.</param>
        /// <param name="input">Content reader used to read the cursor.</param>
        /// <summary>
        /// Reads a cursor type from the current stream.
        /// </summary>
        protected override Cursor Read(ContentReader input, Cursor existingInstance)
        {
            if (existingInstance == null)
            {
                var count = input.ReadInt32();
                var data  = input.ReadBytes(count);

                var path = Path.GetTempFileName();
                File.WriteAllBytes(path, data);
                var tPath = Path.GetTempFileName();
                using (var i = Icon.ExtractAssociatedIcon(path))
                {
                    using (var b = i.ToBitmap())
                    {
                        b.Save(tPath, ImageFormat.Png);
                        b.Dispose();
                    }

                    i.Dispose();
                }
                var handle = NativeMethods.LoadCursor(path);
                var c      = new System.Windows.Forms.Cursor(handle);
                var hs     = new Vector2(c.HotSpot.X, c.HotSpot.Y);
                var w      = c.Size.Width;
                var h      = c.Size.Height;
                c.Dispose();
                File.Delete(path);

                return(new Cursor(tPath, hs, w, h));
            }

            return(existingInstance);
        }
コード例 #2
0
ファイル: DrawArgs.cs プロジェクト: Fav/testww
        public void Dispose()
        {
            foreach (IDisposable font in fontList.Values)
            {
                if (font != null)
                {
                    font.Dispose();
                }
            }
            fontList.Clear();

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

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

            GC.SuppressFinalize(this);
        }
コード例 #3
0
 public static void Disposed(Int32 numberIterations)
 {
     for (int i = 0; i < numberIterations; ++i)
     {
         System.Windows.Forms.Cursor cu = new System.Windows.Forms.Cursor(ms);
         cu.Dispose();
         ms.Position = 0;
     }
 }
コード例 #4
0
        private void SetCursor()
        {
            System.Drawing.Bitmap       bitmap = new System.Drawing.Bitmap(ComboBoxExistingSkin.SelectedValue + "/cursor.png");
            System.Windows.Forms.Cursor cursor = Png2CursorConverter.CreateCursor(bitmap);

            SafeFileHandle panHandle = new SafeFileHandle(cursor.Handle, false);

            GridCursor.Cursor = System.Windows.Interop.CursorInteropHelper.Create(panHandle);
            bitmap.Dispose();
            cursor.Dispose();
        }
コード例 #5
0
        ////////////////////////////////////////////////////////////////////////////
        protected override Cursor Read(ContentReader input, Cursor existingInstance)
        {
            if (existingInstance == null)
            {
                int    count = input.ReadInt32();
                byte[] data  = input.ReadBytes(count);

                string path = Path.GetTempFileName();
                File.WriteAllBytes(path, data);
                string tPath = Path.GetTempFileName();
                using (System.Drawing.Icon i = System.Drawing.Icon.ExtractAssociatedIcon(path))
                {
                    using (System.Drawing.Bitmap b = i.ToBitmap())
                    {
                        b.Save(tPath, System.Drawing.Imaging.ImageFormat.Png);
                        b.Dispose();
                    }

                    i.Dispose();
                }
                //TODO: Replace with xml based solution for getting hotspot and size instead
                IntPtr handle = NativeMethods.LoadCursor(path);
                System.Windows.Forms.Cursor c = new System.Windows.Forms.Cursor(handle);
                Vector2 hs = new Vector2(c.HotSpot.X, c.HotSpot.Y);
                int     w  = c.Size.Width;
                int     h  = c.Size.Height;
                c.Dispose();
                File.Delete(path);

                return(new Cursor(tPath, hs, w, h));
            }
            else
            {
            }

            return(existingInstance);
        }