Exemplo n.º 1
0
        //Add Scene node
        private void addSceneNode_Click(object sender, RoutedEventArgs e)
        {
            SceneNode newItem = new SceneNode();

            if (currentConfig.selectedSceneNodeView != null)
            {
                newItem.parent = currentConfig.selectedSceneNodeView.node;
            }
            SceneNodeView newViewItem = new SceneNodeView(newItem);

            newViewItem.isSelected = true;
            currentConfig.sceneNodes.Add(newItem);

            SceneNodeView parentNode = currentConfig.FindParentNode(newViewItem);

            if (parentNode == null)
            {
                currentConfig.sceneNodesView.Add(newViewItem);
            }
            else
            {
                parentNode.children.Add(newViewItem);
                parentNode.isExpanded = true;
            }
            AppLogger.Add("New scene node added");
            AppLogger.Add("WARNING! Change default values");
            sceneNodesTreeView.Items.Refresh();
            sceneNodeIdTb.Focus();
        }
Exemplo n.º 2
0
 public void DeleteConfig()
 {
     configs.Remove(selectedConfig);
     RegistrySaver.RemoveRegistryValue(RegistrySaver.configList, selectedConfig);
     AppLogger.Add("Configuration file [" + selectedConfig + "] deleted");
     selectedConfig = configs.FirstOrDefault();
 }
Exemplo n.º 3
0
        private async void SendDaemonCommand(string nodeAddress, string cmd)
        {
            TcpClient nodeClient = new TcpClient();

            try
            {
                await nodeClient.ConnectAsync(nodeAddress, nodeListenerPort);

                NetworkStream networkStream      = nodeClient.GetStream();
                StreamWriter  clientStreamWriter = new StreamWriter(networkStream);

                if (networkStream.CanWrite)
                {
                    clientStreamWriter.Write(cmd);
                    clientStreamWriter.Flush();
                }
                else
                {
                    AppLogger.Add("Can't write to client on node [" + nodeAddress + "]");
                }

                nodeClient.Close();
            }
            catch (Exception exception)
            {
                AppLogger.Add("Can't connect to node " + nodeAddress + ". EXCEPTION: " + exception.Message);
            }
        }
Exemplo n.º 4
0
        private void CreateZipLogs(string zipFilename, List <string> files)
        {
            if (files.Count == 0)
            {
                return;
            }

            string currentDir = Path.GetDirectoryName(zipFilename);

            string dirForZip = currentDir + temporaryZipDir;

            // create tmp-dir
            Directory.CreateDirectory(dirForZip);

            // copy to temporary folder for zip
            foreach (string file in files)
            {
                File.Copy(file, dirForZip + Path.GetFileName(file));
            }

            try
            {
                // pack it
                ZipFile.CreateFromDirectory(dirForZip, zipFilename, CompressionLevel.Optimal, false);

                // remove tmp dir and all files after ZIP
                RemoveAllRecursively(dirForZip);
                Directory.Delete(dirForZip);
            }
            catch (Exception exception)
            {
                AppLogger.Add("CreateZipLogs. EXCEPTION: " + exception.Message);
            }
        }
Exemplo n.º 5
0
        public void DeleteApplication()
        {
            applications.Remove(selectedApplication);
            RegistrySaver.RemoveRegistryValue(RegistrySaver.appList, selectedApplication);
            AppLogger.Add("Application [" + selectedApplication + "] deleted");

            selectedApplication = null;
        }
Exemplo n.º 6
0
 private void addNodeButton_Click(object sender, RoutedEventArgs e)
 {
     currentConfig.clusterNodes.Add(new ClusterNode());
     currentConfig.selectedNode = currentConfig.clusterNodes.LastOrDefault();
     nodesListBox.Items.Refresh();
     nodeIdTb.Focus();
     AppLogger.Add("New cluster node added");
     AppLogger.Add("WARNING! Change default values");
 }
