Example #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource is Button button)
            {
                switch (button.Name)
                {
                case "buttonEdit":
                    EditCommand?.Execute(null);
                    break;

                case "buttonDelete":
                    DeleteCommand?.Execute(null);
                    break;

                case "buttonCancel":
                    CancelCommand?.Execute(null);
                    break;

                case "buttonSave":
                    SaveCommand?.Execute(null);
                    break;

                case "buttonAdd":
                    AddCommand?.Execute(null);
                    break;
                }
            }
        }
Example #2
0
 private void EditButtonOnClicked()
 {
     if (EditCommand != null && EditCommand.CanExecute(Product))
     {
         EditCommand.Execute(Product);
     }
 }
Example #3
0
        private void _rightMenuButton_Clicked(object sender, System.EventArgs e)
        {
            switch (RightMenu)
            {
            case RightMenuIcon.Add:
                AddCommand?.Execute(null);
                break;

            case RightMenuIcon.CustomText:
            case RightMenuIcon.CustomIcon:
                RightMenuCommand?.Execute(null);
                break;

            case RightMenuIcon.Delete:
                DeleteCommand?.Execute(null);
                break;

            case RightMenuIcon.Edit:
                EditCommand?.Execute(null);
                break;

            case RightMenuIcon.Save:
                SaveCommand?.Execute(null);
                break;

            case RightMenuIcon.Settings:
                SettingsCommand?.Execute(null);
                break;
            }
        }
 private void OnEdit(object sender, RoutedEventArgs e)
 {
     if (EditCommand != null)
     {
         EditCommand.Execute(User);
     }
 }
 private void OnEditClick(object sender, RoutedEventArgs e)
 {
     if (EditCommand != null)
     {
         EditCommand.Execute((sender as Button).Tag);
     }
 }
Example #6
0
        public void EditUserProfileTest()
        {
            var profilePutModel = new ProfilePutModel();
            var command         = new EditCommand(GetFakeApiController(), GetFakeUserRepository(), profilePutModel);
            Task <HttpResponseMessage> result = command.Execute();

            result.Wait();

            Assert.IsFalse(result.IsFaulted);
            Assert.IsNotNull(result.Result);
            Assert.IsTrue(result.Result.StatusCode == HttpStatusCode.OK);
        }
Example #7
0
 private void LiveEditor_StopEditing(object sender, EventArgs e)
 {
     if (!(sender is LiveEditor view))
     {
         return;
     }
     OnEdited?.Invoke(this, EventArgs.Empty);
     EditCommand.Execute(BindingContext);
     view.StopEditing -= LiveEditor_StopEditing;
     SwipeViewContainer.Children.Remove(view);
     HeaderContent.IsVisible = true;
     GC.Collect();
 }
 private void EndEdit()
 {
     if (Text.IsNullOrWhiteSpace() || _OldText == Text)
     {
         CancelEdit();
         return;
     }
     if (EditCommand != null)
     {
         EditCommand.Execute(Text);
     }
     GotoReadOnlyState();
 }
 private void Button_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Up)
     {
         GoToPageCommand.Execute("next");
     }
     if (e.Key == Key.Down)
     {
         GoToPageCommand.Execute("previous");
     }
     if (e.Key == Key.Enter)
     {
         EditCommand.Execute(null);
     }
 }
        public IActionResult Edit(PhotoEditModel model, [FromServices] EditCommand editCmd)
        {
            var item = _dataContext.Photos.FirstOrDefault(i => i.Id == model.Id);

            if (item == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            editCmd.Execute(model);

            return(RedirectToAction("Details", new { id = model.Id }));
        }
Example #11
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << 8))
            {
                EditCommand command = new EditCommand(myObject, hit.point.x, hit.point.z);
                command.Execute();

                commands.Push(command);
            }
        }

        if (Input.GetMouseButtonDown(1) && commands.Count > 0)
        {
            commands.Pop().Undo();
        }
    }
        /// <summary>
        /// load ItemInstance based on item selected from list, ie load shadow object
        /// </summary>
        /// <param name="selListItem"></param>
        protected override void loadSelectedItem(ItemResult selListItem)
        {
            if ((selListItem?.pk != null) && (selListItem.pk != Guid.Empty))
            {
                selectedItem = db.db.Load <Item>(selListItem.pk);

#if false
                // if not currently editing anything then we match current item, but
                // we don't update currentItem otherwise as may be a clone, etc.
                if (isDetailViewInActive && EditCommand.CanExecute(null))
                {
                    EditCommand.Execute(null);
                }
#else
                // update detail view immediately when a new item is selected
                // note this will loose changes for a clone
                if (currentItem != null && currentItem.IsChanged)
                {
                    var x = MessageBox.Show("Current item has been modified, do you wish to save changes?", $"Changes to {currentItem.displayName} will be lost!", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);
                    if (x == MessageBoxResult.Yes)
                    {
                        if (SaveCommand.CanExecute(null))
                        {
                            SaveCommand.Execute(null);
                        }
                    }
                }
                if (EditCommand.CanExecute(null))
                {
                    EditCommand.Execute(null);
                }
#endif
            }
            else
            {
                selectedItem = null;
            }
        }
        public void EditUserProfileTest()
        {
            var profilePutModel = new ProfilePutModel();
            var command = new EditCommand(GetFakeApiController(), GetFakeUserRepository(), profilePutModel);
            Task<HttpResponseMessage> result = command.Execute();
            result.Wait();

            Assert.IsFalse(result.IsFaulted);
            Assert.IsNotNull(result.Result);
            Assert.IsTrue(result.Result.StatusCode == HttpStatusCode.OK);
        }
