コード例 #1
0
        private void btnForceTrigger_Click(object sender, RoutedEventArgs e)
        {
            SourceFileItem file = _dataGrid.SelectedItem as SourceFileItem;

            if (file != null)
            {
                FileWatcherModel.Execute(file);
            }

            return;

            var mPropertiesService = VEFModule.UnityContainer.Resolve(typeof(IPropertiesService), "") as IPropertiesService;

            SourceFileItem filex = _dataGrid.SelectedItem as SourceFileItem;

            if (filex.FileType == FileType.fbx)
            {
                FBXFileConverter test = new FBXFileConverter();
                test.Convert(filex.SourceFilePath, filex.DestinationFolder, filex.DestinationFileName);

                string fbxfilename = @"F:\Projekte\coop\XGame\_devFolder\Work\Character\[email protected]";
                string skeletonfilename = @"F:\Projekte\coop\XGame\data\assets\TestModel.SKELETON";
                string meshfilename = @"F:\Projekte\coop\XGame\data\assets\TestModel.MESH";
                string logfilename = "log.txt";
                string animname = "WalkBase";
                int    start = Int32.MinValue; int stop = Int32.MaxValue; float rate = 0;

                DLL_FBXToOgre tmp = new DLL_FBXToOgre();
                tmp.Test_AddFBXAnimationToExisting(fbxfilename, skeletonfilename, meshfilename, logfilename,
                                                   animname, start, stop, rate);
            }
        }
コード例 #2
0
 public bool AddFileWatcher(FileWatcherModel FileWatcher)
 {
     if (!FileWatchers.Contains(FileWatcher))
     {
         FileWatchers.Add(FileWatcher);
         return(true);
     }
     return(false);
 }
コード例 #3
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            Form f = new GetTTName();

            if (f.ShowDialog() == DialogResult.OK)
            {
                IVsHierarchy hierarchy = null;
                uint         itemid    = VSConstants.VSITEMID_NIL;

                if (!IsSingleProjectItemSelection(out hierarchy, out itemid))
                {
                    return;
                }
                // Get the file path
                string itemFullPath = null;
                ((IVsProject)hierarchy).GetMkDocument(itemid, out itemFullPath);
                var configFile = new FileInfo(itemFullPath);

                FileWatcherModel m = new FileWatcherModel();

                FileSystemWatcher fileWatcher = new FileSystemWatcher(configFile.DirectoryName);
                fileWatcher.Filter              = configFile.Name;
                fileWatcher.Renamed            += Helper.Fw_Changed;
                fileWatcher.EnableRaisingEvents = true;
                m.watcher       = fileWatcher;
                m.InputFileName = configFile.FullName;

                var         dte      = Handler.DTE;
                Array       ar       = dte.ActiveSolutionProjects as Array;
                ProjectItem projItem = null;
                foreach (Project item in ar)
                {
                    projItem = Helper.LocateProjectItem(item.ProjectItems, m.InputFileName);
                    if (projItem != null)
                    {
                        break;
                    }
                }
                m.TargetItem = projItem;
                Helper.FileWatchers.Add(m);

                Solution      sol         = Handler.DTE.Solution;
                DirectoryInfo solutionLoc = new DirectoryInfo(Path.GetDirectoryName(sol.FullName));

                string relativePathTarget = Helper.GetRelativePath(solutionLoc.FullName, m.TargetItem.FileNames[0]);
                string relativePathInput  = Helper.GetRelativePath(solutionLoc.FullName, m.InputFileName);

                string path = Path.GetDirectoryName(sol.FullName);
                File.AppendAllText(Path.Combine(path, "watcher.config"), relativePathInput + ";" + relativePathTarget);
            }
        }
