Changeset 9697
- Timestamp:
- 07/05/13 10:50:47 (11 years ago)
- Location:
- branches/HeuristicLab.Data Path DataTypes
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/HeuristicLab.Data.Views-3.3.csproj
r9689 r9697 242 242 </ItemGroup> 243 243 <ItemGroup> 244 <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">245 <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>246 <Name>HeuristicLab.Data-3.3</Name>247 <Private>False</Private>248 </ProjectReference>249 </ItemGroup>250 <ItemGroup>251 244 <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> 252 245 <Visible>False</Visible> … … 264 257 <Install>true</Install> 265 258 </BootstrapperPackage> 259 </ItemGroup> 260 <ItemGroup> 261 <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj"> 262 <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project> 263 <Name>HeuristicLab.Data-3.3</Name> 264 </ProjectReference> 266 265 </ItemGroup> 267 266 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/Path Views/DirectoryValueView.cs
r9680 r9697 47 47 protected override void SetEnabledStateOfControls() { 48 48 base.SetEnabledStateOfControls(); 49 valueTextBox.ReadOnly = Locked || ReadOnly || Content == null || Content.CheckExistence; 49 valueTextBox.Enabled = !Locked && !ReadOnly && Content != null; 50 valueTextBox.ReadOnly = Locked || ReadOnly || Content == null; 50 51 openButton.Enabled = !Locked && !ReadOnly && Content != null; 51 52 } … … 64 65 protected virtual void openButton_Click(object sender, EventArgs e) { 65 66 if (folderBrowserDialog.ShowDialog(this) != DialogResult.OK) return; 66 67 valueTextBox.Text = folderBrowserDialog.SelectedPath; 68 valueTextBox.Focus(); 69 Validate(); 67 Content.Value = folderBrowserDialog.SelectedPath; 70 68 } 71 69 } -
branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.cs
r9680 r9697 22 22 using System; 23 23 using System.Windows.Forms; 24 using HeuristicLab.Data.Views;25 24 using HeuristicLab.MainForm; 26 25 … … 56 55 protected override void SetEnabledStateOfControls() { 57 56 base.SetEnabledStateOfControls(); 58 valueTextBox.Enabled = !Locked && !ReadOnly && Content != null && !Content.CheckExistence;59 valueTextBox.ReadOnly = Locked || ReadOnly || Content == null || Content.CheckExistence;57 valueTextBox.Enabled = !Locked && !ReadOnly && Content != null; 58 valueTextBox.ReadOnly = Locked || ReadOnly || Content == null; 60 59 openButton.Enabled = !Locked && !ReadOnly && Content != null; 61 60 } -
branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/Path Views/TextFileView.cs
r9680 r9697 68 68 saveButton.Enabled = !Locked && !ReadOnly && Content != null && ChangedFileContent; 69 69 70 if (Content != null && File.Exists(Content.Value)) {70 if (Content != null && Content.Exists()) { 71 71 fileSystemWatcher.Filter = Path.GetFileName(Content.Value); 72 72 fileSystemWatcher.Path = Path.GetDirectoryName(Content.Value); … … 77 77 protected override void OnVisibleChanged(EventArgs e) { 78 78 //mkommend: necessary to update the textbox to detect intermediate file changes. 79 if (Visible ) UpdateTextBox();79 if (Visible && Content != null) UpdateTextBox(); 80 80 base.OnVisibleChanged(e); 81 81 } … … 228 228 public static string ReadFile(string path) { 229 229 if (!File.Exists(path)) return null; 230 //TODO handle IO Exceptions231 230 string fileContent; 232 231 using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { … … 239 238 240 239 public static void WriteFile(string path, string fileContent) { 241 //TODO handle IO Exceptions242 240 using (FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write)) { 243 241 using (StreamWriter streamWriter = new StreamWriter(fileStream)) { -
branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs
r9657 r9697 23 23 using System.ComponentModel; 24 24 using System.Drawing; 25 using System.Linq;26 25 using System.Text; 27 26 using System.Windows.Forms; … … 105 104 106 105 protected virtual void UpdateRowHeaders() { 107 for (int i = 0; i < dataGridView.RowCount; i++) { 108 if (i < Content.ElementNames.Count()) 109 dataGridView.Rows[i].HeaderCell.Value = Content.ElementNames.ElementAt(i); 110 else 111 dataGridView.Rows[i].HeaderCell.Value = string.Empty; 106 int i = 0; 107 foreach (string elementName in Content.ElementNames) { 108 dataGridView.Rows[i].HeaderCell.Value = elementName; 109 i++; 110 } 111 for (; i < dataGridView.RowCount; i++) { 112 dataGridView.Rows[i].HeaderCell.Value = string.Empty; 112 113 } 113 114 } … … 124 125 Invoke(new EventHandler<EventArgs<int>>(Content_ItemChanged), sender, e); 125 126 else { 127 // if a resize of the array occurs and some other class handles the event and provides default values 128 //then the itemChanged will occur before the reset event. hence the check was added 129 if (dataGridView.RowCount <= e.Value) return; 126 130 dataGridView.Rows[e.Value].Cells[0].Value = Content.GetValue(e.Value); 127 131 Size size = dataGridView.Rows[e.Value].Cells[0].PreferredSize; -
branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data/3.3/Path Types/PathValue.cs
r9680 r9697 21 21 22 22 23 using System;24 23 using System.IO; 25 24 using HeuristicLab.Common; … … 31 30 [StorableClass] 32 31 public abstract class PathValue : StringValue { 33 [Storable]34 private bool checkExistence;35 public bool CheckExistence {36 get { return checkExistence; }37 set {38 if (ReadOnly) throw new NotSupportedException("CheckExistence cannot be set. PathValue is read-only.");39 if (value != checkExistence) {40 checkExistence = value;41 OnCheckExistenceChanged();42 }43 }44 }45 46 32 public override string Value { 47 33 get { return base.Value; } 48 34 set { 49 35 if (value == null) value = string.Empty; 50 if (checkExistence && !string.IsNullOrEmpty(value) && !File.Exists(value) && !Directory.Exists(value)) 51 throw new ArgumentException(string.Format("The given file {0} does not exists.", value)); 52 if (value[value.Length - 1] == Path.DirectorySeparatorChar) 53 value = value.TrimEnd(Path.DirectorySeparatorChar); 54 if (value[value.Length - 1] == Path.AltDirectorySeparatorChar) 55 value = value.TrimEnd(Path.AltDirectorySeparatorChar); 36 value = value.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); 56 37 base.Value = value; 57 38 } … … 60 41 [StorableConstructor] 61 42 protected PathValue(bool deserializing) : base(deserializing) { } 62 protected PathValue(PathValue original, Cloner cloner) 63 : base(original, cloner) { 64 checkExistence = original.checkExistence; 65 } 43 protected PathValue(PathValue original, Cloner cloner) : base(original, cloner) { } 66 44 67 45 protected PathValue() 68 : base(string.Empty) { 69 checkExistence = true; 70 } 46 : base(string.Empty) { } 71 47 72 48 public abstract bool Exists(); 73 74 protected override bool Validate(string value, out string errorMessage) {75 if (CheckExistence && !File.Exists(value) && !Directory.Exists(value)) {76 errorMessage = string.Format("The given path {0} does not exist.", value);77 return false;78 }79 return base.Validate(value, out errorMessage);80 }81 82 public event EventHandler CheckExistenceChanged;83 protected virtual void OnCheckExistenceChanged() {84 var handler = CheckExistenceChanged;85 if (handler != null)86 handler(this, EventArgs.Empty);87 }88 49 } 89 50 }
Note: See TracChangeset
for help on using the changeset viewer.