コード例 #1
0
		void Load ()
		{
			var monitor = loadMonitor;
			System.Threading.ThreadPool.QueueUserWorkItem (delegate {
				try {
					HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create (url);
					WebResponse resp = req.GetResponse ();
					MemoryStream ms = new MemoryStream ();
					using (var s = resp.GetResponseStream ()) {
						s.CopyTo (ms);
					}
					var data = ms.ToArray ();

					MonoDevelop.Ide.DispatchService.GuiSyncDispatch (delegate {
						Gdk.PixbufLoader l = new Gdk.PixbufLoader (resp.ContentType);
						l.Write (data);
						image = l.Pixbuf;
						l.Close ();
						monitor.Dispose ();
					});
					
					// Replace the async operation to avoid holding references to all
					// objects that subscribed the Completed event.
					loadOperation = NullAsyncOperation.Success;
				} catch (Exception ex) {
					loadMonitor.ReportError (null, ex);
					Gtk.Application.Invoke (delegate {
						monitor.Dispose ();
					});
					loadOperation = NullAsyncOperation.Failure;
				}
				loadMonitor = null;
			});
		}
コード例 #2
0
        static Gdk.Pixbuf GetEmbeddedIcon(AssemblyDefinition asm, string iconname)
        {
            Gdk.Pixbuf icon = null;
            if (iconname != null && iconname.Length > 0)
            {
                try
                {
                    // Using the pixbuf resource constructor generates a gdk warning.
                    EmbeddedResource res    = GetResource(asm, iconname);
                    Gdk.PixbufLoader loader = new Gdk.PixbufLoader(res.GetResourceData());
                    icon = loader.Pixbuf;
                }
                catch
                {
                    // Ignore
                }
            }

            if (icon == null)
            {
                ClassDescriptor cc = Registry.LookupClassByName("Gtk.Bin");
                icon = cc.Icon;
            }
            return(icon);
        }
コード例 #3
0
        private Gdk.Pixbuf GetPixbuf(ByteVector data)
        {
            bool bail = false;

            Gdk.Pixbuf       output;
            Gdk.PixbufLoader loader = new Gdk.PixbufLoader();

            try {
                if (!loader.Write(data.Data))
                {
                    bail = true;
                }
            } catch { bail = true; }

            try {
                if (!loader.Close())
                {
                    bail = true;
                }
            } catch { bail = true; }

            output = (!bail) ? loader.Pixbuf : null;

            return(output);
        }
コード例 #4
0
ファイル: ImageLoader.cs プロジェクト: zendbit/monodevelop
        void Load()
        {
            var monitor = loadMonitor;

            System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                try {
                    HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
                    WebResponse resp   = req.GetResponse();
                    MemoryStream ms    = new MemoryStream();
                    using (var s = resp.GetResponseStream()) {
                        s.CopyTo(ms);
                    }
                    var data = ms.ToArray();

                    MonoDevelop.Ide.DispatchService.GuiSyncDispatch(delegate {
                        Gdk.PixbufLoader l = new Gdk.PixbufLoader(resp.ContentType);
                        l.Write(data);
                        image = l.Pixbuf;
                        l.Close();
                        monitor.Dispose();
                    });

                    // Replace the async operation to avoid holding references to all
                    // objects that subscribed the Completed event.
                    loadOperation = NullAsyncOperation.Success;
                } catch (Exception ex) {
                    loadMonitor.ReportError(null, ex);
                    Gtk.Application.Invoke(delegate {
                        monitor.Dispose();
                    });
                    loadOperation = NullAsyncOperation.Failure;
                }
                loadMonitor = null;
            });
        }
コード例 #5
0
		public override Gdk.Pixbuf Load ()
		{
			// FIXME this is a hack. No, really, I mean it.
			
			byte [] data = GetEmbeddedJpeg ();
			if (data != null) {
				Gdk.PixbufLoader loader = new Gdk.PixbufLoader ();
				loader.Write (data, (ulong)data.Length);
				Gdk.Pixbuf pixbuf = loader.Pixbuf;
				loader.Close ();
				return pixbuf;
			}
			return null;
		}