コード例 #4
0
        private void SolutionEvents_Opened()
        {
            Array    ar  = Handler.DTE.ActiveSolutionProjects as Array;
            Solution sol = Handler.DTE.Solution;

            if (File.Exists(Path.Combine(Path.GetDirectoryName(sol.FullName), "watcher.config")))
            {
                string[] lines = File.ReadAllLines(Path.Combine(Path.GetDirectoryName(sol.FullName), "watcher.config"));
                foreach (string s in lines)
                {
                    string[] split  = s.Split(';');
                    FileInfo input  = new FileInfo(Path.Combine(Path.GetDirectoryName(sol.FullName), split[0].TrimStart('\\')));
                    FileInfo target = new FileInfo(Path.Combine(Path.GetDirectoryName(sol.FullName), split[1].TrimStart('\\')));
                    if (File.Exists(input.FullName) && File.Exists(target.FullName))
                    {
                        FileWatcherModel  m           = new FileWatcherModel();
                        FileSystemWatcher fileWatcher = new FileSystemWatcher(input.DirectoryName);
                        fileWatcher.Filter              = input.Name;
                        fileWatcher.Renamed            += Helper.Fw_Changed;
                        fileWatcher.EnableRaisingEvents = true;
                        m.watcher       = fileWatcher;
                        m.InputFileName = input.Name;
                        ProjectItem projItem = null;
                        foreach (Project item in ar)
                        {
                            projItem = Helper.LocateProjectItem(item.ProjectItems, target.Name);
                            if (projItem != null)
                            {
                                break;
                            }
                        }
                        m.TargetItem = projItem;
                        Helper.FileWatchers.Add(m);
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Opens a file and returns the corresponding FileWatcherViewModel
        /// </summary>
        /// <param name="info">The string location of the file</param>
        /// <returns>The <see cref="FileWatcherViewModel"/> 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(FileWatcherViewModel), "") as FileWatcherViewModel;

                    FileWatcherModel model = null;// VEFModule.UnityContainer.Resolve(typeof(FileWatcherModel), "") as FileWatcherModel;

                    FileWatcherManager  fileWatcherService = VEFModule.UnityContainer.Resolve(typeof(FileWatcherManager), "") as FileWatcherManager;
                    IProjectTreeService pfExplorerService  = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService;


                    var fileWatcher = fileWatcherService.FileWatchers.Where(x => x.ContentID == info.ToString());
                    if (fileWatcher.Any())
                    {
                        fileWatcherService.SelectedFileWatcher = fileWatcher.First();
                        fileWatcherService.SelectedFileWatcher.Open(info);
                    }
                    else //new fileWatcher
                    {
                        //    fileWatcherDataModel newfileWatcher = new fileWatcherDataModel() { Name = "fileWatcher NEW", ContentID = "fileWatcherID:##:" };
                        // newfileWatcher.Parent = parent;

                        if (pfExplorerService.SelectedItem is FileWatcherModel)
                        {    // pfExplorerService.SelectedItem.Items.Add(newfileWatcher);
                            var newfileWatcher = pfExplorerService.SelectedItem as FileWatcherModel;
                            if (newfileWatcher != null)
                            {
                                fileWatcherService.FileWatchers.Add(newfileWatcher);
                                //  fileWatcherService.SelectedfileWatcher = newfileWatcher;
                                newfileWatcher.Open(-1);

                                model = newfileWatcher;
                            }
                        }
                    }

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

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


                    //Model details
                    model.SetLocation(info);

                    //Set the model and view
                    vm.SetModel(model);
                    vm.SetView(view);
                    vm.Title = "FileWatcher_" + 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);
        }
コード例 #6
0
        public void Execute(object parameter)
        {
            Type t = parameter as Type;

            //to create the objects i need the parameter data!!!!
            //         mpm.Save();
            //if (t.Name == "VEXZipArchive")
            //{
            //    mpm.Items.Add(new VEXZipArchive() { Parent = mpm, UnityContainer = mpm.UnityContainer, Name = "Unknown.zip" });
            //   // Type instance = (Type)Activator.CreateInstance(t);
            //   // object obj = t.GetConstructor(new Type[] { }).Invoke(new object[] { });
            // //   mpm.Items.Add(obj as IItem);
            //}
            if (t.Name == "VEXDBFileModel")
            {
                VEXDBFileModel dbData = new VEXDBFileModel()
                {
                    Parent = mpm, Name = "DBFile"
                };

                DBEntitiesModel objects = new DBEntitiesModel()
                {
                    Parent = dbData, Name = "Entities"
                };
                objects.IsExpanded = true;


                // EntityCategoryModel staticObjects = new EntityCategoryModel() { Parent = dbData, Name = "EntityCategory" };
                // objects.Items.Add(staticObjects);
                //CharacterCategoryModel characterObjects = new CharacterCategoryModel() { Parent = dbData, Name = "Characters" };
                //objects.Items.Add(characterObjects);

                //SpawnPointCategoryModel allSpawns = new SpawnPointCategoryModel() { Parent = dbData, Name = "SpawnPoints" };
                //SpawnPointCategoryModel allTrigger = new SpawnPointCategoryModel() { Parent = dbData,  Name = "Triggers" };
                //SpawnPointCategoryModel allLights = new SpawnPointCategoryModel() { Parent = dbData,  Name = "Lights" };
                //SpawnPointCategoryModel allSkies = new SpawnPointCategoryModel() { Parent = dbData,  Name = "Skies" };
                //SpawnPointCategoryModel allSounds = new SpawnPointCategoryModel() { Parent = dbData,  Name = "Sounds" };
                //StaticObjectCategoryModel DynamicObjects = new StaticObjectCategoryModel() { Parent = dbData, Name = "Dynamics" };

                //objects.Items.Add(allTrigger);
                //objects.Items.Add(allSpawns);
                //objects.Items.Add(allLights);
                //objects.Items.Add(allSkies);
                //objects.Items.Add(allSounds);
                //objects.Items.Add(DynamicObjects);



                dbData.Items.Add(objects);

                SceneCategoryModel scenes = new SceneCategoryModel()
                {
                    Parent = dbData, Name = "Scenes"
                };
                scenes.IsExpanded = true;
                dbData.Items.Add(scenes);


                mpm.Items.Add(dbData);
                dbData.IsExpanded = true;
            }
            else if (t.Name == "VEXSettings")
            {
                VEXSettings settings = new VEXSettings()
                {
                    Parent = mpm, Name = "VEXSettings"
                };

                mpm.Items.Add(settings);
                settings.IsExpanded = true;
            }
            else if (t.Name == "FileWatcherModel")
            {
                FileWatcherModel fileWatcher = new FileWatcherModel()
                {
                    Parent = mpm, Name = "FileWatcherModel", ContentID = "FileWatcherID:##:0"
                };

                mpm.Items.Add(fileWatcher);
                fileWatcher.IsExpanded = true;
            }
            //else if (t.Name == "VEX_RFS")
            //{
            //    mpm.AssetFolder = @"F:\Projekte\coop\VEX\data"; //todo set per propertygrid
            //    var assetBrowser = mpm.UnityContainer.Resolve<IAssetBrowserTreeService>();
            //    VEX_RFS fileAssets = new VEX_RFS() { Parent = mpm, UnityContainer = mpm.UnityContainer, Name = "Assets VFS", ContentID = "RootVFSID:##:" };
            //    fileAssets.Open(mpm.UnityContainer, mpm.AssetFolder);
            //    //        m_Items.Add(fileAssets);
            //    assetBrowser.SetAsRoot(fileAssets);

            //    mpm.Items.Add(new VEX_RFS() { Parent = mpm, UnityContainer = mpm.UnityContainer, Name = "RFS" });
            //}
        }