Exemple #1
0
        /// <summary>
        /// Opens a file and returns the corresponding VEXProjectViewModel
        /// </summary>
        /// <param name="info">The string location of the file</param>
        /// <returns>The <see cref="VEXProjectViewModel"/> for the file.</returns>
        public ContentViewModel OpenContent(object info, object param)
        {
            var location = info as string;

            if (location != null)
            {
                try
                {
                    var mProjectTreeService = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService;
                    var vm = VEFModule.UnityContainer.Resolve(typeof(VEXProjectViewModel), "") as VEXProjectViewModel;

                    var model = ObjectSerialize.Deserialize <VEXProjectModel>(location);

                    if (model == null)
                    {
                        model = VEFModule.UnityContainer.Resolve(typeof(VEXProjectModel), "") as VEXProjectModel;
                    }

                    var view = VEFModule.UnityContainer.Resolve(typeof(VEXProjectView), "") as VEXProjectView;


                    //Model details
                    model.SetLocation(info);

                    //Set the model and view
                    vm.SetModel(model);
                    vm.SetView(view);
                    vm.Title = Path.GetFileName(location);
                    (vm.View as UserControl).DataContext = model;



                    model.Open(location);

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

                    mProjectTreeService.SetAsRoot(model);


                    return(vm);
                }
                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();
            }
            return(null);
        }
Exemple #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // ObservableCollection<ConnectionViewModel> test = new ObservableCollection<ConnectionViewModel>();

                AnimationNodeViewModel evm  = new AnimationNodeViewModel();
                OutputNodeViewModel    onvm = new OutputNodeViewModel();

                OutputConnectorViewModel opcvm = new OutputConnectorViewModel()
                {
                    Element = evm
                };
                InputConnectorViewModel ipcvm = new InputConnectorViewModel()
                {
                    Element = onvm
                };

                var cvm = new ConnectionViewModel()
                {
                    From = opcvm, To = ipcvm
                };
                //test.Add();

                List <Type> knownTypes = new List <Type>()
                {
                    typeof(AnimationNodeViewModel), typeof(OutputNodeViewModel)
                };

                AnimationComponent ac = new AnimationComponent();
                ac.FB_AnimationComponent.AnimationBlendTree.AnimNodes.Add(evm);
                ac.FB_AnimationComponent.AnimationBlendTree.AnimNodes.Add(onvm);
                ac.FB_AnimationComponent.AnimationBlendTree.NodeConnections.Add(cvm);

                ObjectSerialize.Serialize(ac, "./test", knownTypes);

                //   var testRes = ObjectSerialize.Deserialize<AnimationComponent>("./test");
                var testRes = ObjectSerialize.Deserialize <VEXProjectModel>(@"F:\Projekte\coop\XGame\data\Editor\New VEX Project xyy.oideProj");
            }
            catch (Exception ex)
            {
            }
        }