예제 #1
0
        private void Open(object sender, RoutedEventArgs e)
        {
            if (Data.AddChangesAfterSave && WantSaveData())
            {
                SaveData();
            }

            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter      = "Serialization data|*.sd|All|*.*";
            dialog.FilterIndex = 2;

            if ((bool)dialog.ShowDialog())
            {
                Data = new V5MainCollection();
                try
                {
                    Data.Load(dialog.FileName);
                }
                catch (Exception exeption)
                {
                    MessageBox.Show(
                        exeption.Message,
                        "Warning",
                        MessageBoxButton.OK,
                        MessageBoxImage.Warning,
                        MessageBoxResult.OK,
                        MessageBoxOptions.DefaultDesktopOnly);
                }
                InitializeDataContext();
            }
        }
예제 #2
0
 private void Open_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (MainCollection.IsChanged)
         {
             UnsavedChanges();
         }
         Microsoft.Win32.OpenFileDialog fd = new Microsoft.Win32.OpenFileDialog();
         if ((bool)fd.ShowDialog())
         {
             MainCollection = new V5MainCollection();
             MainCollection.Load(fd.FileName);
             DataContext = MainCollection;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Loading Error: " + ex.Message);
     }
     finally
     {
         ErrorMsg();
     }
 }
예제 #3
0
        private void OpenCommandHandler(object sender, ExecutedRoutedEventArgs e)
        {
            if (SaveBeforeChange() == null)
            {
                return;
            }

            try
            {
                OpenFileDialog dlg = new OpenFileDialog();
                if (dlg.ShowDialog() == true)
                {
                    mainCollection.Load(dlg.FileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }
예제 #4
0
        private void ExecutedOpenCommand(object sender, ExecutedRoutedEventArgs e)
        {
            try

            {
                var fd = new Microsoft.Win32.OpenFileDialog();

                if (_main.IsChanged)
                {
                    if (!UnsavedChanges())
                    {
                        if (!(fd?.ShowDialog() ?? false))
                        {
                            return;
                        }
                        _main = new V5MainCollection();
                        _main.Load(fd.FileName);
                        DataContext = _main;
                    }
                }

                if (!(fd?.ShowDialog() ?? false))
                {
                    return;
                }
                _main = new V5MainCollection();
                _main.Load(fd.FileName);
                DataContext = _main;
            }
            catch (Exception)
            {
                MessageBox.Show("Error");
            }
            finally
            {
                ErrorMsg();
            }
        }