Пример #1
0
        public void Constructor_ShouldSetTitle_IsVisible_View_AndShouldSetViewModelAsDataContextOfView()
        {
            // Arrange
            const string title     = "SomeTitle";
            var          view      = Substitute.For <IView>();
            var          viewModel = new TestViewModel();

            // Act
            var toolViewModel = new ToolViewModel(title, view, viewModel, true);

            // Assert
            Assert.That(toolViewModel.Title, Is.EqualTo(title));
            Assert.That(toolViewModel.IsVisible, Is.True);
            Assert.That(toolViewModel.View, Is.EqualTo(view));
            Assert.That(toolViewModel.View.DataContext, Is.EqualTo(viewModel));
        }
Пример #2
0
        public ToolViewModel GetTools(ContextModel context)
        {
            var result = new ToolViewModel();

            if (_machineService.GetMachinePanels(context).Contains((int)enPanel.ToolsBlitz))
            {
                result.vm_tools_blitz = GetVueModelBlitz(context.ActualMachine);
            }
            else
            {
                result.vm_tools = GetVueModel(context.ActualMachine, true);
            }


            return(result);
        }
Пример #3
0
        // GET: Tools/Details/5
        public ActionResult Details(int?id)
        {
            ViewBag.LinkText = "Tools";
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tool tool = db.Tools.Find(id);

            if (tool == null)
            {
                return(HttpNotFound());
            }

            var Results = from e in db.Employees
                          select new
            {
                employee = e,
                Checked  = ((from te in db.ToolToEmployees
                             where (te.ToolID == id) & (te.EmployeeID == e.ID)
                             select te).Count() > 0),
                Role = ((from te in db.ToolToEmployees
                         where (te.ToolID == id) & (te.EmployeeID == e.ID)
                         select te.Role).FirstOrDefault())
            };

            var MyViewmodel = new ToolViewModel();

            MyViewmodel.tool = tool;

            var MyCheckBoxList = new List <CheckBoxToolViewModel>();

            foreach (var item in Results)
            {
                MyCheckBoxList.Add(new CheckBoxToolViewModel {
                    Employee = item.employee, Checked = item.Checked, Role = item.Role
                });
            }

            List <Employee> ees = db.Employees.ToList();

            ViewBag.E = ees;

            MyViewmodel.Employees = MyCheckBoxList;

            return(View(MyViewmodel));
        }
Пример #4
0
        public void CloseCommand_ShouldSetIsVisibleToFalse()
        {
            // Arrange
            const string title         = "SomeTitle";
            var          view          = Substitute.For <IView>();
            var          viewModel     = new TestViewModel();
            var          toolViewModel = new ToolViewModel(title, view, viewModel, true);

            // Assume
            Assume.That(toolViewModel.IsVisible, Is.True);

            // Act
            toolViewModel.CloseCommand.Execute(null);

            // Assert
            Assert.That(toolViewModel.IsVisible, Is.False);
        }
Пример #5
0
        public void AddDocumentTools(ToolViewModel tool)
        {
            string docType = Data.ActiveDocument.GetType().ToString();

            List <ToolViewModel> tools;

            if (dicToolsLoadedforDocumentTypes.TryGetValue(docType, out tools))
            {
                tools.Add(tool);
            }
            else
            {
                dicToolsLoadedforDocumentTypes.Add(docType, new List <ToolViewModel>()
                {
                    tool
                });
            }
        }
Пример #6
0
        public async Task CreateTool(ToolViewModel inputModel, string path)
        {
            // var tool = this.mapper.Map<Tool>(inputModel);
            var tool = new Tool
            {
                Name    = inputModel.Name,
                Details = inputModel.Details,
            };

            if (path != null)
            {
                tool.ImageUrl = path;
            }

            await this.db.Tools.AddAsync(tool);

            await this.db.SaveChangesAsync();
        }
Пример #7
0
        /// <summary>
        /// Open the styled anchorable context menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AnchorableContextMenu_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            LayoutAnchorableItem tool = ((ContextMenu)sender).DataContext as LayoutAnchorableItem;

            if (tool != null)
            {
                ToolViewModel model = tool.Model as ToolViewModel;

                if (model != null && model != MainWindow.GetInstance().GetDockingManager().ActiveContent)
                {
                    MainWindow.GetInstance().GetDockingManager().ActiveContent = model;
                }

                e.Handled = true;
                return;
            }

            e.Handled = false;
        }
Пример #8
0
 private void OnDockableToolsToggleButtonClicked(KeyValuePair <IRibbonToggleButton, Type> obj)
 {
     if (obj.Key.IsChecked == true)
     {
         ToolViewModel toolInstance = (ToolViewModel)Activator.CreateInstance(obj.Value);
         toolInstance.Connect(Data, _events);
         _dockableTools.Add(toolInstance);
         AddDocumentTools(toolInstance);
     }
     else if (obj.Key.IsChecked == false)
     {
         ToolViewModel tool = _dockableTools.Where(a => a.GetType() == obj.Value).Select(a => a).FirstOrDefault();
         if (tool != null)
         {
             tool.Disconnect();
             _dockableTools.Remove(tool);
             RemoveDocumentTool(tool);
         }
     }
 }
