private void Banzai3_Load(object sender, EventArgs e) { Localization.SetLocalName(this); foreach (var btn in toolStrip.Controls.OfType <ToolStripButton>()) { Localization.SetLocalName(btn); } var dir = Settings.Default.LastDir; var file = Settings.Default.LastFile; if (!string.IsNullOrWhiteSpace(dir) && !string.IsNullOrWhiteSpace(file)) { try { cross = CrossIO.Import(dir, file); } catch (Exception ex) { MessageBox.Show($"Error loading last save{Environment.NewLine}{ex}"); } } scaleSize = Settings.Default.LastScale; if (scaleSize > ScaleMax || scaleSize < ScaleMin) { scaleSize = ScaleStd; } UpdateSize(); UpdateBtnState(); cross.CheckLines(); panelScroll.MouseWheel += PanelCross_MouseWheel; }
private void LoadFiles() { var list = CrossIO.GetListFiles(currentDir); AddItemToPanel(_folder, "...", null, OnClickBack); if (CrossIO.IsUserDir(currentDir)) { AddItemToPanel(_new, Localization.GetLocalName("Create New"), null, OnClickNew); AddItemToPanel(_new, Localization.GetLocalName("Edit"), currentDir, OnClickEditor); } foreach (var fileName in list) { Cross cross; try { cross = CrossIO.Import(currentDir, fileName); } catch (Exception) { //TODO log here continue; } string label = $"{cross.TopSize} x {cross.LeftSize}"; AddItemToPanel(CrossMakeIcon(cross), label, fileName, OnClickFile); } }
private void LoadDirectories() { var list = CrossIO.GetListDirs() .Select( dir => new { Name = dir, Label = Localization.GetLocalName(Path.GetFileNameWithoutExtension(dir)) }); foreach (var dir in list) { AddItemToPanel(_folder, dir.Label, dir.Name, OnClickDirectory); } }
private DialogResult SaveEditor() { var dir = Settings.Default.LastDir; var oldFile = Settings.Default.LastFile; var newFile = SelectNameForm.SelectName(dir, oldFile); if (newFile == null) { return(DialogResult.Cancel); } CrossIO.ExportEditor(newFile, cross); Settings.Default.LastFile = newFile; Settings.Default.Save(); return(DialogResult.OK); }
public static string SelectName(string dir, string name) { var form = new SelectNameForm { crossNames = CrossIO.GetListFiles(dir).ToList(), name = name, controlName = { Text = name } }; var res = form.ShowDialog(); if (res != DialogResult.OK) { return(null); } return(form.controlName.Text.Trim()); }
private void SaveCurrent() { try { var oldDir = Settings.Default.LastDir; var oldFile = Settings.Default.LastFile; if (!string.IsNullOrEmpty(oldDir) && !string.IsNullOrEmpty(oldFile)) { CrossIO.Export(oldDir, oldFile, cross); } } catch (Exception) { MessageBox.Show(Localization.GetLocalName("ERROR_IO")); } }
private void LoadEditor() { var list = CrossIO.GetListEditors(); AddItemToPanel(_folder, "...", null, OnClickBack); foreach (var fileName in list) { Cross cross; try { cross = CrossIO.ImportEditor(fileName); } catch (Exception) { //TODO log here continue; } string label = $"{fileName}"; AddItemToPanel(CrossMakeIcon(cross), label, fileName, OnClickEdit); } }
private void btnSelect_Click(object sender, EventArgs e) { if (!editorMode) { SaveCurrent(); } //TODO need cortage var newCross = CrossChoiceForm.SelectCross(Settings.Default.LastDir); if (newCross == null) { return; } switch (newCross.Length) { case 1: { var size = SelectSizeForm.GetSize(null); if (size == null) { return; } var newDir = newCross[0]; cross = new Cross(size.Value.Width, size.Value.Height); Settings.Default.LastDir = newDir; Settings.Default.LastFile = ""; Settings.Default.Save(); editorMode = true; break; } case 2: { var newDir = newCross[0]; var newFile = newCross[1]; try { cross = CrossIO.Import(newDir, newFile); } catch (Exception) { MessageBox.Show(Localization.GetLocalName("ERROR_IO")); } Settings.Default.LastDir = newDir; Settings.Default.LastFile = newFile; Settings.Default.Save(); editorMode = false; break; } case 3: { var newDir = newCross[0]; var newFile = newCross[1]; try { cross = CrossIO.ImportEditor(newFile); } catch (Exception) { MessageBox.Show(Localization.GetLocalName("ERROR_IO")); } Settings.Default.LastDir = newDir; Settings.Default.LastFile = newFile; Settings.Default.Save(); editorMode = true; break; } } UpdateSize(); UpdateBtnState(); cross.CheckLines(); panelCross.Invalidate(); }