public void UpdateAll(FlameBrowserVM vm1) { //vm = vm1; //DataContext = vm; vm.FlameCollectionName = vm1.FlameCollectionName; vm.Flames.Clear(); //FlameListBox.Items.Clear(); foreach (FLVM f in vm1.Flames) { AddFlame(f, false); } SelectFlame(vm.Flames[0]); }
private void OpenFile_Click(object sender, RoutedEventArgs e) { bool needSave = false; foreach (FLVM f in flamebrowser_main.GetFlames()) { if (!f.Saved) { needSave = true; break; } } if (needSave)//csak akkor kerdezunk ra, ha van valtozas legalabb egy flameben { if (MessageBox.Show(this, "This will erase your unsaved work, continue?", "Open Flame Collection", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.OK, MessageBoxOptions.None) == MessageBoxResult.Cancel) { return; } } Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog { Title = "Open flame collection", DefaultExt = ".flame", Filter = "Flame files (.flame)|*.flame" }; if (ofd.ShowDialog() == true) { try { string CollectionName = "Unnamed Flame Collection"; FlameBrowserVM fbvm = new FlameBrowserVM(FLVM.FromFlameModels(FlameCollectionSerializer.LoadFile(ofd.FileName, out CollectionName)), /*ofd.FileName.Split('\\').Last().Split('.')[0]*/ CollectionName); flamebrowser_main.UpdateAll(fbvm); StatusMessageVM.Instance.Show("Flame opened successfully"); StatusMessageVM.Instance.SetPath(ofd.FileName); } catch { StatusMessageVM.Instance.Show("Error while opening flame: " + ofd.FileName); StatusMessageVM.Instance.SetPath(""); } } }
public FlameBrowser() { vm = new FlameBrowserVM(); DataContext = vm; InitializeComponent(); }