| | |
| | | using DPumpHydr.WinFrmUI.RLT.Child.Crown; |
| | | using DPumpHydr.WinFrmUI.RLT.Controls; |
| | | using DPumpHydr.WinFrmUI.RLT.Docking.Crown; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Drawing; |
| | | using System.Windows.Forms; |
| | | using static System.Net.Mime.MediaTypeNames; |
| | | |
| | | namespace DPumpHydr.WinFrmUI.Volute |
| | | { |
| | | public partial class LayersDockPanel : CrownToolWindow |
| | | { |
| | | #region Constructor Region |
| | | |
| | | { |
| | | public LayersDockPanel() |
| | | { |
| | | InitializeComponent(); |
| | | this.SerializationKey = "LayersDockPanel"; |
| | | // Build dummy list data |
| | | //for (int i = 0; i < 100; i++) |
| | | //{ |
| | | // CrownListItem item = new($"List item #{i}") |
| | | // { |
| | | // Icon = DPumpHydr.WinFrmUI.Volute.Properties.Resources.application_16x |
| | | // }; |
| | | // lstLayers.Items.Add(item); |
| | | //} |
| | | this.DefaultDockArea = RLT.Enum.Crown.DockArea.Left; |
| | | this.DockText = "图层"; |
| | | } |
| | | List<DPumpHydr.WinFrmUI.Base.ViewModel.Layer> allLayers; |
| | | public void InitialInfo() |
| | | { |
| | | allLayers = new List<Base.ViewModel.Layer>(); |
| | | allLayers.Add(new Base.ViewModel.Layer() { ID = 1, Name = "1-8截面线段", Color = Color.Red, IsVisible = true }); |
| | | allLayers.Add(new Base.ViewModel.Layer() { ID = 2, Name = "1-8截面", Color = Color.Blue, IsVisible = false }); |
| | | allLayers.Add(new Base.ViewModel.Layer() { ID = 3, Name = "1-8截面体", Color = Color.Gray, IsVisible = true }); |
| | | allLayers.Add(new Base.ViewModel.Layer() { ID = 4, Name = "出水体", Color = Color.Indigo, IsVisible = true }); |
| | | |
| | | foreach(var item in allLayers) |
| | | { |
| | | //DataGridViewRow dataGridViewRow = new DataGridViewRow(); |
| | | |
| | | |
| | | //// Build dropdown list data |
| | | //for (int i = 0; i < 5; i++) |
| | | //{ |
| | | // cmbList.Items.Add(new CrownDropDownItem($"Dropdown item #{i}")); |
| | | //} |
| | | //dataGridViewRow.Cells["ID"].Value = item.ID; |
| | | //dataGridViewRow.Cells["Color"].Value = Drawicon(item.Color); |
| | | //dataGridViewRow.Cells["Name"].Value = item.Name; |
| | | //dataGridViewRow.Cells["VisibleStatus"].Value = GetVisibleStatusImage(item.IsVisible); |
| | | |
| | | |
| | | GridViewMain.Rows.Add(item.ID, Drawicon(item.Color), item.Name, GetVisibleStatusImage(item.IsVisible)); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | private Bitmap Drawicon(Color myColor) |
| | | { |
| | | Bitmap colorImage = new Bitmap(16, 16); |
| | | using (Graphics g = Graphics.FromImage(colorImage)) |
| | | { |
| | | g.Clear(myColor); |
| | | } |
| | | return colorImage; |
| | | } |
| | | |
| | | |
| | | private void GridViewMain_CellContentClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) |
| | | { |
| | | if (e.ColumnIndex == 1) |
| | | { |
| | | var id = int.Parse(GridViewMain.Rows[e.RowIndex].Cells["ID"].Value.ToString()); |
| | | var m = allLayers.Find(x => x.ID == id); |
| | | System.Windows.Forms.ColorDialog colorDialog1 = new ColorDialog(); |
| | | colorDialog1.Color = m.Color; |
| | | if (colorDialog1.ShowDialog() == DialogResult.OK) |
| | | { |
| | | m.Color = colorDialog1.Color; |
| | | GridViewMain.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Drawicon(m.Color); |
| | | } |
| | | } |
| | | if (e.ColumnIndex == 3) |
| | | { |
| | | var id = int.Parse(GridViewMain.Rows[e.RowIndex].Cells["ID"].Value.ToString()); |
| | | var m = allLayers.Find(x => x.ID == id); |
| | | |
| | | if (m.IsVisible) |
| | | { |
| | | m.IsVisible = false; |
| | | GridViewMain.Rows[e.RowIndex].Cells["VisibleStatus"].Value = GetVisibleStatusImage(false); |
| | | } |
| | | else |
| | | { |
| | | m.IsVisible = true ; |
| | | GridViewMain.Rows[e.RowIndex].Cells["VisibleStatus"].Value = GetVisibleStatusImage(true ); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | // |
| | | System.Drawing.Image imageHidden, imageVisible; |
| | | private System.Drawing.Image GetVisibleStatusImage(bool isVisible) |
| | | { |
| | | if(imageHidden == null) |
| | | { |
| | | imageHidden = DPumpHydr.WinFrmUI.Volute.Properties.Resources.VisibleGray32.GetThumbnailImage(24, 24, () => false, IntPtr.Zero); |
| | | imageVisible = DPumpHydr.WinFrmUI.Volute.Properties.Resources.VisibleBlue32.GetThumbnailImage(24, 24, () => false, IntPtr.Zero); |
| | | } |
| | | |
| | | if (isVisible) |
| | | return imageVisible; |
| | | else |
| | | return imageHidden; |
| | | } |
| | | } |
| | | } |