public static void Main() { PeriodicTableLogic table = new PeriodicTableLogic(); PeriodicTableRenderer renderer = new PeriodicTableRenderer(new PeriodicTableRenderOptions() { ElementWidth = 64, ElementHeight = 64, LinePen = new System.Drawing.Pen(System.Drawing.Color.Black), ForceAntiAlias = true, SymbolBrush = System.Drawing.Brushes.Black, Font = "Tahoma" }); table.Init("./PeriodicTable.dat", new PeriodicTableLogic.HandleProgress(delegate(double d, string s){})); Console.WriteLine("Type a word"); string cmd = ""; do { Console.Write(" > "); cmd = Console.ReadLine().ToLower(); renderer.Render(table.Spell(cmd, PeriodicTableLogic.SearchAlgorithm.ChunkSearch)).Save(cmd + ".png", System.Drawing.Imaging.ImageFormat.Png); Console.WriteLine("Image saved to " + cmd + ".png"); }while (cmd != "quit"); }
public static void Main() { PeriodicTableLogic table = new PeriodicTableLogic(); PeriodicTableRenderer renderer = new PeriodicTableRenderer(new PeriodicTableRenderOptions() { ElementWidth = 64, ElementHeight = 64, LinePen = new System.Drawing.Pen(System.Drawing.Color.Black), ForceAntiAlias = true, SymbolBrush = System.Drawing.Brushes.Black, Font = "Tahoma" }); PeriodicTableUI ui = new PeriodicTableUI(table, renderer); ui.Run(); }
public static void Main() { PeriodicTableLogic table = new PeriodicTableLogic(); PeriodicTableRenderer renderer = new PeriodicTableRenderer(new PeriodicTableRenderOptions() { ElementWidth = 64, ElementHeight = 64, LinePen = new System.Drawing.Pen(System.Drawing.Color.Black), ForceAntiAlias = true, SymbolBrush = System.Drawing.Brushes.Black, Font = "Tahoma" }); table.Init("./PeriodicTable.dat", new PeriodicTableLogic.HandleProgress(delegate(double d, string s){})); Console.WriteLine("Type a word"); string cmd = ""; do { Console.Write(" > "); cmd = Console.ReadLine().ToLower(); renderer.Render(table.Spell(cmd, PeriodicTableLogic.SearchAlgorithm.ChunkSearch)).Save(cmd + ".png", System.Drawing.Imaging.ImageFormat.Png); Console.WriteLine("Image saved to " + cmd + ".png"); } while (cmd != "quit"); }
public PeriodicTableUI(PeriodicTableLogic logic, PeriodicTableRenderer renderer) { Application.Init(); aboutDialog = new AboutDialog(); GladeXml dlg_main = new GladeXml(null, "main.glade", "mainWindow", null); dlg_main.Autoconnect(this); chunkSelect.Active = true; loader = new Loader(logic, mainWindow); generate.Clicked += new EventHandler(delegate(object sender, EventArgs e) { if (!string.IsNullOrEmpty(text.Buffer.Text)) { MemoryStream ms = new MemoryStream(); (loadedBitmap = renderer.Render(logic.Spell(text.Buffer.Text, chunkSelect.Active && !elementSearch.Active ? PeriodicTableLogic.SearchAlgorithm.ChunkSearch : PeriodicTableLogic.SearchAlgorithm.ElementBased))).Save(ms, ImageFormat.Png); output.Clear(); ms.Position = 0; using (Pixbuf oldPixbuf = output.Pixbuf) output.Pixbuf = new Pixbuf(ms); } else { MessageDialog md = new MessageDialog(mainWindow, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, "Please enter text into the conversion field"); md.Run(); md.Destroy(); } UpdateSensitivity(); }); saveAs.Clicked += new EventHandler(delegate(object sender, EventArgs e) { FileChooserDialog fc = new Gtk.FileChooserDialog("Save As...", mainWindow, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept) { DoOverwriteConfirmation = true }; FileFilter filter = new FileFilter(); filter.Name = "PNG images"; filter.AddMimeType("image/png"); filter.AddPattern("*.png"); fc.AddFilter(filter); if (fc.Run() == (int)ResponseType.Accept) { Stream file = File.Open(string.IsNullOrEmpty(Path.GetExtension(fc.Filename)) ? (fc.Filename + ".png") : fc.Filename, FileMode.OpenOrCreate); loadedBitmap.Save(file, ImageFormat.Png); file.Close(); } fc.Destroy(); }); about.Clicked += new EventHandler(delegate(object sender, EventArgs e) { aboutDialog.Run(); }); mainWindow.DeleteEvent += new DeleteEventHandler(delegate(object sender, DeleteEventArgs e) { Application.Quit(); }); Assembly asm = Assembly.GetExecutingAssembly(); aboutDialog.ProgramName = (asm.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute).Title; aboutDialog.Version = asm.GetName().Version.ToString(); aboutDialog.Comments = (asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute).Description; aboutDialog.Copyright = (asm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute).Copyright; aboutDialog.License = license; aboutDialog.Authors = authors; }
public PeriodicTableUI(PeriodicTableLogic logic, PeriodicTableRenderer renderer) { Application.Init(); aboutDialog = new AboutDialog(); GladeXml dlg_main = new GladeXml(null, "main.glade", "mainWindow", null); dlg_main.Autoconnect(this); chunkSelect.Active = true; loader = new Loader(logic, mainWindow); generate.Clicked += new EventHandler(delegate (object sender, EventArgs e) { if (!string.IsNullOrEmpty(text.Buffer.Text)) { MemoryStream ms = new MemoryStream(); (loadedBitmap = renderer.Render(logic.Spell(text.Buffer.Text, chunkSelect.Active && !elementSearch.Active ? PeriodicTableLogic.SearchAlgorithm.ChunkSearch : PeriodicTableLogic.SearchAlgorithm.ElementBased))).Save(ms, ImageFormat.Png); output.Clear(); ms.Position = 0; using (Pixbuf oldPixbuf = output.Pixbuf) output.Pixbuf = new Pixbuf(ms); } else { MessageDialog md = new MessageDialog (mainWindow, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, "Please enter text into the conversion field"); md.Run(); md.Destroy(); } UpdateSensitivity(); }); saveAs.Clicked += new EventHandler(delegate (object sender, EventArgs e) { FileChooserDialog fc = new Gtk.FileChooserDialog("Save As...", mainWindow, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept) { DoOverwriteConfirmation = true }; FileFilter filter = new FileFilter(); filter.Name = "PNG images"; filter.AddMimeType("image/png"); filter.AddPattern("*.png"); fc.AddFilter(filter); if (fc.Run() == (int)ResponseType.Accept) { Stream file = File.Open(string.IsNullOrEmpty(Path.GetExtension(fc.Filename)) ? (fc.Filename + ".png") : fc.Filename, FileMode.OpenOrCreate); loadedBitmap.Save(file, ImageFormat.Png); file.Close(); } fc.Destroy(); }); about.Clicked += new EventHandler(delegate (object sender, EventArgs e) { aboutDialog.Run(); }); mainWindow.DeleteEvent += new DeleteEventHandler(delegate(object sender, DeleteEventArgs e) { Application.Quit(); }); Assembly asm = Assembly.GetExecutingAssembly (); aboutDialog.ProgramName = (asm.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute).Title; aboutDialog.Version = asm.GetName().Version.ToString (); aboutDialog.Comments = (asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute).Description; aboutDialog.Copyright = (asm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute).Copyright; aboutDialog.License = license; aboutDialog.Authors = authors; }