Example #14
0
        private static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Not enough arguments !");
                return;
            }

            Config.Model = args[0].ToLower().UppercaseFirst();
            var command = "";

            if (args.Length > 1)
            {
                command = args[1].ToLower();
            }

            if (args.Length > 2)
            {
                Config.Area = args[2].ToLower().UppercaseFirst();
            }

            Config.ModelsPath     = Environment.CurrentDirectory + "\\";
            Config.ViewModelsPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.FullName + "\\ViewModels\\";
            Config.RepositoryPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.FullName + "\\Repository\\";
            Config.ServicePath    = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.FullName + "\\Service\\";

            if (string.IsNullOrEmpty(Config.Area))
            {
                Config.ControllerPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Controllers\\";
                Config.ViewsPath      = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Views\\" + Config.Model + "\\";
            }
            else
            {
                Config.ControllerPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Areas\\" + Config.Area + "\\Controllers\\";
                Config.ViewsPath      = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Areas\\" + Config.Area + "\\Views\\" + Config.Model + "\\";
            }

            var viewsDir = new System.IO.DirectoryInfo(Config.ViewsPath);

            if (!viewsDir.Exists)
            {
                viewsDir.Create();
            }

            Config.PropertyNames        = ClassHelper.GetPropertyNames(Config.ModelsPath + Config.Model + ".cs");
            Config.PropertyTypes        = ClassHelper.GetPropertyTypes(Config.ModelsPath + Config.Model + ".cs");
            Config.PropertyDeclarations = ClassHelper.GetPropertyDeclarations(Config.ModelsPath + Config.Model + ".cs");

            switch (command)
            {
            case "sr":
            case "service":
                var iserviceCommand = new IServiceCommand();
                var serviceCommand  = new ServiceCommand();
                iserviceCommand.Execute();
                serviceCommand.Execute();
                break;

            case "rp":
            case "repository":
                var irepositoryCommand = new IRepositoryCommand();
                var repositoryCommand  = new RepositoryCommand();
                irepositoryCommand.Execute();
                repositoryCommand.Execute();
                break;

            case "vm":
            case "viewmodel":
                var viewModelCommand = new ViewModelCommand();
                viewModelCommand.Execute();
                break;

            case "ad":
            case "addmodel":
                var addModel = new AddModelCommand();
                addModel.Execute();
                break;

            case "vi":
            case "views":
                var indexCommand   = new IndexCommand();
                var createCommand  = new CreateCommand();
                var editCommand    = new EditCommand();
                var deleteCommand  = new DeleteCommand();
                var detailsCommand = new DetailsCommand();

                indexCommand.Execute();
                createCommand.Execute();
                editCommand.Execute();
                deleteCommand.Execute();
                detailsCommand.Execute();

                break;

            case "cr":
            case "controller":
                var controllerCommand = new ControllerCommand();
                controllerCommand.Execute();
                break;

            case "go":
            default:
                var goCommand = new GoCommand();
                goCommand.Execute();


                break;
            }
        }
Example #15
0
 public CompanyAddressViewModel(CompanyAddressModel model)
 {
     Model = model;
     EditCommand?.Execute(null);
 }
Example #16
0
        /// <summary>
        /// load ItemResult based on item selected from list, ie load shadow object
        /// </summary>
        /// <param name="selListItem"></param>
        protected override void loadSelectedItem(ItemResult selListItem)
        {
            try
            {
                if (currentItem != null)
                {
                    currentItem.PropertyChanged -= CurrentItem_PropertyChanged;
                }

                if ((selListItem?.pk != null) && (selListItem.pk != Guid.Empty))
                {
                    selectedItem = db.db.Load <ItemType>(selListItem.pk);

#if false
                    // if not currently editing anything then we match current item, but
                    // we don't update currentItem otherwise as may be a clone, etc.
                    if (isDetailViewInActive && EditCommand.CanExecute(null))
                    {
                        EditCommand.Execute(null);
                    }
#else
                    // update detail view immediately when a new item is selected
                    // note this will loose changes for a clone
                    if (currentItem != null && currentItem.IsChanged)
                    {
                        var x = MessageBox.Show("Current item has been modified, do you wish to save changes?", $"Changes to {currentItem.displayName} will be lost!", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);
                        if (x == MessageBoxResult.Yes)
                        {
                            if (SaveCommand.CanExecute(null))
                            {
                                SaveCommand.Execute(null);
                            }
                        }
                    }
                    if (EditCommand.CanExecute(null))
                    {
                        EditCommand.Execute(null);
                    }

                    /*
                     * currentItem = selectedItem;  //DoEdit();
                     *                           // Note: need same object so changes triggered via items bound to selectedListItem will show in detail view
                     * selListItem.entity = currentItem;
                     */
#endif
                }
                else
                {
                    selectedItem = null;
                }

                if (currentItem != null)
                {
                    currentItem.PropertyChanged += CurrentItem_PropertyChanged;
                }
                // flag other items that may change when selected item changes
                RaisePropertyChanged(nameof(HasMultipleImages));

                // select first image (or clear)
                currentImageIndex = 0;
            }
            catch (Exception e)
            {
                logger.Error(e, $"Exception in loadSelectedItem - {e.Message}");
                throw;
            }
        }
Example #17
0
 public CompanyContactViewModel(CompanyContactModel model)
 {
     Model = model;
     EditCommand?.Execute(null);
 }