Пример #9
0
        /// <summary>
        /// Register a new tool window definition for usage in this program.
        /// </summary>
        /// <param name="newTool"></param>
        public void RegisterTool(ToolViewModel newTool)
        {
            try
            {
                Messaging.Output.Append(string.Format("{0} Registering tool window: {1} ...",
                                                      DateTime.Now.ToLongTimeString(), newTool.Name));

                _mTodoTools.Add(newTool);
            }
            catch (Exception exp)
            {
                Messaging.Output.AppendLine(exp.Message);
                Messaging.Output.AppendLine(exp.StackTrace);
                throw new Exception("Tool window registration failed in ToolWindowRegistry.", exp);
            }
            finally
            {
                Messaging.Output.AppendLine("Done.");
            }
        }
        private IMachineElementViewModel GetToolViewModel(Tool tool)
        {
            IMachineElementViewModel vm = null;

            if (tool.ToolType == TME.ToolType.AngularTransmission)
            {
                vm = AngularTransmissionViewModel.Create(tool, Position, Direction);
            }
            else if (!string.IsNullOrEmpty(tool.ConeModelFile))
            {
                vm = ToolWithConeViewModel.Create(tool, Position, Direction);
            }
            else
            {
                vm = ToolViewModel.Create(tool, Position, Direction);
            }

            vm.Parent = this;

            return(vm);
        }
Пример #11
0
        public async Task <IActionResult> EditTool(ToolViewModel viewModel)
        {
            if (this.ModelState.IsValid)
            {
                if (viewModel.Photo != null)
                {
                    byte[] destinationImage;

                    using (var memoryStream = new MemoryStream())
                    {
                        await viewModel.Photo.CopyToAsync(memoryStream);

                        destinationImage = memoryStream.ToArray();
                    }

                    using var destinationStream = new MemoryStream(destinationImage);
                    var uploadParams = new ImageUploadParams()
                    {
                        File = new FileDescription(viewModel.Photo.FileName, destinationStream),
                    };

                    var resutl = await this.cloudinary.UploadAsync(uploadParams);

                    var path = resutl.Uri.AbsoluteUri;

                    await this.toolsService.EditTool(viewModel.Id, viewModel.Name, viewModel.Details, path);

                    return(this.RedirectToAction("AllTools"));
                }
                else
                {
                    await this.toolsService.EditTool(viewModel.Id, viewModel.Name, viewModel.Details, null);

                    return(this.RedirectToAction("AllTools"));
                }
            }

            return(this.View(viewModel));
        }
Пример #12
0
        public ActionResult GetEmployees(int id)
        {
            Tool tool = db.Tools.Find(id);

            ViewBag.LinkText = "Editor";

            var Results = from e in db.Employees
                          select new
            {
                //e.ID,
                //e.FirstMidName,
                //e.LastName,
                employee = e,
                Checked  = ((from te in db.ToolToEmployees
                             where (te.ToolID == id) & (te.EmployeeID == e.ID)
                             select te).Count() > 0),
                Role = ((from te in db.ToolToEmployees
                         where (te.ToolID == id) & (te.EmployeeID == e.ID)
                         select te.Role).FirstOrDefault())
            };

            var MyViewmodel = new ToolViewModel();

            MyViewmodel.tool = tool;

            var MyCheckBoxList = new List <CheckBoxToolViewModel>();

            foreach (var item in Results)
            {
                MyCheckBoxList.Add(new CheckBoxToolViewModel {
                    Employee = item.employee, Checked = item.Checked, Role = item.Role
                });
            }

            MyViewmodel.Employees = MyCheckBoxList;

            return(PartialView("PeekEmployees", MyViewmodel));
        }
