Example #1
0
        public MainWindow()
        {
            InitializeComponent();
            SetupViewports();

            App.LoadSettings();

            _fileTreeMenu = new FileTreeViewContextManager(this, treeView);
            _viewModel = new MainWindowViewModel(this, App.Settings.Get<string>("Files.DataPath", ""));
            DataContext = _viewModel;

            var binding = new CommandBinding(ApplicationCommands.Properties);
            binding.Executed += Properties_Executed;
            binding.CanExecute += Properties_CanExecute;
            this.CommandBindings.Add(binding);

            var lastLoadedFile = App.Settings.Get<string>("Files.LastLoadedFile", "");
            if (!string.IsNullOrEmpty(lastLoadedFile))
            {
                _viewModel.LoadFile(lastLoadedFile);
            }
        }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();
            SetupViewports();

            App.LoadSettings();

            _fileTreeMenu = new FileTreeViewContextManager(this, treeView);
            _viewModel    = new MainWindowViewModel(this, App.Settings.Get <string>("Files.DataPath", ""));
            DataContext   = _viewModel;

            var binding = new CommandBinding(ApplicationCommands.Properties);

            binding.Executed   += Properties_Executed;
            binding.CanExecute += Properties_CanExecute;
            this.CommandBindings.Add(binding);

            var lastLoadedFile = App.Settings.Get <string>("Files.LastLoadedFile", "");

            if (!string.IsNullOrEmpty(lastLoadedFile))
            {
                _viewModel.LoadFile(lastLoadedFile);
            }
        }
Example #3
0
        public void OpenFile(string file)
        {
            _viewModel.LoadFile(file);

            var recentFiles = (App.Settings.Get("Files.RecentFiles", "") ?? "").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var list        = recentFiles.ToList();

            // Remove 1 from the end and anything else just in case
            if (list.Count >= 10)
            {
                list.RemoveRange(9, list.Count - 9);
            }

            // If the file is already listed remove it and add it to the top
            if (list.Contains(file))
            {
                list.Remove(file);
            }
            list.Insert(0, file);

            App.Settings["Files.RecentFiles"]    = string.Join(",", list);
            App.Settings["Files.LastLoadedFile"] = file;
            App.SaveSettings();
        }