Пример #1
0
        public ContentViewModel NewContent(object parameter)
        {
            var vm    = VEFModule.UnityContainer.Resolve(typeof(AnimationEditorViewModel), "") as AnimationEditorViewModel;
            var model = VEFModule.UnityContainer.Resolve(typeof(AnimationEditorModel), "") as AnimationEditorModel;
            var view  = VEFModule.UnityContainer.Resolve(typeof(AnimationEditorView), "") as AnimationEditorView;

            //Model details
            _loggerService.Log("Creating a new simple file using AnimationEditorHandler", LogCategory.Info, LogPriority.Low);

            //Clear the undo stack
            //   model.Document.UndoStack.ClearAll();

            //Set the model and view
            vm.SetModel(model);
            vm.SetView(view);
            vm.Title = "AnimationEditor";
            (vm.View as UserControl).DataContext = model;
            vm.SetHandler(this);
            model.SetDirty(true);

            model.SetLocation("AnimationEditorID:##:");

            IProjectTreeService    pfExplorerService      = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService;
            AnimationEditorManager AnimationEditorService = VEFModule.UnityContainer.Resolve(typeof(AnimationEditorManager), "") as AnimationEditorManager;

            AnimationEditorService.AnimationEditors.Add(model);


            model.GraphViewModel = view.GraphControl.DataContext as GraphViewModel;
            AnimationEditorService.AnimationEditors[0].GraphViewModel.AddElement <OutputNodeViewModel>(300, 200);



            PItem parent = null;

            if (pfExplorerService.SelectedItem != null)
            {
                parent = pfExplorerService.SelectedItem;
            }

            AnimationEditorModel newAnimationEditor = new AnimationEditorModel();

            newAnimationEditor.Parent = parent;

            if (pfExplorerService.SelectedItem != null)
            {
                pfExplorerService.SelectedItem.Items.Add(newAnimationEditor);
            }

            AnimationEditorService.AnimationEditors.Add(newAnimationEditor);
            //  AnimationEditorService.SelectedAnimationEditor = newAnimationEditor;
            newAnimationEditor.Open(-1);


            return(vm);
        }
Пример #2
0
        public void Execute(object parameter)
        {
            IWorkspace workspace = VEFModule.UnityContainer.Resolve <AbstractWorkspace>();

            IOpenDocumentService odS = VEFModule.UnityContainer.Resolve <IOpenDocumentService>();

            AnimationEditorViewModel openValue = odS.OpenFromID("AnimationEditorID:##:", true) as AnimationEditorViewModel; ////item.ContentID, true);
            var model = openValue.Model as AnimationEditorModel;

            model.AnimationBlendTree = _AnimationBlendTree;
            AnimationEditorManager AnimationEditorService = VEFModule.UnityContainer.Resolve(typeof(AnimationEditorManager), "") as AnimationEditorManager;

            AnimationEditorService.AnimationEditors[0].GraphViewModel.Elements    = _AnimationBlendTree.AnimNodes;
            AnimationEditorService.AnimationEditors[0].GraphViewModel.Connections = _AnimationBlendTree.NodeConnections;

            if (!AnimationEditorService.AnimationEditors[0].GraphViewModel.Elements.Where(x => x is OutputNodeViewModel).Any())
            {
                AnimationEditorService.AnimationEditors[0].GraphViewModel.AddElement <OutputNodeViewModel>(300, 200);
            }

            //foreach(var connection in _AnimationComponent.FB_AnimationComponent.NodeConnections)
            //{
            //    if (connection.OutputConnectorID != 0)
            //    {
            //        var resultOutputConnector = _AnimationComponent.FB_AnimationComponent.AnimNodes.Where(x => x.OutputConnector.ConnectorID == connection.OutputConnectorID);
            //        if (resultOutputConnector.Any())
            //            connection.From = resultOutputConnector.First().OutputConnector;
            //    }
            //    else if (connection.InputConnectorID != 0)
            //    {
            //        foreach(var ele in _AnimationComponent.FB_AnimationComponent.AnimNodes)
            //        {
            //            var resultInputConnector = ele.InputConnectors.Where(x =>  x.ConnectorID == connection.InputConnectorID);
            //            if (resultInputConnector.Any())
            //                connection.To = resultInputConnector.First();
            //        }


            //    }
            //}

            //GraphViewModel test = new GraphViewModel();
            ////  openValue.GraphViewModel
            //test.Elements = _AnimationComponent.FB_AnimationComponent.AnimNodes;
            //test.Connections = _AnimationComponent.FB_AnimationComponent.AnimNodes;

            //  _AnimationComponent.SendToSocket();
        }