コード例 #6
0
        public override Gdk.Pixbuf Load()
        {
            // FIXME this is a hack. No, really, I mean it.

            byte [] data = GetEmbeddedJpeg();
            if (data != null)
            {
                Gdk.PixbufLoader loader = new Gdk.PixbufLoader();
                loader.Write(data, (ulong)data.Length);
                Gdk.Pixbuf pixbuf = loader.Pixbuf;
                loader.Close();
                return(pixbuf);
            }
            return(null);
        }
コード例 #7
0
 void LoadImage(Stream s)
 {
     using (s) {
         Gdk.PixbufLoader loader = new Gdk.PixbufLoader(s);
         Gdk.Pixbuf       pix    = image.Pixbuf = loader.Pixbuf;
         loader.Dispose();
         if (pix.Width > 250)
         {
             Gdk.Pixbuf spix = pix.ScaleSimple(250, (250 * pix.Height) / pix.Width, Gdk.InterpType.Hyper);
             pix.Dispose();
             pix = spix;
         }
         image.Pixbuf = pix;
         image.Show();
     }
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: q792602257/xt-ray
        public static void Main(string[] args)
        {
            Application.Init();

            var app = new Application("org.xtray.gui", GLib.ApplicationFlags.None);

            app.Register(GLib.Cancellable.Current);

            var win = new MainWindow();

            app.AddWindow(win);
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("app.png"))
                using (var pbl = new PBL(stream))
                {
                    Logo = pbl.Pixbuf;
                }
            win.Icon = Logo;
            win.Show();
            Application.Run();
        }
コード例 #9
0
        private void Close()
        {
            ThumbnailGenerator.Default.PopBlock();

            try {
                result = null;

                delay.Stop();
                if (loader != null)
                {
                    loader.AreaPrepared -= ap;
                    loader.AreaUpdated  -= au;
                    // this can throw exceptions
                    loader.Close();
                }
            } catch (System.Exception) {
                //System.Console.WriteLine (e.ToString ());
                if (pixbuf != null)
                {
                    pixbuf.Dispose();
                }

                pixbuf = null;
            } finally {
                if (loader != null)
                {
                    loader.Closed -= ev;
                    loader.Dispose();
                }

                loader = null;

                if (stream != null)
                {
                    stream.Close();
                }

                stream = null;
            }
        }
コード例 #10
0
 void LoadImage(Stream s)
 {
     using (s) {
         Gdk.PixbufLoader loader = new Gdk.PixbufLoader (s);
         Gdk.Pixbuf pix = image.Pixbuf = loader.Pixbuf;
         loader.Dispose ();
         if (pix.Width > 250) {
             Gdk.Pixbuf spix = pix.ScaleSimple (250, (250 * pix.Height) / pix.Width, Gdk.InterpType.Hyper);
             pix.Dispose ();
             pix = spix;
         }
         image.Pixbuf = pix;
         image.Show ();
     }
 }
