Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/17/13 13:35:44 (11 years ago)
Author:
mkommend
Message:

#2081: Integrated new HL path data types from the branch.

Location:
trunk/sources/HeuristicLab.Data.Views/3.3
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data.Views/3.3

  • trunk/sources/HeuristicLab.Data.Views/3.3/Path Views/TextFileView.cs

    r9705 r9714  
    2929namespace HeuristicLab.Data.Views {
    3030  [View("TextFileView")]
    31   [Content(typeof(TextFile), true)]
    32   public partial class TextFileView : ItemView {
     31  [Content(typeof(TextFileValue), true)]
     32  public sealed partial class TextFileView : ItemView {
    3333    private bool changedFileContent;
    34     protected bool ChangedFileContent {
     34    private bool ChangedFileContent {
    3535      get { return changedFileContent; }
    3636      set {
     
    4242    }
    4343
    44     public new TextFile Content {
    45       get { return (TextFile)base.Content; }
     44    public new TextFileValue Content {
     45      get { return (TextFileValue)base.Content; }
    4646      set { base.Content = value; }
    4747    }
     
    9797    }
    9898
    99     protected virtual void Content_FilePathChanged(object sender, EventArgs e) {
     99    private void Content_FilePathChanged(object sender, EventArgs e) {
    100100      UpdateTextBox();
    101101      SetEnabledStateOfControls();
    102102    }
    103     protected virtual void Content_FileDialogFilterChanged(object sender, EventArgs e) {
     103    private void Content_FileDialogFilterChanged(object sender, EventArgs e) {
    104104      saveFileDialog.Filter = Content.FileDialogFilter;
    105105    }
    106106
    107     protected virtual void textBox_TextChanged(object sender, EventArgs e) {
     107    private void textBox_TextChanged(object sender, EventArgs e) {
    108108      ChangedFileContent = fileText != textBox.Text;
    109109    }
    110110
    111     protected virtual void OnChangedFileContent() {
     111    private void OnChangedFileContent() {
    112112      SetEnabledStateOfControls();
    113113      if (ChangedFileContent) {
     
    118118    }
    119119
    120     protected bool fileSystemWatcherChangedFired = false;
    121     protected virtual void fileSystemWatcher_Changed(object sender, FileSystemEventArgs e) {
     120    private bool fileSystemWatcherChangedFired = false;
     121    private void fileSystemWatcher_Changed(object sender, FileSystemEventArgs e) {
    122122      //mkommend: cannot react on visible changed, because this event is not fired when the parent control gets visible set to false
    123123      if (!Visible) return;
     
    162162    }
    163163
    164     protected virtual void fileSystemWatcher_Renamed(object sender, RenamedEventArgs e) {
     164    private void fileSystemWatcher_Renamed(object sender, RenamedEventArgs e) {
    165165      //mkommend: cannot react on visible changed, because this event is not fired when the parent control gets visible set to false
    166166      if (!Visible) return;
     
    174174    }
    175175
    176     protected virtual void SaveFile() {
     176    private void SaveFile() {
    177177      //omit circular events by changing the file from HL
    178178      fileSystemWatcher.EnableRaisingEvents = false;
     
    189189    }
    190190
    191     protected virtual void saveButton_Click(object sender, EventArgs e) {
     191    private void saveButton_Click(object sender, EventArgs e) {
    192192      SaveFile();
    193193    }
    194194
    195     protected string fileText;
    196     protected virtual void UpdateTextBox() {
     195    private string fileText;
     196    private void UpdateTextBox() {
    197197      if (string.IsNullOrEmpty(Content.Value)) {
    198198        textBox.Enabled = false;
     
    201201      }
    202202
    203       fileText = ReadFile(Content.Value) ?? string.Empty;
    204       if (string.IsNullOrEmpty(fileText)) {
     203      fileText = ReadFile(Content.Value);
     204      if (fileText == null) {
    205205        textBox.Enabled = false;
    206206        textBox.Text = string.Format("The specified file \"{0}\" cannot be found.", Content.Value);
     
    211211      textBox.Text = fileText;
    212212    }
    213     protected virtual void textBox_Validated(object sender, EventArgs e) {
     213    private void textBox_Validated(object sender, EventArgs e) {
    214214      if (!ChangedFileContent) return;
    215215      string msg = string.Format("You have not saved the changes in the file \"{0}\" yet. Do you want to save the changes?", Content.Value);
     
    226226    }
    227227
    228     public static string ReadFile(string path) {
     228    private static string ReadFile(string path) {
    229229      if (!File.Exists(path)) return null;
    230       string fileContent;
     230      string fileContent = string.Empty;
    231231      using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) {
    232232        using (StreamReader streamReader = new StreamReader(fileStream)) {
     
    237237    }
    238238
    239     public static void WriteFile(string path, string fileContent) {
     239    private static void WriteFile(string path, string fileContent) {
    240240      using (FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write)) {
    241241        using (StreamWriter streamWriter = new StreamWriter(fileStream)) {
Note: See TracChangeset for help on using the changeset viewer.