Пример #13
0
        private void LoadMenus()
        {
            eventAggregator.GetEvent <SplashMessageUpdateEvent>()
            .Publish(new SplashMessageUpdateEvent {
                Message = "Menus.."
            });
            ICommandManager     manager         = containerProvider.Resolve <ICommandManager>();
            IMenuService        menuService     = containerProvider.Resolve <IMenuService>();
            ISettingsManager    settingsManager = containerProvider.Resolve <ISettingsManager>();
            IThemeSettings      themeSettings   = containerProvider.Resolve <IThemeSettings>();
            IRecentViewSettings recentFiles     = containerProvider.Resolve <IRecentViewSettings>();
            IWorkspace          workspace       = containerProvider.Resolve <IWorkspace>();
            ToolViewModel       logger          = workspace.Tools.FirstOrDefault(f => f.ContentId == "Logger");

            menuService.Add(new MenuItemViewModel("_File", 1));

            menuService.Get("_File")
            .Add((new MenuItemViewModel("_New", 3,
                                        new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/WiderMD.Core;component/Icons/OpenFileDialog_692.png")),
                                        manager.GetCommand("OPEN"),
                                        new KeyGesture(Key.O, ModifierKeys.Control, "Ctrl + O"))));
            menuService.Get("_File")
            .Add(new MenuItemViewModel("_Save", 5,
                                       new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/WiderMD.Core;component/Icons/Save_6530.png")),
                     manager.GetCommand("SAVEAS")));
            menuService.Get("_File")
            .Add(new MenuItemViewModel("Close", 8, null,
                                       manager.GetCommand("CLOSE"),
                                       new KeyGesture(Key.F4, ModifierKeys.Control, "Ctrl + F4")));

            menuService.Get("_File").Add(recentFiles.RecentMenu);

            menuService.Get("_File")
            .Add(new MenuItemViewModel("E_xit", 101, null,
                                       manager.GetCommand("EXIT"),
                                       new KeyGesture(Key.F4, ModifierKeys.Alt, "Alt + F4")));


            menuService.Add(new MenuItemViewModel("_Edit", 2));
            menuService.Get("_Edit")
            .Add(new MenuItemViewModel("_Undo", 1,
                                       new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/WiderMD.Core;component/Icons/Redo_16x.png")),
                                       ApplicationCommands.Redo));
            menuService.Get("_Edit").Add(MenuItemViewModel.Separator(15));
            menuService.Get("_Edit")
            .Add(new MenuItemViewModel("Cut", 20,
                                       new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/WiderMD.Core;component/Icons/Copy_6524.png")),
                                       ApplicationCommands.Copy));
            menuService.Get("_Edit")
            .Add(new MenuItemViewModel("_Paste", 22,
                                       new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/WiderMD.Core;component/Icons/Undo_16x.png")),
                                           manager.GetCommand("LOGSHOW"))
                {
                    IsCheckable = true, IsChecked = logger.IsVisible
                });
            }

            menuService.Get("_View").Add(new MenuItemViewModel("Themes", 1));

            // Get the listed themses and add to menu
            IThemeManager     themeManager = containerProvider.Resolve <IThemeManager>();
            MenuItemViewModel themeMenu    = menuService.Get("_View").Get("Themes") as MenuItemViewModel;

            // add items based on theme programmed
            foreach (ITheme theme in themeManager.Themes)
            {
                themeMenu
                .Add(new MenuItemViewModel(theme.Name, 1, null,
                                           manager.GetCommand("THEMECHANGE"))
                {
                    IsCheckable      = true,
                    IsChecked        = (themeSettings.SelectedTheme == theme.Name),
                    CommandParameter = theme.Name
                });
            }

            menuService.Add(new MenuItemViewModel("_Tools", 4));
            menuService.Get("_Tools").Add(new MenuItemViewModel("Settings", 1, null, settingsManager.SettingsCommand));

            menuService.Add(new MenuItemViewModel("_Help", 4));
        }
 public MaterialChartPlugin()
 {
     viewModel = new ToolViewModel(this);
 }
Пример #15
0
        public ActionResult Edit(ToolViewModel toolView)
        {
            if (ModelState.IsValid)
            {
                var MyTool = db.Tools.Find(toolView.ID);

                //Edit cover image
                if (toolView.CoverImageFile != null)
                {
                    //cover photo
                    string imageName      = Path.GetFileNameWithoutExtension(toolView.CoverImageFile.FileName); //image
                    string imageExtension = Path.GetExtension(toolView.CoverImageFile.FileName);                //.jpg
                    string coverFullName  = imageName + imageExtension;                                         //image.jpg

                    string oldCoverImage = Request.MapPath(TempData["CoverImagePath"].ToString());

                    MyTool.CoverImagePath = "~/Assets/Tools" + toolView.tool.ToolID + "/cover folder/" + coverFullName;  //  ~/Assets/products/software1/cover image/image.jpg
                    coverFullName         = Path.Combine(Server.MapPath("C:/Users/Adoca/source/repos/ASM_Tools/Assets/Tools" + toolView.tool.ToolID + "/cover folder/" + coverFullName));

                    //Delete old cover image
                    if (System.IO.File.Exists(oldCoverImage))
                    {
                        System.IO.File.Delete(oldCoverImage);
                    }

                    MyTool.CoverImageFile = toolView.CoverImageFile;
                    MyTool.CoverImageFile.SaveAs(coverFullName);
                }
                //if no file chose keep the original
                else
                {
                    MyTool.CoverImagePath = TempData["CoverImagePath"].ToString();
                }

                foreach (var item in db.ToolToEmployees)
                {
                    if (item.ID == toolView.tool.ToolID)
                    {
                        db.Entry(item).State = EntityState.Deleted;
                    }
                }

                foreach (var item in toolView.Employees)
                {
                    if (item.Checked)
                    {
                        var role = item.Role;
                        var tee  = from te in db.ToolToEmployees
                                   where te.ToolID == toolView.tool.ToolID && te.EmployeeID == item.Employee.ID
                                   select te;
                        if (tee.Count() == 0)
                        {
                            db.ToolToEmployees.Add(new ToolToEmployee()
                            {
                                ToolID = toolView.tool.ToolID, EmployeeID = item.Employee.ID, Role = item.Role
                            });
                        }
                        else
                        {
                            tee.First().Role = role;
                        }
                    }
                    else
                    {
                        var tee = from te in db.ToolToEmployees
                                  where te.ToolID == toolView.tool.ToolID && te.EmployeeID == item.Employee.ID
                                  select te;
                        if (tee.Count() != 0)
                        {
                            db.ToolToEmployees.Remove(tee.First());
                        }
                    }
                }

                MyTool.Title             = toolView.tool.Title;
                MyTool.Description       = toolView.tool.Description;
                MyTool.Tag               = toolView.tool.Tag;
                MyTool.team              = toolView.tool.team;
                MyTool.GalleryPath       = toolView.tool.GalleryPath;
                MyTool.DocumentationPath = toolView.tool.DocumentationPath;
                MyTool.InstallationPath  = toolView.tool.InstallationPath;
                MyTool.VideoPath         = toolView.tool.VideoPath;

                db.Entry(MyTool).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(toolView));
        }
 public virtual View ResolveView(ToolViewModel viewModel)
 {
     throw new NotImplementedException();
 }
