- Timestamp:
- 07/17/13 13:35:44 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.Data.Views/3.3
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data.Views/3.3
-
Property
svn:mergeinfo
set to
/branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3 merged eligible
-
Property
svn:mergeinfo
set to
-
trunk/sources/HeuristicLab.Data.Views/3.3/Path Views/TextFileView.cs
r9705 r9714 29 29 namespace HeuristicLab.Data.Views { 30 30 [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 { 33 33 private bool changedFileContent; 34 pr otectedbool ChangedFileContent {34 private bool ChangedFileContent { 35 35 get { return changedFileContent; } 36 36 set { … … 42 42 } 43 43 44 public new TextFile Content {45 get { return (TextFile )base.Content; }44 public new TextFileValue Content { 45 get { return (TextFileValue)base.Content; } 46 46 set { base.Content = value; } 47 47 } … … 97 97 } 98 98 99 pr otected virtualvoid Content_FilePathChanged(object sender, EventArgs e) {99 private void Content_FilePathChanged(object sender, EventArgs e) { 100 100 UpdateTextBox(); 101 101 SetEnabledStateOfControls(); 102 102 } 103 pr otected virtualvoid Content_FileDialogFilterChanged(object sender, EventArgs e) {103 private void Content_FileDialogFilterChanged(object sender, EventArgs e) { 104 104 saveFileDialog.Filter = Content.FileDialogFilter; 105 105 } 106 106 107 pr otected virtualvoid textBox_TextChanged(object sender, EventArgs e) {107 private void textBox_TextChanged(object sender, EventArgs e) { 108 108 ChangedFileContent = fileText != textBox.Text; 109 109 } 110 110 111 pr otected virtualvoid OnChangedFileContent() {111 private void OnChangedFileContent() { 112 112 SetEnabledStateOfControls(); 113 113 if (ChangedFileContent) { … … 118 118 } 119 119 120 pr otectedbool fileSystemWatcherChangedFired = false;121 pr otected virtualvoid fileSystemWatcher_Changed(object sender, FileSystemEventArgs e) {120 private bool fileSystemWatcherChangedFired = false; 121 private void fileSystemWatcher_Changed(object sender, FileSystemEventArgs e) { 122 122 //mkommend: cannot react on visible changed, because this event is not fired when the parent control gets visible set to false 123 123 if (!Visible) return; … … 162 162 } 163 163 164 pr otected virtualvoid fileSystemWatcher_Renamed(object sender, RenamedEventArgs e) {164 private void fileSystemWatcher_Renamed(object sender, RenamedEventArgs e) { 165 165 //mkommend: cannot react on visible changed, because this event is not fired when the parent control gets visible set to false 166 166 if (!Visible) return; … … 174 174 } 175 175 176 pr otected virtualvoid SaveFile() {176 private void SaveFile() { 177 177 //omit circular events by changing the file from HL 178 178 fileSystemWatcher.EnableRaisingEvents = false; … … 189 189 } 190 190 191 pr otected virtualvoid saveButton_Click(object sender, EventArgs e) {191 private void saveButton_Click(object sender, EventArgs e) { 192 192 SaveFile(); 193 193 } 194 194 195 pr otectedstring fileText;196 pr otected virtualvoid UpdateTextBox() {195 private string fileText; 196 private void UpdateTextBox() { 197 197 if (string.IsNullOrEmpty(Content.Value)) { 198 198 textBox.Enabled = false; … … 201 201 } 202 202 203 fileText = ReadFile(Content.Value) ?? string.Empty;204 if ( string.IsNullOrEmpty(fileText)) {203 fileText = ReadFile(Content.Value); 204 if (fileText == null) { 205 205 textBox.Enabled = false; 206 206 textBox.Text = string.Format("The specified file \"{0}\" cannot be found.", Content.Value); … … 211 211 textBox.Text = fileText; 212 212 } 213 pr otected virtualvoid textBox_Validated(object sender, EventArgs e) {213 private void textBox_Validated(object sender, EventArgs e) { 214 214 if (!ChangedFileContent) return; 215 215 string msg = string.Format("You have not saved the changes in the file \"{0}\" yet. Do you want to save the changes?", Content.Value); … … 226 226 } 227 227 228 p ublicstatic string ReadFile(string path) {228 private static string ReadFile(string path) { 229 229 if (!File.Exists(path)) return null; 230 string fileContent ;230 string fileContent = string.Empty; 231 231 using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { 232 232 using (StreamReader streamReader = new StreamReader(fileStream)) { … … 237 237 } 238 238 239 p ublicstatic void WriteFile(string path, string fileContent) {239 private static void WriteFile(string path, string fileContent) { 240 240 using (FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write)) { 241 241 using (StreamWriter streamWriter = new StreamWriter(fileStream)) {
Note: See TracChangeset
for help on using the changeset viewer.