コード例 #11
0
        public void Load(Uri uri)
        {
            this.uri = uri;

            delay.Stop();

            if (!done_reading)
            {
                Close();
            }

            done_reading  = false;
            area_prepared = false;
            damage        = Gdk.Rectangle.Zero;

            using (ImageFile img = ImageFile.Create(uri)) {
                orientation = Accelerometer.GetViewOrientation(img.Orientation);

                try {
                    PixbufOrientation thumb_orientation = Accelerometer.GetViewOrientation(PixbufOrientation.TopLeft);
                    thumb = new Gdk.Pixbuf(ThumbnailGenerator.ThumbnailPath(uri));
                    thumb = PixbufUtils.TransformOrientation(thumb, thumb_orientation);

                    if (FSpot.ColorManagement.IsEnabled && !thumb.HasAlpha)
                    {
                        if (img.GetProfile() == null)
                        {
                            FSpot.ColorManagement.PhotoImageView.Transform = FSpot.ColorManagement.StandartTransform();
                        }
                        else
                        {
                            FSpot.ColorManagement.PhotoImageView.Transform = FSpot.ColorManagement.CreateTransform(thumb, img.GetProfile());
                        }
                    }
                    else
                    {
                        FSpot.ColorManagement.PhotoImageView.Transform = null;
                    }
                } catch (System.Exception e) {
                    //FSpot.ThumbnailGenerator.Default.Request (uri.ToString (), 0, 256, 256);
                    if (!(e is GLib.GException))
                    {
                        System.Console.WriteLine(e.ToString());
                    }
                }

                System.IO.Stream nstream = img.PixbufStream();
                if (nstream == null)
                {
                    FileLoad(img);
                    return;
                }
                else
                {
                    stream = new StreamWrapper(nstream);
                }

                loader = new Gdk.PixbufLoader();
                loader.AreaPrepared += ap;
                loader.AreaUpdated  += au;
                loader.Closed       += ev;

                if (AreaPrepared != null && thumb != null)
                {
                    pixbuf = thumb;
                    AreaPrepared(this, new AreaPreparedArgs(true));
                }

                ThumbnailGenerator.Default.PushBlock();
                //AsyncIORead (null);
                if (nstream is IOChannel)
                {
                    ((IOChannel)nstream).DataReady += IOChannelRead;
                }
                else
                {
                    delay.Start();
                }
            }
        }
コード例 #12
0
		static Gdk.Pixbuf GetEmbeddedIcon (AssemblyDefinition asm, string iconname)
		{
			Gdk.Pixbuf icon = null;
			if (iconname != null && iconname.Length > 0) {
				try {
					// Using the pixbuf resource constructor generates a gdk warning.
					EmbeddedResource res = GetResource (asm, iconname);
					Gdk.PixbufLoader loader = new Gdk.PixbufLoader (res.Data);
					icon = loader.Pixbuf;
				} catch {
					// Ignore
				}
			}
			
			if (icon == null) {
				ClassDescriptor cc = Registry.LookupClassByName ("Gtk.Bin");
				icon = cc.Icon;
			}
			return icon;
		}
コード例 #13
0
ファイル: ImageHandler.cs プロジェクト: StEvUgnIn/xwt
		public override object LoadFromStream (System.IO.Stream stream)
		{
			using (Gdk.PixbufLoader loader = new Gdk.PixbufLoader (stream))
				return new GtkImage (loader.Pixbuf);
		}
コード例 #14
0
		public void Load (Uri uri)
		{
			this.uri = uri;

			delay.Stop ();

			if (!done_reading)
				Close ();

			done_reading = false;
			area_prepared = false;
			damage = Gdk.Rectangle.Zero;

			using (ImageFile img = ImageFile.Create (uri)) {
				orientation = Accelerometer.GetViewOrientation (img.Orientation);
			
				try {
					PixbufOrientation thumb_orientation = Accelerometer.GetViewOrientation (PixbufOrientation.TopLeft);
					thumb = new Gdk.Pixbuf (ThumbnailGenerator.ThumbnailPath (uri));
					thumb = PixbufUtils.TransformOrientation (thumb, thumb_orientation);
					
					if (FSpot.ColorManagement.IsEnabled && !thumb.HasAlpha) {
						if (img.GetProfile () == null)
							FSpot.ColorManagement.PhotoImageView.Transform = FSpot.ColorManagement.StandartTransform ();
						else
							FSpot.ColorManagement.PhotoImageView.Transform = FSpot.ColorManagement.CreateTransform (thumb, img.GetProfile ());
					}
					else
						FSpot.ColorManagement.PhotoImageView.Transform = null;
				} catch (System.Exception e) {
					//FSpot.ThumbnailGenerator.Default.Request (uri.ToString (), 0, 256, 256);	
					if (!(e is GLib.GException)) 
						System.Console.WriteLine (e.ToString ());
				}

				System.IO.Stream nstream = img.PixbufStream ();
				if (nstream == null) {
					FileLoad (img);
					return;
				} else
					stream = new StreamWrapper (nstream);

				loader = new Gdk.PixbufLoader ();
				loader.AreaPrepared += ap;
				loader.AreaUpdated += au;
				loader.Closed += ev;

				if (AreaPrepared != null && thumb != null) {
					pixbuf = thumb;
					AreaPrepared (this, new AreaPreparedArgs (true));
				}

				ThumbnailGenerator.Default.PushBlock ();
				//AsyncIORead (null);
				if (nstream is IOChannel) {
					((IOChannel)nstream).DataReady += IOChannelRead;
				} else
					delay.Start ();
			}

		}			
