FileFind.Meshwork.GtkClient.Windows.PreferencesDialog.on_avatarButton_drag_data_received C# (CSharp) Method

on_avatarButton_drag_data_received() private method

private on_avatarButton_drag_data_received ( object sender, Gtk.DragDataReceivedArgs args ) : void
sender object
args Gtk.DragDataReceivedArgs
return void
        private void on_avatarButton_drag_data_received(object sender, DragDataReceivedArgs args)
        {
            if (args.SelectionData.Length >=0 && args.SelectionData.Format == 8) {
                //Console.WriteLine ("Received {0} in label", args.SelectionData.Text);
                try {
                    string fileName = new Uri (args.SelectionData.Text.Trim ()).LocalPath;

                    Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (fileName);

                    if (pixbuf.Width > 80 | pixbuf.Height > 80)
                        pixbuf = pixbuf.ScaleSimple (80, 80, Gdk.InterpType.Hyper);

                    avatarImage.Pixbuf = pixbuf;
                    avatarImage.Sensitive = true;

                } catch (Exception ex) {
                    Gui.ShowMessageDialog (ex.Message);
                }

            }

            Gtk.Drag.Finish (args.Context, false, false, args.Time);
        }