Esempio n. 1
0
        private void CloseOpenedSection(object sender, ViewModelEventArgs e)
        {
            ViewModelSection callingObj = sender as ViewModelSection;

            //return if list of section is empty
            if (_openedViews.Count == 0)
            {
                return;
            }

            do
            {
                var lastNode = _openedViews.Last;
                _openedViews.RemoveLast();
                lastNode.Value.CreateView  -= AddSectionToPipe;
                lastNode.Value.WantToClose -= CloseOpenedSection;

                //Delete filter if exists
                if (lastNode.Value.Filter != null)
                {
                    _openedViews.Remove(lastNode.Value.Filter);
                }

                if (lastNode.Value == callingObj)
                {
                    break;
                }
            } while (_openedViews.Count > 0);
            if (_openedViews.Count == 0)
            {
                SelectedMenuItem.IsSelected = false;
            }
        }
Esempio n. 2
0
 // Customer is deleted. Ask user to continue or not.
 private void viewModel_Deleting(object sender, ViewModelEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to delete this customer?", "Delete Customer", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
     {
         e.Cancel = true;
     }
 }
Esempio n. 3
0
        // Customer is added
        private void viewModel_Adding(object sender, ViewModelEventArgs e)
        {
            DataGridCustomers.ScrollIntoView(DataGridCustomers.SelectedItem, null);

            DataGridCustomers.IsEnabled = false;
            DataFormCustomer.BeginEdit();
        }
Esempio n. 4
0
        /// <summary>
        /// Handles the OpenSetupRequested event.
        /// </summary>
        /// <param name="sender">The sender<see cref="object"/>.</param>
        /// <param name="e">The e<see cref="ViewModelEventArgs"/>.</param>
        private void Vm_OpenSetupRequested(object sender, ViewModelEventArgs e)
        {
            WpfHelper.SetWindowSettings(Window.GetWindow(this));
            var win = new SetupWindow();

            win.ShowDialog();
        }
Esempio n. 5
0
        // User was successfully logged in.
        private void viewModel_LoggedIn(object sender, ViewModelEventArgs e)
        {
            DetachEventHandlers();

            this.Cursor = Cursors.Arrow;

            NavigationService.Navigate(new Uri("/Customers", UriKind.Relative));
        }
Esempio n. 6
0
        // Customer changes are about to being saved to database
        private void viewModel_Saving(object sender, ViewModelEventArgs e)
        {
            IEditableObject customer = DataGridCustomers.SelectedItem as Customer;

            customer.EndEdit();

            DataFormCustomer.CommitEdit(true);
        }
        /// <summary>
        /// Reset ressources.
        /// </summary>
        private void Reset(ViewModelEventArgs eventArgs)
        {
            isReseting = true;

            OnReset();

            isReseting = false;
        }
        /// <summary>
        /// Reset ressources.
        /// </summary>
        private void Reset(ViewModelEventArgs eventArgs)
        {
            isReseting = true;

            OnReset();

            isReseting = false;
        }
