コード例 #1
0
ファイル: AppRunner.cs プロジェクト: magicfor/Tools
 public void DeleteConfig()
 {
     configs.Remove(selectedConfig);
     RegistrySaver.RemoveRegistryValue(RegistrySaver.configList, selectedConfig);
     AppLogger.Add("Configuration file [" + selectedConfig + "] deleted");
     selectedConfig = configs.FirstOrDefault();
 }
コード例 #2
0
ファイル: AppRunner.cs プロジェクト: magicfor/Tools
        public void DeleteApplication()
        {
            applications.Remove(selectedApplication);
            RegistrySaver.RemoveRegistryValue(RegistrySaver.appList, selectedApplication);
            AppLogger.Add("Application [" + selectedApplication + "] deleted");

            selectedApplication = null;
        }
コード例 #3
0
ファイル: AppRunner.cs プロジェクト: magicfor/Tools
 public void DeleteNodes(List <ActiveNode> nodes)
 {
     foreach (ActiveNode node in nodes)
     {
         RegistrySaver.RemoveRegistryValue(RegistrySaver.nodeList, node.key);
         activeNodes.Remove(node);
         AppLogger.Add("Node [" + node.key + "] deleted");
     }
 }
コード例 #4
0
ファイル: AppRunner.cs プロジェクト: fingerx/Tools
 //Reloading all config lists
 private void InitConfigLists()
 {
     applications = RegistrySaver.ReadStringsFromRegistry(RegistrySaver.appList);
     AppLogger.Add("Applications loaded successfully");
     configs = RegistrySaver.ReadStringsFromRegistry(RegistrySaver.configList);
     SetSelectedConfig();
     AppLogger.Add("Configs loaded successfully");
     AppLogger.Add("List of Active nodes loaded successfully");
     selectedCamera = cameras.SingleOrDefault(x => x == "camera_dynamic");
 }
コード例 #5
0
ファイル: AppRunner.cs プロジェクト: magicfor/Tools
        public void SetSelectedConfig()
        {
            selectedConfig = string.Empty;
            string selected = RegistrySaver.FindSelectedRegValue(RegistrySaver.configList);

            if (!string.IsNullOrEmpty(selected))
            {
                selectedConfig = configs.Find(x => x == selected);
            }
        }
コード例 #6
0
 void CreateConfig()
 {
     RegistrySaver.RemoveAllRegistryValues(RegistrySaver.configName);
     currentConfig    = new Config();
     this.DataContext = currentConfig;
     //crutch. for refactoring
     currentConfig.selectedSceneNodeView = null;
     AppLogger.Add("New config inited");
     SetTitle();
 }
コード例 #7
0
ファイル: AppRunner.cs プロジェクト: magicfor/Tools
        //private void RewriteListToFile(string filePath, List<string> list)
        //{
        //    try
        //    {
        //        File.WriteAllLines(filePath, list);
        //    }
        //    catch(Exception exception)
        //    {
        //        AppLogger.Add("Can't renew file [" + RegistrySaver.nodeList + "]. EXCEPTION: " + exception.Message);
        //    }
        //}

        public void AddApplication(string appPath)
        {
            if (!applications.Contains(appPath))
            {
                applications.Add(appPath);
                RegistrySaver.AddRegistryValue(RegistrySaver.appList, appPath);
                AppLogger.Add("Application [" + appPath + "] added to list");
            }
            else
            {
                AppLogger.Add("WARNING! Application [" + appPath + "] is already in the list");
            }
        }
コード例 #8
0
        private void SetDefaultConfig()
        {
            string configPath = RegistrySaver.ReadStringFromRegistry(RegistrySaver.configName);

            if (string.IsNullOrEmpty(configPath))
            {
                CreateConfig();
            }
            else
            {
                ConfigFileParser(configPath);
            }
        }