コード例 #15
0
ファイル: MainWindow.cs プロジェクト: OECBot/OECUpdater
        public MainWindow(Builder builder, IntPtr handle, RepositoryManager manager) : base(handle)
        {
            //revealer = new Widget (builder.GetObject ("revealer1").Handle);
            this.Title = "Spazio";
            CssProvider provider = new CssProvider();

            builder.Autoconnect(this);
            DeleteEvent += OnDeleteEvent;

            Serializer.InitPlugins();
            SettingsWindow.InitializeSettingsManager(new SettingsManager("settings.ini"));

            Menu     menu    = new Menu();
            MenuItem confirm = new MenuItem("Confirm");

            menu.Append(confirm);
            confirm.Activated += OnLogout;
            menubutton2.Popup  = menu;
            menu.ShowAll();

            bf = BotForm.Create();

            var box3 = new HBox();

            var pixbuffloader = new Gdk.PixbufLoader("Assets/push.png", 32, 32);
            var pixbuff       = pixbuffloader.Pixbuf;
            //pixbuff.ScaleSimple (36, 36, Gdk.InterpType.Hyper);
            var icon2 = new Image(pixbuff);

            Label l3 = new Label("Pull-Requests");

            box3.PackStart(icon2, false, false, 0);
            l3.StyleContext.AddClass("fontWhite");
            box3.PackStart(l3, false, false, 0);

            var box4 = new HBox();

            pixbuffloader = new Gdk.PixbufLoader("Assets/plugin.png", 32, 32);
            var icon3 = new Image(pixbuffloader.Pixbuf);

            box4.PackStart(icon3, false, false, 0);
            var l4 = new Label("Plugins");

            l4.StyleContext.AddClass("fontWhite");
            box4.PackStart(l4, false, false, 0);
            box4.ShowAll();

            var box = new HBox();

            pixbuffloader = new Gdk.PixbufLoader("Assets/home.png", 32, 32);
            var img = new Image(pixbuffloader.Pixbuf);


            var box2 = new HBox();

            pixbuffloader = new Gdk.PixbufLoader("Assets/power.png", 32, 32);
            var icon = new Image(pixbuffloader.Pixbuf);

            box2.PackStart(icon, false, false, 0);

            box.PackStart(img, false, false, 0);
            Label l1 = new Label("OECBot");

            l1.StyleContext.AddClass("fontWhite");
            box2.PackStart(l1, false, false, 0);
            Label l2 = new Label("Dashboard");

            box.PackStart(l2, false, false, 0);
            l2.StyleContext.AddClass("fontWhite");

            pixbuffloader = new Gdk.PixbufLoader("Assets/logo.png", 110, 40);
            image1.Pixbuf = pixbuffloader.Pixbuf;

            var   box5 = new HBox();
            Label l5   = new Label("Settings");

            l5.StyleContext.AddClass("fontWhite");
            pixbuffloader = new Gdk.PixbufLoader("Assets/settings.png", 32, 32);
            var icon5 = new Image(pixbuffloader.Pixbuf);

            box5.PackStart(icon5, false, false, 0);
            box5.PackStart(l5, false, false, 0);

            box.ShowAll();
            box2.ShowAll();
            box3.ShowAll();
            box5.ShowAll();

            DashboardForm  df = DashboardForm.Create();
            RequestWindow  rw = RequestWindow.Create();
            PluginWindow   pw = PluginWindow.Create();
            SettingsWindow sw = SettingsWindow.Create();

            sw.Subscribe(bf.updateFromSettings);
            sw.notifySubs();
            notebook1.AppendPage(df, box);
            rw.dashboard = df;
            bf.dashboard = df;
            bf.settings  = sw;
            bf.request   = rw;
            pw.dashboard = df;
            notebook1.AppendPage(bf, box2);
            //notebook1.AppendPage (DashboardForm.Create (), box4);
            notebook1.AppendPage(rw, box3);
            notebook1.AppendPage(pw, box4);
            notebook1.AppendPage(sw, box5);



            provider.LoadFromPath("test.css");
            l1.StyleContext.AddProvider(provider, uint.MaxValue);
            l2.StyleContext.AddProvider(provider, uint.MaxValue);
            l3.StyleContext.AddProvider(provider, uint.MaxValue);
            l4.StyleContext.AddProvider(provider, uint.MaxValue);
            l5.StyleContext.AddProvider(provider, uint.MaxValue);
            ApplyCss(this, provider, uint.MaxValue);
            //ShowAll ();
        }
