Пример #1
0
        /// <summary>
        /// Set the current item
        /// </summary>
        /// <param name="guid">The guid of the item</param>
        /// <returns>true if the new item is set, false otherwise</returns>
        //public bool SetCurrent(Guid guid)
        //{
        //    var item = Items.Where(x => x.Guid == guid);
        //    if (item.Any())
        //    {
        //        IItem newItem = item.First();
        //        CurrentItem = newItem;

        //        //ResourceDictionary theme = Application.Current.MainWindow.Resources.MergedDictionaries[0];
        //        //ResourceDictionary appTheme = Application.Current.Resources.MergedDictionaries.Count > 0
        //        //                                  ? Application.Current.Resources.MergedDictionaries[0]
        //        //                                  : null;
        //        //theme.BeginInit();
        //        //theme.MergedDictionaries.Clear();
        //        //if (appTheme != null)
        //        //{
        //        //    appTheme.BeginInit();
        //        //    appTheme.MergedDictionaries.Clear();
        //        //}
        //        //else
        //        //{
        //        //    appTheme = new ResourceDictionary();
        //        //    appTheme.BeginInit();
        //        //    Application.Current.Resources.MergedDictionaries.Add(appTheme);
        //        //}
        //        //foreach (Uri uri in newTheme.UriList)
        //        //{
        //        //    ResourceDictionary newDict = new ResourceDictionary {Source = uri};
        //        //    /*AvalonDock and menu style needs to move to the application
        //        //     * 1. AvalonDock needs global styles as floatable windows can be created
        //        //     * 2. Menu's need global style as context menu can be created
        //        //    */
        //        //    if (uri.ToString().Contains("AvalonDock") ||
        //        //        uri.ToString().Contains("Wide;component/Interfaces/Styles/VS2012/Menu.xaml"))
        //        //    {
        //        //        appTheme.MergedDictionaries.Add(newDict);
        //        //    }
        //        //    else
        //        //    {
        //        //        theme.MergedDictionaries.Add(newDict);
        //        //    }
        //        //}
        //        //appTheme.EndInit();
        //        //theme.EndInit();
        //        _logger.Log("projectfile item set to " + newItem.Name, LogCategory.Info, LogPriority.None);
        //        _eventAggregator.GetEvent<ItemChangeEvent>().Publish(newItem);
        //    }
        //    return false;
        //}

        /// <summary>
        /// Adds a base item to the project-file manager
        /// </summary>
        /// <param name="theme">The item to add</param>
        /// <returns>true, if successful - false, otherwise</returns>
        public bool AddScene(SceneDataModel scene)
        {
            if (!Scenes.Contains(scene))
            {
                Scenes.Add(scene);
                return(true);
            }
            return(false);
        }
Пример #2
0
        public ContentViewModel NewContent(object parameter)
        {
            var vm    = VEFModule.UnityContainer.Resolve(typeof(SceneViewModel), "") as SceneViewModel;
            var model = VEFModule.UnityContainer.Resolve(typeof(SceneDataModel), "") as SceneDataModel;
            var view  = VEFModule.UnityContainer.Resolve(typeof(SceneView), "") as SceneView;

            //Model details
            _loggerService.Log("Creating a new simple file using SceneHandler", 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 = "Scene New";
            (vm.View as UserControl).DataContext = model;
            vm.SetHandler(this);
            model.SetDirty(true);

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

            IProjectTreeService pfExplorerService = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService;
            ISceneService       sceneService      = VEFModule.UnityContainer.Resolve(typeof(ISceneService), "") as ISceneService;

            PItem parent = null;

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

            SceneDataModel newScene = new SceneDataModel()
            {
                Name = "Scene NEW", ContentID = "SceneID:##:"
            };

            newScene.Parent = parent;

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

            sceneService.Scenes.Add(newScene);
            //  sceneService.SelectedScene = newScene;
            newScene.Open(-1);


            return(vm);
        }
Пример #3
0
        public void Execute(object parameter)
        {
            SceneCategoryModel parent = parameter as SceneCategoryModel;

            //  sceneCategoryModel.Items.Add(new SceneCategoryModel() { Parent = sceneCategoryModel, UnityContainer = sceneCategoryModel.UnityContainer, Name = "Scene 1", ContentID = "SceneID:##:" }); //CreateScene();

            ushort id = 0;

            if (parent != null)
            {
                var tableModel = parent as DBTableModel;
                if (tableModel != null)
                {
                    id = tableModel.AutoIncrement();
                }
            }
            else
            {
                return;
            }

            parent.IsDirty = true;

            if (id > 0)
            {
                SceneDataModel pom = new SceneDataModel()
                {
                    Parent = parent, Name = "Scene Obj NEW", ContentID = "SceneID:##:" + id, SceneID = id
                };

                pom.Create();
                parent.Items.Add(pom);
            }
            else
            {
                var log = VEFModule.UnityContainer.Resolve(typeof(ILoggerService), "") as ILoggerService;
                log.Log("Error: CmdCreateScene id =  (" + id.ToString() + ")", LogCategory.Error, LogPriority.High);
            }
        }
Пример #4
0
 public CmdDeleteScene(SceneDataModel model)
 {
     m_model = model;
 }
Пример #5
0
 public CmdCreateFile(SceneDataModel model)
 {
     m_model = model;
 }
Пример #6
0
 public CmdSaveToDB(SceneDataModel pm)
 {
     mpm = pm;
 }
Пример #7
0
 public SceneItemEventArgs(SceneDataModel sceneItem)
 {
     SceneItem = sceneItem;
 }
Пример #8
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)
            {
                SceneDataModel model = null;
                SceneViewModel vm    = VEFModule.UnityContainer.Resolve(typeof(SceneViewModel), "") as SceneViewModel;
                var            view  = VEFModule.UnityContainer.Resolve(typeof(SceneView), "") as SceneView;

                try
                {
                    ISceneService       sceneService      = VEFModule.UnityContainer.Resolve(typeof(ISceneService), "") as ISceneService;
                    IProjectTreeService pfExplorerService = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService;

                    //          string[] split = Regex.Split(info.ToString(), ":##:");
                    //if (split.Count() == 2)
                    //{
                    //    string identifier = split[0];
                    //    string ID = split[1];
                    //    if (identifier == "SceneID")
                    //    {
                    var scene = sceneService.Scenes.Where(x => x.ContentID == info.ToString());
                    if (scene.Any())
                    {
                        sceneService.SelectedScene = scene.First();
                        sceneService.SelectedScene.Open(info);
                    }
                    else //new scene
                    {
                        //    SceneDataModel newScene = new SceneDataModel() { Name = "Scene NEW", ContentID = "SceneID:##:" };
                        // newScene.Parent = parent;

                        if (pfExplorerService.SelectedItem is SceneDataModel)
                        {    // pfExplorerService.SelectedItem.Items.Add(newScene);
                            var newScene = pfExplorerService.SelectedItem as SceneDataModel;
                            if (newScene != null)
                            {
                                sceneService.Scenes.Add(newScene);
                                //  sceneService.SelectedScene = newScene;
                                newScene.Open(-1);

                                model = newScene;
                            }
                        }
                    }

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

                    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 = model.Name ?? "Scene";//model.nae  // Path.GetFileName("Scene gefunden");
                (vm.View as UserControl).DataContext = model;

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