Inheritance: IDisposable
Exemple #1
0
        public static void ResetDrawBackgroundCache()
        {
            if (image == null)
                return;

            image.Dispose ();
            image = null;
        }
Exemple #2
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();
 }
Exemple #3
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);
     }
 }
Exemple #4
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);
     }
 }
Exemple #5
0
        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);
            }
        }
 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);
     }
 }
 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);
     }
 }
 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 ();
 }
        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);
        }