Exemplo n.º 7
0
 private void addViewportButton_Click(object sender, RoutedEventArgs e)
 {
     currentConfig.viewports.Add(new Viewport());
     currentConfig.selectedViewport = currentConfig.viewports.LastOrDefault();
     viewportsListBox.Items.Refresh();
     viewportsCb.Items.Refresh();
     viewportIdTb.Focus();
     AppLogger.Add("New viewport added");
     AppLogger.Add("WARNING! Change default values");
 }
Exemplo n.º 8
0
 private void addScreenButton_Click(object sender, RoutedEventArgs e)
 {
     currentConfig.screens.Add(new Screen());
     currentConfig.selectedScreen = currentConfig.screens.LastOrDefault();
     screensListBox.Items.Refresh();
     screensCb.Items.Refresh();
     screenIdTb.Focus();
     AppLogger.Add("New screen added");
     AppLogger.Add("WARNING! Change default values");
 }
Exemplo n.º 9
0
 void CreateConfig()
 {
     RegistrySaver.RemoveAllRegistryValues(RegistrySaver.configName);
     currentConfig    = new VRConfig();
     this.DataContext = currentConfig;
     //crutch. for refactoring
     currentConfig.selectedSceneNodeView = null;
     AppLogger.Add("New config initialized");
     SetTitle();
     SetViewportPreview();
 }
Exemplo n.º 10
0
 private void CleanLogFolders(List <ClusterNode> nodes)
 {
     foreach (ClusterNode node in nodes)
     {
         string dirPath = GetLogFolder(node.address);
         if (dirPath != null)
         {
             RemoveAllRecursively(dirPath);
             AppLogger.Add("Removed all files in : " + dirPath);
         }
     }
 }
Exemplo n.º 11
0
        private void deleteNodeButton_Click(object sender, RoutedEventArgs e)
        {
            if (currentConfig.selectedNode != null)
            {
                var id            = currentConfig.selectedNode.id;
                int selectedIndex = currentConfig.clusterNodes.IndexOf(currentConfig.selectedNode);
                currentConfig.clusterNodes.RemoveAt(selectedIndex);
                currentConfig.selectedNode = currentConfig.clusterNodes.FirstOrDefault();

                AppLogger.Add("Cluster node " + id + " deleted");
            }
            nodesListBox.Items.Refresh();
        }
Exemplo n.º 12
0
 //Delete Scene Node
 private void deleteSceneNode_Click(object sender, RoutedEventArgs e)
 {
     if (sceneNodesTreeView.SelectedItem != null)
     {
         SceneNodeView item = (SceneNodeView)sceneNodesTreeView.SelectedItem;
         var           id   = item.node.id;
         currentConfig.DeleteSceneNode(item);
         currentConfig.selectedSceneNodeView = currentConfig.sceneNodesView.FirstOrDefault();
         AppLogger.Add("Scene Node " + id + " deleted");
     }
     sceneNodesTreeView.Items.Refresh();
     parentWallsCb.Items.Refresh();
 }
Exemplo n.º 13
0
 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");
     }
 }
Exemplo n.º 14
0
        private void deleteScreenButton_Click(object sender, RoutedEventArgs e)
        {
            if (currentConfig.selectedScreen != null)
            {
                var id            = currentConfig.selectedScreen.id;
                int selectedIndex = currentConfig.screens.IndexOf(currentConfig.selectedScreen);
                currentConfig.screens.RemoveAt(selectedIndex);
                currentConfig.selectedScreen = currentConfig.screens.FirstOrDefault();

                AppLogger.Add("Screen " + id + " deleted");
            }
            screensListBox.Items.Refresh();
            screensCb.Items.Refresh();
        }
Exemplo n.º 15
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");
            }
        }
Exemplo n.º 16
0
 private void isMasterCheckBox_Checked(object sender, RoutedEventArgs e)
 {
     foreach (ClusterNode node in currentConfig.clusterNodes)
     {
         if (node == currentConfig.selectedNode)
         {
             node.isMaster = true;
             AppLogger.Add("Cluster node " + currentConfig.selectedNode.id + " set as master node");
         }
         else
         {
             node.isMaster = false;
         }
     }
 }
