private void RegisterWindowClosable(Window window, IClosable closable)
 {
     if (closable != null && window != null)
     {
         closable.ClosingRequest += (s, e) => window.Close();
     }
 }
Exemple #2
0
 private void CloseCommandHandler(IClosable window)
 {
     if (window != null)
     {
         window.CloseWindow();
     }
 }
        public PersistenceFixture(IReferenceable refs, IConfigurable conf, IOpenable open, IClosable close, ICleanable clean,
            IWriter<Dummy, string> write, IGetter<Dummy, string> get, ISetter<Dummy> set)
        {
            Assert.NotNull(refs);
            _refs = refs;

            Assert.NotNull(conf);
            _conf = conf;

            Assert.NotNull(open);
            _open = open;

            Assert.NotNull(close);
            _close = close;

            Assert.NotNull(clean);
            _clean = clean;

            Assert.NotNull(write);
            _write = write;

            Assert.NotNull(get);
            _get = get;

            Assert.NotNull(set);
            _set = set;
        }
 private void CloseAddDialog(IClosable obj)
 {
     if (obj != null)
     {
         obj.Close();
     }
 }
Exemple #5
0
 /// <summary>
 /// Sends a valid member to the Main VM to replace at the selected index with, then closes the change window.
 /// </summary>
 /// <param name="window">The window to close.</param>
 public void UpdateMethod(IClosable window)
 {
     try
     {
         if (window != null)
         {
             // sends "Update" message to MainViewModel.ReceiveMember(MessageMember m)
             var changeViewModelMessage = new MessageMember(EnteredFName, EnteredLName, EnteredEmail, "Update");
             Messenger.Default.Send(changeViewModelMessage);
             window.Close();
         }
     }
     catch (ArgumentException)
     {
         MessageBox.Show("Fields must be under 25 characters.", "Entry Error");
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Fields cannot be empty.", "Entry Error");
     }
     catch (FormatException)
     {
         MessageBox.Show("Must be a valid e-mail address.", "Entry Error");
     }
 }
        /// <summary>
        /// Method that contains code to open Maintenance window
        /// and close Add window.
        /// </summary>

        private void BackToMaintenance(IClosable window)
        {
            var mainWindow = new MembershipMaintenance();

            mainWindow.Show();
            window.Close();
        }