コード例 #16
0
		private void Close () {
			ThumbnailGenerator.Default.PopBlock ();
				
			try {
				result = null;

				delay.Stop ();
				if (loader != null) { 
					loader.AreaPrepared -= ap;
					loader.AreaUpdated -= au;
					// this can throw exceptions
					loader.Close ();
				}
			} catch (System.Exception) {
				//System.Console.WriteLine (e.ToString ());
				if (pixbuf != null)
					pixbuf.Dispose ();

				pixbuf = null;
			} finally {
				if (loader != null) {
					loader.Closed -= ev;
					loader.Dispose ();
				}

				loader = null;

				if (stream != null) 
					stream.Close ();

				stream = null;
			}
		}
コード例 #17
0
        public TypedClassDescriptor(Assembly assembly, XmlElement elem)
        {
            bool inheritedWrapper = false;

            wrapped = Registry.GetType(elem.GetAttribute("type"), true);
            if (wrapped != null)
            {
                ConstructorInfo[] cInfos = wrapped.GetConstructors();
                foreach (ConstructorInfo ci in cInfos)
                {
                    if (ci.GetParameters().Length == 0)
                    {
                        cinfoNoParams = ci;
                        break;
                    }
                }
            }

            if (elem.HasAttribute("wrapper"))
            {
                wrapper = Registry.GetType(elem.GetAttribute("wrapper"), true);
            }
            else
            {
                inheritedWrapper = true;
                string baseClass = elem.GetAttribute("base-type");
                if (baseClass.Length > 0)
                {
                    // If a base type is specified, use the wrapper of that base type
                    TypedClassDescriptor parent = Registry.LookupClassByName(baseClass) as TypedClassDescriptor;
                    if (parent != null)
                    {
                        wrapper = parent.WrapperType;
                    }
                }
                else
                {
                    for (Type type = wrapped.BaseType; type != null; type = type.BaseType)
                    {
                        TypedClassDescriptor parent = Registry.LookupClassByName(type.FullName) as TypedClassDescriptor;
                        if (parent != null)
                        {
                            wrapper = parent.WrapperType;
                            break;
                        }
                    }
                }
                if (wrapper == null)
                {
                    throw new ArgumentException(string.Format("No wrapper type for class {0}", wrapped.FullName));
                }
            }

            gtype = (GLib.GType)wrapped;
            cname = gtype.ToString();

            string iconname = elem.GetAttribute("icon");

            if (iconname.Length > 0)
            {
                try {
                    // Using the pixbuf resource constructor generates a gdk warning.
                    Gdk.PixbufLoader loader = new Gdk.PixbufLoader(assembly, iconname);
                    icon = loader.Pixbuf;
                } catch {
                    Console.WriteLine("Could not load icon: " + iconname);
                    icon = GetDefaultIcon();
                }
            }
            else
            {
                icon = GetDefaultIcon();
            }

            BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;

            // If the wrapper is inherited from a base class, ignore the CreateInstance method
            // since it is going to create an instance of the base class.
            if (!inheritedWrapper)
            {
                ctorMethodInfoWithClass = wrapper.GetMethod("CreateInstance", flags, null, new Type[] { typeof(ClassDescriptor) }, null);
                if (ctorMethodInfoWithClass == null)
                {
                    ctorMethodInfo = wrapper.GetMethod("CreateInstance", flags, null, Type.EmptyTypes, null);
                }
            }

            // Look for a constructor even if a CreateInstance method was
            // found, since it may return null.
            cinfo = wrapped.GetConstructor(Type.EmptyTypes);
            if (cinfo == null)
            {
                useGTypeCtor = true;
                cinfo        = wrapped.GetConstructor(new Type[] { typeof(IntPtr) });
            }

            Load(elem);
        }