Esempio n. 9
0
        private void RaiseViewClosedEvent(ViewModelEventArgs e)
        {
            var handler = Closed;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 10
0
        // User login failed. Display message.
        private void viewModel_LoginFailed(object sender, ViewModelEventArgs e)
        {
            this.Cursor = Cursors.Arrow;
            MessageBox.Show("Invalid Username or Password. Please try again", "Login", MessageBoxButton.OK);

            // Reset controls
            textBoxUserName.Text         = "";
            passwordBoxPassword.Password = "";
            textBoxUserName.Focus();
        }
Esempio n. 11
0
        /// <summary>
        /// Handles the EditSelectedFolderRequested event.
        /// </summary>
        /// <param name="sender">The sender<see cref="object"/>.</param>
        /// <param name="e">The e<see cref="ViewModelEventArgs"/>.</param>
        private void Vm_EditSelectedFolderRequested(object sender, ViewModelEventArgs e)
        {
            WpfHelper.SetWindowSettings(Window.GetWindow(this));
            var vm  = e.ViewModel as FolderViewModel;
            var win = new FolderWindow(vm);

            win.ShowDialog();
            var dc = Locator.MainViewModel;

            dc.FolderViewModelClosed(vm);
        }
Esempio n. 12
0
 private static void logicWindowViewModel_Closed(object sender, ViewModelEventArgs e)
 {
     if (e.DialogResult == DialogResult.OK)
     {
         IMainViewModel mainWindowViewModel = ViewModelFactory.Instance.GetMainWindowViewModel();
         MessengerService.Instance.ShowView <IMainViewModel>(mainWindowViewModel);
     }
     else
     {
         ShutDownApplication();
     }
 }
Esempio n. 13
0
        protected async void OnConnectionEstablished(ViewModel sender, ViewModelEventArgs e)
        {
            if (e.MType != ViewModelEventArgs.MessageType.Error)
            {
                await DisplayAlert("Success", "Connection established!", "OK");

                await Navigation.PushAsync(new MenuPage());
            }
            else
            {
                await DisplayAlert("Error", e.Message, "OK");
            }
        }
        private void ViewModel_GraphicSetToDraw(object sender, ViewModelEventArgs e)
        {
            PointCollection[] graphicRepresentation     = null;
            List <Polyline>   listOfLines               = null;
            List <Graphic>    listOfGraphicsToRepresent = (List <Graphic>)e.ListOfGraphics;
            FuncRect          funcR = viewModel.FuncRect;

            RepresentationCanvas.Children.Clear();
            DrawAxisAndLines();

            if (graphicRepresentationDictionary == null) // Para que no se dibuje nada en el sizeChanged
            {
                graphicRepresentationDictionary = new Dictionary <Graphic, List <Polyline> >();
            }

            graphicRepresentationDictionary.Clear();

            foreach (Graphic g in listOfGraphicsToRepresent)
            {
                if (graphicRepresentationDictionary.ContainsKey(g) && g != null)
                {
                    listOfLines = graphicRepresentationDictionary[g];
                    foreach (Polyline line in listOfLines)
                    {
                        RepresentationCanvas.Children.Add(line);
                    }
                }
                else
                {
                    listOfLines = new List <Polyline>();

                    graphicRepresentation = FunctionRepresentationVar.DrawGraphic(g, RepresentationCanvas.ActualWidth, RepresentationCanvas.ActualHeight, funcR);
                    foreach (PointCollection p in graphicRepresentation)
                    {
                        Polyline line = new Polyline()
                        {
                            Points = p,
                            Stroke = new SolidColorBrush(g.GraphicColor)
                        };
                        listOfLines.Add(line);
                    }
                    graphicRepresentationDictionary.Add(g, listOfLines);

                    foreach (Polyline line in listOfLines)
                    {
                        RepresentationCanvas.Children.Add(line);
                    }
                }
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Handles the EditZipFileRequested event.
        /// </summary>
        /// <param name="sender">The sender<see cref="object"/>.</param>
        /// <param name="e">The e<see cref="ViewModelEventArgs"/>.</param>
        private void Vm_EditZipFileRequested(object sender, ViewModelEventArgs e)
        {
            WpfHelper.SetWindowSettings(Window.GetWindow(this));
            var vm  = e.ViewModel as ZipFileViewModel;
            var win = new ZipFileWindow(vm);

            win.ShowDialog();

            // Raise SelectedZipFile.Folders changed event in case folders were added
            vm.RaiseFoldersChangedEvent();

            var dc = Locator.MainViewModel;

            dc.ZipFileViewModelClosed(vm);
        }
 private void addUserViewModel_Closed(object sender, ViewModelEventArgs e)
 {
     if (e.DialogResult == DialogResult.OK)
     {
         if (((IAddUserViewModel)(e.ViewModel)).IsUserAdded)
         {
             ToSuccessor();
         }
         else
         {
             MessengerService.Instance.ShowMessageBox("Aborted!", "No user is created, application is exiting.",
                                                      MessageBoxButtons.OK, MessageBoxIcon.Information);
             ShutDownApplication();
         }
     }
 }
Esempio n. 17
0
        private void OnViewAttached(object sender, ViewModelEventArgs e)
        {
            UnitsViewModel viewModel = e.ViewModel as UnitsViewModel;

            if (viewModel == null)
            {
                return;
            }
            Type unitType = viewModel.UnitType;
            IContextMenuIntegration integration;

            if (_collection.TryGetValue(unitType, out integration))
            {
                integration.Integrate(viewModel);
            }
        }
        private void ViewModel_GraphicRepresentationUpdated(object sender, ViewModelEventArgs e)
        {
            List <Graphic> listOfGraphics = graphicRepresentationDictionary.Keys.ToList <Graphic>();

            graphicRepresentationDictionary.Clear();
            RepresentationCanvas.Children.Clear();
            DrawAxisAndLines();

            if (graphicRepresentationDictionary != null)
            {
                foreach (Graphic g in listOfGraphics)
                {
                    DrawGraphicsInList(g);
                }
            }
        }
Esempio n. 19
0
        private async void OnConnectionSkipped(ViewModel sender, ViewModelEventArgs e)
        {
            var vm = BindingContext as ConnectionEstablishmentViewModel;

            if (vm == null)
            {
                throw new ApplicationException("Unexpected error occured. Please, restart the application.");
            }

            if (vm.HasConnection)
            {
                await Navigation.PushAsync(new MenuPage());
            }
            else
            {
                await DisplayAlert("Error", "No connections were previously established.", "OK");
            }
        }
        private void ViewModel_GraphicDeleted(object sender, ViewModelEventArgs e)
        {
            List <Graphic>  listOfGraphicsToRemove = (List <Graphic>)e.ListOfGraphics;
            List <Polyline> listOfPolylines        = null;

            if (graphicRepresentationDictionary != null)
            {
                foreach (Graphic g in listOfGraphicsToRemove)
                {
                    if (graphicRepresentationDictionary.ContainsKey(g) && g != null)
                    {
                        listOfPolylines = graphicRepresentationDictionary[g];
                        graphicRepresentationDictionary.Remove(g);
                        foreach (Polyline p in listOfPolylines)
                        {
                            RepresentationCanvas.Children.Remove(p);
                        }
                    }
                }
            }
        }
Esempio n. 21
0
        private async void OnEventDeleted(object sender, ViewModelEventArgs e)
        {
            if (e.MType == ViewModelEventArgs.MessageType.Information && e.Message == "Success")
            {
                try
                {
                    var xml_scan = await RemoteDevice.Send(Protocol.ScanEvents);

                    await RemoteDevice.LoadEvents(xml_scan);
                }
                catch { }

                await DisplayAlert("Success", "The event was successfully deleted.", "OK");

                await Navigation.PopAsync();
            }
            else
            {
                await DisplayAlert("Error", e.Message, "OK");
            }
        }
Esempio n. 22
0
        private void AddSectionToPipe(object sender, ViewModelEventArgs e)
        {
            ViewModelSection newView = e.VMObject;

            newView.CreateView  += AddSectionToPipe;
            newView.WantToClose += CloseOpenedSection;
            if (e.JoinType == JoinDirectionEnum.First)
            {
                _openedViews.AddFirst(newView);
            }
            else
            {
                var lastView = _openedViews.Last.Value;
                while (!lastView.Equals(sender))
                {
                    _openedViews.RemoveLast();
                    lastView = _openedViews.Last.Value;
                }
                _openedViews.AddLast(newView);
            }
        }
Esempio n. 23
0
        private void OnDelete(object parameter)
        {
            Status = "";

            // Do not simply raise the Deleting event, because we are giving the
            // user the opportunity to cancel the delete, and we need to check for this.
            if (Deleting != null)
            {
                var args = new ViewModelEventArgs();
                Deleting(this, args);

                // Check if user choose to cancel deletion.
                if (args.Cancel)
                {
                    return;
                }
            }

            // Start by checking if user has any orders. If so, delete is not allowed.
            int customerId = CurrentCustomer.CustomerId;

            context.GetOrderCountByCustomer(customerId, GetOrderCountByCustomerCallback, false);
        }
Esempio n. 24
0
 // Adding product to cart was unsuccessful.
 private void viewModel_AddedToCartFailed(object sender, ViewModelEventArgs e)
 {
     this.Cursor = Cursors.Arrow;
 }
Esempio n. 25
0
 // Successfully added product to cart. Redirect to cart page.
 private void viewModel_AddedToCart(object sender, ViewModelEventArgs e)
 {
     this.Cursor = Cursors.Arrow;
     NavigationService.Navigate(new Uri("/Cart", UriKind.Relative));
 }
Esempio n. 26
0
 // Cancel operation has completed
 private void viewModel_Canceled(object sender, ViewModelEventArgs e)
 {
     DataGridCustomers.IsEnabled = true;
 }
Esempio n. 27
0
 // Add or Edit Customer is being cancelled
 private void viewModel_Canceling(object sender, ViewModelEventArgs e)
 {
     DataFormCustomer.CancelEdit();
 }
Esempio n. 28
0
 // Customer is edited
 private void viewModel_Editing(object sender, ViewModelEventArgs e)
 {
     DataGridCustomers.IsEnabled = false;
     DataFormCustomer.BeginEdit();
 }
Esempio n. 29
0
 // About to add product to cart.
 private void viewModel_AddingToCart(object sender, ViewModelEventArgs e)
 {
     this.Cursor = Cursors.Wait;
 }
Esempio n. 30
0
 // Customers are loaded
 private void viewModel_Loaded(object sender, ViewModelEventArgs e)
 {
     this.Cursor = Cursors.Arrow;
 }
Esempio n. 31
0
 // Customers are loading
 private void viewModel_Loading(object sender, ViewModelEventArgs e)
 {
     this.Cursor = Cursors.Wait;
 }