Exemple #1
0
        /// <summary>
        /// Méthode "qui marche" pour charger un curseur.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static Cursor LoadCursor(Stream reader)
        {
            string file = Path.GetTempPath() + "/cursor_pcs.cur";
            // create a write stream
            FileStream writeStream = new FileStream(file, FileMode.Create, FileAccess.Write);

            // write to the stream
            FormsTools.ReadWriteStream(reader, writeStream);

            Cursor cursor = FormsTools.LoadCustomCursor(file);

            writeStream.Close();
            File.Delete(file);

            return(cursor);
        }
Exemple #2
0
        /// <summary>
        /// Place la Surface Source dans un Surface de taille pSize.
        /// </summary>
        /// <param name="pSource">Surface à centrer</param>
        /// <param name="pBackground">Surface de background</param>
        /// <param name="pSize">Taille du conteneur</param>
        /// <param name="pSize">Taille du contenu</param>
        /// <returns>Surface transformée</returns>
        static public Image GetImageReducedAndCentered(Image source, Image background, Rectangle size, Rectangle sizeSource, bool full)
        {
            Rectangle finalSize    = FormsTools.GetSurfacePositionCenterInSurface(size, sizeSource);
            Image     finalSurface = new Bitmap(background);

            using (Graphics graphics = Graphics.FromImage(finalSurface))
            {
                if (full)
                {
                    graphics.DrawImageUnscaled(source, finalSize);
                }
                else
                {
                    graphics.DrawImage(source, finalSize);
                }
            }
            return(finalSurface);
        }