private void lviSaveFile_Click(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { TxtEditor.SaveFile(); } }
public void SelectFile() { var fileSelection = new FileSelection { Owner = Application.Current.MainWindow, CompilerMode = _compilerMode }; fileSelection.SendFilePath += val => { txtFilePath.Text = val; TxtEditor.FilePath = val; try { TxtEditor.UpdateFileContent(); UpdateScreenAlert("File loaded.", false); } catch { UpdateScreenAlert("Cannot read the file. Is it opened in another program?", true); } }; fileSelection.ShowDialog(); }
private void txtEditor_SelectionChanged(object sender, RoutedEventArgs e) { int row = TxtEditor.GetLineIndexFromCharacterIndex(TxtEditor.CaretIndex); int col = TxtEditor.CaretIndex - TxtEditor.GetCharacterIndexFromLineIndex(row); LblCursorPosition.Text = "Line " + (row + 1) + ", Char " + (col + 1); }
private void TxtEditor_SelectionChanged(object sender, RoutedEventArgs e) { int row = TxtEditor.GetLineIndexFromCharacterIndex(TxtEditor.CaretIndex); int col = TxtEditor.CaretIndex - TxtEditor.GetCharacterIndexFromLineIndex(row); LbCursorPosition.Text = $"Line {row + 1}, Char {col + 1}"; }
private void SaveFile_KeyDown(object sender, KeyEventArgs e) { if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.S) { TxtEditor.SaveFile(); } }
public void Run(TxtEditor editor) { if (!editor.File.SavedToHard) { var record = new AutoSaveRecord { CreateDate = DateTime.Now, FileName = editor.File.Name, FilePath = editor.File.Path, SavedFileName = $"{_directory}\\{Guid.NewGuid()}.ats" }; TxtProcessor.WriteToFile( record.SavedFileName, editor.File.Text); } }
public EditorInfoService(TxtEditor editor) { _editor = editor; }
public static void EnterScript(string ScriptName, Action afterAction) { Scripts = TxtEditor.ReadAllLines("Scripts", ScriptName); Projectors.Projector.Load(scn); AfterAction = afterAction; }
public void LoadFileInfo(TxtEditor editor) { var info = editor.File.Info; if (info == null) { DataSource = new List <FileProperty> { new FileProperty { Title = "تعداد کاراکترها", Value = editor.TextLength.ToString("N0") }, new FileProperty { Title = "تعداد خطوط", Value = editor.LinesCount.ToString("N0") }, new FileProperty { Title = "تعداد کلمات", Value = editor.WordsCount.ToString("N0") } }; } else { DataSource = new List <FileProperty> { new FileProperty { Title = "نام فایل", Value = editor.File.Name }, new FileProperty { Title = "مسیر", Value = editor.File.Info.DirectoryName }, new FileProperty { Title = "سایز فایل", Value = editor.File.FileSizeDisplay }, new FileProperty { Title = "تاریخ ایجاد", Value = DateTimeHelper.GetPersianDateStr( editor.File.Info.CreationTimeUtc, InsertDateFormat.DayMonthNameYear, true) }, new FileProperty { Title = "آخرین تغییر", Value = DateTimeHelper.GetPersianDateStr( editor.File.Info.LastWriteTimeUtc, InsertDateFormat.DayMonthNameYear, true) }, new FileProperty { Title = "آخرین دسترسی", Value = DateTimeHelper.GetPersianDateStr( editor.File.Info.LastAccessTimeUtc, InsertDateFormat.DayMonthNameYear, true) }, new FileProperty { Title = "تعداد کاراکترها", Value = editor.TextLength.ToString("N0") }, new FileProperty { Title = "تعداد خطوط", Value = editor.LinesCount.ToString("N0") }, new FileProperty { Title = "تعداد کلمات", Value = editor.WordsCount.ToString("N0") } }; } bindDataSource(); }
public FileProperties(TxtEditor editor) { InitializeComponent(); initListView(); LoadFileInfo(editor); }