コード例 #18
0
ファイル: ImageHandler.cs プロジェクト: wwwK/dotdevelop-xwt
 public override object LoadFromStream(System.IO.Stream stream)
 {
     using (Gdk.PixbufLoader loader = new Gdk.PixbufLoader(stream))
         return(new GtkImage(loader.Pixbuf));
 }
コード例 #19
0
		public TypedClassDescriptor (Assembly assembly, XmlElement elem)
		{
			bool inheritedWrapper = false;
			
			wrapped = Registry.GetType (elem.GetAttribute ("type"), true);
			if (elem.HasAttribute ("wrapper"))
			    wrapper = Registry.GetType (elem.GetAttribute ("wrapper"), true);
			else {
				inheritedWrapper = true;
				string baseClass = elem.GetAttribute ("base-type");
				if (baseClass.Length > 0) {
					// If a base type is specified, use the wrapper of that base type
					TypedClassDescriptor parent = Registry.LookupClassByName (baseClass) as TypedClassDescriptor;
					if (parent != null)
						wrapper = parent.WrapperType;
				}
				else {
					for (Type type = wrapped.BaseType; type != null; type = type.BaseType) {
						TypedClassDescriptor parent = Registry.LookupClassByName (type.FullName) as TypedClassDescriptor;
						if (parent != null) {
							wrapper = parent.WrapperType;
							break;
						}
					}
				}
				if (wrapper == null)
					throw new ArgumentException (string.Format ("No wrapper type for class {0}", wrapped.FullName));
			}

			gtype = (GLib.GType)wrapped;
			cname = gtype.ToString ();

			string iconname = elem.GetAttribute ("icon");
			if (iconname.Length > 0) {
				try {
					// Using the pixbuf resource constructor generates a gdk warning.
					Gdk.PixbufLoader loader = new Gdk.PixbufLoader (assembly, iconname);
					icon = loader.Pixbuf;
				} catch {
					Console.WriteLine ("Could not load icon: " + iconname);
					icon = GetDefaultIcon ();
				}
			} else
				icon = GetDefaultIcon ();
			
			BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
						
			// If the wrapper is inherited from a base class, ignore the CreateInstance method
			// since it is going to create an instance of the base class.
			if (!inheritedWrapper) {
				ctorMethodInfoWithClass = wrapper.GetMethod ("CreateInstance", flags, null, new Type[] { typeof(ClassDescriptor)}, null);
				if (ctorMethodInfoWithClass == null) {
					ctorMethodInfo = wrapper.GetMethod ("CreateInstance", flags, null, Type.EmptyTypes, null);
				}
			}
			
			// Look for a constructor even if a CreateInstance method was
			// found, since it may return null.
			cinfo = wrapped.GetConstructor (Type.EmptyTypes);
			if (cinfo == null) {
				useGTypeCtor = true;
				cinfo = wrapped.GetConstructor (new Type[] { typeof (IntPtr) });
			}
			
			Load (elem);
		}