Changeset 3298 for trunk/sources
- Timestamp:
- 04/11/10 03:16:07 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.Designer.cs
r3292 r3298 21 21 22 22 namespace HeuristicLab.Core.Views { 23 partial class Clipboard {23 partial class Clipboard<T> { 24 24 /// <summary> 25 25 /// Required designer variable. … … 33 33 protected override void Dispose(bool disposing) { 34 34 if (disposing) { 35 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 35 36 if (components != null) components.Dispose(); 36 37 } … … 45 46 /// </summary> 46 47 private void InitializeComponent() { 48 this.components = new System.ComponentModel.Container(); 49 this.listView = new System.Windows.Forms.ListView(); 50 this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); 51 this.imageList = new System.Windows.Forms.ImageList(this.components); 52 this.infoPanel = new System.Windows.Forms.Panel(); 53 this.progressBar = new System.Windows.Forms.ProgressBar(); 54 this.infoLabel = new System.Windows.Forms.Label(); 55 this.sortDescendingButton = new System.Windows.Forms.Button(); 56 this.sortAscendingButton = new System.Windows.Forms.Button(); 57 this.removeButton = new System.Windows.Forms.Button(); 58 this.addButton = new System.Windows.Forms.Button(); 59 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 60 this.saveButton = new System.Windows.Forms.Button(); 61 this.infoPanel.SuspendLayout(); 47 62 this.SuspendLayout(); 63 // 64 // listView 65 // 66 this.listView.AllowDrop = true; 67 this.listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 68 | System.Windows.Forms.AnchorStyles.Left) 69 | System.Windows.Forms.AnchorStyles.Right))); 70 this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 71 this.columnHeader1}); 72 this.listView.FullRowSelect = true; 73 this.listView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; 74 this.listView.HideSelection = false; 75 this.listView.Location = new System.Drawing.Point(0, 30); 76 this.listView.Name = "listView"; 77 this.listView.ShowItemToolTips = true; 78 this.listView.Size = new System.Drawing.Size(179, 432); 79 this.listView.SmallImageList = this.imageList; 80 this.listView.Sorting = System.Windows.Forms.SortOrder.Ascending; 81 this.listView.TabIndex = 0; 82 this.listView.UseCompatibleStateImageBehavior = false; 83 this.listView.View = System.Windows.Forms.View.Details; 84 this.listView.SelectedIndexChanged += new System.EventHandler(this.listView_SelectedIndexChanged); 85 this.listView.SizeChanged += new System.EventHandler(this.listView_SizeChanged); 86 this.listView.DoubleClick += new System.EventHandler(this.listView_DoubleClick); 87 this.listView.DragDrop += new System.Windows.Forms.DragEventHandler(this.listView_DragDrop); 88 this.listView.DragEnter += new System.Windows.Forms.DragEventHandler(this.listView_DragEnterOver); 89 this.listView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listView_KeyDown); 90 this.listView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.listView_ItemDrag); 91 this.listView.DragOver += new System.Windows.Forms.DragEventHandler(this.listView_DragEnterOver); 92 // 93 // imageList 94 // 95 this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; 96 this.imageList.ImageSize = new System.Drawing.Size(16, 16); 97 this.imageList.TransparentColor = System.Drawing.Color.Transparent; 98 // 99 // infoPanel 100 // 101 this.infoPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); 102 this.infoPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 103 this.infoPanel.Controls.Add(this.progressBar); 104 this.infoPanel.Controls.Add(this.infoLabel); 105 this.infoPanel.Enabled = false; 106 this.infoPanel.Location = new System.Drawing.Point(13, 202); 107 this.infoPanel.Name = "infoPanel"; 108 this.infoPanel.Size = new System.Drawing.Size(154, 59); 109 this.infoPanel.TabIndex = 6; 110 // 111 // progressBar 112 // 113 this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); 114 this.progressBar.Location = new System.Drawing.Point(3, 30); 115 this.progressBar.Name = "progressBar"; 116 this.progressBar.Size = new System.Drawing.Size(146, 23); 117 this.progressBar.Step = 1; 118 this.progressBar.TabIndex = 1; 119 // 120 // infoLabel 121 // 122 this.infoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); 123 this.infoLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 124 this.infoLabel.Location = new System.Drawing.Point(3, 4); 125 this.infoLabel.Name = "infoLabel"; 126 this.infoLabel.Size = new System.Drawing.Size(146, 23); 127 this.infoLabel.TabIndex = 0; 128 this.infoLabel.Text = "Loading ..."; 129 this.infoLabel.TextAlign = System.Drawing.ContentAlignment.BottomCenter; 130 // 131 // sortDescendingButton 132 // 133 this.sortDescendingButton.Enabled = false; 134 this.sortDescendingButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.SortUp; 135 this.sortDescendingButton.Location = new System.Drawing.Point(30, 0); 136 this.sortDescendingButton.Name = "sortDescendingButton"; 137 this.sortDescendingButton.Size = new System.Drawing.Size(24, 24); 138 this.sortDescendingButton.TabIndex = 2; 139 this.toolTip.SetToolTip(this.sortDescendingButton, "Sort Descending"); 140 this.sortDescendingButton.UseVisualStyleBackColor = true; 141 this.sortDescendingButton.Click += new System.EventHandler(this.sortDescendingButton_Click); 142 // 143 // sortAscendingButton 144 // 145 this.sortAscendingButton.Enabled = false; 146 this.sortAscendingButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Sort; 147 this.sortAscendingButton.Location = new System.Drawing.Point(60, 0); 148 this.sortAscendingButton.Name = "sortAscendingButton"; 149 this.sortAscendingButton.Size = new System.Drawing.Size(24, 24); 150 this.sortAscendingButton.TabIndex = 3; 151 this.toolTip.SetToolTip(this.sortAscendingButton, "Sort Ascending"); 152 this.sortAscendingButton.UseVisualStyleBackColor = true; 153 this.sortAscendingButton.Click += new System.EventHandler(this.sortAscendingButton_Click); 154 // 155 // removeButton 156 // 157 this.removeButton.Enabled = false; 158 this.removeButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Remove; 159 this.removeButton.Location = new System.Drawing.Point(90, 0); 160 this.removeButton.Name = "removeButton"; 161 this.removeButton.Size = new System.Drawing.Size(24, 24); 162 this.removeButton.TabIndex = 4; 163 this.toolTip.SetToolTip(this.removeButton, "Remove Item"); 164 this.removeButton.UseVisualStyleBackColor = true; 165 this.removeButton.Click += new System.EventHandler(this.removeButton_Click); 166 // 167 // addButton 168 // 169 this.addButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Add; 170 this.addButton.Location = new System.Drawing.Point(0, 0); 171 this.addButton.Name = "addButton"; 172 this.addButton.Size = new System.Drawing.Size(24, 24); 173 this.addButton.TabIndex = 1; 174 this.toolTip.SetToolTip(this.addButton, "Add Item"); 175 this.addButton.UseVisualStyleBackColor = true; 176 this.addButton.Click += new System.EventHandler(this.addButton_Click); 177 // 178 // saveButton 179 // 180 this.saveButton.Enabled = false; 181 this.saveButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Save; 182 this.saveButton.Location = new System.Drawing.Point(120, 0); 183 this.saveButton.Name = "saveButton"; 184 this.saveButton.Size = new System.Drawing.Size(24, 24); 185 this.saveButton.TabIndex = 5; 186 this.toolTip.SetToolTip(this.saveButton, "Save All Items"); 187 this.saveButton.UseVisualStyleBackColor = true; 188 this.saveButton.Click += new System.EventHandler(this.saveButton_Click); 48 189 // 49 190 // Clipboard … … 52 193 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 53 194 this.Caption = "Clipboard"; 195 this.Controls.Add(this.sortDescendingButton); 196 this.Controls.Add(this.sortAscendingButton); 197 this.Controls.Add(this.saveButton); 198 this.Controls.Add(this.removeButton); 199 this.Controls.Add(this.addButton); 200 this.Controls.Add(this.infoPanel); 201 this.Controls.Add(this.listView); 54 202 this.Name = "Clipboard"; 55 this.Size = new System.Drawing.Size(316, 296); 203 this.Size = new System.Drawing.Size(179, 462); 204 this.infoPanel.ResumeLayout(false); 56 205 this.ResumeLayout(false); 57 206 … … 59 208 60 209 #endregion 210 211 private System.Windows.Forms.ListView listView; 212 private System.Windows.Forms.Panel infoPanel; 213 private System.Windows.Forms.ProgressBar progressBar; 214 private System.Windows.Forms.Label infoLabel; 215 private System.Windows.Forms.ImageList imageList; 216 private System.Windows.Forms.Button sortDescendingButton; 217 private System.Windows.Forms.Button sortAscendingButton; 218 private System.Windows.Forms.Button removeButton; 219 private System.Windows.Forms.Button addButton; 220 private System.Windows.Forms.ColumnHeader columnHeader1; 221 private System.Windows.Forms.ToolTip toolTip; 222 private System.Windows.Forms.Button saveButton; 61 223 62 224 } -
trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs
r3292 r3298 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.IO; 25 using System.Linq; 26 using System.Threading; 23 27 using System.Windows.Forms; 24 28 using HeuristicLab.MainForm; 29 using HeuristicLab.Persistence.Default.Xml; 25 30 26 31 namespace HeuristicLab.Core.Views { 27 32 [View("Clipboard")] 28 public partial class Clipboard : HeuristicLab.MainForm.WindowsForms.View { 33 public sealed partial class Clipboard<T> : HeuristicLab.MainForm.WindowsForms.View where T : class, IItem { 34 private TypeSelectorDialog typeSelectorDialog; 35 private Dictionary<T, ListViewItem> itemListViewItemTable; 36 37 private string itemsPath; 38 public string ItemsPath { 39 get { return itemsPath; } 40 private set { 41 if (string.IsNullOrEmpty(value)) throw new ArgumentException(string.Format("Invalid items path \"{0}\".", value)); 42 itemsPath = value; 43 try { 44 if (!Directory.Exists(itemsPath)) { 45 Directory.CreateDirectory(itemsPath); 46 // directory creation might take some time -> wait until it is definitively created 47 while (!Directory.Exists(itemsPath)) { 48 Thread.Sleep(100); 49 Directory.CreateDirectory(itemsPath); 50 } 51 } 52 } 53 catch (Exception ex) { 54 throw new ArgumentException(string.Format("Invalid items path \"{0}\".", itemsPath), ex); 55 } 56 } 57 } 58 29 59 public Clipboard() { 30 60 InitializeComponent(); 61 ItemsPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + 62 Path.DirectorySeparatorChar + "HeuristicLab" + Path.DirectorySeparatorChar + "Clipboard"; 63 itemListViewItemTable = new Dictionary<T, ListViewItem>(); 64 } 65 public Clipboard(string itemsPath) { 66 InitializeComponent(); 67 ItemsPath = itemsPath; 68 itemListViewItemTable = new Dictionary<T, ListViewItem>(); 31 69 } 32 70 33 71 protected override void OnInitialized(EventArgs e) { 34 72 base.OnInitialized(e); 73 Enabled = false; 74 infoLabel.Text = "Loading ..."; 75 progressBar.Value = 0; 76 infoPanel.Visible = true; 77 ThreadPool.QueueUserWorkItem(new WaitCallback(LoadItems)); 35 78 } 36 79 protected override void OnClosing(FormClosingEventArgs e) { … … 41 84 } 42 85 } 86 87 public void AddItem(T item) { 88 if (InvokeRequired) 89 Invoke(new Action<T>(AddItem), item); 90 else { 91 if (!itemListViewItemTable.ContainsKey(item)) { 92 if (!listView.SmallImageList.Images.ContainsKey(item.GetType().FullName)) 93 listView.SmallImageList.Images.Add(item.GetType().FullName, item.ItemImage); 94 95 ListViewItem listViewItem = new ListViewItem(item.ToString()); 96 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 97 listViewItem.ImageIndex = listView.SmallImageList.Images.IndexOfKey(item.GetType().FullName); 98 listViewItem.Tag = item; 99 listView.Items.Add(listViewItem); 100 itemListViewItemTable.Add(item, listViewItem); 101 item.ToStringChanged += new EventHandler(Item_ToStringChanged); 102 sortAscendingButton.Enabled = sortDescendingButton.Enabled = listView.Items.Count > 1; 103 saveButton.Enabled = listView.Items.Count > 0; 104 } 105 } 106 } 107 private void RemoveItem(T item) { 108 if (InvokeRequired) 109 Invoke(new Action<T>(RemoveItem), item); 110 else { 111 if (itemListViewItemTable.ContainsKey(item)) { 112 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 113 itemListViewItemTable[item].Remove(); 114 itemListViewItemTable.Remove(item); 115 sortAscendingButton.Enabled = sortDescendingButton.Enabled = listView.Items.Count > 1; 116 saveButton.Enabled = listView.Items.Count > 0; 117 } 118 } 119 } 120 private void Save() { 121 if (InvokeRequired) 122 Invoke(new Action(Save)); 123 else { 124 Enabled = false; 125 infoLabel.Text = "Saving ..."; 126 progressBar.Value = 0; 127 infoPanel.Visible = true; 128 ThreadPool.QueueUserWorkItem(new WaitCallback(SaveItems)); 129 } 130 } 131 132 #region Loading/Saving Items 133 private void LoadItems(object state) { 134 string[] items = Directory.GetFiles(ItemsPath); 135 foreach (string filename in items) { 136 try { 137 T item = XmlParser.Deserialize<T>(filename); 138 OnItemLoaded(item, progressBar.Maximum / items.Length); 139 } 140 catch (Exception) { } 141 } 142 OnAllItemsLoaded(); 143 } 144 private void OnItemLoaded(T item, int progress) { 145 if (InvokeRequired) 146 Invoke(new Action<T, int>(OnItemLoaded), item, progress); 147 else { 148 AddItem(item); 149 progressBar.Value += progress; 150 } 151 } 152 private void OnAllItemsLoaded() { 153 if (InvokeRequired) 154 Invoke(new Action(OnAllItemsLoaded)); 155 else { 156 Enabled = true; 157 if (listView.Items.Count > 0) { 158 for (int i = 0; i < listView.Columns.Count; i++) 159 listView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 160 } 161 infoPanel.Visible = false; 162 } 163 } 164 private void SaveItems(object param) { 165 Directory.Delete(ItemsPath, true); 166 Directory.CreateDirectory(ItemsPath); 167 // directory creation might take some time -> wait until it is definitively created 168 while (!Directory.Exists(ItemsPath)) { 169 Thread.Sleep(100); 170 Directory.CreateDirectory(ItemsPath); 171 } 172 173 int i = 0; 174 T[] items = itemListViewItemTable.Keys.ToArray(); 175 foreach (T item in items) { 176 try { 177 i++; 178 XmlGenerator.Serialize(item, ItemsPath + Path.DirectorySeparatorChar + i.ToString("00000000") + ".hl", 9); 179 OnItemSaved(item, progressBar.Maximum / listView.Items.Count); 180 } 181 catch (Exception) { } 182 } 183 OnAllItemsSaved(); 184 } 185 private void OnItemSaved(T item, int progress) { 186 if (item != null) { 187 if (InvokeRequired) 188 Invoke(new Action<T, int>(OnItemLoaded), item, progress); 189 else 190 progressBar.Value += progress; 191 } 192 } 193 private void OnAllItemsSaved() { 194 if (InvokeRequired) 195 Invoke(new Action(OnAllItemsLoaded)); 196 else { 197 Enabled = true; 198 infoPanel.Visible = false; 199 } 200 } 201 #endregion 202 203 #region ListView Events 204 private void listView_SelectedIndexChanged(object sender, EventArgs e) { 205 removeButton.Enabled = listView.SelectedItems.Count > 0; 206 } 207 private void listView_SizeChanged(object sender, EventArgs e) { 208 if (listView.Columns.Count > 0) 209 listView.Columns[0].Width = Math.Max(0, listView.Width - 25); 210 } 211 private void listView_KeyDown(object sender, KeyEventArgs e) { 212 if (e.KeyCode == Keys.Delete) { 213 if (listView.SelectedItems.Count > 0) { 214 foreach (ListViewItem item in listView.SelectedItems) 215 RemoveItem((T)item.Tag); 216 } 217 } 218 } 219 private void listView_DoubleClick(object sender, EventArgs e) { 220 if (listView.SelectedItems.Count == 1) { 221 T item = (T)listView.SelectedItems[0].Tag; 222 IView view = MainFormManager.CreateDefaultView(item); 223 if (view != null) view.Show(); 224 } 225 } 226 private void listView_ItemDrag(object sender, ItemDragEventArgs e) { 227 ListViewItem listViewItem = (ListViewItem)e.Item; 228 T item = (T)listViewItem.Tag; 229 DataObject data = new DataObject(); 230 data.SetData("Type", item.GetType()); 231 data.SetData("Value", item); 232 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 233 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 234 RemoveItem(item); 235 } 236 private void listView_DragEnterOver(object sender, DragEventArgs e) { 237 e.Effect = DragDropEffects.None; 238 Type type = e.Data.GetData("Type") as Type; 239 T item = e.Data.GetData("Value") as T; 240 if ((type != null) && (item != null)) { 241 if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy; // CTRL key 242 else if (((e.KeyState & 4) == 4) && !itemListViewItemTable.ContainsKey(item)) e.Effect = DragDropEffects.Move; // SHIFT key 243 else if (((e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) && !itemListViewItemTable.ContainsKey(item)) e.Effect = DragDropEffects.Link; 244 else if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy; 245 else if (((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) && !itemListViewItemTable.ContainsKey(item)) e.Effect = DragDropEffects.Move; 246 } 247 } 248 private void listView_DragDrop(object sender, DragEventArgs e) { 249 if (e.Effect != DragDropEffects.None) { 250 T item = e.Data.GetData("Value") as T; 251 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (T)item.Clone(); 252 AddItem(item); 253 } 254 } 255 #endregion 256 257 #region Button Events 258 private void addButton_Click(object sender, EventArgs e) { 259 if (typeSelectorDialog == null) { 260 typeSelectorDialog = new TypeSelectorDialog(); 261 typeSelectorDialog.Caption = "Select Item"; 262 typeSelectorDialog.TypeSelector.Caption = "Available Items"; 263 typeSelectorDialog.TypeSelector.Configure(typeof(T), false, false); 264 } 265 266 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) 267 AddItem((T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType()); 268 } 269 private void sortAscendingButton_Click(object sender, EventArgs e) { 270 listView.Sorting = SortOrder.None; 271 listView.Sorting = SortOrder.Ascending; 272 } 273 private void sortDescendingButton_Click(object sender, EventArgs e) { 274 listView.Sorting = SortOrder.None; 275 listView.Sorting = SortOrder.Descending; 276 } 277 private void removeButton_Click(object sender, EventArgs e) { 278 if (listView.SelectedItems.Count > 0) { 279 foreach (ListViewItem item in listView.SelectedItems) 280 RemoveItem((T)item.Tag); 281 } 282 } 283 private void saveButton_Click(object sender, EventArgs e) { 284 Save(); 285 } 286 #endregion 287 288 #region Item Events 289 private void Item_ToStringChanged(object sender, EventArgs e) { 290 if (InvokeRequired) 291 Invoke(new EventHandler(Item_ToStringChanged), sender, e); 292 else { 293 T item = (T)sender; 294 itemListViewItemTable[item].Text = item.ToString(); 295 listView.Sort(); 296 } 297 } 298 #endregion 43 299 } 44 300 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs
r3228 r3298 268 268 #region Helpers 269 269 protected virtual void SortItemsListView(SortOrder sortOrder) { 270 itemsListView.Sorting = SortOrder.None; 270 271 itemsListView.Sorting = sortOrder; 271 itemsListView.Sort();272 272 itemsListView.Sorting = SortOrder.None; 273 273 } -
trunk/sources/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj
r3292 r3298 88 88 <Compile Include="FileManager.cs" /> 89 89 <Compile Include="MenuItems\ClipboardMenuItem.cs" /> 90 <Compile Include="MenuItems\CopyToClipboardMenuItem.cs" /> 90 91 <Compile Include="MenuItems\StartPageMenuItem.cs" /> 91 92 <Compile Include="Properties\Settings.Designer.cs"> -
trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/ClipboardMenuItem.cs
r3292 r3298 24 24 using System.Linq; 25 25 using System.Windows.Forms; 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Core.Views; 27 28 using HeuristicLab.MainForm; … … 38 39 } 39 40 public override int Position { 40 get { return 2200; }41 get { return 3200; } 41 42 } 42 43 … … 53 54 54 55 private void MainForm_ViewShown(object sender, ViewShownEventArgs e) { 55 if ((e.View is HeuristicLab.Core.Views.Clipboard) && (menuItem != null)) {56 if ((e.View is Clipboard<IItem>) && (menuItem != null)) { 56 57 menuItem.Checked = true; 57 58 Properties.Settings.Default.ShowClipboard = true; … … 60 61 } 61 62 private void MainForm_ViewHidden(object sender, ViewEventArgs e) { 62 if ((e.View is HeuristicLab.Core.Views.Clipboard) && (menuItem != null)) {63 if ((e.View is Clipboard<IItem>) && (menuItem != null)) { 63 64 menuItem.Checked = false; 64 65 Properties.Settings.Default.ShowClipboard = false; -
trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/OperatorsMenuItem.cs
r3292 r3298 38 38 } 39 39 public override int Position { 40 get { return 2300; }40 get { return 3300; } 41 41 } 42 42 -
trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/StartPageMenuItem.cs
r3291 r3298 38 38 } 39 39 public override int Position { 40 get { return 2100; }40 get { return 3100; } 41 41 } 42 42 -
trunk/sources/HeuristicLab.Optimizer/3.3/OptimizerMainForm.cs
r3292 r3298 24 24 using System.Reflection; 25 25 using System.Windows.Forms; 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Core.Views; 27 28 using HeuristicLab.MainForm; … … 30 31 namespace HeuristicLab.Optimizer { 31 32 internal partial class OptimizerMainForm : DockingMainForm { 32 private HeuristicLab.Core.Views.Clipboardclipboard;33 public HeuristicLab.Core.Views.ClipboardClipboard {33 private Clipboard<IItem> clipboard; 34 public Clipboard<IItem> Clipboard { 34 35 get { return clipboard; } 35 36 } … … 53 54 ViewClosed += new EventHandler<ViewEventArgs>(FileManager.ViewClosed); 54 55 55 clipboard = new HeuristicLab.Core.Views.Clipboard();56 clipboard = new Clipboard<IItem>(); 56 57 clipboard.Dock = DockStyle.Left; 57 58 if (Properties.Settings.Default.ShowClipboard) { -
trunk/sources/HeuristicLab.Optimizer/3.3/StartPage.Designer.cs
r3291 r3298 164 164 this.samplesListView.View = System.Windows.Forms.View.Details; 165 165 this.samplesListView.DoubleClick += new System.EventHandler(this.samplesListView_DoubleClick); 166 this.samplesListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.samplesListView_ItemDrag); 166 167 // 167 168 // nameColumnHeader -
trunk/sources/HeuristicLab.Optimizer/3.3/StartPage.cs
r3296 r3298 70 70 Assembly assembly = Assembly.GetExecutingAssembly(); 71 71 var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".hl")); 72 int count = samples.Count(); 72 73 string path = Path.GetTempFileName(); 73 int progress = loadingProgressBar.Maximum / samples.Count();74 74 75 75 foreach (string name in samples) { … … 77 77 using (Stream stream = assembly.GetManifestResourceStream(name)) { 78 78 WriteStreamToTempFile(stream, path); 79 I Item item = XmlParser.Deserialize<IItem>(path);80 OnSampleLoaded(item as INamedItem, progress);79 INamedItem item = XmlParser.Deserialize<INamedItem>(path); 80 OnSampleLoaded(item, loadingProgressBar.Maximum / count); 81 81 } 82 82 } … … 86 86 } 87 87 private void OnSampleLoaded(INamedItem sample, int progress) { 88 if (sample != null) { 89 if (InvokeRequired) 90 Invoke(new Action<INamedItem, int>(OnSampleLoaded), sample, progress); 91 else { 92 ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description }); 93 item.ToolTipText = sample.ItemName + " (" + sample.ItemDescription + ")"; 94 samplesListView.SmallImageList.Images.Add(sample.ItemImage); 95 item.ImageIndex = samplesListView.SmallImageList.Images.Count - 1; 96 item.Tag = sample; 97 samplesListView.Items.Add(item); 98 loadingProgressBar.Value += progress; 99 } 88 if (InvokeRequired) 89 Invoke(new Action<INamedItem, int>(OnSampleLoaded), sample, progress); 90 else { 91 ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description }); 92 item.ToolTipText = sample.ItemName + ": " + sample.ItemDescription; 93 samplesListView.SmallImageList.Images.Add(sample.ItemImage); 94 item.ImageIndex = samplesListView.SmallImageList.Images.Count - 1; 95 item.Tag = sample; 96 samplesListView.Items.Add(item); 97 loadingProgressBar.Value += progress; 100 98 } 101 99 } … … 121 119 MainFormManager.CreateDefaultView(((IItem)samplesListView.SelectedItems[0].Tag).Clone()).Show(); 122 120 } 121 private void samplesListView_ItemDrag(object sender, ItemDragEventArgs e) { 122 ListViewItem listViewItem = (ListViewItem)e.Item; 123 IItem item = (IItem)listViewItem.Tag; 124 DataObject data = new DataObject(); 125 data.SetData("Type", item.GetType()); 126 data.SetData("Value", item); 127 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy); 128 } 123 129 124 130 private void showStartPageCheckBox_CheckedChanged(object sender, EventArgs e) {
Note: See TracChangeset
for help on using the changeset viewer.