private void LogText_TextChanged(object sender, EventArgs e) { int i = LogText.SelectionStart; Page[currentPage] = LogText.Text; LogText.SelectAll(); LogText.SelectionFont = new Font(LogText.Font.FontFamily, LogText.Font.Size, LogText.Font.Style); LogText.DeselectAll(); LogText.SelectionStart = i; writtenLetters++; if (writtenLetters == 25 && autoSave) { writtenLetters = 0; string backcolor = LogText.BackColor.R + "@" + LogText.BackColor.G + "@" + LogText.BackColor.B; string forecolor = LogText.ForeColor.R + "@" + LogText.ForeColor.G + "@" + LogText.ForeColor.B; int[] style = new int[3]; if (LogText.Font.Bold) { style[0] = 1; } if (LogText.Font.Italic) { style[1] = 1; } if (LogText.Font.Underline) { style[2] = 1; } LogOperations.saveTheLog(parentForm.activeUser, header.Text, Page, backcolor, forecolor, LogText.Font.FontFamily.Name, Convert.ToInt32(LogText.Font.Size), style, alig); } }
void changeAligment() { int i = LogText.SelectionStart; LogText.SelectAll(); if (alig == 1) { LogText.SelectionAlignment = HorizontalAlignment.Left; } else if (alig == 2) { LogText.SelectionAlignment = HorizontalAlignment.Center; } else if (alig == 3) { LogText.SelectionAlignment = HorizontalAlignment.Right; } LogText.DeselectAll(); LogText.SelectionStart = i; }
public TextEditor(Form parent, string title) { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; parentForm = ((Main)parent); parentForm.loseFocus(); currentPage = 0; header.Text = title.Replace(Environment.NewLine, ""); labelfont.Text = LogText.Font.FontFamily.Name; sizeLabel.Text = LogText.Font.Size.ToString(); Page = LogOperations.getLog(parentForm.activeUser, title); if (Page.Count > 0) { LogText.Text = Page[0]; } else { Page.Add(""); } LogText.SelectAll(); List <string> style = LogOperations.getPageStyle(parentForm.activeUser, title); if (style.Count > 0) { string[] items; items = style[0].Split('@'); LogText.BackColor = Color.FromArgb(int.Parse(items[0]), int.Parse(items[1]), int.Parse(items[2])); items = style[1].Split('@'); LogText.SelectionColor = LogText.ForeColor = Color.FromArgb(int.Parse(items[0]), int.Parse(items[1]), int.Parse(items[2])); LogText.SelectionFont = LogText.Font = new Font(style[2], int.Parse(style[3])); labelfont.Text = style[2]; sizeLabel.Text = style[3]; if (style[4][0] == '1') { Bold.BackColor = selectedColor; LogText.Font = new Font(LogText.Font, LogText.Font.Style ^ FontStyle.Bold); } if (style[4][1] == '1') { Italic.BackColor = selectedColor; LogText.Font = new Font(LogText.Font, LogText.Font.Style ^ FontStyle.Italic); } if (style[4][2] == '1') { underLine.BackColor = selectedColor; LogText.Font = new Font(LogText.Font, LogText.Font.Style ^ FontStyle.Underline); } alig = int.Parse(style[5]); if (alig == 1) { alignLeft.BackColor = selectedColor; alignMiddle.BackColor = alignRight.BackColor = standartColor; } else if (alig == 2) { alignMiddle.BackColor = selectedColor; alignLeft.BackColor = alignRight.BackColor = standartColor; } else { alignRight.BackColor = selectedColor; alignMiddle.BackColor = alignMiddle.BackColor = standartColor; } changeAligment(); LogText.DeselectAll(); } LogText.SelectionStart = LogText.Text.Length; Dictionary <string, string> settings = RegisterLogin.getUserSettings(); if (settings["AutoSave"] == "0") { autoSave = false; } else { autoSave = true; } }