Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="WelcomeDlg"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public WelcomeDlg()
        {
            Font = SystemFonts.MessageBoxFont;             //use the default OS UI font
            MruProjects.Initialize(Settings.Default.MRUList);

            InitializeComponent();

            var rc = Settings.Default.WelcomeDlgBounds;

            if (rc.Height < 0)
            {
                StartPosition = FormStartPosition.CenterScreen;
            }
            else
            {
                Bounds = rc;
            }

            var ver = Assembly.GetExecutingAssembly().GetName().Version;

            // The build number is just the number of days since 01/01/2000
            DateTime bldDate = new DateTime(2000, 1, 1).AddDays(ver.Build);

            lblVersionInfo.Text = string.Format(lblVersionInfo.Text, ver.Major,
                                                ver.Minor, ver.Build, bldDate.ToString("dd-MMM-yyyy"));

            LoadMRUButtons();
            SetupLinkLabel();
            LocalizeItemDlg.StringsLocalized += SetupLinkLabel;

            tsOptions.BackColorBegin = Color.White;
            tsOptions.BackColorEnd   = Color.White;

            DialogResult = DialogResult.Cancel;
        }
Exemple #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Browse for an existing project.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void tsbBrowse_Click(object sender, EventArgs e)
        {
            using (var dlg = new OpenFileDialog())
            {
                var caption = LocalizationManager.LocalizeString(
                    "WelcomeDlg.OpenFileDlgCaption", "Open Sponge Project", "Dialog Boxes");

                var prjFilterText = LocalizationManager.LocalizeString(
                    "WelcomeDlg.SpongePrjFileType", "Sponge Project (*.sprj)", "Dialog Boxes");

                dlg.Title            = caption;
                dlg.Filter           = prjFilterText + "|*.sprj|" + Sponge.OFDlgAllFileTypeText + "|*.*";
                dlg.InitialDirectory = SpongeProject.ProjectsFolder;
                dlg.CheckFileExists  = true;
                dlg.CheckPathExists  = true;
                if (dlg.ShowDialog(this) == DialogResult.Cancel)
                {
                    return;
                }

                Project = SpongeProject.Load(dlg.FileName);
                if (Project != null)
                {
                    MruProjects.AddNewPath(dlg.FileName);
                    MruProjects.Save();
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }
Exemple #3
0
        public void AddNewPath()
        {
            // Test a path that does not exists.
            Assert.IsFalse(MruProjects.AddNewPath(Path.Combine(Path.GetTempPath(), "@#$%badpath")));

            Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[0]));
            Assert.AreEqual(_prjFiles[0], _paths[0]);
            Assert.AreEqual(1, _paths.Count);

            Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[1]));
            Assert.AreEqual(_prjFiles[1], _paths[0]);
            Assert.AreEqual(2, _paths.Count);

            Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[2]));
            Assert.AreEqual(_prjFiles[2], _paths[0]);
            Assert.AreEqual(3, _paths.Count);

            // Readd a path that already exists.
            Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[1]));
            Assert.AreEqual(_prjFiles[1], _paths[0]);
            Assert.AreEqual(3, _paths.Count);

            _paths.Clear();
            for (int i = 0; i < _prjFiles.Count; i++)
            {
                Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[i]));
                Assert.IsTrue(_paths.Count <= MruProjects.MaxMRUListSize);

                if (i < MruProjects.MaxMRUListSize)
                {
                    Assert.AreEqual(i + 1, _paths.Count);
                    Assert.AreEqual(_prjFiles[i], _paths[0]);
                }
            }
        }
Exemple #4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Create a new project.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private void tsbCreate_Click(object sender, EventArgs e)
 {
     Project = SpongeProject.Create(this);
     if (Project != null)
     {
         MruProjects.AddNewPath(Project.FullFilePath);
         MruProjects.Save();
         DialogResult = DialogResult.OK;
         Close();
     }
 }
Exemple #5
0
        public void Latest()
        {
            Assert.IsNull(MruProjects.Latest);

            Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[0]));
            Assert.AreEqual(_prjFiles[0], MruProjects.Latest);

            Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[1]));
            Assert.AreEqual(_prjFiles[1], MruProjects.Latest);

            Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[2]));
            Assert.AreEqual(_prjFiles[2], MruProjects.Latest);
        }
Exemple #6
0
 public void AddNewNullPath()
 {
     MruProjects.AddNewPath(null);
 }