public void Clean(AuditTrailViewModel sender) { try { TStrings Lines = new TStrings(); Lines.LoadFromFile(outputFile); while (Lines.Count > sender.MaxLines) { Lines.Delete(0); } ; Lines.SaveToFile(outputFile, System.Text.Encoding.ASCII); } catch (Exception ex) { Debug.WriteLine(ex.Message); if (Debugger.IsAttached) { Debugger.Break(); } ; }; }
public AuditTrail(Exception ex, TextFormat textFormat = TextFormat.Txt) { TimeStamp = DateTime.Now; Level = ErrorLevel.Critical; Tag = "Exception"; if (ex != null) { Message = ex.Message; switch (textFormat) { default: case TextFormat.Txt: DataOutType = "TXT"; DataOut = ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + Environment.NewLine + ex.Source; break; case TextFormat.TxtEx: DataOutType = "TXTEx"; DataOut = "!" + ex.Message + Environment.NewLine + Environment.NewLine + "#StackTrace" + Environment.NewLine + ex.StackTrace + Environment.NewLine + Environment.NewLine + "#Source" + Environment.NewLine + ex.Source; break; case TextFormat.HTML: DataOutType = "HTML"; TStrings html = new TStrings(); html.Add("<p style='font-family: Consolas,monospace; bgcolor=transparent;'>"); html.Add(string.Format("{0}</br>", "Message")); html.Add(string.Format("<b>{0}</b></br></br>", ex.Message)); html.Add(string.Format("{0}</br>", "StackTrace")); html.Add(string.Format("<b>{0}</b></br></br>", ex.StackTrace)); html.Add(string.Format("{0}</br>", "Source")); html.Add(string.Format("<b>{0}</b></br></br>", ex.Source)); html.Add("</p>"); DataOut = html.Text; break; } ; } ; }
public string GetConfig([FromHeader] string authorization) { MainViewModel.Current.Prologue(Request); if (!string.IsNullOrEmpty(authorization) && MainViewModel.Current.CheckAuthorization(authorization)) { MainViewModel.Current.TestUnitaires = false; TStrings config = DB_SQL.QuickQueryList("select DBList.Param as Name, DBList.Value from DBList where DBList.List='Config'"); return(config.Text); } else { return(null); }; }
private void saveChangesToolStripMenuItem_Click(object sender, EventArgs e) { // TStrings File = if (File1Modified) { TStrings File = new TStrings(); for (int i = 0; i < File1.Count; i++) { if (File1.GetObject(i) != null) { File.Add(File1[i]); } ; } ; File.SaveToFile(FileName1, System.Text.Encoding.Unicode); File1Modified = false; } ; if (File2Modified) { TStrings File = new TStrings(); for (int i = 0; i < File2.Count; i++) { if (File2.GetObject(i) != null) { File.Add(File2[i]); } ; } ; File.SaveToFile(FileName2, System.Text.Encoding.Unicode); File2Modified = false; } ; }
public AboutWindow() { InitializeComponent(); //lbVersion.Content = AnalyticsHelper.DeviceInfo.AV; using (Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName)) using (StreamReader reader = new StreamReader(stream)) { TStrings text = new TStrings(); text.Text = reader.ReadToEnd(); tbText.Inlines.Clear(); for (int i = 0; i < text.Count; i++) { if (text[i].TrimStart().StartsWith("#")) { tbText.Inlines.Add(new Run() { Text = text[i].TrimStart().Substring(1), FontWeight = FontWeights.Bold }); } else if (text[i].TrimStart().StartsWith("!")) { tbText.Inlines.Add(new Run() { Text = text[i].TrimStart().Substring(1), FontWeight = FontWeights.Bold, Foreground = Brushes.Red }); } else { tbText.Inlines.Add(text[i]); }; } ; }; }
/// <summary> /// Inno Setup <a href="https://jrsoftware.org/ishelp/index.php?topic=scriptclasses">Documentation</a> /// </summary> public void AddStrings(TStrings Strings) { }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static public void Exec(TStrings _Lines, TStrings Text1, TStrings Text2) { bool Continue; Lines = _Lines; File1 = Text1; File2 = Text2; //ToDo: //ToDo: Basics.ShowWaitCursor(true); try { // // - - - - - - //Last[ 1 ] = 0; //Last[ 2 ] = 0; LastEqualLine = 0; Nr = 0; Continue = true; while (Continue) { Continue = ReadUntilDiff(); if (Continue) { Continue = ReSync(); } } //if( !Continue ) Beenden(); } finally { } while (Lines.Count < File1.Count) { Lines.Add("="); } ; while (Lines.Count < File2.Count) { Lines.Add("="); } ; for (int i = 0; i < Lines.Count; i++) { try { if ((Lines[i] == "#") && (File1.GetObject(i) == null)) { Lines[i] = ">"; } } catch { Lines[i] = ">"; }; try { if ((Lines[i] == "#") && (File2.GetObject(i) == null)) { Lines[i] = "<"; } } catch { Lines[i] = "<"; }; } ; //ToDo: Basics.ShowWaitCursor(false); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public static void ReadFormPos(Window window, bool PosOnly, bool FromBorder) { TIniFile IniFile = new TIniFile(IniFileName); TStrings Strings = new TStrings(); if (FromBorder) { bool AlignLeft = IniFile.ReadBool(window.Name, "AlignLeft", false); bool AlignTop = IniFile.ReadBool(window.Name, "AlignTop", false); int MarginX = IniFile.ReadInteger(window.Name, "MarginX", 15); int MarginY = IniFile.ReadInteger(window.Name, "MarginY", 15); if (MarginX < 0) { MarginX = 0; } if (MarginY < 0) { MarginY = 0; } if (AlignLeft) { window.Left = MarginX; } else { window.Left = System.Windows.SystemParameters.PrimaryScreenWidth - window.Width - MarginX; }; if (AlignTop) { window.Top = MarginY; } else { window.Top = System.Windows.SystemParameters.PrimaryScreenHeight - window.Height - MarginY; }; return; } ; window.Left = IniFile.ReadInteger(window.Name, "Left", (int)window.Left); window.Top = IniFile.ReadInteger(window.Name, "Top", (int)window.Top); if (!PosOnly) { window.Width = IniFile.ReadInteger(window.Name, "Width", (int)window.Width); window.Height = IniFile.ReadInteger(window.Name, "Height", (int)window.Height); } ; //if (window.Left < 0) if (window.Left < System.Windows.SystemParameters.VirtualScreenLeft) { window.Left = 0; } ; //if (window.Top < 0) if (window.Top < System.Windows.SystemParameters.VirtualScreenTop) { window.Top = 0; } ; if (!PosOnly) { if (window.Left > System.Windows.SystemParameters.WorkArea.Width) { window.Left = System.Windows.SystemParameters.WorkArea.Width - window.Width; } ; if (window.Top > System.Windows.SystemParameters.WorkArea.Height) { window.Top = System.Windows.SystemParameters.WorkArea.Height - window.Height; } ; if (window.Width > System.Windows.SystemParameters.WorkArea.Width) { window.Width = System.Windows.SystemParameters.WorkArea.Width; } ; if (window.Height > System.Windows.SystemParameters.WorkArea.Height) { window.Height = System.Windows.SystemParameters.WorkArea.Height; } ; } ; int windowState = IniFile.ReadInteger(window.Name, "WindowState", (int)(WindowState.Normal)); if (windowState == (int)(WindowState.Maximized)) { window.WindowState = WindowState.Maximized; } }
public bool Load() { { TIniFile IniFile = new TIniFile(IniFileName); FileName = IniFile.ReadString("General", "FileName", FileName); Glow = IniFile.ReadBool("General", "Glow", Glow); }; // - - - - - - using (Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(TemplatesFileName)) using (StreamReader reader = new StreamReader(stream)) { TStrings text = new TStrings(); text.Text = reader.ReadToEnd(); text.SaveToFile("Templates.ini"); TIniFile IniFile = new TIniFile("Templates.ini"); #if PCL await IniFile.LoadValues(); #else IniFile.LoadValues(); #endif TStrings Sections = IniFile.ReadSections(); Icons.Clear(); for (int s = 0; s < Sections.Count; s++) { if (Sections[s].StartsWith("#")) { TStrings l = IniFile.ReadSectionValues(Sections[s]); for (int i = 0; i < l.Count; i++) { var o = new Icon(); o.Section = Sections[s].Substring(1); o.Name = l.Names(i); string st = l.ValueFromIndex(i); o.Width = int.Parse(st.Split(new char[] { 'x', 'X' })[0]); o.Height = int.Parse(st.Split(new char[] { 'x', 'X', ',' })[1]); if (st.Split(new char[] { 'x', 'X', ',' }).Length > 2) { o.Scale = int.Parse(st.Split(new char[] { 'x', 'X', ',' })[2]); } ; Application.Current.Dispatcher.Invoke(new Action(() => { Icons.Add(o); })); } ; } ; } ; OnPropertyChanged("Icons"); }; return(true); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - private void btnClean_Click(object sender, RoutedEventArgs e) { spBtn.IsEnabled = false; string[] filePaths = Directory.GetFiles(System.IO.Path.GetDirectoryName((string)(lbSolution.Content)), "*.csproj", SearchOption.AllDirectories); bool DidIt = false; foreach (var p in filePaths) { var encoding = ZPF.ProjectTool.GetEncoding(p); DidIt = false; TStrings text = new TStrings(); text.Text = File.ReadAllText(p); for (int i = 0; i < text.Count; i++) { var st = text[i].ToLower(); var ind = st.IndexOf(@"\packages\"); if (ind > 2) { if (st[ind - 1] == '.' && st[ind - 2] == '.') { } else { // KO Debug.WriteLine(">>> " + text[i]); int b = FindBegin(text[i], ind, "'>"); if (b > -1) { var searchPattern = text[i].Substring(b + 1, (ind - b) + (@"\packages\").Length - 1); Debug.WriteLine(" " + searchPattern); text[i] = text[i].Replace(searchPattern, @"..\packages\"); DidIt = true; } ; }; } ; } ; if (DidIt) { File.WriteAllText(p, text.Text, encoding); } } ; //ToDo: Progressbar or other feedback on progress ... //if (DidIt) //{ MessageBox.Show("Clean projects terminated.", "Info", MessageBoxButton.OK, MessageBoxImage.Information); //} //else //{ // MessageBox.Show("Nothing to do ...", "Info", MessageBoxButton.OK, MessageBoxImage.Information); //}; spBtn.IsEnabled = true; }