private void Delete_Click(object sender, EventArgs e) { if (MessageBox.Show(Language.GetLocalizedText(520, "Deleting this figure library will delete the constellation figures you created. Do you want to continue?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { if (Earth3d.MainWindow.figureEditor != null) { if (Earth3d.MainWindow.figureEditor.SaveAndClose() != DialogResult.OK) { return; } Earth3d.MainWindow.figureEditor = null; } string filename = Constellations.GetFigurePath(figureLibrary.SelectedItem.ToString()); try { File.Delete(filename); figureLibrary.Items.Remove(figureLibrary.SelectedItem); figureLibrary.SelectedIndex = 0; } catch { MessageBox.Show("The constellation figures file cannot be deleted because the file cannot be found.", "Constellation Figure Editor"); } } }
private void newFigures_Click(object sender, EventArgs e) { if (Earth3d.MainWindow.figureEditor != null) { if (Earth3d.MainWindow.figureEditor.SaveAndClose() != DialogResult.OK) { return; } Earth3d.MainWindow.figureEditor = null; } SimpleInput input = new SimpleInput(Language.GetLocalizedText(515, "Figure Library Name"), Language.GetLocalizedText(238, "Name"), "", 32); bool retry = false; do { if (input.ShowDialog() == DialogResult.OK) { if (!File.Exists(Constellations.GetFigurePath(input.ResultText))) { int index = figureLibrary.Items.IndexOf(input.ResultText); if (index > -1) { MessageBox.Show(Language.GetLocalizedText(516, "Name already exists, type a different name."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); retry = true; } else { string validfileName = @"^[A-Za-z0-9_ ]*$"; if (input.ResultText.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || !UiTools.ValidateString(input.ResultText, validfileName)) { MessageBox.Show(Language.GetLocalizedText(231, "A name can not contain any of the following characters:") + " \\ / : * ? \" < > |", "Constellation Figure Editor"); retry = true; } else { Constellations figures = new Constellations(input.ResultText); figures.Save(input.ResultText); figures = null; figureLibrary.Items.Add(input.ResultText); figureLibrary.SelectedIndex = figureLibrary.Items.IndexOf(input.ResultText); Earth3d.MainWindow.ShowFigureEditorWindow(Earth3d.MainWindow.constellationsFigures); retry = false; } } } else { MessageBox.Show(Language.GetLocalizedText(516, "Name already exists, type a different name."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); retry = true; } } else { return; } } while (retry); }
public void InstallNewFigureFile(string launchTourFile) { if (UiTools.ShowMessageBox(Language.GetLocalizedText(514, "Do you want to add these constellation figures to your Figure Library?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), MessageBoxButtons.YesNo) == DialogResult.Yes) { String newName = launchTourFile.ToLower().Replace(".wwtfig", ""); newName = newName.Substring(newName.LastIndexOf("\\") + 1); SimpleInput input = new SimpleInput(Language.GetLocalizedText(515, "Figure Library Name"), Language.GetLocalizedText(238, "Name"), newName, 32); bool retry = false; do { if (input.ShowDialog() == DialogResult.OK) { if (!File.Exists(Constellations.GetFigurePath(input.ResultText))) { int index = figureLibrary.Items.IndexOf(input.ResultText); if (index > -1) { MessageBox.Show(Language.GetLocalizedText(516, "Name already exists, type a different name."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); retry = true; } else { try { File.Copy(launchTourFile, Constellations.GetFigurePath(input.ResultText)); Constellations newFigures = new Constellations(input.ResultText, null, false, false); newFigures.Save(input.ResultText); figureLibrary.Items.Add(input.ResultText); figureLibrary.SelectedIndex = figureLibrary.Items.IndexOf(input.ResultText); retry = false; } catch { if (File.Exists(Constellations.GetFigurePath(input.ResultText))) { File.Delete(Constellations.GetFigurePath(input.ResultText)); } UiTools.ShowMessageBox(Language.GetLocalizedText(517, "The file is not a valid WorldWide Telescope Constellation Figure File"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); return; } } } else { MessageBox.Show(Language.GetLocalizedText(518, "Name already exists, type a different name."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); retry = true; } } else { return; } } while (retry); } }
private void EditFigure_Click(object sender, EventArgs e) { if (Earth3d.MainWindow.figureEditor != null) { if (Earth3d.MainWindow.figureEditor.SaveAndClose() != DialogResult.OK) { return; } Earth3d.MainWindow.figureEditor = null; } if (figureLibrary.SelectedItem.ToString() == Language.GetLocalizedText(519, "Default Figures")) { SimpleInput input = new SimpleInput(Language.GetLocalizedText(515, "Figure Library Name"), Language.GetLocalizedText(238, "Name"), "", 32); bool retry = false; do { if (input.ShowDialog() == DialogResult.OK) { if (!File.Exists(Constellations.GetFigurePath(input.ResultText))) { int index = figureLibrary.Items.IndexOf(input.ResultText); if (index > -1) { MessageBox.Show(Language.GetLocalizedText(516, "Name already exists, type a different name."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); retry = true; } else { Earth3d.MainWindow.constellationsFigures.Save(input.ResultText); figureLibrary.Items.Add(input.ResultText); figureLibrary.SelectedIndex = figureLibrary.Items.IndexOf(input.ResultText); Earth3d.MainWindow.ShowFigureEditorWindow(Earth3d.MainWindow.constellationsFigures); retry = false; } } else { MessageBox.Show(Language.GetLocalizedText(516, "Name already exists, type a different name."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope")); retry = true; } } else { return; } } while (retry); } else { Earth3d.MainWindow.ShowFigureEditorWindow(Earth3d.MainWindow.constellationsFigures); } }