Changeset 9935 for trunk/sources/HeuristicLab.MainForm.WindowsForms
- Timestamp:
- 09/04/13 10:49:47 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Dialogs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Dialogs/InfoBox.Designer.cs
r9916 r9935 59 59 this.okButton.Text = "&OK"; 60 60 this.okButton.UseVisualStyleBackColor = true; 61 this.okButton.Click += new System.EventHandler(this.okButton_Click);62 61 // 63 62 // infoRichTextBox … … 78 77 // InfoBox 79 78 // 79 this.AcceptButton = this.okButton; 80 80 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 81 81 this.ClientSize = new System.Drawing.Size(636, 494); … … 89 89 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 90 90 this.Text = "Info Box"; 91 this.Load += new System.EventHandler(this.InfoBox_Load); 91 92 this.ResumeLayout(false); 92 93 -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Dialogs/InfoBox.cs
r9916 r9935 27 27 namespace HeuristicLab.MainForm.WindowsForms { 28 28 public partial class InfoBox : Form { 29 p ublic string Caption {30 get { return this.Text; }31 set { 32 if (InvokeRequired)33 Invoke(new Action<string>(x => this.Text = x), value);34 else35 this.Text = value;36 }29 protected string embeddedResourceName; 30 protected IView parentView; 31 32 public InfoBox(string caption, string embeddedResourceName, IView parentView) { 33 InitializeComponent(); 34 this.Text = caption; 35 this.parentView = parentView; 36 this.embeddedResourceName = embeddedResourceName; 37 37 } 38 38 39 protected string embeddedResourceName; 40 public string EmbeddedResourceName { 41 get { return embeddedResourceName; } 42 set { 43 if (InvokeRequired) 44 Invoke(new Action<string>(x => this.EmbeddedResourceName = x), value); 45 else { 46 embeddedResourceName = value; 47 LoadEmbeddedResource(embeddedResourceName); 48 } 49 } 50 } 51 52 public IView ParentView { get; set; } 53 54 public InfoBox() { 55 InitializeComponent(); 56 } 57 58 public InfoBox(string caption, string embeddedResourceName, IView parentView) 59 : this() { 60 Caption = caption; 61 ParentView = parentView; 62 EmbeddedResourceName = embeddedResourceName; 63 } 64 65 protected virtual void LoadEmbeddedResource(string resourceName) { 66 string extension = Path.GetExtension(resourceName); 67 Assembly assembly = Assembly.GetAssembly(ParentView.GetType()); 39 protected virtual void LoadEmbeddedResource() { 40 string extension = Path.GetExtension(embeddedResourceName); 41 Assembly assembly = Assembly.GetAssembly(parentView.GetType()); 68 42 try { 69 using (Stream stream = assembly.GetManifestResourceStream( resourceName)) {43 using (Stream stream = assembly.GetManifestResourceStream(embeddedResourceName)) { 70 44 if (extension == ".rtf") { 71 45 infoRichTextBox.LoadFile(stream, RichTextBoxStreamType.RichText); … … 82 56 } 83 57 84 pr otected virtual void okButton_Click(object sender, EventArgs e) {85 Close();58 private void InfoBox_Load(object sender, EventArgs e) { 59 LoadEmbeddedResource(); 86 60 } 87 61 }
Note: See TracChangeset
for help on using the changeset viewer.