From b4c867bf85d3edef5d084a3a26f13cbc6784bf58 Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期一, 16 十二月 2024 13:37:21 +0800 Subject: [PATCH] 提交 --- WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/LayersDockPanel.cs | 101 ++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 72 insertions(+), 29 deletions(-) diff --git a/WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/LayersDockPanel.cs b/WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/LayersDockPanel.cs index 6eb40be..a0f0753 100644 --- a/WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/LayersDockPanel.cs +++ b/WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/LayersDockPanel.cs @@ -1,65 +1,108 @@ 锘縰sing 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 - { - + { public LayersDockPanel() { InitializeComponent(); this.SerializationKey = "LayersDockPanel"; - visible.Image = imagevisible; - Color AcquiesceColor = ColorTranslator.FromHtml("#a7ebcc"); - Color.Image = Drawicon(AcquiesceColor); - GridViewLayers.Rows.Add(); - GridViewLayers.Rows.Add(); - GridViewLayers.Rows.Add(); - GridViewLayers.Rows[0].Cells["layer"].Value = "鍥惧眰鍥惧眰鍥惧眰鍥惧眰"; - GridViewLayers.Rows[1].Cells["layer"].Value = "鍥惧眰2"; - GridViewLayers.Rows[2].Cells["layer"].Value = "鍥惧眰3"; + this.DefaultDockArea = RLT.Enum.Crown.DockArea.Left; + this.DockText = "鍥惧眰"; } - - private Bitmap Drawicon(Color color) + List<DPumpHydr.WinFrmUI.Base.ViewModel.Layer> allLayers; + public void InitialInfo() { - Bitmap colorImage = new Bitmap(20, 20); - using (Graphics g = Graphics.FromImage(colorImage)) + 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) { - Color myColor = color; + //DataGridViewRow dataGridViewRow = new DataGridViewRow(); + + + //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 Image imageHidden = GlobalResource.BuildImage("Generic-Hidden.png", 20, 20); - private Image imagevisible = GlobalResource.BuildImage("Generic-Visible.png", 20, 20); - private void GridViewLayers_CellContentClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) + + + private void GridViewMain_CellContentClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) { - if (e.ColumnIndex == 0) + 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) { - GridViewLayers.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Drawicon(colorDialog1.Color); - } - + m.Color = colorDialog1.Color; + GridViewMain.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Drawicon(m.Color); + } } - if (e.ColumnIndex == 2) + if (e.ColumnIndex == 3) { - if (GridViewLayers.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == imageHidden) + var id = int.Parse(GridViewMain.Rows[e.RowIndex].Cells["ID"].Value.ToString()); + var m = allLayers.Find(x => x.ID == id); + + if (m.IsVisible) { - GridViewLayers.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = imagevisible; - return; + m.IsVisible = false; + GridViewMain.Rows[e.RowIndex].Cells["VisibleStatus"].Value = GetVisibleStatusImage(false); } else { - GridViewLayers.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = imageHidden; - return; + m.IsVisible = true ; + GridViewMain.Rows[e.RowIndex].Cells["VisibleStatus"].Value = GetVisibleStatusImage(true ); } } } + + // + 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; + } } } \ No newline at end of file -- Gitblit v1.9.3