Exemplo n.º 17
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");
     }
 }
Exemplo n.º 18
0
        private void deleteViewportButton_Click(object sender, RoutedEventArgs e)
        {
            if (currentConfig.selectedViewport != null)
            {
                var id            = currentConfig.selectedViewport.id;
                int selectedIndex = currentConfig.viewports.IndexOf(currentConfig.selectedViewport);

                currentConfig.viewports.RemoveAt(selectedIndex);
                currentConfig.selectedViewport = currentConfig.viewports.FirstOrDefault();

                AppLogger.Add("Viewport " + id + " deleted");
            }
            viewportsListBox.Items.Refresh();
            viewportsCb.Items.Refresh();
        }
Exemplo n.º 19
0
        private void addInputBtn_Click(object sender, RoutedEventArgs e)
        {
            InputTypeDialog dialogChooser = new InputTypeDialog();

            dialogChooser.Owner = this;
            dialogChooser.Title = "Select new input type";
            dialogChooser.ShowDialog();
            if (dialogChooser.DialogResult.Value)
            {
                string type = dialogChooser.inputType;
                addInput(type);
                inputIdTb.Focus();
                AppLogger.Add("New " + type + " input added");
                AppLogger.Add("WARNING! Change default values");
            }
        }
Exemplo n.º 20
0
        //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");

            try
            {
                selectedCamera = cameras.First(x => x == RegistrySaver.ReadStringValue(RegistrySaver.paramsList, RegistrySaver.curCamera));
            }
            catch (Exception)
            {
                selectedCamera = cameras.SingleOrDefault(x => x == "camera_dynamic");
            }
        }
Exemplo n.º 21
0
        private List <string> ReadConfigFile(string confFilePath)
        {
            List <string> infoList = new List <string>();

            try
            {
                string[] lines = System.IO.File.ReadAllLines(confFilePath);
                infoList = lines.ToList();

                AppLogger.Add("Read file [" + confFilePath + "] finished.");
            }
            catch (Exception exception)
            {
                AppLogger.Add("Can't read file [" + confFilePath + "]. EXCEPTION: " + exception.Message);
            }

            return(infoList);
        }
Exemplo n.º 22
0
 private void delInputBtn_Click(object sender, RoutedEventArgs e)
 {
     if (currentConfig.selectedInput != null)
     {
         var id            = currentConfig.selectedInput.id;
         int selectedIndex = currentConfig.inputs.IndexOf(currentConfig.selectedInput);
         currentConfig.inputs.RemoveAt(selectedIndex);
         AppLogger.Add(currentConfig.selectedInput.type + " input " + id + " deleted");
         currentConfig.selectedInput = currentConfig.inputs.FirstOrDefault();
         try
         {
             ((CollectionViewSource)this.Resources["cvsInputTrackers"]).View.Refresh();
         }
         catch (NullReferenceException)
         {
         }
         RefreshUiControls();
     }
 }
Exemplo n.º 23
0
 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);
     }
 }
Exemplo n.º 24
0
        private void RemoveAllRecursively(string rootDir)
        {
            try
            {
                // remove all files
                var allFilesToDelete = Directory.EnumerateFiles(rootDir, "*.*", SearchOption.AllDirectories);
                foreach (var file in allFilesToDelete)
                {
                    File.Delete(file);
                }

                // remove all directories
                DirectoryInfo diRoot = new DirectoryInfo(rootDir);
                foreach (DirectoryInfo subDir in diRoot.GetDirectories())
                {
                    subDir.Delete(true);
                }
            }
            catch (Exception exception)
            {
                AppLogger.Add("RemoveAllRecursively. EXCEPTION: " + exception.Message);
            }
        }
