/// <summary> /// SaveConnectionsCommandCF /// </summary> private void SaveConnectionsCommandCF() { MdiChild tw = GetTopMDIWindow(); if (tw == null) { _logger.Info("Nothing to save!!"); return; } string configFileName = LST.SaveFileDialog("Cmc Datein (*.cmc)|*.cmc;|Alle Dateien (*.*)|*.*\""); if (String.IsNullOrEmpty(configFileName)) { return; } RecentFileList.InsertFile(configFileName); Filepath = configFileName; _IsFileLoaded = true; _IsFileNamed = true; ((UserControlTCPMDIChild)tw.Content).SetNewConnectionName(Path.GetFileName(configFileName)); tw.Title = Path.GetFileName(configFileName); if (((UserControlTCPMDIChild)tw.Content).IsConnected) { tw.Title += " (!)"; } else { tw.Title += " ( )"; } Connection.Save(((UserControlTCPMDIChild)tw.Content).MyConnection, configFileName); _logger.Info(String.Format("Save Connection File {0}", configFileName)); }
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs args) { base.OnPropertyChanged(args); if (args.Property != DataContextProperty || !(args.NewValue is MainWindowViewModel model)) { return; } _viewModel = model; _viewModel.InsertRecentFile += (o, e) => { if (e.Data != null) { RecentFileList.InsertFile(e.Data); } }; _viewModel.SetGlobalCursor += (o, e) => Mouse.OverrideCursor = e.Data; // These no longer use interactions in XAML due to the conversion needed for the command parameter PreviewDragEnter += OnPreviewDragEnter; Drop += OnDrop; }
/// <summary> /// LoadConnectionsCommandCF /// </summary> private void LoadConnectionsCommandCF() { double AcParentWindoHeight = ActualHeight; double AcParentWindoWidth = ActualWidth; string configFileName = LST.OpenFileDialog("Cmc Datein (*.cmc)|*.cmc;|Alle Dateien (*.*)|*.*\""); if (String.IsNullOrEmpty(configFileName)) { return; } RecentFileList.InsertFile(configFileName); Filepath = configFileName; _IsFileLoaded = true; _IsFileNamed = true; Connection newConnection = Connection.Load(configFileName); _logger.Info(String.Format("Load Connection File {0}", configFileName)); MdiChild MdiChild = new MdiChild() { Title = String.Format("{0} ( )", Path.GetFileName(configFileName)), Height = (AcParentWindoHeight - MainMenu.ActualHeight - MainToolBar.ActualHeight) * 0.6, Width = AcParentWindoWidth * 0.6, Content = new UserControlTCPMDIChild(newConnection, this) }; ((UserControlTCPMDIChild)MdiChild.Content).TheMdiChild = MdiChild; MainMdiContainer.Children.Add(MdiChild); }
private void OpenSolution(string solutionFilePath) { _settings.CurrentSolution = solutionFilePath; _solution = new SolutionVm(solutionFilePath, null, _settings.Config); _testsTreeView.ItemsSource = _solution.TestSuits; RecentFileList.InsertFile(solutionFilePath); }
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()); }
public void OpenFiles(string folderPath) { // TO-DO: Check if the folder has the appropriate data (i.e. check for the files) RecentFileList.InsertFile(folderPath); LoadAbilities(); LoadPokemonTypes(); //LoadMoves(); LoadPokemon(); }
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(); }
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); } } }
bool FileOpenCore(string filepath) { RecentFileList.InsertFile(filepath); return(true); }
private void Button_Click_1(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.DefaultExt = ".rsp"; openFileDialog.Filter = "Raspored dokument (.rsp)|*.rsp"; if (openFileDialog.ShowDialog() == true) { String filename = openFileDialog.FileName; RecentFileList.InsertFile(filename); saveRecent(filename); Prozor1.Visibility = Visibility.Visible; Prozor2.Visibility = Visibility.Hidden; Raspored_Button.IsEnabled = true; citanje_pisanje = new CitanjeIPisanje(filename); //TO_DO: raspored -> citanjeIz fajla raspored = citanje_pisanje.otvoriRaspored(filename); raspored.File = filename; saveRecent(filename); RecentFileList.InsertFile(filename); 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(); } }
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); }
/// <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); } } }