コード例 #9
0
ファイル: AppRunner.cs プロジェクト: magicfor/Tools
 public void AddConfig(string configPath)
 {
     try
     {
         configs.Add(configPath);
         selectedConfig = configs.Find(x => x == configPath);
         RegistrySaver.AddRegistryValue(RegistrySaver.configList, configPath);
         ChangeConfigSelection(configPath);
         AppLogger.Add("Configuration file [" + configPath + "] added to list");
     }
     catch (Exception)
     {
         AppLogger.Add("ERROR! Can not add configuration file [" + configPath + "] to list");
     }
 }
コード例 #10
0
 private void Save(bool isSaveAs)
 {
     if (currentConfig.Validate())
     {
         try
         {
             string currentFileName = RegistrySaver.ReadStringFromRegistry(RegistrySaver.configName);
             if (!isSaveAs && File.Exists(currentFileName))
             {
                 File.WriteAllText(currentFileName, currentConfig.CreateConfig());
             }
             else
             {
                 SaveFileDialog saveFileDialog = new SaveFileDialog();
                 saveFileDialog.Filter = configFileExtention;
                 if (saveFileDialog.ShowDialog() == true)
                 {
                     currentFileName    = saveFileDialog.FileName;
                     currentConfig.name = Path.GetFileNameWithoutExtension(currentFileName);
                     RegistrySaver.RemoveAllRegistryValues(RegistrySaver.configName);
                     RegistrySaver.AddRegistryValue(RegistrySaver.configName, currentFileName);
                     File.WriteAllText(currentFileName, currentConfig.CreateConfig());
                 }
             }
             SetTitle();
             AppLogger.Add("Config saved to " + currentFileName);
         }
         catch (Exception exception)
         {
             InfoDialog errorDialog = new InfoDialog("Error! \nCan not save configuration file. \nSee exception message in Log");
             errorDialog.Owner  = this;
             errorDialog.Width  = 350;
             errorDialog.Height = 200;
             errorDialog.Show();
             AppLogger.Add("ERROR! Can not save config to file. EXCEPTION: " + exception.Message);
         }
     }
     else
     {
         InfoDialog errorDialog = new InfoDialog("Error! \nCan not save configuration file. \nWrong config. See errors in Log");
         errorDialog.Owner  = this;
         errorDialog.Width  = 350;
         errorDialog.Height = 200;
         errorDialog.Show();
         AppLogger.Add("ERROR! Can not save config to file. Errors in configuration");
     }
 }
コード例 #11
0
ファイル: AppRunner.cs プロジェクト: magicfor/Tools
 private void InitOptions()
 {
     try
     {
         selectedOpenGlParam = openGlParams.First(x => x.Key == RegistrySaver.ReadStringValue(RegistrySaver.paramsList, RegistrySaver.openGLName));
     }
     catch (Exception)
     {
         selectedOpenGlParam = openGlParams.SingleOrDefault(x => x.Key == "OpenGL3");
     }
     additionalParams     = RegistrySaver.ReadStringValue(RegistrySaver.paramsList, RegistrySaver.additionalParamsName);
     isStereo             = RegistrySaver.ReadBoolValue(RegistrySaver.paramsList, RegistrySaver.isStereoName);
     isNoSound            = RegistrySaver.ReadBoolValue(RegistrySaver.paramsList, RegistrySaver.isNoSoundName);
     isUseAllCores        = RegistrySaver.ReadBoolValue(RegistrySaver.paramsList, RegistrySaver.isAllCoresName);
     isFixedSeed          = RegistrySaver.ReadBoolValue(RegistrySaver.paramsList, RegistrySaver.isFixedSeedName);
     isNotextureStreaming = RegistrySaver.ReadBoolValue(RegistrySaver.paramsList, RegistrySaver.isNoTextureStreamingName);
     AppLogger.Add("Application Options inited");
 }
コード例 #12
0
ファイル: AppRunner.cs プロジェクト: magicfor/Tools
 public void ChangeConfigSelection(string configPath)
 {
     try
     {
         foreach (string config in configs)
         {
             if (config != configPath)
             {
                 RegistrySaver.UpdateRegistry(RegistrySaver.configList, config, false);
             }
             else
             {
                 RegistrySaver.UpdateRegistry(RegistrySaver.configList, config, true);
             }
         }
     }
     catch (Exception exception)
     {
         AppLogger.Add("ERROR while changing config selection. EXCEPTION: " + exception.Message);
     }
 }