Пример #17
0
 public ToolsViewModel()
 {
     this.Tools        = new List <ToolViewModel>(PluginService.Current.Get <ITool>().Select(x => new ToolViewModel(x)));
     this.SelectedTool = this.Tools.FirstOrDefault();
 }
Пример #18
0
 public ToolsViewModel()
 {
     this.Tools        = new List <ToolViewModel>(PluginHost.Instance.Tools.Select(x => new ToolViewModel(x)));
     this.SelectedTool = this.Tools.FirstOrDefault();
 }
Пример #19
0
 /// <summary>
 /// Class constructor from default parameters.
 /// </summary>
 /// <param name="tool"></param>
 public RegisterToolWindowEventArgs(ToolViewModel tool)
     : this()
 {
     this.Tool = tool;
 }
Пример #20
0
        public PluginMain()
        {
            this.ToolViewModel = new ToolViewModel();

            cacheControl = new Dictionary <string, Tuple <DateTime, DateTime> >();
        }
Пример #21
0
 public void Initialize()
 {
     this.vm = new ToolViewModel(new MapInfoProxy());
 }
Пример #22
0
		public ToolsViewModel()
		{
			this.Tools = new List<ToolViewModel>(PluginService.Current.Get<ITool>().Select(x => new ToolViewModel(x)));
			this.SelectedTool = this.Tools.FirstOrDefault();
		}
