Exemplo n.º 1
0
        public AddWindow(WidgetOperation widgetOperation)
        {
            InitializeComponent();
            AddWindowViewModel addWindowViewModel = new AddWindowViewModel(widgetOperation);

            DataContext = addWindowViewModel;
        }
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            AddWindowViewModel mwvm = (AddWindowViewModel)DataContext;

            mwvm.WindowResolver         = new UpdateDepartmentWindowResolver();
            mwvm.MessageBoxShowDelegate = text => MessageBox.Show(text, "Button interaction", MessageBoxButton.OK, MessageBoxImage.Information);
        }
        public void ConstructorTest()
        {
            AddWindowViewModel _vm = new AddWindowViewModel();

            Assert.IsNotNull(_vm.ModifiedDate);
            Assert.IsNotNull(_vm.MessageBoxShowDelegate);
            Assert.IsNotNull(_vm.AddDepartmentCommand);
            Assert.IsNotNull(_vm.DepartmentRepository);
            Assert.IsNull(_vm.Department);
            Assert.IsTrue(_vm.AddDepartmentCommand.CanExecute(null));
        }
        public void ShowPopupWindowTest()
        {
            AddWindowViewModel _vm = new AddWindowViewModel();
            int _boxShowCount      = 0;

            _vm.MessageBoxShowDelegate = (messageBoxText) =>
            {
                _boxShowCount++;
            };
            _vm.ShowPopupWindow("");
            Assert.AreEqual <int>(1, _boxShowCount);
        }
        public void AddTest()
        {
            AddWindowViewModel _vm = new AddWindowViewModel();

            _vm.Name         = "_testDepartment22";
            _vm.GroupName    = "_test2Edit";
            _vm.ModifiedDate = DateTime.Now;
            _vm.AddDepartmentCommand.Execute(null);

            MainWindowViewModel _vm2 = new MainWindowViewModel();

            _vm2.DeleteDepartmentCommand.Execute(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handling the event of clicking the "Add" button
        /// Обработка события нажатия на кнопку добавить
        /// </summary>
        private void OnAddClick(object sender, RoutedEventArgs e)
        {
            AddWindowViewModel model = (AddWindowViewModel)this.DataContext;

            model.AddCurrentReport();

            MainWindow mainWindow = new MainWindow()
            {
                DataContext = new MainWindowViewModel(),
            };

            mainWindow.Show();
            this.Close();
        }
Exemplo n.º 7
0
        public Customer AddCustomer()
        {
            vm = new AddWindowViewModel
            {
                CancelCommand = new RelayCommand(o => window.Close()),
                OkCommand     = new RelayCommand(o => { window.DialogResult = true; window.Close(); })
            };

            window = new AddWindow
            {
                DataContext = vm
            };

            var result = window.ShowDialog() ?? false;

            return(!string.IsNullOrEmpty(vm.FirstName) || !string.IsNullOrEmpty(vm.LastName)
                ? result ? vm.Customer : null
                : null);
        }
Exemplo n.º 8
0
 public AddWindow()
 {
     addWindowViewModel = new AddWindowViewModel();
     InitializeComponent();
     Loaded += AddMainWindow_Loaded;
 }