using System; using System.IO; using Gtk; using Glade; using System.Collections.Generic; namespace AmicEditor { public class OOConvertDialog : Dialog { [Widget] Gtk.Dialog Export2OO; [Widget] Gtk.Button BtOk; [Widget] Gtk.Button BtCancel; [Widget] Gtk.Entry OOCatName; [Widget] Gtk.SpinButton spinWidth; [Widget] Gtk.SpinButton spinHeight; [Widget] Gtk.CheckButton BorderOptions; [Widget] Gtk.SpinButton spinWidthBorder; [Widget] Gtk.SpinButton spinHeightBorder; [Widget] Gtk.CheckButton CaptionOptions; List pictogrames; bool Convert2OO; public OOConvertDialog (List pictogrames, bool Convert2OO) { Application.Init (); this.pictogrames=pictogrames; this.Convert2OO=Convert2OO; Glade.XML gxml = new Glade.XML(null, "Export2OO.glade", "Export2OO", null); gxml.Autoconnect (this); // Inicialització del borderoptions BorderOptions.Active=true; CaptionOptions.Active=true; BtCancel.Clicked += HandleBtCancelClicked; BorderOptions.Clicked += HandleBorderOptionsClicked; BtOk.Clicked += HandleBtOkClicked; } void HandleBtOkClicked (object sender, EventArgs e) { //string HomeDir=Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); //Console.WriteLine(System.Environment.SpecialFolder.Personal); if(OOCatName.Text==""){ MessageDialog md = new MessageDialog (null, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, Mono.Unix.Catalog.GetString("The gallery should have a name.")); md.Run(); md.Destroy(); } else{ if(Directory.Exists(Preferences.dir_OO+"/"+OOCatName.Text)) { MessageDialog md = new MessageDialog (null, DialogFlags.DestroyWithParent, MessageType.Warning, ButtonsType.YesNo, Mono.Unix.Catalog.GetString("This category is already created. Overwrite it?")); ResponseType result = (ResponseType)md.Run(); md.Destroy(); if (result==ResponseType.Yes){ Directory.Delete(Preferences.dir_OO+"/"+OOCatName.Text, true); OOConverter.OOConvert(pictogrames, OOCatName.Text, (int)spinWidth.Value, (int)spinHeight.Value, BorderOptions.Active, (int)spinWidthBorder.Value, (int)spinHeightBorder.Value, CaptionOptions.Active, Convert2OO); Application.Quit(); Export2OO.Destroy(); } } else{ OOConverter.OOConvert(pictogrames, OOCatName.Text, (int)spinWidth.Value, (int)spinHeight.Value, BorderOptions.Active, (int)spinWidthBorder.Value, (int)spinHeightBorder.Value, CaptionOptions.Active, Convert2OO); Application.Quit(); Export2OO.Destroy(); } /*Console.WriteLine(Preferences.dir_OO+"/"+OOCatName.Text); Console.WriteLine("CatName: "+OOCatName.Text); Console.WriteLine("Width, heigth: "+ spinWidth.Value+","+spinHeight.Value); Console.WriteLine("Border: "+BorderOptions.Active+" "+spinWidthBorder.Value+" "+spinHeightBorder.Value); Console.WriteLine("Caption: "+CaptionOptions.Active); */ } } void HandleBorderOptionsClicked (object sender, EventArgs e) { Console.WriteLine("tralari"); Console.WriteLine(BorderOptions.Active); if (BorderOptions.Active){ spinHeightBorder.Sensitive=true; spinWidthBorder.Sensitive=true; } else{ spinHeightBorder.Sensitive=false; spinWidthBorder.Sensitive=false; } } void HandleBtCancelClicked (object sender, EventArgs e) { Application.Quit(); Export2OO.Destroy(); } public new void Show(){ Export2OO.ShowAll(); Application.Run(); } } }