Beispiel #1
0
        private void SaveRecentFile(string fileName)
        {
            // Clear the recent files list
            // and add this file to the top.
            RecentFiles.Clear();
            RecentFiles.Add(fileName);

            var i = 0;

            while (i < 2 &&
                   Settings.Default.recentFiles != null &&
                   Settings.Default.recentFiles.Count > i)
            {
                var recentPath = Settings.Default.recentFiles[i];

                // Only add the path if it isn't already
                // in the list.
                if (!RecentFiles.Contains(recentPath))
                {
                    RecentFiles.Add(Settings.Default.recentFiles[i]);
                }

                i++;
            }

            var sc = new StringCollection();

            sc.AddRange(RecentFiles.ToArray());
            Settings.Default.recentFiles = sc;
            Settings.Default.Save();
        }
Beispiel #2
0
 public void AddRecentFile(string file)
 {
     if (RecentFiles.Contains(file))
     {
         RecentFiles.Remove(file);
     }
     RecentFiles.Add(file);
     Save();
 }
Beispiel #3
0
        public void CloseTab(MyTab tab)
        {
            if (!string.IsNullOrEmpty(tab.Path) && !RecentFiles.Contains(tab.Path))
            {
                RecentFiles.Add(tab.Path);
            }

            Tabs.Remove(tab);
        }
Beispiel #4
0
        private void OpenFile()
        {
            if (ofdMain.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (!RecentFiles.Contains(ofdMain.FileName))
                {
                    RecentFiles.Add(ofdMain.FileName);
                }

                CreateTab(ofdMain.FileName);
            }
        }
Beispiel #5
0
        public void AddRecentFile(string file)
        {
            if (RecentFiles.Contains(file))
            {
                RecentFiles.Remove(file);
            }

            RecentFiles.Add(file);
            if (RecentFiles.Count > 10)
            {
                RecentFiles.RemoveAt(0);
            }
        }
