示例#1
0
        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)
            {
                var newName = launchTourFile.ToLower().Replace(".wwtfig","");

                newName = newName.Substring(newName.LastIndexOf("\\")+1);
                var input = new SimpleInput(Language.GetLocalizedText(515, "Figure Library Name"), Language.GetLocalizedText(238, "Name"), newName, 32);
                var retry = false;
                do
                {
                    if (input.ShowDialog() == DialogResult.OK)
                    {
                        if (!File.Exists(Constellations.GetFigurePath(input.ResultText)))
                        {
                            var 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));
                                    var 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);
            }
        }
示例#3
0
        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 newFigures_Click(object sender, EventArgs e)
        {
            if (Earth3d.MainWindow.figureEditor != null)
            {
                if (Earth3d.MainWindow.figureEditor.SaveAndClose() != DialogResult.OK)
                {
                    return;
                }
                Earth3d.MainWindow.figureEditor = null;
            }

            var input = new SimpleInput(Language.GetLocalizedText(515, "Figure Library Name"), Language.GetLocalizedText(238, "Name"), "", 32);
            var retry = false;
            do
            {
                if (input.ShowDialog() == DialogResult.OK)
                {
                    if (!File.Exists(Constellations.GetFigurePath(input.ResultText)))
                    {
                        var 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
                        {
                            var 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
                            {
                                var 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);
        }
 private void SaveFigures_Click(object sender, EventArgs e)
 {
     figures.Save(figures.Name);
 }