/* Copyright (C) Arnaud Houdelette 2012-2014 Copyright (C) Emmanuel Langlois 2012-2014 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ using System; using Gtk; namespace DMX2 { class MainClass { public static void Main (string[] args) { bool fullscreen = false; //WebServer ws = null; bool webserv = false; OSCServer osc = null; bool oscEn = true; System.IO.FileInfo openfile = null; bool live = false; // Traitement des options en ligne de commande : foreach (string arg in args) { switch (arg) { case "fullscreen": case "fs": fullscreen = true; break; case "live": live = true; break; case "noosc": oscEn = false; break; /*case "ws": webserv = true; break; */ default: if (System.IO.File.Exists (arg)) openfile = new System.IO.FileInfo (arg); break; } } //if(webserv) ws = new WebServer(); if (oscEn) osc = new OSCServer (); // Initialisation GTK# Application.Init (); // Repertoire courrant est celui de l'executable System.IO.Directory.SetCurrentDirectory ( (new System.IO.FileInfo ( System.Reflection.Assembly.GetExecutingAssembly ().Location )).DirectoryName ); // Chargement du style GTK if (System.IO.File.Exists ("style.gtkrc")) Gtk.Rc.Parse ("style.gtkrc"); else using (System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("style.gtkrc")) using (System.IO.TextReader reader = new System.IO.StreamReader(stream)) Gtk.Rc.ParseString (reader.ReadToEnd ()); // Creation de la fenetre principale MainWindow win = new MainWindow (); // application des options if (fullscreen) win.ToggleFullscreen (); if (openfile != null) win.OpenFile (openfile); // Gestion des erreurs non traitées dans l'interface GLib.ExceptionManager.UnhandledException += HandleUnhandledException; System.IO.DirectoryInfo hDir = new System.IO.DirectoryInfo (Environment.GetEnvironmentVariable ("HOME")); if (hDir.Exists) { if (live) { System.IO.DirectoryInfo lDir = new System.IO.DirectoryInfo(hDir.FullName+"/LIVE"); if(lDir.Exists) hDir=lDir; } var cDir=new System.IO.DirectoryInfo(hDir.FullName+"/loupiottes"); if(!cDir.Exists) cDir.Create(); cDir.Refresh(); if(cDir.Exists) win.CurFolder = cDir.FullName; else win.CurFolder = hDir.FullName; } // Lancement win.Show (); Application.Run (); // Nettoyage if (Conduite.Courante != null) { Conduite.Courante.Dispose (); } //if(ws!=null) ws.Dispose(); if(osc!=null) osc.Dispose(); } static void HandleUnhandledException (GLib.UnhandledExceptionArgs args) { // En cas d'erreur non traitée : on affiche et on demande ... var dlg = new Dialog ("Erreur !", null, DialogFlags.Modal); dlg.AddButton ("Continuer ..." , ResponseType.Cancel ).GrabDefault(); dlg.AddButton ("Fermer l'application" , ResponseType.Close ); dlg.VBox.Add (new Label (args.ExceptionObject.ToString())); dlg.VBox.ShowAll (); // Si l'utilisateur a clique sur le bon bouton, on continue comme si de rien n'etait... args.ExitApplication= (ResponseType)dlg.Run() == ResponseType.Close ; dlg.Destroy(); } } }