コード例 #13
0
ファイル: AppRunner.cs プロジェクト: magicfor/Tools
 public bool AddNode(string node)
 {
     try
     {
         if (!activeNodes.Exists(x => x.key == node))
         {
             activeNodes.Add(new ActiveNode(node, true));
             RegistrySaver.AddRegistryValue(RegistrySaver.nodeList, node);
             AppLogger.Add("Node [" + node + "] added to list");
             return(true);
         }
         else
         {
             AppLogger.Add("WARNING! Node [" + node + "] is already in the list");
             return(false);
         }
     }
     catch (Exception e)
     {
         AppLogger.Add("ERROR! can not add node [" + node + "] to list");
         return(false);
     }
 }
コード例 #14
0
        //Config file parser
        public static Config Parse(string filePath, Config currentConfig)
        {
            // refactoring needed
            List <string> inputLines       = new List <string>();
            List <string> sceneNodeLines   = new List <string>();
            List <string> screenLines      = new List <string>();
            List <string> viewportLines    = new List <string>();
            List <string> clusterNodeLines = new List <string>();
            List <string> cameraLines      = new List <string>();
            List <string> generalLines     = new List <string>();
            List <string> stereoLines      = new List <string>();
            List <string> debugLines       = new List <string>();

            try
            {
                foreach (string line in File.ReadLines(filePath))
                {
                    if (line == string.Empty || line.First() == '#')
                    {
                        //Do nothing
                    }
                    else
                    {
                        if (line.Contains("[input]"))
                        {
                            inputLines.Add(line);
                        }
                        if (line.Contains("[scene_node]"))
                        {
                            sceneNodeLines.Add(line);
                        }
                        if (line.Contains("[screen]"))
                        {
                            screenLines.Add(line);
                        }
                        if (line.Contains("[viewport]"))
                        {
                            viewportLines.Add(line);
                        }
                        if (line.Contains("[cluster_node]"))
                        {
                            clusterNodeLines.Add(line);
                        }
                        if (line.Contains("[camera]"))
                        {
                            cameraLines.Add(line);
                        }
                        if (line.Contains("[general]"))
                        {
                            generalLines.Add(line);
                        }
                        if (line.Contains("[stereo]"))
                        {
                            stereoLines.Add(line);
                        }
                        if (line.Contains("[debug]"))
                        {
                            debugLines.Add(line);
                        }
                        if (line.Contains("[render]"))
                        {
                            //todo
                        }
                        if (line.Contains("[custom]"))
                        {
                            //todo
                        }
                    }
                }
                foreach (string line in viewportLines)
                {
                    currentConfig.ViewportParse(line);
                }
                foreach (string line in generalLines)
                {
                    currentConfig.GeneralParse(line);
                }
                foreach (string line in stereoLines)
                {
                    currentConfig.StereoParse(line);
                }
                foreach (string line in debugLines)
                {
                    currentConfig.DebugParse(line);
                }
                foreach (string line in inputLines)
                {
                    currentConfig.InputsParse(line);
                }
                foreach (string line in cameraLines)
                {
                    currentConfig.CameraParse(line);
                }
                foreach (string line in sceneNodeLines)
                {
                    currentConfig.SceneNodeParse(line);
                }
                foreach (string line in screenLines)
                {
                    currentConfig.ScreenParse(line);
                }
                foreach (string line in clusterNodeLines)
                {
                    currentConfig.ClusterNodeParse(line);
                }

                currentConfig.sceneNodesView = currentConfig.ConvertSceneNodeList(currentConfig.sceneNodes);
                currentConfig.name           = Path.GetFileNameWithoutExtension(filePath);
                AppLogger.Add("Config " + currentConfig.name + " loaded");
                RegistrySaver.AddRegistryValue(RegistrySaver.configName, filePath);
            }
            catch (FileNotFoundException e)
            {
                AppLogger.Add("ERROR! Config " + currentConfig.name + "not found!");
            }
            catch (System.ArgumentException e)
            {
                AppLogger.Add("ERROR! Config " + currentConfig.name + "not found!");
            }

            return(currentConfig);
        }
