// W_configurar.cs created with MonoDevelop // User: dmontalva at 12:34 09/07/2009 // // To change standard headers go to Edit->Preferences->Coding->Standard Headers // using System; using System.IO; using System.Text; using System.Xml; using GConf; public partial class W_configurar : Gtk.Window { //Multimedia public static string audio=""; public static string video=""; public static string grabador=""; public static string escaner=""; public static string edimatges=""; //internet public static string navegador=""; public static string correo=""; public static string missatgeria=""; public static string telefonia=""; public static string p2p=""; //general public static string component_viewer=""; public W_configurar() : base(Gtk.WindowType.Toplevel) { this.Build(); W_configurar.obtener_datos_conf(); this.mostrar_datos_conf(); } public static void obtener_datos_conf() { try{ StreamReader reader = new StreamReader ("./lliurex_assistant.xml", System.Text.Encoding.UTF8); XmlTextReader lector = new XmlTextReader (reader); while (lector.Read ()) { switch (lector.NodeType) { case XmlNodeType.Element: switch (lector.Name) { case "configuracio": break; case "multimedia": break; case "audio": W_configurar.audio = lector.ReadString ();break; case "video": W_configurar.video = lector.ReadString ();break; case "grabador": W_configurar.grabador = lector.ReadString ();break; case "escaner": W_configurar.escaner = lector.ReadString ();break; case "edimatges": W_configurar.edimatges = lector.ReadString ();break; case "internet":break; case "navegador": W_configurar.navegador = lector.ReadString ();break; case "correo": W_configurar.correo = lector.ReadString ();break; case "missatgeria": W_configurar.missatgeria = lector.ReadString ();break; case "telefonia": W_configurar.telefonia = lector.ReadString ();break; case "p2p": W_configurar.p2p = lector.ReadString ();break; case "general":break; case "component_viewer":W_configurar.component_viewer = lector.ReadString ();break; } break; } } lector.Close(); reader.Close(); } catch(Exception e){ System.Console.Write(e.StackTrace); } } protected virtual void mostrar_datos_conf () { //multimedia this.tx_sonido.Text = W_configurar.audio; this.tx_video.Text = W_configurar.video; this.tx_grabador.Text = W_configurar.grabador; this.tx_escaner.Text = W_configurar.escaner; this.tx_edimages.Text = W_configurar.edimatges; //internet this.tx_navegador.Text = W_configurar.navegador; this.tx_email.Text = W_configurar.correo; this.tx_missatgeria.Text = W_configurar.missatgeria; this.tx_telefonia.Text = W_configurar.telefonia; this.tx_p2p.Text = W_configurar.p2p; //general this.tx_component_viewer.Text = W_configurar.component_viewer; } protected virtual void OnBTGuardarClicked (object sender, System.EventArgs e) { //GConf.Client cliente_gconf = new GConf.Client(); //Write the changes in the config file XmlTextWriter xml = new XmlTextWriter ("./lliurex_assistant.xml", System.Text.Encoding.UTF8); xml.Formatting = Formatting.Indented; //Inicializamos el Documento XML xml.WriteStartDocument (); //Escribimos el Elemento Principal (configuracion) xml.WriteStartElement (null, "configuracion", null); xml.WriteStartElement (null, "multimedia", null); xml.WriteStartElement (null, "video", null); xml.WriteString (this.tx_video.Text); xml.WriteEndElement (); xml.WriteStartElement (null, "audio", null); xml.WriteString (this.tx_sonido.Text); xml.WriteEndElement (); xml.WriteStartElement (null, "grabador", null); xml.WriteString (this.tx_grabador.Text); xml.WriteEndElement (); xml.WriteStartElement (null, "escaner", null); xml.WriteString (this.tx_escaner.Text); xml.WriteEndElement (); xml.WriteStartElement (null, "edimatges", null); xml.WriteString (this.tx_edimages.Text); xml.WriteEndElement (); xml.WriteEndElement ();//multimedia xml.WriteStartElement (null, "internet", null); xml.WriteStartElement (null, "navegador", null); xml.WriteString (this.tx_navegador.Text); xml.WriteEndElement (); xml.WriteStartElement (null, "correo", null); xml.WriteString (this.tx_email.Text); xml.WriteEndElement (); xml.WriteStartElement (null, "missatgeria", null); xml.WriteString (this.tx_missatgeria.Text); xml.WriteEndElement (); xml.WriteStartElement (null, "telefonia", null); xml.WriteString (this.tx_telefonia.Text); xml.WriteEndElement (); xml.WriteStartElement (null, "p2p", null); xml.WriteString (this.tx_p2p.Text); xml.WriteEndElement (); xml.WriteEndElement ();//internet xml.WriteStartElement (null, "general", null); xml.WriteStartElement (null, "component_viewer", null); xml.WriteString (this.tx_component_viewer.Text); xml.WriteEndElement (); xml.WriteEndElement ();//general xml.WriteEndElement ();//configuracion xml.WriteEndDocument (); //Cerramos el Documento XML xml.Close (); //Cerramos el Escritor XML W_configurar.obtener_datos_conf(); } protected virtual void OnBtRestaurarClicked (object sender, System.EventArgs e) { System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents=false; proc.StartInfo.FileName = "config.sh"; proc.Start(); proc.WaitForExit(); W_configurar.obtener_datos_conf(); this.mostrar_datos_conf(); } protected virtual void OnBTTornarClicked (object sender, System.EventArgs e) { this.Destroy (); MainWindow.main_window.getFixed().Sensitive=true; } protected virtual void OnFcVideoSelectionChanged (object sender, System.EventArgs e) { this.tx_video.Text = fc_video.Filename; } protected virtual void OnFcAudioSelectionChanged (object sender, System.EventArgs e) { this.tx_sonido.Text = fc_audio.Filename; } protected virtual void OnFcGrabadorSelectionChanged (object sender, System.EventArgs e) { this.tx_grabador.Text = fc_grabador.Filename; } protected virtual void OnFcEscanerSelectionChanged (object sender, System.EventArgs e) { this.tx_escaner.Text = fc_escaner.Filename; } protected virtual void OnFcImagesSelectionChanged (object sender, System.EventArgs e) { this.tx_edimages.Text = fc_images.Filename; } protected virtual void OnFcNavegadorSelectionChanged (object sender, System.EventArgs e) { this.tx_navegador.Text = fc_navegador.Filename; } protected virtual void OnFcEmailSelectionChanged (object sender, System.EventArgs e) { this.tx_email.Text = fc_email.Filename; } protected virtual void OnFcMissatgeriaSelectionChanged (object sender, System.EventArgs e) { this.tx_missatgeria.Text = fc_missatgeria.Filename; } protected virtual void OnFcTelefoniaSelectionChanged (object sender, System.EventArgs e) { this.tx_telefonia.Text = fc_telefonia.Filename; } protected virtual void OnFcP2pSelectionChanged (object sender, System.EventArgs e) { this.tx_p2p.Text = fc_p2p.Filename; } protected virtual void OnFcComponentViewerFileActivated (object sender, System.EventArgs e) { this.tx_component_viewer.Text = fc_component_viewer.Filename; } protected virtual void OnDestroyEvent (object o, Gtk.DestroyEventArgs args) { MainWindow.main_window.getFixed().Sensitive=true; } protected virtual void OnRemoved (object o, Gtk.RemovedArgs args) { MainWindow.main_window.getFixed().Sensitive=true; } protected virtual void OnDeleteEvent (object o, Gtk.DeleteEventArgs args) { MainWindow.main_window.getFixed().Sensitive=true; } }