Exemple #1
0
        //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");
            }
        }
Exemple #2
0
 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");
     }
 }
Exemple #3
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");
     }
 }
Exemple #4
0
 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);
     }
 }
Exemple #5
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);
        }
Exemple #6
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!");
            }
        }