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); }
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(); } }
public MainWindow() { InitializeComponent(); this.DataContext = this; FileStream f = new FileStream("../../Save/recent.txt", FileMode.OpenOrCreate); f.Close(); RecentFileList.MenuClick += (s, e) => FileOpenCore(e.Filepath); //w = new Tabele.Tabele(); RegexOptions options = RegexOptions.None; Regex regex = new Regex("[\r\n]{3,}", options); string recentText = File.ReadAllText("../../Save/recent.txt"); string[] tekst = recentText.Split('\n'); string recentFile = tekst[0]; string[] dani = { "Ponedeljak", "Utorak", "Sreda", "Cetvtak", "Petak", "Subota" }; Dani = new ObservableCollection <string>(dani); citanje_pisanje = new CitanjeIPisanje(recentFile); try { Raspored_Button.IsEnabled = true; raspored = citanje_pisanje.otvoriRaspored(recentFile); raspored.File = recentFile; List <Ucionica> u = citanje_pisanje.otvoriUcionicu(raspored.File); Ucionice = new ObservableCollection <Ucionica>(u); //this.dgrMainUcionica.ItemsSource = u; //this.dgrMainUcionica.SelectedItem = SelectedUcionica; this.lsUcionice.ItemsSource = Ucionice; string fileText = File.ReadAllText(recentFile); 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); } uc = new List <string>(); for (int i = 0; i < u.Count; i++) { uc.Add(u[i].Oznaka); } uc1 = uc[0]; 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); } } catch (Exception e) { Prozor2.Visibility = Visibility.Visible; Prozor1.Visibility = Visibility.Hidden; Raspored_Button.IsEnabled = false; //MessageBox.Show("error"); } }