private string MakePathRelativeToMCNList(string path) { if (string.IsNullOrEmpty(path)) { return(path); } string file = MacrosSystem.GetInstance().ExpandMacro(path); if (File.Exists(file)) { System.Uri uri1 = new Uri(Path.GetFullPath(file)); System.Uri uri2 = new Uri(MCNCollection.GetInstance().FileDirectory); if (uri2.IsBaseOf(uri1) == false) { // only use relative paths if the file is in a subdirectory of the mcn liit file return(path); } Uri relativeUri = uri2.MakeRelativeUri(uri1); // replace %20 with spaces, etc string decoded = HttpUtility.UrlDecode(relativeUri.OriginalString); return(decoded); } return(path); }
public void SetCustomValue(MacrosSystem.ReservedVersionMacroKeys key, string value) { // based on the key, set the value for the currently selected connect version switch (key) { case MacrosSystem.ReservedVersionMacroKeys.APP_INSTALL_PATH: VersionDictionary[CustomStr].AppInstall = value; break; case MacrosSystem.ReservedVersionMacroKeys.APP_INSTALL_FULL_PATH: VersionDictionary[CustomStr].AppExe = value; break; case MacrosSystem.ReservedVersionMacroKeys.APP_SAMPLES_PATH: VersionDictionary[CustomStr].AppSamples = value; break; case MacrosSystem.ReservedVersionMacroKeys.APP_LOCAL_SETTINGS_PATH: VersionDictionary[CustomStr].AppLocalSettings = value; break; case MacrosSystem.ReservedVersionMacroKeys.APP_ROAMING_SETTINGS_PATH: VersionDictionary[CustomStr].AppRoamingSettings = value; break; default: OutputLog.Log(LogSeverity.Error, "cannot find case for switch value " + key.ToString()); break; } MacrosSystem.GetInstance().BuildDictionary(); }
private void buttonMacrosCancel_Click(object sender, EventArgs e) { try { MacrosSystem.GetInstance().RevertCustomList(); this.Close(); } catch (System.Exception ex) { Program.Logger.Log(LogSeverity.Error, ex.ToString()); } }
private void buttonMacrosOK_Click(object sender, EventArgs e) { try { MacrosSystem.GetInstance().BuildDictionary(); this.Close(); } catch (System.Exception ex) { Program.Logger.Log(LogSeverity.Error, ex.ToString()); } }
public Color ValidateTextBoxIsDirectory(TextBox textBox) { // helper function to check for directory existence string text = MacrosSystem.GetInstance().ExpandMacro(textBox.Text); if (Directory.Exists(text) || string.IsNullOrEmpty(text)) { return(Logger.Color_Info); } else { return(Logger.Color_Warning); } }
private string GetAbsolutePathExpanded(string path) { path = MacrosSystem.GetInstance().ExpandMacro(path); bool isAbsolute = Path.IsPathRooted(path); if (!isAbsolute) { string newPath = Path.Combine(MCNCollection.GetInstance().FileDirectory, path); newPath = Path.GetFullPath(newPath); return(newPath); } return(path); }
private void dataGridViewPlatforms_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (dataGridViewPlatforms.Columns[e.ColumnIndex].Name == DataGridViewPlatformNames.AssetCompilerCustomEXEName) { // Open a file dialog to choose the asset compiler executable. openFileDialogAssetCompiler.InitialDirectory = Settings.GetInstance().RuntimeSDKRoot; DialogResult dialogResult = openFileDialogAssetCompiler.ShowDialog(); if (dialogResult == DialogResult.OK) { string acExe = openFileDialogAssetCompiler.FileNames[0]; string localAcExe = MacrosSystem.GetInstance().ConvertToMacro(acExe); Settings.GetInstance().Platforms[e.RowIndex].AssetCompilerCustomEXE = localAcExe; dataGridViewPlatforms.Refresh(); } } } }
public void BatchExport(ref MorphemeConnectExporter.Result result) { try { string morphemeConnectExe = MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().MorphemeConnectPath); string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); appDataFolder += MorphemeConnectExporter.AppDataSubFolder; string luaLogDirectory = appDataFolder += MorphemeConnectExporter.LuaLogSubDirectory; if (false == Directory.Exists(luaLogDirectory)) { Directory.CreateDirectory(luaLogDirectory); } string lua = ""; foreach (MorphemeConnectData morphemeConnectData in morphemeConnectDataList) { string mcpFile; string mcnFile; string intermediateFile; MorphemeHelper.GetFilePathsFromNetwork(morphemeConnectData.Network, morphemeConnectData.ExportPath, out mcpFile, out mcnFile, out intermediateFile); // TODO optimization. pre-sort on mcp and only open when project changes // generate the lua to open the project, open the mcn and export the mcn lua += string.Format(" project.open({0})\n mcn.open({1})\n mcn.export({2})", '\"' + mcpFile + '\"', '\"' + mcnFile + '\"', '\"' + intermediateFile + "\"\n"); } string luaFileName = "BatchExport_" + DateTime.Now.Ticks.ToString() + ".lua"; MorphemeHelper.CreateLuaAndLaunchConnect(luaFileName, lua, morphemeConnectExe, ref result); } catch (System.Exception ex) { result.Success = false; result.ErrorString = ex.ToString(); } }
public EditMacros() { try { InitializeComponent(); MacrosSystem.GetInstance().BackUpCustomList(); macroPairBindingSource.DataSource = MacrosSystem.GetInstance().MacroStringCustomList; macroPairBindingSource2.DataSource = MacrosSystem.GetInstance().MacroStringSystemList; // reserved macros { int counter = 0; foreach (MacrosSystem.ReservedNetworkMacroKeys macro in Enum.GetValues(typeof(MacrosSystem.ReservedNetworkMacroKeys))) { DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell cell1 = new DataGridViewTextBoxCell(); cell1.Value = Enum.GetName(typeof(MacrosSystem.ReservedNetworkMacroKeys), macro); DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell(); cell2.Value = MacrosSystem.ReservedNetworkMacroDescriptions[counter]; row.Cells.Add(cell1); row.Cells.Add(cell2); row.ReadOnly = true; dataGridView3.Rows.Add(row); counter++; } } } catch (System.Exception ex) { Program.Logger.Log(LogSeverity.Error, ex.ToString()); } }
private void openFileDialog3_FileOk(object sender, CancelEventArgs e) { // desrialise the config and build the macro table try { using (FileStream fs = new FileStream(openFileDialogConfig.FileName, FileMode.Open)) { Config config = new Config(); config.Deserialise(fs); MacrosSystem.GetInstance().BuildDictionary(); dataGridViewPlatforms.Refresh(); textBoxMorphemeConnect.Refresh(); textBoxExportPath.Refresh(); } } catch (System.Exception ex) { Program.Logger.Log(LogSeverity.Error, ex.ToString()); } }
public void Export(ref MorphemeConnectExporter.Result result) { try { string morphemeConnectExe = MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().MorphemeConnectPath); string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); appDataFolder += MorphemeConnectExporter.AppDataSubFolder; string luaLogDirectory = appDataFolder += MorphemeConnectExporter.LuaLogSubDirectory; if (false == Directory.Exists(luaLogDirectory)) { Directory.CreateDirectory(luaLogDirectory); } string mcpFile; string mcnFile; string intermediateFile; MorphemeHelper.GetFilePathsFromNetwork(morphemeConnectData.Network, morphemeConnectData.ExportPath, out mcpFile, out mcnFile, out intermediateFile); // generate the lua to open the project, open the mcn and export the mcn string lua = string.Format(" project.open({0})\n mcn.open({1})\n mcn.export({2})", '\"' + mcpFile + '\"', '\"' + mcnFile + '\"', '\"' + intermediateFile + '\"'); // generate the lua fileName FileInfo mcnfileInfo = new FileInfo(mcnFile); string luaFileName = Path.GetFileNameWithoutExtension(mcnfileInfo.Name); luaFileName += "_" + DateTime.Now.Ticks.ToString() + ".lua"; MorphemeHelper.CreateLuaAndLaunchConnect(luaFileName, lua, morphemeConnectExe, ref result); } catch (System.Exception ex) { result.Success = false; result.ErrorString = ex.ToString(); } }
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 0) { DataGridViewTextBoxCell cell = dataGridView1[e.ColumnIndex, e.RowIndex] as DataGridViewTextBoxCell; string macro = cell.Value as string; if (string.IsNullOrEmpty(macro)) { return; } // The following function call outputs to the log if the macro is not valid. MacrosSystem.GetInstance().IsCustomMacroValid(macro); } } catch (System.Exception ex) { Program.Logger.Log(LogSeverity.Error, ex.ToString()); } }
private void dataGridView2_CellValueChanged(object sender, DataGridViewCellEventArgs e) { // check that the mcn and mcp exist try { if (e.RowIndex < 0) { return; } DataGridViewColumn column = dataGridViewMCNList.Columns[e.ColumnIndex]; if (column is DataGridViewTextBoxColumn) { DataGridViewCell cell = dataGridViewMCNList[e.ColumnIndex, e.RowIndex]; if (cell == null) { return; } if (cell.Value == null) { // reset the background colour cell.Style.BackColor = Logger.Color_Info; return; } string file = cell.Value.ToString(); if (string.IsNullOrEmpty(file)) { // reset the background colour cell.Style.BackColor = Logger.Color_Info; return; } // expand any macros in the file file = MacrosSystem.GetInstance().ExpandMacro(file); bool isAbsolute = Path.IsPathRooted(file); if (!isAbsolute) { // it's a relative path. prepend the mcn list path to make it absolute string newPath = Path.Combine(MCNCollection.GetInstance().FileDirectory, file); file = Path.GetFullPath(newPath); } cell.Style.BackColor = Logger.Color_Info; if (!File.Exists(file)) { // cannot find file - show warning cell.Style.BackColor = Logger.Color_Warning; return; } // check the mcn is valid { string MCNFileName = "MCNFileName"; MemberInfo[] info = typeof(MCN).GetMember(MCNFileName); if (info.Length > 0) { if (column.DataPropertyName == MCNFileName) { FileInfo fileInfo = new FileInfo(file); if (false == fileInfo.Extension.Equals(MCN.MCNExtension, StringComparison.CurrentCultureIgnoreCase)) { cell.Style.BackColor = Logger.Color_Warning; return; } } } else { Program.Logger.Log(LogSeverity.Error, "Cannot find member variable " + MCNFileName); } } // check the mcp is valid { string MCPFileName = "MCPFileName"; MemberInfo[] info = typeof(MCN).GetMember(MCPFileName); if (info.Length > 0) { if (column.DataPropertyName == MCPFileName) { FileInfo fileInfo = new FileInfo(file); if (false == fileInfo.Extension.Equals(MCN.MCPExtension, StringComparison.CurrentCultureIgnoreCase)) { cell.Style.BackColor = Logger.Color_Warning; return; } } } else { Program.Logger.Log(LogSeverity.Error, "Cannot find member variable " + MCPFileName); } } } } catch (System.Exception ex) { Program.Logger.Log(LogSeverity.Error, "Exception caught: " + ex.ToString()); } }
public Config() { settings = Settings.GetInstance(); macro = MacrosSystem.GetInstance(); morphemeVersionSelector = MorphemeVersionSelector.GetInstance(); }
private void dataGridViewPlatforms_CellContentClick(object sender, DataGridViewCellEventArgs e) { #if DEV_ENV_SUPPORT try { if ((e.RowIndex >= 0) && (dataGridViewPlatforms[e.ColumnIndex, e.RowIndex] is DataGridViewButtonCell) && (dataGridViewPlatforms[DataGridViewPlatformNames.AssetCompilerSLNFile, e.RowIndex].Value != null)) { string testFileName = "build.log"; // create the file, close the file stream using (File.Create(testFileName)) { } string slnPlatformName = dataGridViewPlatforms[DataGridViewPlatformNames.AssetCompilerSLNFile, e.RowIndex].Value.ToString(); string type = dataGridViewPlatforms.Columns[e.ColumnIndex].Name; // build the correct asset compiler string assetCompiler = string.Format("morphemeAssetCompiler_{0}_{1}.sln", type, slnPlatformName); string path = Path.Combine(MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().RuntimeSDKRoot), @"morpheme\tools\assetCompiler"); string sln = Path.Combine(path, assetCompiler); if (!File.Exists(sln)) { Program.Logger.Log(LogSeverity.Error, "cannot find solution " + sln); return; } // build up the config string string config = dataGridViewPlatforms[DataGridViewPlatformNames.Config, e.RowIndex].Value.ToString(); string commandLine = "\"" + sln + "\"" + " " + "/Build \"" + config + "\" /Out " + testFileName; // build up the devenv exe string exe = string.Empty; string platformName = dataGridViewPlatforms[DataGridViewPlatformNames.Name, e.RowIndex].Value.ToString(); exe = Path.Combine(Environment.GetEnvironmentVariable("VS90COMNTOOLS"), @"..\IDE\devenv.exe"); if (!File.Exists(exe)) { Program.Logger.Log(LogSeverity.Error, "cannot find executable " + exe); return; } Program.Logger.Log(LogSeverity.Info, "building ... " + commandLine); using (Process proc = System.Diagnostics.Process.Start(exe, commandLine)) { // wait for the process to end proc.WaitForExit(); } using (StreamReader sr = new StreamReader(testFileName)) { String line; // Read and display lines from the file until the end of // the file is reached. while ((line = sr.ReadLine()) != null) { Program.Logger.Log(LogSeverity.Info, "devenv.exe > " + line); } } DataGridViewPlatformsValidate(e.RowIndex); } } catch (System.Exception ex) { Program.Logger.Log(LogSeverity.Error, ex.ToString()); } #endif // #if DEV_ENV_SUPPORT }
private void DataGridViewPlatformsValidate(int rowIndex) { #if DEV_ENV_SUPPORT try { if (dataGridViewPlatforms.ColumnCount <= 1) { return; } if (dataGridViewPlatforms[DataGridViewPlatformNames.AssetCompilerEXEPath, rowIndex].Value == null) { return; } if (dataGridViewPlatforms[DataGridViewPlatformNames.AssetCompilerEXEPlatform, rowIndex].Value == null) { return; } Array values = Enum.GetValues(typeof(MCN.AssetCompilerType)); int columnIndex = DataGridViewPlatformNames.BuildButtonStartColumnIndex; foreach (MCN.AssetCompilerType val in values) { Enum.GetName(typeof(MCN.AssetCompilerType), val); string assetCompilerPath = MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().RuntimeSDKRoot); string assetCompilerSubPath = dataGridViewPlatforms[DataGridViewPlatformNames.AssetCompilerEXEPath, rowIndex].Value.ToString(); string assetCompilerType = Enum.GetName(typeof(MCN.AssetCompilerType), val); string assetCompilerPlatform = dataGridViewPlatforms[DataGridViewPlatformNames.AssetCompilerEXEPlatform, rowIndex].Value.ToString(); string assetCompilerExe = MorphemeAssetProcessor.ConstructAssetCompilerFile(assetCompilerPath, assetCompilerSubPath, assetCompilerType, assetCompilerPlatform); DataGridViewButtonCell button = dataGridViewPlatforms[columnIndex, rowIndex] as DataGridViewButtonCell; button.Value = "build"; if (!File.Exists(assetCompilerExe)) { Program.Logger.Log(LogSeverity.Info, "cannot find asset compiler: " + assetCompilerExe); button.FlatStyle = FlatStyle.Popup; button.Style.BackColor = Logger.Color_Error; } else { button.FlatStyle = FlatStyle.Popup; button.Style.BackColor = Logger.Color_GoodNews; } columnIndex++; } } catch (System.Exception ex) { Program.Logger.Log(LogSeverity.Error, ex.ToString()); } #endif // #if DEV_ENV_SUPPORT }
public void ExportAll(object sender) { if (!File.Exists(MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().MorphemeConnectPath))) { Log.Add(new LogItem(LogSeverity.Error, "cannot find morpheme connect exe " + MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().MorphemeConnectPath))); return; } string exportRootPath = MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().ExportRootPath); if (!Directory.Exists(exportRootPath)) { try { Directory.CreateDirectory(exportRootPath); } catch (System.Exception ex) { Log.Add(new LogItem(LogSeverity.Error, String.Format("cannot find Export root: {0} ({1})", exportRootPath, ex.Message))); return; } } int index = 0; int count = MCNCollection.GetInstance().Count; // only required for multithreaded export ManualResetEvent[] doneEvents = new ManualResetEvent[count]; Result[] results = new Result[count]; List <MCN> uniqueList = MCNCollection.GetInstance().Distinct().ToList(); if (uniqueList.Count != MCNCollection.GetInstance().Count) { Log.Add(new LogItem(LogSeverity.Warning, "connect exporter skipping duplicate triplet(s) <mcn, asset compiler, mcp>")); } Log.Add(new LogItem(LogSeverity.Info, "morpheme connect started exporting " + uniqueList.Count + " networks...")); MorphemeConnectBatchExportTask batchExporter = new MorphemeConnectBatchExportTask(); // export each network foreach (MCN network in uniqueList) { // currently connect writes to a hard coded log file so we need to disable logging or fix the connect log file issue try { if (!network.Use) { Log.Add(new LogItem(LogSeverity.Info, "connect exporter skipping network at user request: " + network.MCNFileName)); continue; } if (!File.Exists(network.GetMCNPathAbsoluteExpanded())) { Log.Add(new LogItem(LogSeverity.Warning, "connect exporter skipping missing mcn " + network.MCNFileName)); continue; } if (!File.Exists(network.GetMCPPathAbsoluteExpanded())) { Log.Add(new LogItem(LogSeverity.Warning, "connect exporter skipping missing mcp " + network.MCPFileName)); continue; } // create a new Result to monitor when it is done results[index] = new Result(network); string exportPath = MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().ExportRootPath); string rootPathAdjustedForNetwork = MacrosSystem.GetInstance().ExpandMacroUsingNetwork(exportPath, network); // create the export directory, if required if (!Directory.Exists(rootPathAdjustedForNetwork)) { Directory.CreateDirectory(rootPathAdjustedForNetwork); Log.Add(new LogItem(LogSeverity.Info, "Created directory: " + rootPathAdjustedForNetwork)); } // add the task batchExporter.AddTask(network, rootPathAdjustedForNetwork); } catch (System.IO.IOException ex) { Log.Add(new LogItem(LogSeverity.Error, ex.ToString())); doneEvents[index].Set(); results[index].Success = false; } catch (System.Exception ex) { Log.Add(new LogItem(LogSeverity.Error, ex.ToString())); doneEvents[index].Set(); results[index].Success = false; } } Result result = new Result(new MCN()); batchExporter.BatchExport(ref result); ParseConnectlogFile(); if (result.Success) { Log.Add(new LogItem(LogSeverity.GoodNews, "exported all networks")); } else { Log.Add(new LogItem(LogSeverity.Error, result.ErrorString)); } }
public void ProcessAll(object sender) { // using a thread pool, fire up all the reuqired asset compilers int index = 0; int numSelectedPlatforms = Settings.GetInstance().NumSelectedPlatforms(); int numSelectedNetworks = MCNCollection.GetInstance().NumSelectedNetworks(); int count = numSelectedPlatforms * numSelectedNetworks; // set up the events to monitor when each task is done ManualResetEvent[] doneEvents = new ManualResetEvent[count]; Result[] results = new Result[count]; // check for duplicates List <MCN> uniqueList = MCNCollection.GetInstance().Distinct().ToList(); if (uniqueList.Count != MCNCollection.GetInstance().Count) { Log.Add(new LogItem(LogSeverity.Warning, "asset processor skipping duplicate triplet(s) <mcn, asset compiler, mcp>")); } int actualNumNetworks = 0; foreach (MCN mcn in uniqueList) { if (mcn.Use) { ++actualNumNetworks; } } Log.Add(new LogItem(LogSeverity.Info, "asset compiler started processing " + actualNumNetworks + " networks on " + numSelectedPlatforms + " platforms...")); // for each platform export all the mcns foreach (PlatformConfiguration platform in Settings.GetInstance().Platforms) { if (platform.UseDuringExport == false) { index++; Log.Add(new LogItem(LogSeverity.Info, "asset processor skipping platform at user request: " + platform.AssetCompilerCustomEXE)); continue; } foreach (MCN network in uniqueList) { try { if (network.Use == false) { index++; Log.Add(new LogItem(LogSeverity.Info, "asset processor skipping network at user request: " + network.MCNFileName)); continue; } // skip over missing mcns, missing mcps if (!File.Exists(network.GetMCNPathAbsoluteExpanded()) || !File.Exists(network.GetMCPPathAbsoluteExpanded()) ) { index++; Log.Add(new LogItem(LogSeverity.Warning, "asset processor skipping missing mcn/mcp " + network.MCNFileName + " " + network.MCPFileName)); continue; } // build up all the paths to generate the asset compiler exe string assetCompilerPath = MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().RuntimeSDKRoot); string assetCompilerType = Enum.GetName(typeof(MCN.AssetCompilerType), network.AssetCompiler); string assetCompilerExe = MacrosSystem.GetInstance().ExpandMacro(platform.AssetCompilerCustomEXE); string commandLineOptions = ConstructAssetCompilerOptions(assetCompilerExe, Settings.GetInstance().AssetCompilerCommandLine, network.AssetCompiler, platform); if (!File.Exists(assetCompilerExe)) { Log.Add(new LogItem(LogSeverity.Error, "cannot find asset compiler: " + assetCompilerExe)); continue; } results[index] = new Result(network); // set task to 'not done' doneEvents[index] = new ManualResetEvent(false); // build more paths string rootPathAdjustedForNetwork = MacrosSystem.GetInstance().ExpandMacroUsingNetwork(Settings.GetInstance().ExportRootPath, network); string processSubPath = Path.Combine(rootPathAdjustedForNetwork, MacrosSystem.GetInstance().ExpandMacroUsingNetwork(platform.ProcessPathSubDirectory, network)); if (false == Directory.Exists(processSubPath)) { if (File.Exists(processSubPath)) { Log.Add(new LogItem(LogSeverity.Error, "cannot create directory - file with this name already exists: " + processSubPath)); index++; continue; } Directory.CreateDirectory(processSubPath); // wait for creation while (false == Directory.Exists(processSubPath)) { Thread.Sleep(100); } Log.Add(new LogItem(LogSeverity.Info, "Created directory: " + processSubPath)); } // create the task and send it to the thread pool MorphemeAssetProcessorTask processor = new MorphemeAssetProcessorTask(network, rootPathAdjustedForNetwork, processSubPath, assetCompilerExe, commandLineOptions, doneEvents[index]); // need to keep a local copy as it doesn't appear that the lambda expression below is evaluated on that line Result res = results[index]; ThreadPool.QueueUserWorkItem(o => processor.ThreadPoolCallback(ref res)); // default to true and set to false on errors (see below) network.Processed = true; // finally, increment index (ensure this is the final statement as it is used in the catch below) index++; } catch (System.Exception ex) { Log.Add(new LogItem(LogSeverity.Error, ex.ToString())); doneEvents[index].Set(); results[index].Success = false; } } } try { index = 0; // wait for all the threads to be done foreach (WaitHandle handle in doneEvents) { if (handle != null) { handle.WaitOne(); } if (results[index] != null) { if (results[index].Success) { Log.Add(new LogItem(LogSeverity.GoodNews, "processed " + results[index].Platform + " " + results[index].Network.GetMCNPathAbsoluteExpanded())); } else { Log.Add(new LogItem(LogSeverity.Error, "FAILED " + results[index].Platform + " " + results[index].Network.GetMCNPathAbsoluteExpanded() + " " + results[index].ErrorString)); results[index].Network.Processed = false; } } index++; // update the progress bar if (sender != null) { (sender as BackgroundWorker).ReportProgress(50 + ((50 * index) / count)); } } } catch (System.Exception ex) { Log.Add(new LogItem(LogSeverity.Error, ex.ToString())); } }