Esempio n. 1
0
 public ActionResult Delete(int id, ToolVM toolVM)
 {
     if (toolManager.DeleteTool(toolVM.Id))
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         ModelState.AddModelError("", "Ошибка сохранения данных.");
         return(RedirectToAction("Delete", new { id = id }));
     }
 }
Esempio n. 2
0
        private void Tools_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            ToolVM tool = (ToolVM)this.ToolsView.SelectedValue;

            if (tool.ToolElement.HasValue)
            {
                this.ViewModel.SelectedTool = tool;
            }
            else if (tool == ToolVM.Cursor)
            {
                this.ViewModel.SelectedTool = ToolVM.Cursor;
            }
            else if (tool.Elements != null)
            {
                tool.IsExpanded             = true;
                this.ViewModel.SelectedTool = tool.Elements[0];
            }
        }
Esempio n. 3
0
        public ActionResult Edit(int id, ToolVM toolVM)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }


            var tool = new Tool {
                Id = toolVM.Id, Name = toolVM.Name
            };

            if (toolManager.UpdateTool(tool))
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Ошибка сохранения данных.");
                return(View());
            }
        }
Esempio n. 4
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane;

            if (destinationContainer != null && destinationContainer.FindParent <LayoutFloatingWindow>() != null)
            {
                return(false);
            }

            if (anchorableToShow.Content is ToolVM)
            {
                ToolVM tvm       = (ToolVM)anchorableToShow.Content;
                var    toolsPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == tvm.InitialPane);

                if (toolsPane != null)
                {
                    toolsPane.Children.Add(anchorableToShow);
                    return(true);
                }
            }
            return(false);
        }