Exemplo n.º 1
0
 private void lviSaveFile_Click(object sender, MouseButtonEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed)
     {
         TxtEditor.SaveFile();
     }
 }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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}";
        }
Exemplo n.º 5
0
 private void SaveFile_KeyDown(object sender, KeyEventArgs e)
 {
     if (Keyboard.Modifiers == ModifierKeys.Control &&
         e.Key == Key.S)
     {
         TxtEditor.SaveFile();
     }
 }
Exemplo n.º 6
0
 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);
     }
 }
Exemplo n.º 7
0
 public EditorInfoService(TxtEditor editor)
 {
     _editor = editor;
 }
Exemplo n.º 8
0
 public static void EnterScript(string ScriptName, Action afterAction)
 {
     Scripts = TxtEditor.ReadAllLines("Scripts", ScriptName);
     Projectors.Projector.Load(scn);
     AfterAction = afterAction;
 }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
0
 public FileProperties(TxtEditor editor)
 {
     InitializeComponent();
     initListView();
     LoadFileInfo(editor);
 }