Exemplo n.º 25
0
        private void InitOptions()
        {
            try
            {
                selectedCamera = cameras.First(x => x == RegistrySaver.ReadStringValue(RegistrySaver.paramsList, RegistrySaver.curCamera));
            }
            catch (Exception)
            {
                selectedCamera = cameras.SingleOrDefault(x => x == "camera_dynamic");
            }

            try
            {
                selectedRenderApiParam = renderApiParams.First(x => x.Key == RegistrySaver.ReadStringValue(RegistrySaver.paramsList, RegistrySaver.renderApiName));
            }
            catch (Exception)
            {
                selectedRenderApiParam = renderApiParams.SingleOrDefault(x => x.Key == "OpenGL3");
            }

            try
            {
                selectedRenderModeParam = renderModeParams.First(x => x.Key == RegistrySaver.ReadStringValue(RegistrySaver.paramsList, RegistrySaver.renderModeName));
            }
            catch (Exception)
            {
                selectedRenderApiParam = renderModeParams.SingleOrDefault(x => x.Key == "Mono");
            }


            additionalParams     = RegistrySaver.ReadStringValue(RegistrySaver.paramsList, RegistrySaver.additionalParamsName);
            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 initialized");
        }
Exemplo n.º 26
0
        private string GetLogFolder(string node)
        {
            string fullpath = null;
            //get path
            string appPath = selectedApplication;

            // remove drive-name, like      [C:]
            if (appPath != null)
            {
                //fast crutch with localhost. refactoring needed!!
                if (node != "127.0.0.1")
                {
                    appPath = appPath.Substring(2, appPath.Length - 2);
                }
                // remove filename and extension
                string logPath = Path.GetDirectoryName(appPath);

                // replace slash to back-slash
                logPath.Replace("/", "\\");

                string projectName = Path.GetFileNameWithoutExtension(appPath);
                if (node != "127.0.0.1")
                {
                    fullpath = @"\\" + node + logPath + @"\" + projectName + @"\Saved\Logs\";
                }
                else
                {
                    fullpath = logPath + @"\" + projectName + @"\Saved\Logs\";
                }
            }
            else
            {
                AppLogger.Add("WARNING! Cannot create logs, select application for start");
            }
            return(fullpath);
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
0
        private void CollectLogFiles(List <ClusterNode> nodes)
        {
            //List<string> nodes = GetNodes();

            FolderBrowserDialog fbDialog = new FolderBrowserDialog();

            //fbDialog.Description = "Select a folder for save log files from nodes :";
            if (fbDialog.ShowDialog() != DialogResult.OK || nodes.Count == 0)
            {
                return;
            }



            // clean all files except *.zip, *.rar


            // list of new files
            List <string> fileList = new List <string>();

            // copy + rename
            foreach (ClusterNode node in nodes)
            {
                string logFilename = logFile;

                string logFilenameSep = (logFilename == string.Empty) ? "" : ("_");

                string srcLogPath = GetLogFolder(node.address) + Path.GetFileNameWithoutExtension(selectedApplication) + ".log";
                string dstLogPath = fbDialog.SelectedPath + @"\" + logFilenamePrefix + node.id + logFilenameSep + logFilename;
                string logMsg     = "[" + srcLogPath + "] to [" + dstLogPath + "]";

                // add to list
                fileList.Add(dstLogPath);

                try
                {
                    File.Copy(srcLogPath, dstLogPath);
                    AppLogger.Add("Copied file from " + logMsg);
                }
                catch (Exception exception)
                {
                    AppLogger.Add("Can't copy file from " + logMsg + ". EXCEPTION: " + exception.Message);
                }
            }

            // create archive
            if (!isLogZip)
            {
                return;
            }

            string currentTime = DateTime.Now.ToString("HHmmss");
            string currentDate = DateTime.Now.ToString("yyyyMMdd");

            string zipFilename = fbDialog.SelectedPath + @"\" + logFilenamePrefix + currentDate + "_" + currentTime + ".zip";

            CreateZipLogs(zipFilename, fileList);

            // clean *.log-files
            if (isLogRemove)
            {
                RemoveListOfFiles(fileList);
            }
        }