Пример #23
0
        public override void LoadMenus()
        {
            var        menuService     = _container.Resolve <IMenuService>();
            var        manager         = _container.Resolve <ICommandManager>();
            var        settingsManager = _container.Resolve <ISettingsManager>();
            var        themeSettings   = _container.Resolve <IThemeSettings>();
            IWorkspace workspace       = _container.Resolve <DefaultWorkspace>();

            ToolViewModel output          = workspace.Tools.First(f => f.ContentId == "Output");
            ToolViewModel error           = workspace.Tools.First(f => f.ContentId == "Error");
            ToolViewModel toolbox         = workspace.Tools.First(f => f.ContentId == "Toolbox");
            ToolViewModel projectExplorer = workspace.Tools.First(f => f.ContentId == "Project Explorer");
            ToolViewModel properties      = workspace.Tools.First(f => f.ContentId == "Properties");


            menuService.Add(new MenuItemViewModel("_File", "_File", 1));
            menuService.Add(new MenuItemViewModel("_Edit", "_Edit", 2));
            menuService.Add(new MenuItemViewModel("_View", "_View", 3));
            menuService.Add(new MenuItemViewModel("_Tools", "_Tools", 4));
            menuService.Add(new MenuItemViewModel("_Help", "_Help", 5));

            menuService.Get("_File").Add(
                (new MenuItemViewModel("_New", "_New", 3,
                                       new BitmapImage(
                                           new Uri(
                                               @"pack://*****:*****@"pack://application:,,,/Mjolnir.IDE.Test;component/Icons/OpenFileDialog_692.png")),
                                       manager.GetCommand("OPEN"),
                                       new KeyGesture(Key.O, ModifierKeys.Control, "Ctrl + O"))));

            menuService.Get("_File").Add(new MenuItemViewModel("_Save", "_Save", 5,
                                                               new BitmapImage(
                                                                   new Uri(
                                                                       @"pack://*****:*****@"pack://application:,,,/Mjolnir.IDE.Test;component/Icons/Saveall_6518.png")),
                                                               manager.GetCommand("SAVEALL"),
                                                               new KeyGesture(Key.A, ModifierKeys.Control, "Ctrl + A")));


            //menuService.Get("_File").Add(new SaveAsMenuItemViewModel("Save As..", 6,
            //                                       new BitmapImage(
            //                                           new Uri(
            //                                               @"pack://*****:*****@"pack://application:,,,/Mjolnir.IDE.Test;component/Icons/Undo_16x.png")),
                                                               ApplicationCommands.Undo));
            menuService.Get("_Edit").Add(new MenuItemViewModel("_Redo", "_Redo", 2,
                                                               new BitmapImage(
                                                                   new Uri(
                                                                       @"pack://*****:*****@"pack://application:,,,/Mjolnir.IDE.Test;component/Icons/Cut_6523.png")),
                                                               ApplicationCommands.Cut));
            menuService.Get("_Edit").Add(new MenuItemViewModel("Copy", "Copy", 21,
                                                               new BitmapImage(
                                                                   new Uri(
                                                                       @"pack://*****:*****@"pack://application:,,,/Mjolnir.IDE.Test;component/Icons/Paste_6520.png")),
                                                               ApplicationCommands.Paste));



            if (output != null)
            {
                menuService.Get("_View")
                .Add(new MenuItemViewModel("_Output", "_Output", 1,
                                           new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Mjolnir.IDE.Core;component/Assets/Error_6206.png")),
                                           new DelegateCommand(ErrorOutput)
                {
                    IsActive = false
                }));
            }


            if (toolbox != null)
            {
                menuService.Get("_View")
                .Add(new MenuItemViewModel("_Toolbox", "_Toolbox", 1,
                                           new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Mjolnir.IDE.Core;component/Assets/toolbox_16xLG.png")),
                                           new DelegateCommand(ToggleProjectExplorer)
                {
                    IsActive = false
                }));
            }

            if (properties != null)
            {
                menuService.Get("_View")
                .Add(new MenuItemViewModel("_Properties", "_Properties", 1,
                                           new BitmapImage(new Uri(@"pack://application:,,,/Mjolnir.IDE.Core;component/Assets/toolbox_16xLG.png")),
                                           new DelegateCommand(ToggleProperties)
                {
                    IsActive = false
                }));
            }



            menuService.Get("_View").Add(new MenuItemViewModel("Themes", "Themes", 1));

            //Set the checkmark of the theme menu's based on which is currently selected
            menuService.Get("_View").Get("Themes")
            .Add(new MenuItemViewModel("Dark", "Dark", 1, null,
                                       new DelegateCommand <string>(ThemeChangeCommand))
            {
                IsCheckable      = true,
                IsChecked        = (themeSettings.SelectedTheme == "Dark"),
                CommandParameter = "Dark"
            });

            menuService.Get("_View").Get("Themes")
            .Add(new MenuItemViewModel("Light", "Light", 2, null,
                                       new DelegateCommand <string>(ThemeChangeCommand))
            {
                IsCheckable      = true,
                IsChecked        = (themeSettings.SelectedTheme == "Light"),
                CommandParameter = "Light"
            });


            menuService.Get("_Tools").Add(new MenuItemViewModel("Settings", "Settings", 1, null, settingsManager.SettingsCommand));
        }
Пример #24
0
 /// <summary>
 /// Class constructor from default parameters.
 /// </summary>
 /// <param name="tool"></param>
 public PublishToolWindowEventArgs(ToolViewModel tool)
     : this()
 {
     Tool = tool;
 }
Пример #25
0
        public void Initialize()
        {
            LoadCommands();
            LoadMenus();
            LoadToolbar();

            IWorkspace workspace = VEFModule.UnityContainer.Resolve(typeof(AbstractWorkspace), "") as AbstractWorkspace;



            VEFModule.UnityContainer.RegisterType <VEXProjectHandler>();
            VEFModule.UnityContainer.RegisterType <VEXProjectViewModel>();
            VEFModule.UnityContainer.RegisterType <VEXProjectView>();

            IContentHandler         handler = VEFModule.UnityContainer.Resolve(typeof(VEXProjectHandler), "") as VEXProjectHandler;
            IContentHandlerRegistry chr     = VEFModule.UnityContainer.Resolve(typeof(IContentHandlerRegistry), "") as IContentHandlerRegistry;

            chr.Register(handler);

            //SceneManager and scenegraph needs socketserver!
            VEFModule.UnityContainer.RegisterType <ISocketServerService, SocketServerManager>(new ContainerControlledLifetimeManager());
            VEFModule.UnityContainer.RegisterType <SocketServerToolViewModel>(new ContainerControlledLifetimeManager());
            var tvm = VEFModule.UnityContainer.Resolve(typeof(SocketServerToolViewModel), "") as SocketServerToolViewModel;

            tvm.IsVisible = false;
            workspace.Tools.Add(tvm);
            ToolViewModel propertiesView = workspace.Tools.First(f => f.ContentId == "SocketServer");

            propertiesView.IsVisible = true;
            var _SocketServerManager = VEFModule.UnityContainer.Resolve(typeof(SocketServerManager), "") as SocketServerManager;

            _SocketServerManager.SocketServerToolModel = tvm.Model as SocketServerToolModel;


            VEFModule.UnityContainer.RegisterType <FileWatcherHandler>();
            VEFModule.UnityContainer.RegisterType <FileWatcherViewModel>();
            VEFModule.UnityContainer.RegisterType <FileWatcherView>();

            IContentHandler fileWatcherHandler = VEFModule.UnityContainer.Resolve(typeof(FileWatcherHandler), "") as FileWatcherHandler;

            chr.Register(fileWatcherHandler);


            //VEFModule.UnityContainer.RegisterType<IFileWatcherService, FileWatcherManager>(new ContainerControlledLifetimeManager());
            //VEFModule.UnityContainer.RegisterType<FileWatcherViewModel>(new ContainerControlledLifetimeManager());
            //var fw_tvm = VEFModule.UnityContainer.Resolve(typeof(FileWatcherViewModel), "") as FileWatcherViewModel;
            //fw_tvm.IsVisible = false;
            //workspace.Tools.Add(fw_tvm);
            //ToolViewModel fwView = workspace.Tools.First(f => f.ContentId == "FileWatcher");
            //fwView.IsVisible = true;
            //var _FileWatcherManager = VEFModule.UnityContainer.Resolve(typeof(FileWatcherManager), "") as FileWatcherManager;
            //_FileWatcherManager.FileWatcherToolModel = fw_tvm.Model as FileWatcherToolModel;


            //------------------------------------------------------
            // REgister SceneService
            //------------------------------------------------------
            VEFModule.UnityContainer.RegisterType <ISceneService, SceneManager>(new ContainerControlledLifetimeManager());

            //------------------------------------------------------
            //Register File Type
            //------------------------------------------------------
            VEFModule.UnityContainer.RegisterType <SceneViewerHandler>();
            VEFModule.UnityContainer.RegisterType <SceneViewModel>();
            VEFModule.UnityContainer.RegisterType <SceneView>();

            IContentHandler sceneViewerhandler = VEFModule.UnityContainer.Resolve(typeof(SceneViewerHandler), "") as SceneViewerHandler;

            chr.Register(sceneViewerhandler);

            VEFModule.UnityContainer.RegisterType <SceneGraphToolViewModel>();
            // _container.RegisterType<SceneToolView>();

            var sgtvm = VEFModule.UnityContainer.Resolve(typeof(SceneGraphToolViewModel), "") as SceneGraphToolViewModel;

            sgtvm.IsVisible = true;
            workspace.Tools.Add(sgtvm);
            ToolViewModel sceneGraphView = workspace.Tools.First(f => f.ContentId == "SceneGraph");

            sceneGraphView.IsVisible = true;


            //------------------------------------------------------
            // REgister AtlasService
            //------------------------------------------------------
            VEFModule.UnityContainer.RegisterType <IAtlasService, AtlasManager>(new ContainerControlledLifetimeManager());

            //------------------------------------------------------
            //Register File Type
            //------------------------------------------------------
            VEFModule.UnityContainer.RegisterType <AtlasHandler>();
            VEFModule.UnityContainer.RegisterType <AtlasViewModel>();
            VEFModule.UnityContainer.RegisterType <AtlasView>();

            IContentHandler AtlasViewerhandler = VEFModule.UnityContainer.Resolve(typeof(AtlasHandler), "") as AtlasHandler;

            chr.Register(AtlasViewerhandler);

            //VEFModule.UnityContainer.RegisterType<AtlasGraphToolViewModel>();
            //// _container.RegisterType<AtlasToolView>();

            //var sgtvm = VEFModule.UnityContainer.Resolve(typeof(AtlasGraphToolViewModel), "") as AtlasGraphToolViewModel;
            //sgtvm.IsVisible = true;
            //workspace.Tools.Add(sgtvm);

            //------------------------------------------------------
            // REgister AtlasService
            //------------------------------------------------------
            VEFModule.UnityContainer.RegisterType <IAnimationEditorService, AnimationEditorManager>(new ContainerControlledLifetimeManager());

            //------------------------------------------------------
            //Register File Type
            //------------------------------------------------------
            VEFModule.UnityContainer.RegisterType <AnimationEditorHandler>();
            VEFModule.UnityContainer.RegisterType <AnimationEditorViewModel>();
            VEFModule.UnityContainer.RegisterType <AnimationEditorView>();

            IContentHandler AnimationEditorViewerhandler = VEFModule.UnityContainer.Resolve(typeof(AnimationEditorHandler), "") as AnimationEditorHandler;

            chr.Register(AnimationEditorViewerhandler);



            //------------------------------------------------------
            // Register DatabaseManager
            //------------------------------------------------------
            VEFModule.UnityContainer.RegisterType <IDatabaseService, DatabaseManager>(new ContainerControlledLifetimeManager());

            LoadSettings();

            RegisterDatabase();
            SetDatabaseContext();



            var shell = VEFModule.UnityContainer.Resolve(typeof(ShellViewMetro), "shell") as ShellViewMetro;

            shell.LoadLayout(); //load avalondock layout
            (shell as Window).Show();
        }
        public ActionResult Create()
        {
            var tool = new ToolViewModel();

            return(this.View(tool));
        }
		public ToolsViewModel()
		{
			this.Tools = new List<ToolViewModel>(PluginHost.Instance.Tools.Select(x => new ToolViewModel(x)));
			this.SelectedTool = this.Tools.FirstOrDefault();
		}
Пример #28
0
        private void LoadMenus()
        {
            new SplashMessageUpdateEvent().Publish(new SplashMessageUpdateEvent()
            {
                Message = "Menus.."
            });
            var           manager         = _container.Resolve <ICommandManager>();
            var           menuService     = _container.Resolve <IMenuService>();
            var           settingsManager = _container.Resolve <ISettingsManager>();
            var           themeSettings   = _container.Resolve <IThemeSettings>();
            var           recentFiles     = _container.Resolve <IRecentViewSettings>();
            IWorkspace    workspace       = _container.Resolve <AbstractWorkspace>();
            ToolViewModel logger          = workspace.Tools.First(f => f.ContentId == "Logger");

            menuService.Add(new MenuItemViewModel("_File", 1));

            menuService.Get("_File").Add(
                (new MenuItemViewModel("_New", 3,
                                       new BitmapImage(
                                           new Uri(
                                               @"pack://*****:*****@"pack://application:,,,/WideMD.Core;component/Icons/OpenFileDialog_692.png")),
                                       manager.GetCommand("OPEN"),
                                       new KeyGesture(Key.O, ModifierKeys.Control, "Ctrl + O"))));
            menuService.Get("_File").Add(new MenuItemViewModel("_Save", 5,
                                                               new BitmapImage(
                                                                   new Uri(
                                                                       @"pack://*****:*****@"pack://application:,,,/WideMD.Core;component/Icons/Save_6530.png")),
                                                                     manager.GetCommand("SAVEAS"), null, false, false, _container));

            menuService.Get("_File").Add(new MenuItemViewModel("Close", 8, null, manager.GetCommand("CLOSE"),
                                                               new KeyGesture(Key.F4, ModifierKeys.Control, "Ctrl + F4")));

            menuService.Get("_File").Add(recentFiles.RecentMenu);

            menuService.Get("_File").Add(new MenuItemViewModel("E_xit", 101, null, manager.GetCommand("EXIT"),
                                                               new KeyGesture(Key.F4, ModifierKeys.Alt, "Alt + F4")));


            menuService.Add(new MenuItemViewModel("_Edit", 2));
            menuService.Get("_Edit").Add(new MenuItemViewModel("_Undo", 1,
                                                               new BitmapImage(
                                                                   new Uri(
                                                                       @"pack://*****:*****@"pack://application:,,,/WideMD.Core;component/Icons/Redo_16x.png")),
                                                               ApplicationCommands.Redo));
            menuService.Get("_Edit").Add(MenuItemViewModel.Separator(15));
            menuService.Get("_Edit").Add(new MenuItemViewModel("Cut", 20,
                                                               new BitmapImage(
                                                                   new Uri(
                                                                       @"pack://*****:*****@"pack://application:,,,/WideMD.Core;component/Icons/Copy_6524.png")),
                                                               ApplicationCommands.Copy));
            menuService.Get("_Edit").Add(new MenuItemViewModel("_Paste", 22,
                                                               new BitmapImage(
                                                                   new Uri(
                                                                       @"pack://*****:*****@"pack://application:,,,/WideMD.Core;component/Icons/Undo_16x.png")),
                                                                   manager.GetCommand("LOGSHOW"))
                {
                    IsCheckable = true, IsChecked = logger.IsVisible
                });
            }

            menuService.Get("_View").Add(new MenuItemViewModel("Themes", 1));

            //Set the checkmark of the theme menu's based on which is currently selected
            menuService.Get("_View").Get("Themes").Add(new MenuItemViewModel("Dark", 1, null,
                                                                             manager.GetCommand("THEMECHANGE"))
            {
                IsCheckable      = true,
                IsChecked        = (themeSettings.SelectedTheme == "Dark"),
                CommandParameter = "Dark"
            });
            menuService.Get("_View").Get("Themes").Add(new MenuItemViewModel("Light", 2, null,
                                                                             manager.GetCommand("THEMECHANGE"))
            {
                IsCheckable      = true,
                IsChecked        = (themeSettings.SelectedTheme == "Light"),
                CommandParameter = "Light"
            });

            menuService.Add(new MenuItemViewModel("_Tools", 4));
            menuService.Get("_Tools").Add(new MenuItemViewModel("Settings", 1, null, settingsManager.SettingsCommand));

            menuService.Add(new MenuItemViewModel("_Help", 4));
        }
Пример #29
0
 public Plugin()
 {
     this.vm = new ToolViewModel(this);
 }
Пример #30
0
        public override void Initialize()
        {
            base.Initialize();
            //  EventAggregator.PublishOnUIThread(new SplashMessageUpdateEvent { Message = "Loading Wide Core Module" });
            // EventAggregator.GetEvent<SplashMessageUpdateEvent>().Publish(new SplashMessageUpdateEvent { Message = "Loading Wide Core Module" });
            //not per default!
            //_container.RegisterType<TextViewModel>();
            //_container.RegisterType<TextModel>();
            //_container.RegisterType<TextView>();
            //      _container.RegisterType<AllFileHandler>();
            //UnityContainer.RegisterType<IThemeSettings, ThemeSettingsWPF>();
            UnityContainer.RegisterType <IThemeSettings, ThemeSettings>();
            UnityContainer.RegisterType <IRecentViewSettings, RecentViewSettings>(new ContainerControlledLifetimeManager());
            UnityContainer.RegisterType <IWindowPositionSettings, WindowPositionSettings>(new ContainerControlledLifetimeManager());
            UnityContainer.RegisterType <IToolbarPositionSettings, ToolbarPositionSettings>(new ContainerControlledLifetimeManager());
            UnityContainer.RegisterType <ICommandManager, VEF.Model.Services.CommandManager>(new ContainerControlledLifetimeManager());
            UnityContainer.RegisterType <IContentHandlerRegistry, ContentHandlerRegistry>(new ContainerControlledLifetimeManager());

            UnityContainer.RegisterType <IStatusbarService, VEFStatusbar>(new ContainerControlledLifetimeManager());
            UnityContainer.RegisterType <IThemeManager, ThemeManager>(new ContainerControlledLifetimeManager());
            UnityContainer.RegisterType <IToolbarService, ToolbarService>(new ContainerControlledLifetimeManager());
            UnityContainer.RegisterType <IMenuService, MenuItemViewModel>(new ContainerControlledLifetimeManager(),
                                                                          new InjectionConstructor(
                                                                              new InjectionParameter(typeof(string), "$MAIN$"),
                                                                              new InjectionParameter(typeof(int), 1),
                                                                              new InjectionParameter(typeof(IImageSource), null),
                                                                              new InjectionParameter(typeof(ICommand),
                                                                                                     null),
                                                                              new InjectionParameter(
                                                                                  typeof(IKeyGesture), null),
                                                                              new InjectionParameter(typeof(bool), false),
                                                                              new InjectionParameter(typeof(bool), false)));
            UnityContainer.RegisterType <ToolbarViewModel>(
                new InjectionConstructor(new InjectionParameter(typeof(string), "$MAIN$"),
                                         new InjectionParameter(typeof(int), 1),
                                         new InjectionParameter(typeof(IImageSource), null),
                                         new InjectionParameter(typeof(ICommand), null),
                                         new InjectionParameter(typeof(bool), false)));

            UnityContainer.RegisterType <ISettingsManager, SettingsManager>(new ContainerControlledLifetimeManager());
            UnityContainer.RegisterType <IOpenDocumentService, OpenDocumentService>(new ContainerControlledLifetimeManager());
            UnityContainer.RegisterType <ILoggerService, LoggerService>(new ContainerControlledLifetimeManager());
            //AppCommands();
            //LoadSettings();

            ////Try resolving a workspace
            //try
            //{
            //    _container.Resolve<AbstractWorkspace>();
            //}
            //catch
            //{
            //    _container.RegisterType<AbstractWorkspace, Workspace>(new ContainerControlledLifetimeManager());
            //}

            //// Try resolving a logger service - if not found, then register the NLog service
            //try
            //{
            //    _container.Resolve<ILoggerService>();
            //}
            //catch
            //{
            //    _container.RegisterType<ILoggerService, NLogService>(new ContainerControlledLifetimeManager());
            //}
            // if (IsMetro)
            // {
            //Use MahApps Metro window
            VEFModule.UnityContainer.RegisterType <IShell, ShellViewMetro>(new ContainerControlledLifetimeManager());
            // }

            var commandManager = VEFModule.UnityContainer.Resolve(typeof(ICommandManager), "") as ICommandManager;
            var registry       = VEFModule.UnityContainer.Resolve(typeof(ContentHandlerRegistry), "") as ContentHandlerRegistry;

            //TODO: Check if you can hook up to the Workspace.ActiveDocument.CloseCommand
            var closeCommand = new DelegateCommand <object>(CloseDocument, CanExecuteCloseDocument);

            commandManager.RegisterCommand("CLOSE", closeCommand);


            commandManager.RegisterCommand("NEW", registry.NewCommand);


            VEFModule.UnityContainer.RegisterType <IPropertiesService, PropertiesManager>(new ContainerControlledLifetimeManager());
            VEFModule.UnityContainer.RegisterType <PropertiesToolViewModel>();
            IWorkspace workspace = VEFModule.UnityContainer.Resolve(typeof(AbstractWorkspace), "") as AbstractWorkspace;
            var        tvm       = VEFModule.UnityContainer.Resolve(typeof(PropertiesToolViewModel), "") as PropertiesToolViewModel;

            tvm.IsVisible = false;
            workspace.Tools.Add(tvm);
            ToolViewModel propertiesView = workspace.Tools.First(f => f.ContentId == "Properties");

            propertiesView.IsVisible = true; //todo as menu item!!

            var loggerToolViewModel = VEFModule.UnityContainer.Resolve(typeof(LoggerToolViewModel), "") as LoggerToolViewModel;

            workspace.Tools.Add(loggerToolViewModel);
            ToolViewModel loggerView = workspace.Tools.First(f => f.ContentId == "Logger");

            loggerView.IsVisible = true;                                                                                     //todo as menu item!!

            VEFModule.UnityContainer.RegisterType <IOutputService, OutputService>(new ContainerControlledLifetimeManager()); //new ContainerControlledLifetimeManager());
            VEFModule.UnityContainer.RegisterType <OutputViewModel>();
            var outputViewModel = VEFModule.UnityContainer.Resolve(typeof(OutputViewModel), "") as OutputViewModel;

            workspace.Tools.Add(outputViewModel);
            ToolViewModel outputView = workspace.Tools.First(f => f.ContentId == "Output");

            outputView.IsVisible = true; //todo as menu item!!

            //------------------------------------------------------
            //Register File Type
            //------------------------------------------------------
            VEFModule.UnityContainer.RegisterType <XMLHandler>();
            VEFModule.UnityContainer.RegisterType <XMLViewModel>();
            VEFModule.UnityContainer.RegisterType <XMLView>();

            IContentHandler handler = VEFModule.UnityContainer.Resolve(typeof(XMLHandler), "") as XMLHandler;

            (VEFModule.UnityContainer.Resolve(typeof(ContentHandlerRegistry), "") as ContentHandlerRegistry).Register(handler);


            //------------------------------------------------------
            // REgister Project-FileExplorer
            //------------------------------------------------------
            VEFModule.UnityContainer.RegisterType <IProjectTreeService, ProjectTreeManager>(new ContainerControlledLifetimeManager());
            VEFModule.UnityContainer.RegisterType <ProjectToolViewModel>();
            workspace.Tools.Add(VEFModule.UnityContainer.Resolve(typeof(ProjectToolViewModel), "") as ProjectToolViewModel);
            ToolViewModel projectView = workspace.Tools.First(f => f.ContentId == "Project");

            projectView.IsVisible = true; //todo as menu item!!

            //load layout after all modules are loaded!
            //var shell = VEFModule.UnityContainer.Resolve(typeof(ShellViewMetro), "shell") as ShellViewMetro;
            //shell.LoadLayout(); //load avalondock layout

            var manager       = VEFModule.UnityContainer.Resolve(typeof(ThemeManagerWPF), "ThemeManagerWPF") as ThemeManagerWPF;
            var themeSettings = VEFModule.UnityContainer.Resolve(typeof(ThemeSettings), "ThemeSettings") as ThemeSettings;

            //   var win = VEFModule.UnityContainer.Resolve<IShell>() as Window;
            manager.AddTheme(new LightTheme());
            //  manager.AddTheme(new DarkTheme());

            manager.SetCurrent("Light");

            //need to load core module first -> Show needs the style resources
            //  (shell as Window).Show();
        }