Exemple #7
0
 public void CancelAction(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
 public void UpdateMethod(IClosable window)
 {
     try
     {
         if (window != null)
         {
             var updatedMember = new MessageMember(enteredFName, enteredLName, enteredEmail, "Update")
             {
                 FirstName = enteredFName,
                 LastName  = enteredLName,
                 Email     = enteredEmail
             };
             Messenger.Default.Send(updatedMember);
             window.Close();
         }
     }
     catch (ArgumentException)
     {
         MessageBox.Show("Fields must be under 25 characters.", "Entry Error");
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Fields cannot be empty.", "Entry Error");
     }
     catch (FormatException)
     {
         MessageBox.Show("Must be a valid e-mail address.", "Entry Error");
     }
 }
        public bool Register <T>(IClosable viewModelBase, Action <T> action, string msgTag)
        {
            var type = viewModelBase.GetType();

            foreach (var actionDetailse in actions)
            {
                if (actionDetailse.ViewModel.GetType() == type && actionDetailse.ViewModel.IsClosed && actionDetailse.MethodName == action.Method.Name && actionDetailse.Type == typeof(T) && actionDetailse.MsgTag == msgTag)
                {
                    actionDetailse.ViewModel = viewModelBase;
                    ((ActionDetails <T>)actionDetailse).Action = action;
                }
            }

            foreach (var actionDetailse in actions)
            {
                if (actionDetailse.ViewModel == viewModelBase && actionDetailse.MethodName == action.Method.Name && actionDetailse.Type == typeof(T) && actionDetailse.MsgTag == msgTag)
                {
                    return(false);
                }
            }


            var actionDetails = new ActionDetails <T>();

            actionDetails.ViewModel = viewModelBase;
            actionDetails.Action    = action;
            actionDetails.Type      = typeof(T);
            actionDetails.MsgTag    = msgTag;
            actions.Add(actionDetails);
            return(InternalMediator.Register(actionDetails));
        }
Exemple #10
0
        private void Enter(IClosable win)
        {
            if (IsCheckedRegistration)
            {
                if (FirstRegistrationPassword != SecondRegistrationPassword)
                {
                    MessageBox.Show("Hesla sa musia zhodovať");
                }
                MessageBox.Show("Registracia bola úspešná");
            }

            if (IsCheckedLogin)
            {
                MessageBox.Show("Prihlasenie boo úspešné");
                ChatSerivce.Nick = LoginNick;
                MainWindow mainWin = new MainWindow();
                mainWin.Show();


                if (win != null)
                {
                    win.Close();
                }
            }
        }
        public override async void AddEntity(IClosable window)
        {
            try
            {
                base.IsLoading = true;
                AddEntityCommand.RaiseCanExecuteChanged();
                _mapper.Map(EntityViewModel, _questionnaire);
                await _client.GetSyncTable <Questionnaire>().InsertAsync(_questionnaire);

                await _client.SyncAsync();

                foreach (var questionViewModel in EntityViewModel.QuestionViewModels)
                {
                    await questionViewModel.Save();
                }

                _list.AddEntity(_questionnaire);
                window?.Close();
                await _client.SyncAsync();
            }
            finally
            {
                base.IsLoading = false;
            }
        }
 private void CancelExecute(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
Exemple #13
0
        public MainViewModel(
            IDataApiClient dataApiClient,
            DataVisualizer dataVisualizer,
            IReadonlyObjectDatabase <UserProfile> userDatabase,
            IReadonlyObjectDatabase <DataSet> dataSetDatabase,
            IReadonlyObjectDatabase <DataProject> dataProjectDatabase,
            IClipboard clipboard,
            IClosable mainWindow)
        {
            this.dataApiClient       = dataApiClient;
            this.userDatabase        = userDatabase;
            this.mainWindow          = mainWindow;
            DataSetMainViewModel     = new DataSetMainViewModel(dataApiClient, dataSetDatabase, dataProjectDatabase, clipboard);
            CollectionsMainViewModel = new CollectionsMainViewModel(dataApiClient, dataVisualizer, userDatabase, clipboard);

            var passwordBoxSpawner = new WpfPasswordBoxSpawner();
            var loginViewSpawner   = new WpfWindowSpawner <LoginViewModel>(vm => new LoginWindow {
                ViewModel = vm
            });
            var changePasswordViewSpawner = new WpfWindowSpawner <ChangePasswordViewModel>(vm => new ChangePasswordWindow {
                ViewModel = vm
            });

            UserSwitchViewModel = new UserSwitchViewModel(
                dataApiClient,
                LoginSuccessful,
                LoginFailed,
                passwordBoxSpawner,
                loginViewSpawner,
                changePasswordViewSpawner);
            OpenUserManagementWindowCommand = new RelayCommand(OpenUserManagementWindow);
            OpenAboutWindowCommand          = new RelayCommand(OpenAboutWindow);
        }
Exemple #14
0
        private async void Login(IClosable window)
        {
            IsLoading = true;
            try
            {
                await _msClient.LoginAsync(Username, Password);

                var newWindow = new MainWindow();
                newWindow.Show();
                window?.Close();
            }
            catch (MobileServiceInvalidOperationException e)
            {
                Debug.Write(e);
                MessageBox.Show(e.Response.ReasonPhrase.Equals("Unauthorized")
                    ? "Het gebruikersnaam of wachtwoord is fout, probeer het opnieuw."
                    : "Er is iets fout gegaan bij het inloggen, probeer het opnieuw.");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message.Equals("Er is een fout opgetreden bij het verzenden van het aanvraag.")
                    ? e.InnerException.Message
                    : "Er is iets fout gegaan bij het inloggen, probeer het opnieuw.");
            }

            IsLoading = false;
        }
Exemple #15
0
 /// <summary>
 /// The method that closes the add window.
 /// </summary>
 /// <param name="window">The window to close.</param>
 private void CancelMethod(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
Exemple #16
0
        public MainViewModel(
            IDataApiClient dataApiClient,
            LogEntryMonitor logEntryMonitor,
            IClosable mainWindow)
        {
            this.logEntryMonitor                      = logEntryMonitor;
            this.mainWindow                           = mainWindow;
            logEntryMonitor.NewLogEntry              += LogEntryMonitor_NewLogEntry;
            logEntryMonitor.MonitoringStateChanged   += LogEntryMonitor_MonitoringStateChanged;
            logEntryMonitor.HistoricLogEntriesLoaded += LogEntryMonitor_HistoricLogEntriesLoaded;

            UserSwitchViewModel = new UserSwitchViewModelFactory(
                dataApiClient,
                LoginSuccessful,
                LoginFailed).Create();
            OpenProcessorWindowCommand  = new RelayCommand(OpenProcessorWindow, () => SelectedProcessor != null);
            OpenTaskWindowCommand       = new RelayCommand(OpenTaskWindow, () => SelectedTask != null);
            UpdateTaskPeriodsCommand    = new RelayCommand(UpdateTaskPeriod);
            UpdateExecutionTimesCommand = new RelayCommand(UpdateExecutionTimes);

            periodUpdateTimer                 = new Timer(TimeSpan.FromMinutes(5).TotalMilliseconds);
            periodUpdateTimer.Elapsed        += (sender, args) => UpdateTaskPeriod();
            executionTimeUpdateTimer          = new Timer(TimeSpan.FromMinutes(5).TotalMilliseconds);
            executionTimeUpdateTimer.Elapsed += (sender, args) => UpdateExecutionTimes();
        }
Exemple #17
0
        /// <summary>
        /// Modify the selected category in a window
        /// </summary>
        /// <param name="window">The window where the modification take place</param>
        public void Modify(IClosable window)
        {
            // check if the categoryname was modified
            if (SelectedCategory.IsNameModified())
            {
                // make sure there is no category with the same name already in database
                if (CategoryExists(SelectedCategory.Category.CategoryName))
                {
                    windowService.UserMessage("Létezik már ilyen névvel kategória, kérem adjon meg másik nevet!");
                    return;
                }
            }

            // try to modify, if any changes was made
            if (SelectedCategory.IsModified())
            {
                if (Modify())
                {
                    windowService.UserMessage("A kategória sikeresen módosításra került!");
                    IsModified = true;
                }
                else
                {
                    windowService.UserMessage("A kategóriát nem sikerül módosítani!");
                }
            }
            else
            {
                windowService.UserMessage("Nem történt módosítás.");
            }

            // close the window anyway
            window.Close();
        }
 /// <summary>
 /// Closes the application.
 /// </summary>
 /// <param name="window">The window to close.</param>
 public void ExitMethod(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="window"></param>
 public void ExitAction(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
Exemple #20
0
 /// <summary>
 /// Sends a valid member to the Main VM to add to the list, then closes the window.
 /// </summary>
 /// <param name="window">The window to close.</param>
 public void SaveMethod(IClosable window)
 {
     try
     {
         if (window != null)
         {
             // (Missing) -> Send a valid member
             Messenger.Default.Send(new MessageMember(EnteredFName, EnteredLName, EnteredEmail, "Add"));
             ResetInputFields();
             window.Close();
         }
     }
     catch (ArgumentException)
     {
         MessageBox.Show("Fields must be under 25 characters.", "Entry Error");
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Fields cannot be empty.", "Entry Error");
     }
     catch (FormatException)
     {
         MessageBox.Show("Must be a valid e-mail address.", "Entry Error");
     }
 }
 private bool IsModelValid(IClosable arg)
 {
     return(SelectedUserId != null &&
            SelectedLeaveTypeId != null &&
            StartDate != null &&
            EndDate != null);
 }
        private void SaveExecute(IClosable window)
        {
            var leaveToAdd = new LeaveToAdd
            {
                UserId      = (int)SelectedUserId,
                LeaveTypeId = (int)SelectedLeaveTypeId,
                StartDate   = (DateTime)StartDate,
                EndDate     = (DateTime)EndDate,
                Comment     = Comment
            };

            try
            {
                _leaveService.AddLeave(leaveToAdd);

                Messenger.Default.Send <LeaveToAdd>(leaveToAdd);



                if (window != null)
                {
                    window.Close();
                }
            }
            catch (LeaveException exc)
            {
                CustomMessageBox.CustomMessageBox.Show(exc.Message, "Błąd");
            }
        }
        private void SaveExecute(IClosable window)
        {
            var userToAdd = new UserToAdd
            {
                Login                = this.Login,
                FirstName            = this.FirstName,
                LastName             = this.LastName,
                Password             = this.Password,
                PasswordConfirmation = this.PasswordConfirmation,
                RoleId               = (int)this.SelectedRoleId
            };

            try
            {
                _userService.AddUser(userToAdd);

                Messenger.Default.Send <UserToAdd>(userToAdd);

                if (window != null)
                {
                    window.Close();
                }
            }
            catch (UserException exc)
            {
                CustomMessageBox.CustomMessageBox.Show(exc.Message, "Błąd");
            }
        }
 private void CloseWindow(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
Exemple #25
0
        /// <summary>
        /// The method that adds a new customer based on the input fields to the database.
        /// </summary>
        /// <param name="window">The window to close if successful.</param>
        private void AcceptMethod(IClosable window)
        {
            if (IsValidData())
            {
                try
                {
                    Customer adding = new Customer();
                    adding.Name    = enteredName;
                    adding.Address = enteredAddress;
                    adding.City    = enteredCity;
                    adding.State   = SelectedState.StateCode;
                    adding.ZipCode = enteredZipCode;

                    MMABooksEntity.dbcontext.Customers.Add(adding);
                    MMABooksEntity.dbcontext.SaveChanges();

                    if (window != null)
                    {
                        window.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            }
            else
            {
                MessageBox.Show("Invalid data.", "Error");
            }
        }
        public void AcceptMethod(IClosable window)
        {
            if (Name != null && City != null && Address != null && SelectedState != null && Zipcode != null)
            {
                try
                {
                    var state = (from cust in MMABooksClass.context.Customers
                                 where cust.State1.StateName == SelectedState.StateName
                                 select cust.State).FirstOrDefault();

                    Customer customer = new Customer();
                    customer.Name    = Name;
                    customer.Address = Address;
                    customer.City    = City;
                    customer.State   = state;
                    customer.ZipCode = Zipcode;

                    MMABooksClass.context.Customers.Add(customer);
                    MMABooksClass.context.SaveChanges();
                    MessageBox.Show(customer.CustomerID.ToString(), "Customer Added ID");
                    Messenger.Default.Send(new MessageMember(customer, "Add"));

                    Name          = "";
                    Address       = "";
                    City          = "";
                    SelectedState = null;
                    Zipcode       = "";

                    if (window != null)
                    {
                        window.Close();
                    }
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    ex.Entries.Single().Reload();
                    if (MMABooksClass.context.Entry(selectedstate).State == EntityState.Detached)
                    {
                        MessageBox.Show("Another user has deleted " + "that customer.", "Concurrency Error");
                    }
                    else
                    {
                        MessageBox.Show("Another user has updated " + "that customer.", "Concurrency Error");
                    }
                }
                catch (NullReferenceException)
                {
                    MessageBox.Show("Null reference", "Error");
                }
                catch (Exception)
                {
                    MessageBox.Show("Error", "Error");
                }
            }
            else
            {
                MessageBox.Show("ERROR: NULL DATA");
            }
        }
Exemple #27
0
 private void Cancel(IClosable window)
 {
     if (window != null)
     {
         ShowProfileWindow(Authenticator.CurrentUser.PharmacyID);
         window.Close();
     }
 }
Exemple #28
0
 private bool CanLogin(IClosable window)
 {
     if (IsLoading)
     {
         return(false);
     }
     return(ValidationHelper.IsNotEmpty(Password) && ValidationHelper.IsNotEmpty(Username));
 }
Exemple #29
0
 private void Logout(IClosable window)
 {
     if (window != null)
     {
         Authenticator.LogOut();
         window.Close();
     }
 }
 private void CloseCommandHandler(IClosable window)
 {
     if (window != null)
     {
         DeregisterFromServiceEvents();
         window.CloseWindow();
     }
 }