コード例 #15
0
        //Config file parser
        private void ConfigFileParser(string filePath)
        {
            // refactoring needed
            CreateConfig();
            List <string> inputLines       = new List <string>();
            List <string> sceneNodeLines   = new List <string>();
            List <string> screenLines      = new List <string>();
            List <string> viewportLines    = new List <string>();
            List <string> clusterNodeLines = new List <string>();
            List <string> cameraLines      = new List <string>();
            List <string> generalLines     = new List <string>();
            List <string> stereoLines      = new List <string>();
            List <string> debugLines       = new List <string>();

            try
            {
                foreach (string line in File.ReadLines(filePath))
                {
                    if (line == string.Empty || line.First() == '#')
                    {
                        //Do nothing
                    }
                    else
                    {
                        if (line.Contains("[input]"))
                        {
                            inputLines.Add(line);
                        }
                        if (line.Contains("[scene_node]"))
                        {
                            sceneNodeLines.Add(line);
                        }
                        if (line.Contains("[screen]"))
                        {
                            screenLines.Add(line);
                        }
                        if (line.Contains("[viewport]"))
                        {
                            viewportLines.Add(line);
                        }
                        if (line.Contains("[cluster_node]"))
                        {
                            clusterNodeLines.Add(line);
                        }
                        if (line.Contains("[camera]"))
                        {
                            cameraLines.Add(line);
                        }
                        if (line.Contains("[general]"))
                        {
                            generalLines.Add(line);
                        }
                        if (line.Contains("[stereo]"))
                        {
                            stereoLines.Add(line);
                        }
                        if (line.Contains("[debug]"))
                        {
                            debugLines.Add(line);
                        }
                        if (line.Contains("[render]"))
                        {
                            //todo
                        }
                        if (line.Contains("[custom]"))
                        {
                            //todo
                        }
                    }
                }
                foreach (string line in viewportLines)
                {
                    currentConfig.ViewportParse(line);
                }
                foreach (string line in generalLines)
                {
                    currentConfig.GeneralParse(line);
                }
                foreach (string line in stereoLines)
                {
                    currentConfig.StereoParse(line);
                }
                foreach (string line in debugLines)
                {
                    currentConfig.DebugParse(line);
                }
                foreach (string line in inputLines)
                {
                    currentConfig.InputsParse(line);
                }
                foreach (string line in cameraLines)
                {
                    currentConfig.CameraParse(line);
                }
                foreach (string line in sceneNodeLines)
                {
                    currentConfig.SceneNodeParse(line);
                }
                foreach (string line in screenLines)
                {
                    currentConfig.ScreenParse(line);
                }
                foreach (string line in clusterNodeLines)
                {
                    currentConfig.ClusterNodeParse(line);
                }

                currentConfig.sceneNodesView = currentConfig.ConvertSceneNodeList(currentConfig.sceneNodes);
                currentConfig.name           = Path.GetFileNameWithoutExtension(filePath);
                AppLogger.Add("Config " + currentConfig.name + " loaded");
                RegistrySaver.AddRegistryValue(RegistrySaver.configName, filePath);


                //Set first items in listboxes and treeview as default if existed
                currentConfig.SelectFirstItems();
                RefreshUiControls();
                try
                {
                    ((CollectionViewSource)this.Resources["cvsInputTrackers"]).View.Refresh();
                }
                catch (NullReferenceException)
                {
                }
                //sceneNodeTrackerCb.SelectedIndex = -1;
                SetTitle();
            }
            catch (FileNotFoundException e)
            {
                AppLogger.Add("ERROR! Config " + currentConfig.name + "not found!");
            }
        }