コード例 #1
0
        private void ctrlBtnEventNew_Click(object sender, RoutedEventArgs e)
        {
            ClusterEventWindow Wnd = new ClusterEventWindow();

            Wnd.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Wnd.Owner = this;

            Wnd.AvailableCategories = GetAvailableCategories();
            Wnd.AvailableTypes      = GetAvailableTypes();
            Wnd.AvailableNames      = GetAvailableNames();

            bool?RetVal = Wnd.ShowDialog();

            if (RetVal.HasValue && RetVal == true)
            {
                Dictionary <string, string> ArgMap = new Dictionary <string, string>();
                ClusterEvent NewEvt = new ClusterEvent(Wnd.SelectedCategory, Wnd.SelectedType, Wnd.SelectedName, Wnd.GetArgDictionary());
                NewEvt.RebuildJsonStringForGui();
                ClusterEvents.Add(NewEvt);

                RegistrySaver.AddRegistryValue(RegistrySaver.RegCategoryClusterEvents, NewEvt.SerializeToString());

                AppLogger.Log("New cluster event stored: " + NewEvt.ToString());
            }
            else
            {
                // Nothing to do
            }
        }
コード例 #2
0
 public void AddApplication(string appPath)
 {
     if (!Applications.Contains(appPath))
     {
         Applications.Add(appPath);
         RegistrySaver.AddRegistryValue(RegistrySaver.RegCategoryAppList, appPath);
         AppLogger.Log("Application [" + appPath + "] added to list");
     }
     else
     {
         AppLogger.Log("WARNING! Application [" + appPath + "] is already in the list");
     }
 }
コード例 #3
0
        private void Save(bool isSaveAs)
        {
            //TEMP: only launcher tab is available
            return;

            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");
            }
        }
コード例 #4
0
 public void AddConfig(string configPath)
 {
     try
     {
         Configs.Add(configPath);
         SelectedConfig = Configs.Find(x => x == configPath);
         RegistrySaver.AddRegistryValue(RegistrySaver.RegCategoryConfigList, configPath);
         ChangeConfigSelection(configPath);
         AppLogger.Log("Configuration file [" + configPath + "] added to list");
     }
     catch (Exception)
     {
         AppLogger.Log("ERROR! Can not add configuration file [" + configPath + "] to list");
     }
 }
コード例 #5
0
        private void ctrlBtnEventModify_Click(object sender, RoutedEventArgs e)
        {
            if (ctrlListClusterEvents.SelectedItems.Count > 0)
            {
                List <ClusterEvent> ItemsToModify = new List <ClusterEvent>();

                foreach (ClusterEvent Evt in ctrlListClusterEvents.SelectedItems)
                {
                    ItemsToModify.Add(Evt);
                }

                foreach (ClusterEvent Evt in ItemsToModify)
                {
                    int Idx = ClusterEvents.IndexOf(Evt);
                    if (Idx >= 0)
                    {
                        ClusterEventWindow Wnd = new ClusterEventWindow();
                        Wnd.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                        Wnd.Owner = this;

                        Wnd.AvailableCategories = GetAvailableCategories();
                        Wnd.AvailableTypes      = GetAvailableTypes();
                        Wnd.AvailableNames      = GetAvailableNames();
                        Wnd.SelectedCategory    = Evt.Category;
                        Wnd.SelectedType        = Evt.Type;
                        Wnd.SelectedName        = Evt.Name;
                        Wnd.SetArgDictionary(Evt.Parameters);

                        bool?RetVal = Wnd.ShowDialog();
                        if (RetVal.HasValue && RetVal == true)
                        {
                            RegistrySaver.RemoveRegistryValue(RegistrySaver.RegCategoryClusterEvents, ClusterEvents[Idx].SerializeToString());
                            ClusterEvents[Idx] = new ClusterEvent(Wnd.SelectedCategory, Wnd.SelectedType, Wnd.SelectedName, Wnd.GetArgDictionary());
                            RegistrySaver.AddRegistryValue(RegistrySaver.RegCategoryClusterEvents, ClusterEvents[Idx].SerializeToString());
                        }
                    }
                }

                UpdateJsonInfo();
            }
        }
コード例 #6
0
        //Config file parser
        public static VRConfig Parse(string filePath, VRConfig 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.ToLower().Contains("[input]"))
                        {
                            inputLines.Add(line);
                        }
                        if (line.ToLower().Contains("[scene_node]"))
                        {
                            sceneNodeLines.Add(line);
                        }
                        if (line.ToLower().Contains("[screen]"))
                        {
                            screenLines.Add(line);
                        }
                        if (line.ToLower().Contains("[viewport]"))
                        {
                            viewportLines.Add(line);
                        }
                        if (line.ToLower().Contains("[cluster_node]"))
                        {
                            clusterNodeLines.Add(line);
                        }
                        if (line.ToLower().Contains("[camera]"))
                        {
                            cameraLines.Add(line);
                        }
                        if (line.ToLower().Contains("[general]"))
                        {
                            generalLines.Add(line);
                        }
                        if (line.ToLower().Contains("[stereo]"))
                        {
                            stereoLines.Add(line);
                        }
                        if (line.ToLower().Contains("[debug]"))
                        {
                            debugLines.Add(line);
                        }
                        if (line.ToLower().Contains("[render]"))
                        {
                            //todo
                        }
                        if (line.ToLower().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)
            {
                AppLogger.Add("ERROR! Config " + currentConfig.name + "not found!");
            }
            catch (System.ArgumentException)
            {
                AppLogger.Add("ERROR! Config " + currentConfig.name + "not found!");
            }

            return(currentConfig);
        }