Inheritance: IDisposable
コード例 #1
0
ファイル: CairoContextEx.cs プロジェクト: GNOME/gbrainy
        public static void ResetDrawBackgroundCache()
        {
            if (image == null)
                return;

            image.Dispose ();
            image = null;
        }
コード例 #2
0
ファイル: CairoContext.cs プロジェクト: nated099/gbrainy
 public void DrawImage(SVGImage image, double x, double y, double width, double height)
 {
     Save();
     Translate(x, y);
     Scale(width / image.Width, height / image.Height);
     image.RenderToCairo(Handle);
     Restore();
 }
コード例 #3
0
ファイル: CairoContext.cs プロジェクト: nated099/gbrainy
 public void DrawImageFromFile(string filename, double x, double y, double width, double height)
 {
     try {
         using (SVGImage image = new SVGImage(filename))
         {
             DrawImage(image, x, y, width, height);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("CairoContext.DrawImageFromFile. Could not load file {0}. Error {1}", filename, e);
     }
 }
コード例 #4
0
ファイル: CairoContext.cs プロジェクト: nated099/gbrainy
 public void DrawImageFromAssembly(string resource, double x, double y, double width, double height)
 {
     try {
         using (SVGImage image = new SVGImage(System.Reflection.Assembly.GetCallingAssembly(), resource))
         {
             DrawImage(image, x, y, width, height);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("CairoContext.DrawImageFromAssembly. Could not load resource {0}. Error {1}", resource, e);
     }
 }
コード例 #5
0
ファイル: CairoContextEx.cs プロジェクト: GNOME/gbrainy
        public virtual void DrawBackground()
        {
            try {
                if (image == null)
                {
                    Theme theme;

                    theme = ThemeManager.FromName (Preferences.Get <string> (Preferences.ThemeKey));
                    image = new SVGImage (System.IO.Path.Combine (Defines.DATA_DIR, theme.BackgroundImage));
                }

                Save ();
                Rectangle (0, 0, 1, 1);
                Scale (0.999 / image.Width, 0.999 / image.Height);
                image.RenderToCairo (Handle);
                Restore ();
            }
            catch (Exception e)
            {
                Console.WriteLine ("CairoContextEx.DrawBackground {0}", e);
            }
        }
コード例 #6
0
 public void DrawImageFromFile(string filename, double x, double y, double width, double height)
 {
     try {
         using (SVGImage image = new SVGImage (filename))
         {
             DrawImage (image, x, y, width, height);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine ("CairoContext.DrawImageFromFile. Could not load file {0}. Error {1}", filename, e);
     }
 }
コード例 #7
0
 public void DrawImageFromAssembly(string  resource, double x, double y, double width, double height)
 {
     try {
         using (SVGImage image = new SVGImage (System.Reflection.Assembly.GetCallingAssembly (), resource))
         {
             DrawImage (image, x, y, width, height);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine ("CairoContext.DrawImageFromAssembly. Could not load resource {0}. Error {1}", resource, e);
     }
 }
コード例 #8
0
 public void DrawImage(SVGImage image, double x, double y, double width, double height)
 {
     Save ();
     Translate (x, y);
     Scale (width / image.Width, height / image.Height);
     image.RenderToCairo (Handle);
     Restore ();
 }
コード例 #9
0
        void DrawSolutionIcon(CairoContextEx cr, double x, double y, double width, double height)
        {
            string image;
            int img_index = (int) SolutionIcon;

            switch (SolutionIcon) {
            case SolutionType.CorrectAnswer:
                image = "gtk-ok.svg";
                break;
            case SolutionType.InvalidAnswer:
                image = "gtk-stop.svg";
                break;
            case SolutionType.Tip:
                image = "gtk-info.svg";
                break;
            default:
                return;
            }

            // In memory games, the image gets painted several dozen times
            if (images [img_index] == null) {
                images [img_index] = new SVGImage (System.Reflection.Assembly.GetExecutingAssembly (), image);
            }

            cr.DrawImage (images [img_index], x + icon_margin, y, width, height);
        }