Ejemplo n.º 1
0
 public static Xwt.Drawing.Image GetIconFromFile(string filePath)
 {
     Path.GetExtension(filePath);
     if (!File.Exists(filePath))
     {
         return((Xwt.Drawing.Image)null);
     }
     try
     {
         Xwt.Drawing.Image image1 = (Xwt.Drawing.Image)null;
         using (FileStream fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read))
             image1 = Xwt.Drawing.Image.FromStream((Stream)fileStream);
         List <Xwt.Drawing.Image> imageList = new List <Xwt.Drawing.Image>();
         string resource2xId = ImageIcon.GetResource2xID(filePath);
         if (File.Exists(resource2xId))
         {
             using (FileStream fileStream = File.Open(resource2xId, FileMode.Open, FileAccess.Read))
             {
                 Xwt.Drawing.Image image2 = Xwt.Drawing.Image.FromStream((Stream)fileStream);
                 imageList.Add(image2);
             }
         }
         if (imageList.Count > 0)
         {
             imageList.Insert(0, image1);
             image1 = Xwt.Drawing.Image.CreateMultiResolutionImage((IEnumerable <Xwt.Drawing.Image>)imageList);
         }
         return(image1);
     }
     catch (Exception ex)
     {
         LogConfig.Logger.Debug((object)LanguageInfo.MessageBox_Content170, ex);
         return((Xwt.Drawing.Image)null);
     }
 }
Ejemplo n.º 2
0
        static Cursors()
        {
            Display display = Display.Default;

            if (Platform.IsWindows)
            {
                Cursors.arrow = new Cursor(CursorType.Arrow);
            }
            else if (Platform.IsMac)
            {
                Cursors.arrow = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.Arrow.png"), 4, 1);
            }
            Cursors.arrowForbid      = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.ArrowForbid.png"), 2, 1);
            Cursors.arrowMove        = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.ArrowMove.png"), 2, 1);
            Cursors.arrowMoveAnchor  = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.ArrowMoveAnchor.png"), 2, 1);
            Cursors.chamferHorizon   = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.ChamferHorizon.png"), 7, 7);
            Cursors.chamferVertical  = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.ChamferVertical.png"), 7, 7);
            Cursors.cross            = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.Cross.png"), 7, 7);
            Cursors.fist             = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.Fist.png"), 7, 7);
            Cursors.hand             = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.Hand.png"), 7, 7);
            Cursors.input            = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.Input.png"), 7, 7);
            Cursors.link             = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.Link.png"), 6, 2);
            Cursors.rotateDown       = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.RotateDown.png"), 7, 7);
            Cursors.rotateLeft       = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.RotateLeft.png"), 7, 7);
            Cursors.rotateLeftDown   = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.RotateLeftDown.png"), 7, 7);
            Cursors.rotateLeftUp     = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.RotateLeftUp.png"), 7, 7);
            Cursors.rotateRight      = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.RotateRight.png"), 7, 7);
            Cursors.rotateRightDown  = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.RotateRightDown.png"), 7, 7);
            Cursors.rotateRightUp    = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.RotateRightUp.png"), 7, 7);
            Cursors.rotateUp         = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.RotateUp.png"), 7, 7);
            Cursors.stretchHorizon   = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.StretchHorizon.png"), 7, 7);
            Cursors.stretchLeftDown  = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.StretchLeftDown.png"), 7, 7);
            Cursors.stretchRightDown = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.StretchRightDown.png"), 7, 7);
            Cursors.stretchVertical  = new Cursor(display, ImageIcon.GetPixbuf("CocoStudio.DefaultResource.CursorImage.StretchVertical.png"), 7, 7);
        }
Ejemplo n.º 3
0
 public virtual void Init(string imageUnCheck, string imageCheck, int tag)
 {
     this.ImageCheck                = imageCheck;
     this.ImageUnCheck              = imageUnCheck;
     this.Tag                       = tag;
     this.checkedImage              = ImageIcon.GetIcon(imageCheck);
     this.uncheckedImage            = ImageIcon.GetIcon(imageUnCheck);
     this.imageWidget.Image         = this.uncheckedImage;
     this.imageWidget.WidthRequest  = 24;
     this.imageWidget.HeightRequest = 24;
     this.imageWidget.Show();
 }
Ejemplo n.º 4
0
        public static Pixbuf GetPixbuf(string resourceID)
        {
            Assembly callingAssembly = Assembly.GetCallingAssembly();
            IconSet  iconSet         = IconFactory.LookupDefault(resourceID);

            if (iconSet == null)
            {
                iconSet = new IconSet();
                ImageIcon.LoadIcon(iconSet, resourceID, callingAssembly);
                ImageIcon.iconFactory.Add(resourceID, iconSet);
            }
            return(iconSet.RenderIcon(Widget.DefaultStyle, TextDirection.Ltr, StateType.Normal, IconSize.Button, (Widget)null, (string)null, ImageIcon.ScaleFactor));
        }
Ejemplo n.º 5
0
 public static Xwt.Drawing.Image GetPreviewIcon(string filePath, out double width, out double height, bool isFouse = false)
 {
     filePath = Path.Combine(filePath);
     Xwt.Drawing.Image image = (Xwt.Drawing.Image)null;
     if (!isFouse && ImageIcon.previewIcons.TryGetValue(filePath, out image))
     {
         width  = image.Width;
         height = image.Height;
         return(image);
     }
     image = ImageIcon.GetImageFromFile(filePath);
     if (image != null)
     {
         width  = image.Width;
         height = image.Height;
         if (ImageIcon.previewIconNames.Count <string>() >= ImageIcon.previewIconCacheMax)
         {
             string key = ImageIcon.previewIconNames.Dequeue();
             ImageIcon.previewIcons.Remove(key);
         }
         double num = 1.0;
         if (image.Width > 46.0 && image.Width >= image.Height)
         {
             num = 46.0 / image.Width;
         }
         if (image.Height > 46.0 && image.Height >= image.Width)
         {
             num = 46.0 / image.Height;
         }
         image = image.Scale(num, num);
         ImageIcon.previewIcons[filePath] = image;
         ImageIcon.previewIconNames.Enqueue(filePath);
     }
     else
     {
         width  = 0.0;
         height = 0.0;
     }
     return(image);
 }
Ejemplo n.º 6
0
        private static void LoadIcon(IconSet iconSet, string resourceID, Assembly callingAssembly)
        {
            Pixbuf     pixbuf1     = ImageIcon.LoadResource(resourceID, callingAssembly);
            Pixbuf     pixbuf2     = ImageIcon.LoadResource2x(resourceID, callingAssembly);
            IconSource iconSource1 = new IconSource();

            ImageIcon.ConfigIconSource(pixbuf1, iconSource1);
            if (pixbuf2 != null)
            {
                GtkWorkarounds.SetSourceScale(iconSource1, 1.0);
                GtkWorkarounds.SetSourceScaleWildcarded(iconSource1, false);
                IconSource iconSource2 = new IconSource();
                ImageIcon.ConfigIconSource(pixbuf2, iconSource2);
                GtkWorkarounds.SetSourceScale(iconSource2, ImageIcon.ScaleFactor);
                GtkWorkarounds.SetSourceScaleWildcarded(iconSource2, false);
                iconSet.AddSource(iconSource2);
            }
            else
            {
                iconSet.AddSource(iconSource1);
            }
        }
Ejemplo n.º 7
0
 private static Pixbuf LoadResource2x(string resourceID, Assembly callingAssembly)
 {
     return(ImageIcon.LoadResource(ImageIcon.GetResource2xID(resourceID), callingAssembly));
 }