public static bool Init(string[] args) { string appName = Assembly.GetExecutingAssembly().GetName().Name; // check gtk if (!ThemeHelper.CheckGtk()) return false; ThemeHelper.ApplyCustomTheme(args); // init gtk app Application.Init(appName, ref args); // check windows platform if (!Gui.PlatformUtils.IsWindows) { CustomMessageDialog dlg = new CustomMessageDialog( null, MessageType.Error, "Your OS is not supported on this version!"); dlg.Ok += (sender, e) => Application.Quit(); dlg.Show(); Application.Run(); return false; } // load dgle IEngineCore pEngineCore = null; if (!Engine.GetEngine(DLL_PATH, out pEngineCore)) { CustomMessageDialog dlg = new CustomMessageDialog( null, MessageType.Error, "Couldn't load \"{0}\"!", DLL_NAME); dlg.Ok += (sender, e) => Application.Quit(); dlg.Show(); Application.Run(); return false; } Core = pEngineCore; // init dgle with force no window TEngWindow eng_win = new TEngWindow(); Core.InitializeEngine( IntPtr.Zero, appName, ref eng_win, 33, E_ENGINE_INIT_FLAGS.EIF_FORCE_NO_WINDOW | E_ENGINE_INIT_FLAGS.EIF_FORCE_NO_SPLASH); Core.ConsoleVisible(false); // init main win MainWindow win = new MainWindow(); win.Show(); win.DeleteEvent += (o, a) => { Stop(); a.RetVal = true; }; return true; }
private void AppendFile(TreeIter destIter, string filename) { Gtk.Application.Invoke((sender, e) => waitWindow.FileText = filename); Packer.Item fileItem = NewItem(destIter, filename); if (fileSystem.Add(fileItem)) AppendItem(destIter, fileItem); else { CustomMessageDialog msg = new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError); msg.Run(); msg.Destroy(); } }
private void AppendFolders(TreeIter destIter, string path) { try { Directory.EnumerateDirectories(path, "*", SearchOption.TopDirectoryOnly).ToList() .ForEach(folder => { Packer.Item folderItem = NewItem(destIter, folder); TreeIter folderIter = AppendItem(destIter, folderItem); AppendFolders(folderIter, folder); }); AppendFiles(destIter, path); } catch(UnauthorizedAccessException) { CustomMessageDialog msg = new CustomMessageDialog(this, MessageType.Error, String.Format("Access denied to {0}", path)); msg.Run(); msg.Destroy(); } }
private void AppendFiles(TreeIter destIter, string path) { try { Directory.EnumerateFiles(path, "*.*", SearchOption.TopDirectoryOnly).ToList() .ForEach(file => AppendFile(destIter, file)); } catch(UnauthorizedAccessException) { CustomMessageDialog msg = new CustomMessageDialog(this, MessageType.Error, String.Format("Access denied to {0}", path)); msg.Run(); msg.Destroy(); } }
private void OpenPack(string filename) { if (Packer.Create(System.IO.Path.GetExtension(filename), out fileSystem)) { waitWindow = new WaitWindow(this, "Opening", filename); waitWindow.Show(); ThreadNotify done = new ThreadNotify(new ReadyEvent(() => { waitWindow.Destroy(); waitWindow = null; })); ThreadNotify error = new ThreadNotify(new ReadyEvent(() => { waitWindow.Destroy(); waitWindow = null; CustomMessageDialog msg = new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError); msg.Run(); msg.Destroy(); })); new Thread(new ThreadStart(() => { if (fileSystem.Open(filename)) { RebuildPackTree(fileSystem.ListFiles()); ChangePackActionSensitive(true); done.WakeupMain(); } else error.WakeupMain(); })).Start(); } }
private void HandleSaveAction() { if (fileSystem == null) return; CustomFileChooserDialog dlg = new CustomFileChooserDialog(this, "Save pack", FileChooserAction.Save); dlg.FileChooser.SelectMultiple = false; using (Gtk.FileFilter filter = new Gtk.FileFilter()) { filter.Name = fileSystem.Extension.ToUpper(); filter.AddPattern("*." + fileSystem.Extension.ToLower()); dlg.FileChooser.AddFilter(filter); } using (Gtk.FileFilter filter = new Gtk.FileFilter()) { filter.Name = "All"; filter.AddPattern("*.*"); dlg.FileChooser.AddFilter(filter); } dlg.Ok += (sender, e) => { string filename = dlg.FileChooser.Filename; waitWindow = new WaitWindow(this, "Saving", filename); waitWindow.Show(); ThreadNotify done = new ThreadNotify(new ReadyEvent(() => { waitWindow.Destroy(); waitWindow = null; })); ThreadNotify error = new ThreadNotify(new ReadyEvent(() => { waitWindow.Destroy(); waitWindow = null; CustomMessageDialog msg = new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError); msg.Run(); msg.Destroy(); })); new Thread(new ThreadStart(() => { if (fileSystem.Save(filename)) done.WakeupMain(); else error.WakeupMain(); })).Start(); dlg.Destroy(); }; dlg.Cancel += (sender, e) => dlg.Destroy(); dlg.Show(); }
private void ExtractFile(TreeIter iter, string filename) { waitWindow = new WaitWindow(this, "Extracting", filename); waitWindow.Show(); ThreadNotify done = new ThreadNotify(new ReadyEvent(() => { waitWindow.Destroy(); waitWindow = null; })); ThreadNotify error = new ThreadNotify(new ReadyEvent(() => { waitWindow.Destroy(); waitWindow = null; CustomMessageDialog msg = new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError); msg.Run(); msg.Destroy(); })); Packer.Item item = packStore.GetValue(iter, 0) as Packer.Item; new Thread(new ThreadStart(() => { if (fileSystem.Extract(item, filename)) done.WakeupMain(); else error.WakeupMain(); })).Start(); }
private bool InitDCP() { // init dcp file system from dgle try { dcp = new DCP(); return true; } catch { CustomMessageDialog dlg = new CustomMessageDialog( this, MessageType.Error, ButtonsType.Ok, "Failed to load DCP file system from DGLE!"); dlg.Ok += (sender, e) => Program.Stop(); dlg.Show(); return false; } }