| | |
| | | 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 |
| | | { |
| | | |
| | | { |
| | | 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; |
| | | } |
| | | } |
| | | } |