Exemplo n.º 1
0
 /// <summary>
 /// DeleteListCommandCF
 /// </summary>
 private void DeleteListCommandCF()
 {
     foreach (var v in RecentFileList.RecentFiles)
     {
         RecentFileList.RemoveFile(v);
     }
 }
Exemplo n.º 2
0
        public void RemoveFileTest()
        {
            RecentFileList target = new RecentFileList(); // TODO: Initialize to an appropriate value

            while (target.RecentFiles.Count > 0)
            {
                target.RemoveFile(target.RecentFiles[0]);
            }

            string filepath = "C:\\test.txt", filepath2 = "C:\\TesT.txt", filepath3 = "C:\\hallowelt.txt";

            target.InsertFile(filepath);
            target.InsertFile(filepath3);
            Assert.AreEqual(2, target.BindableRecentFiles.Count());
            target.RemoveFile(filepath2);
            Assert.AreEqual(1, target.RecentFiles.Count());
            Assert.AreEqual(1, target.BindableRecentFiles.Count());
        }
Exemplo n.º 3
0
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            if (RecentFileListBox == null || RecentFileListBox.SelectedItem == null)
            {
                return;
            }
            var file = ((RecentFileInfo)RecentFileListBox.SelectedItem).File;

            _recentFileList.RemoveFile(file);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Warning: does not check for unsaved changes. Use OpenProject() if you need to.
        /// </summary>
        /// <param name="fileName"></param>
        private void OpenProject(string fileName, FileLoadedHandler OnLoaded)
        {
            try
            {
                if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName))
                {
                    listPluginsAlreadyInitialized.Clear();

                    var ext = new FileInfo(fileName).Extension;
                    if (ext.Length < 2)
                    {
                        return;
                    }

                    ext = ext.Remove(0, 1);
                    if (ComponentInformations.EditorExtension.ContainsKey(ext))
                    {
                        Type editorType = ComponentInformations.EditorExtension[ext];

                        var editor = AddEditorDispatched(editorType);
                        if (editor == null)
                        {
                            return;
                        }

                        if (OnLoaded != null)
                        {
                            editor.OnFileLoaded += OnLoaded;
                            editor.OnFileLoaded += delegate { editor.OnFileLoaded -= OnLoaded; };
                        }

                        editor.Open(fileName);
                        if (editor.Presentation != null)
                        {
                            editor.Presentation.ToolTip = fileName;
                        }

                        SetCurrentEditorAsDefaultEditor();
                        this.ProjectFileName = fileName;

                        recentFileList.AddRecentFile(fileName);
                    }
                }
                else
                {
                    MessageBox.Show(string.Format(Properties.Resources.File__0__doesn_t_exist_, fileName), Properties.Resources.Error_loading_file);
                    recentFileList.RemoveFile(fileName);
                }
            }
            catch (Exception ex)
            {
                GuiLogMessage(string.Format("Couldn't open project file {0}:{1}", fileName, ex.Message), NotificationLevel.Error);
            }
        }
Exemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();

            TLCGenSplashScreenHelper.SplashScreen = new TLCGenSplashScreenView();
            TLCGenSplashScreenHelper.Show();
            TLCGenSplashScreenHelper.ShowText("TLCGen wordt gestart...");

            DispatcherHelper.Initialize();

            MainToolBarTray.DataContextChanged += (s, e) =>
            {
                if (!(e.NewValue is MainWindowViewModel vm))
                {
                    return;
                }
                foreach (var pl in vm.ApplicationParts)
                {
                    if ((pl.Item1 & TLCGenPluginElems.ToolBarControl) != TLCGenPluginElems.ToolBarControl)
                    {
                        continue;
                    }
                    var tb = new ToolBar();
                    if (pl.Item2 is ITLCGenToolBar tlcGenToolBar)
                    {
                        tb.Items.Add(tlcGenToolBar.ToolBarView);
                    }
                    MainToolBarTray.ToolBars.Add(tb);
                }
            };

            RecentFileList.MenuClick += (sender, args) =>
            {
                if (DataContext == null)
                {
                    return;
                }
                var mymvm = DataContext as MainWindowViewModel;
                mymvm?.LoadController(args.Filepath);
            };

            var mvm = new ViewModels.MainWindowViewModel();

            DataContext = mvm;

            mvm.FileSaved      += (sender, s) => RecentFileList.InsertFile(s);
            mvm.FileOpened     += (sender, s) => RecentFileList.InsertFile(s);
            mvm.FileOpenFailed += (sender, s) => RecentFileList.RemoveFile(s);

            mvm.CheckCommandLineArgs();

            TLCGenSplashScreenHelper.Hide();
        }
