public History() { loc = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); loc = loc + "\\NetSky\\"; if (Directory.Exists(loc)) { loc = loc + "NetSky_History.db"; if (File.Exists(loc)) { ini = new IniFile(loc); string t = ini.IniReadValue("Total_History", "Value"); if (t.Trim().Length > 0) { int total = Convert.ToInt32(t); for (int i = 1; i <= total; i++) { string h = ini.IniReadValue("History", i.ToString()); if (h.Trim().Length > 0) { string[] data = Regex.Split(h, "#GAP#"); if (data.Length == 2) { file_names.Add(data[0]); vir_name.Add(data[1]); } } } } } else { File.Create(loc); } } else { Directory.CreateDirectory(loc); File.Create(loc + "Netsky_History.db"); loc = loc + "Netsky_History.db"; } }
public Exclusion() { loc = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); loc = loc + "\\NetSky\\"; if (Directory.Exists(loc)) { loc = loc + "NetSky_Exclusion.db"; if (File.Exists(loc)) { ini = new IniFile(loc); string t = ini.IniReadValue("Total_Exclusion", "Value"); if (t.Trim().Length > 0) { int total = Convert.ToInt32(t); for (int i = 1; i <= total; i++) { string h = ini.IniReadValue("Exclusion", i.ToString()); if (h.Trim().Length > 0) { if(Directory.Exists(h)) exclusions.Add(h); if (File.Exists(h)) exclusions.Add(h); } } } } else { File.Create(loc); } } else { Directory.CreateDirectory(loc); File.Create(loc + "Netsky_Exclusion.db"); loc = loc + "Netsky_Exclusion.db"; } }
public CompressionManager() { InitializeComponent(); string status; CMINI = new IniFile(Directory.GetCurrentDirectory() + "\\CompressionManager.ini"); string Dir = "!"; int i = 0; while (Dir != "") { Dir = CMINI.IniReadValue("General", "File" + i.ToString(), ""); if (Dir != "") { status = CMINI.IniReadValue("General", "Status" + i.ToString(), ""); FileList.Items.Add(Dir); StatusBox.Items.Add(status); i++; } } CurrentDir = CMINI.IniReadValue("General", "CurrentDir", 0); CurrentFile = CMINI.IniReadValue("General", "CurrentFile", 0); if (FileList.Items.Count > 0) FileList.SelectedIndex = Math.Min(CurrentDir, FileList.Items.Count - 1); }
public static void LogFileSecurityMove(IniFile ini, int matchid) { try { for(int j = 0; j < MAX_LOGS; ++j) { string szLogFile = ini.IniReadValue("logs", "log" + j); if(File.Exists(szLogFile)) { string md5 = MD5file(szLogFile); Wire.InterfaceFactory.gameInterface().moveToMatchMedia(szLogFile, "SAMP_AC_Extension Log file " + matchid + " - " + md5, matchid); } } } catch(Exception e) { Log.WriteLog(e.ToString()); } }
public static void LogFileSecurityUpdate( IniFile ini, int matchId, string szLogFilePath) { for(int j = 0; j < MAX_LOGS; ++j) { string szLogFile = ini.IniReadValue("logs", "log" + j); if(szLogFile.Length == 0) { ini.IniWriteValue("logs", "log" + j, szLogFilePath); break; } if(szLogFile.Equals(szLogFilePath)) { break; } if(!File.Exists(szLogFile)) { ini.IniWriteValue("logs", "log" + j, ""); } } }
public void AddExclusion(string path) { IniFile ins = new IniFile(loc); int index = 0; string t = string.Empty; try { t = ins.IniReadValue("Total_Exclusion", "Value"); } catch { } if (t.Trim().Length > 0) { index = Convert.ToInt32(t); index++; } else index++; exclusions.Add(path); ins.IniWriteValue("Exclusion", index.ToString(), path); ins.IniWriteValue("Total_Exclusion", "Value", index.ToString()); }
public void AddHistory(string file, string vir_name) { IniFile ins = new IniFile(loc); int index = 0; string t = string.Empty; try { t = ins.IniReadValue("Total_History", "Value"); } catch { } if (t.Trim().Length > 0) { index = Convert.ToInt32(t); index++; } else index++; string val = file + "#GAP#" + vir_name; file_names.Add(file); this.vir_name.Add(vir_name); ins.IniWriteValue("History", index.ToString(), val); ins.IniWriteValue("Total_History", "Value", index.ToString()); }
public void DelExclusion(string path) { IniFile ins = new IniFile(loc); string t = string.Empty; int total = 0; try { t = ins.IniReadValue("Total_Exclusion", "Value"); } catch { } if (t.Trim().Length > 0) { total = Convert.ToInt32(t); for(int i=1;i<=total;i++) { t = ins.IniReadValue("Exclusion", i.ToString()); if(t==path) { ins.IniWriteValue("Exclusion", i.ToString(), path + "netsky.removed.exclusion"); exclusions.Remove(path); } } } }
// NOTE: this function does not get called on some PCs (QWERTs), for most things, don't rely on this function!!!! public static void onMatchStarted(int matchId, string matchMediaPath) { try { // Set current matchId, and match media path to our equivalent global variables. g_iMatchId = matchId; g_szMatchMediaPath = matchMediaPath; // Check the match media path for any files there might already be in there, and print them in our log. string[] f = Directory.GetFiles(g_szMatchMediaPath); if(f.Length > 0) { Log.WriteLog("Match Media Path files: "); foreach(string ff in f) { Log.WriteLog(ff); } } // When players do an incorrect logout from ESL Wire, This code will make it so // if they do 5 incorrect log outs in a row, and do 1 correct logout after that // then all 6 logs will be uploaded - this file keeps track of all the created logs // incase of an incorrect logout, plugin crash, or Wire crash. // { int i = 0; IniFile ini = new IniFile(System.IO.Path.GetTempPath() + matchId + ".txt"); string str = ini.IniReadValue("misc", "logfilenum"); if(str.Length > 0) { i = int.Parse(str)+1; } else { i = 1; } ini.IniWriteValue("misc", "logfilenum", i.ToString()); Log.LogFileSecurityMove(ini, matchId); Log.LogFileSecurityUpdate(ini, matchId, g_szLogFilePath); //} // Get the ESL Wire profile of the user, and print it in the log. Dictionary<string, object> d = new Dictionary<string, object>(); Wire.SessionInterface si = Wire.InterfaceFactory.sessionInterface(); d = si.user(); string prof = "Unknown"; foreach (KeyValuePair<string, object> pair in d) { if(pair.Key.Equals("profileURL")) { prof = (string)pair.Value; } } Log.WriteLog(" -> SA-MP AC Extension Plugin v" + g_dVersion.ToString() + " for use in ESL loaded."); Log.WriteLog(" -> Number of log files: " + i); Log.WriteLog(" -> ESL Profile: " + prof); Log.WriteLog("Match ID: " + matchId); } catch(Exception e) { Log.WriteLog(e.ToString()); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { //http://icons.iconarchive.com/icons/laurent-baumann/blend/256/Location-File-icon.png IntPtr hWnd = new WindowInteropHelper(this).Handle; Int32 windowLong = GetWindowLong(hWnd, GWL_STYLE); windowLong = windowLong & ~WS_MAXIMIZEBOX; SetWindowLong(hWnd, GWL_STYLE, windowLong); IniFile ini = new IniFile(Setting_path[0]); /*loaders*/ if (Size_Helper.get_IMVU_Ver() == Next_IMVU_Ver.get_Ver() || Next_IMVU_Ver.get_Ver() == "") { Update_But.Visibility = System.Windows.Visibility.Hidden; per.Visibility = System.Windows.Visibility.Hidden; dl_go.Visibility = System.Windows.Visibility.Hidden; IMVU_Ver.Content = "Current Version: " + Size_Helper.get_IMVU_Ver() + "\tLast Checked: " + ini.IniReadValue("Update", "Last_Update"); ram_amout.Content = "Current IMVU Version: " + Size_Helper.get_IMVU_Ver() + "\tLast Checked: " + ini.IniReadValue("Update", "Last_Update"); this.Title = "[ACID]Cache Cleaner (IMVU Version: " + Size_Helper.get_IMVU_Ver() + ")"; } else { this.Title = "[ACID]Cache Cleaner (IMVU Version: " + Size_Helper.get_IMVU_Ver() + " Next Version: " + Next_IMVU_Ver.get_Ver() + ")"; ram_amout.Content = "Current IMVU Version: " + Size_Helper.get_IMVU_Ver() + "\tNext Version: " + Next_IMVU_Ver.get_Ver() + "\tLast Checked: " + ini.IniReadValue("Update", "Last_Update"); IMVU_Ver.Content = "Current Version: " + Size_Helper.get_IMVU_Ver() + "\tNext Version: " + Next_IMVU_Ver.get_Ver(); Update_But.Content = string.Format("Update to: '{0}'", Next_IMVU_Ver.get_Ver()); } g_card.Content = "Video Card: "+Sys_Info.get_video() + "\t\tTotal Ram: " + Sys_Ram.get_ram(); OS_Name.Content = Sys_Info.get_Windows() + Sys_Info.GetServicePack(); if (is_online) { worker2.DoWork += new DoWorkEventHandler(worker2_DoWork); //worker2.WorkerSupportsCancellation = true; worker2.RunWorkerAsync(); } else { tabControl1.Items.RemoveAt(2); } ip_getter.DoWork += new DoWorkEventHandler(ip_getter_DoWork); ip_getter.RunWorkerAsync(); worker3.DoWork += new DoWorkEventHandler(worker3_DoWork); worker3.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker3_RunWorkerCompleted); worker3.RunWorkerAsync(); this.Cursor = Cursors.Wait; A_Ver.Content = string.Format("Version: {0} \t\t Last Checked: {1}", ini.IniReadValue("Auto", "Version"), DateTime.Now); //A_Ver.Content = string.Format("Version: {0}", ini.IniReadValue("Auto", "Version")); textBox2.Text = ini.IniReadValue("Auto", "Auto_Clean_Timeout"); }
private void AddDir_Click(object sender, EventArgs e) { FolderBrowserDialog FBD = new FolderBrowserDialog(); FBD.ShowDialog(); string[] IniFiles; double PercentCompletion; bool Compressed; if (FBD.SelectedPath != "") { FileList.Items.Add(FBD.SelectedPath); IniFiles = Directory.GetFiles(FBD.SelectedPath, "*_Settings.txt"); if (IniFiles.Length == 1) { BioINI = new IniFile(IniFiles[0]); PercentCompletion = BioINI.IniReadValue("Review", "Complete", (double)0); Compressed = BioINI.IniReadValue("Review", "Compressed", false); if (PercentCompletion > 99) { if (Compressed) { StatusBox.Items.Add("Compressed"); } else { StatusBox.Items.Add("Uncompressed"); } } else { if (Compressed) { StatusBox.Items.Add("NR - Compressed"); } else { StatusBox.Items.Add("NR - Uncompressed"); } } } else { StatusBox.Items.Add("Error no ini"); } } UpdateINI(); }
private void ReadSettings() { try { IniFile ini = new IniFile(TargetFile); Volume = double.Parse(ini.IniReadValue("config", "Volume")); HadithNoLastOpen = int.Parse(ini.IniReadValue("config", "HadithNoLastOpen")); ChapterLastOpen = int.Parse(ini.IniReadValue("config", "ChapterLastOpen")); PageLastOpen = int.Parse(ini.IniReadValue("config", "PageLastOpen")); LanguageLastOpen = int.Parse(ini.IniReadValue("config", "LanguageLastOpen")); HadithLastOpen = int.Parse(ini.IniReadValue("config", "HadithLastOpen")); UrlRecitation = ini.IniReadValue("config", "UrlRecitation"); isAutoSpeech = bool.Parse(ini.IniReadValue("config", "isAutoSpeech")); VerseSize = int.Parse(ini.IniReadValue("config", "VerseSize")); //ClickMode = int.Parse(ini.IniReadValue("config", "ClickMode")); //PlayMode = int.Parse(ini.IniReadValue("config", "PlayMode")); isVoiceEnable = bool.Parse(ini.IniReadValue("config", "isVoiceEnable")); isGestureEnable = bool.Parse(ini.IniReadValue("config", "isGestureEnable")); isAutoShutdownEnable = bool.Parse(ini.IniReadValue("config", "isAutoShutdownEnable")); ShutdownTime = int.Parse(ini.IniReadValue("config", "ShutdownTime")); } catch { throw; } }
public static void Load(string filename) { var file = new IniFile(Directory.GetCurrentDirectory() + "\\" + filename); //MapLegend SpawnPointSymbol = file.IniReadValue("MapLegend", "SpawnPoint", "S").ToCharArray()[0]; HeroSymbol = file.IniReadValue("MapLegend", "Hero", "H").ToCharArray()[0]; PathSymbol = file.IniReadValue("MapLegend", "Path", ".").ToCharArray()[0]; WallSymbol = file.IniReadValue("MapLegend", "Wall", "#").ToCharArray()[0]; EnemySymbol = file.IniReadValue("MapLegend", "Enemy", "E").ToCharArray()[0]; TreasureSymbol = file.IniReadValue("MapLegend", "Treasure", "T").ToCharArray()[0]; ExitSymbol = file.IniReadValue("MapLegend", "Exit", "G").ToCharArray()[0]; //Paths LevelsPath = file.IniReadValue("Paths", "Levels", @"\Levels\"); MapsSubPath = file.IniReadValue("Paths", "Maps", @"Maps\"); EnemiesSubPath = file.IniReadValue("Paths", "Enemies", @"Enemies\"); TexturesSubPath = file.IniReadValue("Paths", "Textures", @"Textures\"); TreasuresSubPath = file.IniReadValue("Paths", "Treasures", @"Treasures\"); LogFile = file.IniReadValue("Paths", "LogFile", "\\log.txt"); //Hero MaxHealthPotions = int.Parse(file.IniReadValue("Hero", "MaxHealthPotions", "3")); MaxManaPotions = int.Parse(file.IniReadValue("Hero", "MaxManaPotions", "3")); HealthPotionPercent = float.Parse(file.IniReadValue("Hero", "HealthPotionPercent", "30")); ManaPotionPercent = float.Parse(file.IniReadValue("Hero", "ManaPotionPercent", "30")); }
private void LoginWorker(string plogin, string ppass, AsyncOperation asyncOp) { if (m_clientSocket != null) { try { Stop(); } catch { } } Canceled = false; m_clientSocket = new TcpClient(); Exception ex = null; byte[] buffer = new byte[PD.MAX_PACKET_SIZE]; int size; bool response = false; PD receivedPD=new PDAuthentificationResp(); ((PDAuthentificationResp)receivedPD).Succeded = false; try { IniFile ini = new IniFile(Application.StartupPath + "\\opensudoku.ini"); m_host = ini.IniReadValue("GENERAL", "Host", "127.0.0.1"); m_port = int.Parse(ini.IniReadValue("GENERAL", "Port", "31200")); m_clientSocket.Connect(System.Net.IPAddress.Parse(Host), Port); NetworkStream stream = m_clientSocket.GetStream(); BinaryReader br = new BinaryReader(stream); PDAuthentification loginPD = new PDAuthentification(plogin, ppass); byte[] data = loginPD.getBytesData(); stream.Write(data, 0, data.Length); while (!Canceled) { size = stream.Read(buffer, 0, buffer.Length); if (size > PD.MIN_PACKET_SIZE) { receivedPD = PDFactory.createPd(buffer); if (receivedPD.PDType == E_PD_TYPE.AUTHENTIFICATION_RESP) { response = ((PDAuthentificationResp)receivedPD).Succeded; } break; } } ex = null; //stream.Close(); } catch (SocketException e) { ex = e; } catch (Exception e) { ex = e; } finally { LoginCompletionMethod((PDAuthentificationResp)receivedPD, false, ex, asyncOp); } }
private IEnemy GetRandomEnemy() { try { var enemiesFile = new IniFile(_enemiesFilename); var name = enemiesFile.IniReadValue("Enemy", "Name", "Unknown"); var health = float.Parse(enemiesFile.IniReadValue("Enemy", "Health", "1")); var mana = float.Parse(enemiesFile.IniReadValue("Enemy", "Mana", "0")); var baseDamage = float.Parse(enemiesFile.IniReadValue("Enemy", "BaseDamage", "1")); var enemy = new Enemy(name: name, maxHp: health, maxMana: mana, baseDamage: baseDamage); Logger.WriteLine("Created enemy '{0}' from file: '{1}'", enemy.ToString(), _enemiesFilename); return enemy; } catch(Exception e) { Logger.WriteLine(e.Message); return null; } }
public frmUNIcastStreamer() { InitializeComponent(); // Clear sample texts lblSubject.Text = String.Empty; lblLecturer.Text = String.Empty; lblDate.Text = String.Empty; // Fix screen position bug this.StartPosition = FormStartPosition.CenterScreen; // Load settings IniFile ini = new IniFile(Path.Combine(Environment.CurrentDirectory, IniFile)); string str = ini.IniReadValue(Section, KeyStream); if (!Address.TryParse(str, out streamAddress)) { streamAddress = DefaultStreamAddress; ini.IniWriteValue(Section, KeyStream, streamAddress.ToString()); } str = ini.IniReadValue(Section, KeyMessage); if (!Address.TryParse(str, out messageAddress)) { messageAddress = DefaultMessageAddress; ini.IniWriteValue(Section, KeyMessage, messageAddress.ToString()); } // Load DeckLink API Thread deckLinkStreamerThread = new Thread(() => { deckLinkStreamer = new DeckLinkStreamer(); // Set callback deckLinkStreamer.SetCallback(this); // Initialise API if (!deckLinkStreamer.TryInitializeAPI()) { deckLinkStreamer.SetCallback(null); MessageBox.Show(strings.errorDeckLinkDriver, strings.error); Environment.Exit(1); } deckLinkAPIVersion = deckLinkStreamer.DeckLinkAPIVersion; lblDeckLinkVersion.InvokeIfRequired(c => c.Text = deckLinkAPIVersion); }); deckLinkStreamerThread.SetApartmentState(ApartmentState.MTA); deckLinkStreamerThread.IsBackground = true; deckLinkStreamerThread.Start(); // Initialise variables, load settings duration = new TimeSpan(1, 30, 00); timeMode = 0; timer = new System.Windows.Forms.Timer(); timer.Tick += timer_Tick; tabControl.SelectedIndex = 0; progressRing.ProgressPercentage = 0; isStreaming = false; streamServer = new MulticastServer(streamAddress.IP, streamAddress.Port, TTL); messageServer = new MulticastServer(messageAddress.IP, messageAddress.Port, TTL); Thread inputMonitorThread = new Thread(() => { inputMonitor = new InputMonitor(); inputMonitor.InputPositionReceived += inputMonitor_InputPositionReceived; inputMonitor.Start(); }); inputMonitorThread.IsBackground = true; inputMonitorThread.Start(); ffmpeg = new FFmpeg(); if (ffmpeg.isAvailable) { //ffmpeg.OnLogDataReceived += ffmpeg_LogDataReceived; ffmpegVersion = ffmpeg.GetVersion(); lblFFmpegVersion.Text = ffmpegVersion; } pipeHandler = new PipeHandler(); pipeHandler.ClientConnected += pipeHandler_ClientConnected; pipeHandler.ClientDisconnected += pipeHandler_ClientDisconnected; //else //{ // MessageBox.Show(strings.errorFFmpeg, strings.error); // Environment.Exit(1); //} //performanceMonitor = new PerformanceMonitor(new string[] { "ffmpeg", "BMDStreamingServer", Process.GetCurrentProcess().ProcessName }); //performanceMonitor.PerfValuesReceived += performanceMonitor_PerfValuesReceived; //performanceMonitor.StartMonitoring(); lblVersion.Text += Application.ProductVersion; progressRing.Enabled = true; messenger = new frmMessenger(); }
private void ReadReviewINI(IniFile F) { CrashWarning = F.IniReadValue("General", "Crash",false); Compressed = F.IniReadValue("Review", "Compressed", false); PercentCompletion = F.IniReadValue("Review", "Complete", (double)0); if (PercentCompletion > 0) { Reviewer = F.IniReadValue("Review", "Reviewer", Reviewer); DateTime.TryParse(F.IniReadValue("Review", "LastReviewed", ""), out LastReview); DateTime.TryParse(F.IniReadValue("Review", "LastOpen", ""), out LastOpen); ReviewNotes = F.IniReadValue("Review", "Notes", ""); } }
/// <summary> /// Copies to dropbox. /// </summary> /// <param name="__args">Arguments</param> private int copyToDropbox(string[] __args) { IniFile __ini; FileInfo __inifi; bool __isdir; string __path; FileInfo __selectedfile = null; string __selectedfilename = null; string __selectedfileext = null; int __count = 0; if (Directory.Exists(__args[1 +__form.idx])) { __isdir = true; __path = __args[1 +__form.idx]; } else { __isdir = false; __path = new FileInfo(__args[2]).DirectoryName; __selectedfile = new FileInfo(__args[2]); __selectedfilename = __selectedfile.Name; __selectedfileext = __selectedfile.Extension; } if (File.Exists(__path + "\\.dbx") || File.Exists(__path + "\\+ Screens\\.dbx")) { __ini = new IniFile(__path + "\\.dbx"); string __conf = __ini.IniReadValue("Dropbox", System.Environment.UserName); if (__conf == "") { __ini = new IniFile(__path + "\\+ Screens\\.dbx"); __conf = __ini.IniReadValue("Dropbox", System.Environment.UserName); __inifi = new FileInfo(__path + "\\+ Screens\\.dbx"); } else { __inifi = new FileInfo(__path + "\\.dbx"); } __inifi.Attributes = FileAttributes.Hidden; string[] extensions = { ".jpg", ".png", ".gif" }; if (__conf != "") { if (Directory.Exists(__conf)) { if (__isdir) // IF DIRECTORY { string[] __files; __files = Directory.GetFiles(__conf, "*.*", SearchOption.TopDirectoryOnly).Where(f => extensions.Contains(new FileInfo(f).Extension.ToLower())).ToArray(); foreach (string __file in __files) { try { File.Delete(__file); } catch//(Exception __e) { //MessageBox.Show(__e.Message); } } __files = Directory.GetFiles(__path, "*.*", SearchOption.TopDirectoryOnly).Where(f => extensions.Contains(new FileInfo(f).Extension.ToLower())).ToArray(); foreach (string __file in __files) { __count++; FileInfo __fi = new FileInfo(__file); try { __fi.CopyTo(__conf + "\\" + __fi.Name, true); } catch(Exception __e) { MessageBox.Show(__e.Message); } } } else // IF FILE { //MessageBox.Show(__selectedfileext); if (__selectedfileext.ToLower() == ".psd") //IF PSD FILE { string __tempname = __selectedfilename.Substring(0, __selectedfilename.Length - __selectedfileext.Length); string[] __files = Directory.GetFiles(__path + "/+ Screens", __tempname + "*.*", SearchOption.TopDirectoryOnly).Where(f => extensions.Contains(new FileInfo(f).Extension.ToLower())).ToArray(); foreach (string __file in __files) { __count++; FileInfo __fi = new FileInfo(__file); try { __fi.CopyTo(__conf + "\\" + __fi.Name, true); } catch (Exception __e) { MessageBox.Show(__e.Message); } } } else if (__selectedfileext.ToLower() == ".jpg" || __selectedfileext.ToLower() == ".png") //IF JPEG/PNG FILE { __count++; __selectedfile.CopyTo(__conf + "\\" + __selectedfilename, true); } } } else { goto config; } } else { goto config; } } else { goto config; } goto stop; config: string __prompt = Prompt.ShowDialog("Path to your Dropbox directory", "Configuration"); if (__prompt != "") { __ini = new IniFile(__path + "\\.dbx"); __ini.IniWriteValue("Dropbox", System.Environment.UserName, __prompt); __inifi = new FileInfo(__path + "\\.dbx"); __inifi.Attributes = FileAttributes.Hidden; return copyToDropbox(__args); } stop: { return __count; } }
private void button4_Click(object sender, RoutedEventArgs e) { IniFile ini = new IniFile(Setting_path[0]); A_Ver.Content = string.Format("Version: {0} \t\t Last Checked: {1}", ini.IniReadValue("Auto", "Version"), DateTime.Now); }