Beispiel #6
0
        private bool Save(FATabStripItem tab)
        {
            var tb = (tab.Controls[0] as RegexTesterTab);

            YamlNode pnode =
                new YamlMapping(
                    "regex", new YamlScalar(tb.RegexText.Text),
                    "text", new YamlScalar(tb.TesterText.Text)
                    );

            if (tab.Tag == null)
            {
                if (sfdMain.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return(false);
                }
                tab.Title = Path.GetFileName(sfdMain.FileName);
                tab.Tag   = sfdMain.FileName;

                if (!RecentFiles.Contains(sfdMain.FileName))
                {
                    RecentFiles.Add(sfdMain.FileName);
                }
            }

            try
            {
                File.WriteAllText(tab.Tag as string, pnode.ToYaml());
                tb.RegexText.IsChanged  = false;
                tb.TesterText.IsChanged = false;
            }
            catch (Exception ex)
            {
                if (MessageBox.Show(ex.Message, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
                {
                    return(Save(tab));
                }
                else
                {
                    return(false);
                }
            }

            tb.Invalidate();

            return(true);
        }
Beispiel #7
0
 public void AddRecentFile(string path)
 {
     if (RecentFiles.Contains(path))
     {
         RecentFiles.Remove(path);
     }
     RecentFiles.Insert(0, path);
     while (RecentFiles.Count > 5)
     {
         try
         {
             RecentFiles.Remove(RecentFiles[5]);
         }
         catch
         {
         }
     }
 }
        private void SaveFileWithLocation()
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "Console Sprite (*.csp)|*.csp";
            if (SavePath == string.Empty)
            {
                saveFileDialog.InitialDirectory = Environment.CurrentDirectory;
            }
            else
            {
                saveFileDialog.InitialDirectory = Path.GetDirectoryName(SavePath);
            }
            if (saveFileDialog.ShowDialog() == true)
            {
                SavePath = saveFileDialog.FileName;
                SaveFile();
                if (!RecentFiles.Contains(SavePath))
                {
                    RecentFiles.Insert(0, SavePath);
                    Properties.Settings.Default.RecentFiles.Insert(0, SavePath);
                    Properties.Settings.Default.Save();
                    OnPropertyChanged("RecentFiles");
                    OnPropertyChanged("CanBrowseRecents");
                }
                else
                {
                    int idx = RecentFiles.IndexOf(saveFileDialog.FileName);
                    if (idx > 0)
                    {
                        for (int i = 0; i < idx; i++)
                        {
                            string movedFile = RecentFiles[i];
                            RecentFiles[i + 1] = movedFile;
                            Properties.Settings.Default.RecentFiles[i + 1] = movedFile;
                        }
                        RecentFiles[0] = saveFileDialog.FileName;
                        Properties.Settings.Default.RecentFiles[0] = saveFileDialog.FileName;
                        Properties.Settings.Default.Save();
                        OnPropertyChanged("RecentFiles");
                    }
                }
            }
        }
Beispiel #9
0
        private void updateRecentFiles()
        {
            //Delete it if it already exists so it can be re-added to the top
            if (RecentFiles.Contains(FilePath))
            {
                RecentFiles.Remove(FilePath);
            }

            //Add it to the top
            RecentFiles.Insert(0, FilePath);

            //Only keep up to ten recents
            if (RecentFiles.Count > 10)
            {
                RecentFiles.RemoveAt(RecentFiles.Count - 1);
            }

            recentFilesChangedHandler(RecentFiles);
        }
Beispiel #10
0
        public void Open(string path)
        {
            path = Path.GetFullPath(path);

            if (RecentFiles.Contains(path))
            {
                RecentFiles.Remove(path);
            }
            RecentFiles.Insert(0, path);

            foreach (var doc in Documents)
            {
                if (doc.FilePath == path)
                {
                    CurrentDocument = doc;
                    return;
                }
            }

            var newDoc = new Document(path);

            Documents.Add(newDoc);
            CurrentDocument = newDoc;
        }
        private void OpenSprite()
        {
            if (!DiscardChanges())
            {
                return;
            }
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Console Sprite (*.csp)|*.csp";
            if (SavePath == string.Empty)
            {
                openFileDialog.InitialDirectory = Environment.CurrentDirectory;
            }
            else
            {
                openFileDialog.InitialDirectory = Path.GetDirectoryName(SavePath);
            }
            if (openFileDialog.ShowDialog() == true)
            {
                var filePath  = openFileDialog.FileName;
                var formatter = new BinaryFormatter();
                var stream    = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None);
                var sprite    = (ConsoleSprite)formatter.Deserialize(stream);
                stream.Close();
                ApplySprite(sprite);
                IsDirty     = false;
                ImportedArt = string.Empty;
                SavePath    = filePath;

                if (!RecentFiles.Contains(SavePath))
                {
                    RecentFiles.Insert(0, SavePath);
                    Properties.Settings.Default.RecentFiles.Insert(0, SavePath);
                    if (RecentFiles.Count > 10)
                    {
                        RecentFiles.RemoveAt(10);
                        Properties.Settings.Default.RecentFiles.RemoveAt(10);
                    }
                    Properties.Settings.Default.Save();
                }
                else
                {
                    int idx = RecentFiles.IndexOf(openFileDialog.FileName);
                    if (idx > 0)
                    {
                        for (int i = 0; i < idx; i++)
                        {
                            string movedFile = RecentFiles[i];
                            RecentFiles[i + 1] = movedFile;
                            Properties.Settings.Default.RecentFiles[i + 1] = movedFile;
                        }
                        RecentFiles[0] = openFileDialog.FileName;
                        Properties.Settings.Default.RecentFiles[0] = openFileDialog.FileName;
                        Properties.Settings.Default.Save();
                        OnPropertyChanged("RecentFiles");
                    }
                }
                OnPropertyChanged("RecentFiles");
                OnPropertyChanged("CanBrowseRecents");
            }
        }