Exemplo n.º 6
0
 private void OpenFile(string filename)
 {
     if (filename != string.Empty)
     {
         if (System.IO.File.Exists(filename))
         {
             ITabItem newTab = FindTabByFilename(filename);
             if (newTab == null)
             {
                 newTab = this.TabItemFactory.CreateTabItem(filename, this.HighlightHelper);
                 newTab.FindFinished += new EventHandler <EventArgs>(MainWindow_FindFinished);
                 tabControlMain.Items.Add(newTab);
             }
             tabControlMain.SelectedItem = newTab;
             recentFileList.InsertFile(filename);
         }
         else if (MessageBox.Show(LanguageHelper.GetLocalisedText((Application.Current as IApplication), Constants.REMOVE_FROM_RECENT_FILE_LIST), LanguageHelper.GetLocalisedText((Application.Current as IApplication), "fileNotFound"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             recentFileList.RemoveFile(filename);
         }
     }
 }
Exemplo n.º 7
0
        bool FileOpenCore(string filepath)
        {
            // MessageBox.Show(filepath);
            if (!File.Exists(filepath))
            {
                MessageBox.Show("File is removed or moved.");
                RecentFileList.RemoveFile(filepath);
            }
            else
            {
                RecentFileList.InsertFile(filepath);
                saveRecent(filepath);
                Prozor1.Visibility        = Visibility.Visible;
                Prozor2.Visibility        = Visibility.Hidden;
                Raspored_Button.IsEnabled = true;
                //TO_DO: raspored -> citanjeIz fajla
                raspored        = citanje_pisanje.otvoriRaspored(filepath);
                raspored.File   = filepath;
                citanje_pisanje = new CitanjeIPisanje(filepath);
                RecentFileList.InsertFile(filepath);
                Prozor1.Visibility        = Visibility.Visible;
                Prozor2.Visibility        = Visibility.Hidden;
                Raspored_Button.IsEnabled = true;
                ///raspored = new Model.Raspored();

                List <Ucionica> u = citanje_pisanje.otvoriUcionicu(raspored.File);
                Raspored_Button.IsEnabled = true;
                Ucionice = new ObservableCollection <Ucionica>(u);
                //this.dgrMainUcionica.ItemsSource = u;
                //this.dgrMainUcionica.SelectedItem = SelectedUcionica;
                this.lsUcionice.ItemsSource = Ucionice;
                Prozor1.Visibility          = Visibility.Visible;
                Prozor2.Visibility          = Visibility.Hidden;

                Termini    = new List <List <ObservableCollection <Predmet> > >();
                TerminiDan = new List <List <ObservableCollection <Predmet> > >();
                //Termini = new List<List<Predmet>>();
                for (int i = 0; i < 61; i++)
                {
                    List <ObservableCollection <Predmet> > temp  = new List <ObservableCollection <Predmet> >();
                    List <ObservableCollection <Predmet> > temp1 = new List <ObservableCollection <Predmet> >();
                    for (int j = 0; j < 7; j++)
                    {
                        temp.Add(new ObservableCollection <Predmet>());
                    }
                    Termini.Add(temp);
                    for (int k = 0; k < 11; k++)
                    {
                        temp1.Add(new ObservableCollection <Predmet>());
                    }

                    TerminiDan.Add(temp1);
                }

                c10.Width = new GridLength(100);

                c9.Width = new GridLength(100);

                c8.Width = new GridLength(100);

                c7.Width = new GridLength(100);

                c6.Width = new GridLength(100);

                c5.Width = new GridLength(100);

                c4.Width = new GridLength(100);

                c3.Width = new GridLength(100);

                c2.Width = new GridLength(100);

                c1.Width = new GridLength(100);


                if (uc.Count == 0)
                {
                    uc = new List <string>();
                    for (int i = 0; i < u.Count; i++)
                    {
                        uc.Add(u[i].Oznaka);
                    }
                }
                else
                {
                    for (int i = 0; i < u.Count; i++)
                    {
                        uc[i] = (u[i].Oznaka);
                    }
                }

                if (u.Count < 10)
                {
                    c10.Width = new GridLength(0);
                }
                if (u.Count < 9)
                {
                    c9.Width = new GridLength(0);
                }
                if (u.Count < 8)
                {
                    c8.Width = new GridLength(0);
                }
                if (u.Count < 7)
                {
                    c7.Width = new GridLength(0);
                }
                if (u.Count < 6)
                {
                    c6.Width = new GridLength(0);
                }
                if (u.Count < 5)
                {
                    c5.Width = new GridLength(0);
                }
                if (u.Count < 4)
                {
                    c4.Width = new GridLength(0);
                }
                if (u.Count < 3)
                {
                    c3.Width = new GridLength(0);
                }
                if (u.Count < 2)
                {
                    c2.Width = new GridLength(0);
                }
                if (u.Count < 1)
                {
                    c1.Width = new GridLength(0);
                }
                //raspored = new Model.Raspored();
            }

            return(true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Reads the file specified by fileName into the program.
        /// </summary>
        /// <param name="fileName">File to read into the program</param>
        public void Open(string fileName)
        {
            if (isDataLoaded)
            {
                Close();
            }

            IModelSource source = null;

            try
            {
                string[] fileNameExtension = fileName.Split('.');

                if (fileNameExtension.Count() >= 2)
                {
                    switch (fileNameExtension[fileNameExtension.Count() - 1])
                    {
                        case "arc":
                        case "rarc":
                            source = new ARC();
                            break;
                        case "dae":
                            source = new DAE();
                            break;
                        case "dzb":
                            source = new DZB();
                            break;
                        case "obj":
                            source = new OBJ();
                            break;
                        default:
                            Console.WriteLine("Unknown file type " + 
                                fileNameExtension[fileNameExtension.Count() - 1] + ". Aborting...");
                            return;
                    }

                    Categories = (ObservableCollection<Category>)source.Load(fileName);

                    // Probably a hotfix. If the user tried to open an archive, but the archive didn't have any DZBs in it,
                    // the archive loader will return null.
                    if (Categories == null)
                    {
                        MessageBox.Show("The archive you opened did not contain any DZB collision files.", "No DZB files found");

                        return;
                    }

                    AddRenderableObjs();

                    FocusCameraAll();

                    CurrentFile = fileName;

                    m_recentFileList.InsertFile(CurrentFile);

                    isDataLoaded = true;
                }
            }

            catch
            {
                if (m_recentFileList.RecentFiles.Contains(fileName))
                {
                    MessageBox.Show("The file '" + fileName + "' no longer exists. It will be removed from the recently used files.", "File Not Found");

                    m_recentFileList.RemoveFile(fileName);
                }
            }
        }