Пример #3
0
        /// <summary>
        /// Opens a file and returns the corresponding MDViewModel
        /// </summary>
        /// <param name="info">The string location of the file</param>
        /// <returns>The <see cref="MDViewModel"/> for the file.</returns>
        public ContentViewModel OpenContent(object info, object param)
        {
            var location = info as string;

            if (location != null)
            {
                AnimationEditorModel     model = null;
                AnimationEditorViewModel vm    = VEFModule.UnityContainer.Resolve(typeof(AnimationEditorViewModel), "") as AnimationEditorViewModel;
                var view = VEFModule.UnityContainer.Resolve(typeof(AnimationEditorView), "") as AnimationEditorView;

                try
                {
                    //  IAnimationEditorService AnimationEditorService = VEFModule.UnityContainer.Resolve(typeof(IAnimationEditorService), "") as IAnimationEditorService;
                    IProjectTreeService pfExplorerService = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService;

                    AnimationEditorManager AnimationEditorService = VEFModule.UnityContainer.Resolve(typeof(AnimationEditorManager), "") as AnimationEditorManager;


                    //          string[] split = Regex.Split(info.ToString(), ":##:");
                    //if (split.Count() == 2)
                    //{
                    //    string identifier = split[0];
                    //    string ID = split[1];
                    //    if (identifier == "AnimationEditorID")
                    //    {
                    var AnimationEditor = AnimationEditorService.AnimationEditors.Where(x => x.ContentID == info.ToString());
                    if (AnimationEditor.Any())
                    {
                        AnimationEditorService.SelectedAnimationEditor = AnimationEditor.First();
                        AnimationEditorService.SelectedAnimationEditor.Open(info);
                    }
                    else //new AnimationEditor
                    {
                        //    AnimationEditorModel newAnimationEditor = new AnimationEditorModel() { Name = "AnimationEditor NEW", ContentID = "AnimationEditorID:##:" };
                        // newAnimationEditor.Parent = parent;

                        if (pfExplorerService.SelectedItem is AnimationEditorModel)
                        {    // pfExplorerService.SelectedItem.Items.Add(newAnimationEditor);
                            var newAnimationEditor = pfExplorerService.SelectedItem as AnimationEditorModel;
                            if (newAnimationEditor != null)
                            {
                                AnimationEditorService.AnimationEditors.Add(newAnimationEditor);
                                //  AnimationEditorService.SelectedAnimationEditor = newAnimationEditor;
                                newAnimationEditor.Open(-1);

                                model = newAnimationEditor;
                            }
                        }
                    }

                    //Model details
                    if (model == null)
                    {
                        model = VEFModule.UnityContainer.Resolve(typeof(AnimationEditorModel), "") as AnimationEditorModel;
                        AnimationEditorService.AnimationEditors.Add(model);
                    }

                    model.GraphViewModel = view.GraphControl.DataContext as GraphViewModel;
                    AnimationEditorService.AnimationEditors[0].GraphViewModel.AddElement <OutputNodeViewModel>(300, 200);


                    model.SetLocation(info);

                    //  model.SetLocation("AuftragID:##:" + info + "");

                    //      model.Document.Text = File.ReadAllText(location);
                    model.SetDirty(true);
                    //   }
                }



                catch (Exception exception)
                {
                    _loggerService.Log(exception.Message, LogCategory.Exception, LogPriority.High);
                    _loggerService.Log(exception.StackTrace, LogCategory.Exception, LogPriority.High);
                    return(null);
                }

                //Clear the undo stack
                // model.Document.UndoStack.ClearAll();

                //Set the model and view
                vm.SetModel(model);
                vm.SetView(view);
                vm.Title = "AnimationEditorViewer";//model.nae  // Path.GetFileName("AnimationEditor gefunden");
                (vm.View as UserControl).DataContext = model;

                return(vm);
            }
            return(null);
        }