public MapEditor(MapFile file) : base(file) { map = file; this.tileset = map.TilesetFile[map.TilesetID]; mapPanel = new MapPanel(map.Layers, tileset); mapPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.Controls.Add(mapPanel); this.KeyPreview = true; this.KeyDown += new System.Windows.Forms.KeyEventHandler(MapEditor_KeyDown); this.mapPanel.MouseDown += new System.Windows.Forms.MouseEventHandler(mapPanel_MouseDown); this.mapPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(mapPanel_MouseMove); tilePanel = new TilePanel(tileset); tilePanel.TileSelected += new EventHandler<TilePanel.TileSelectedArgs>(tilePanel_TileSelected); tilePanel.Dock = System.Windows.Forms.DockStyle.Fill; toolstrip = new System.Windows.Forms.ToolStrip(); toolstrip.Dock = System.Windows.Forms.DockStyle.Top; toolstrip.Stretch = true; toolstrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; buttonSelected = new System.Windows.Forms.ToolStripButton(); buttonSelected.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.SizeToFit; buttonSelected.AutoSize = true; buttonSelected.Image = tileset[0]; buttonSelected.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; toolstrip.Items.Add(buttonSelected); toolstrip.Items.Add(new System.Windows.Forms.ToolStripSeparator()); buttonLayers = new List<System.Windows.Forms.ToolStripButton>(); for (int i = 0; i < this.map.Layers.Count; i++) { var laybtn = new System.Windows.Forms.ToolStripButton(); laybtn.Text = string.Format("{0}", i + 1); laybtn.Tag = i; laybtn.Click += new EventHandler(laybtn_Click); if (this.map.Layers[i].Type == MapLayerType.HalfBlockShadow) { laybtn.Text = "阴影"; } toolstrip.Items.Add(laybtn); buttonLayers.Add(laybtn); } toolboxPanel = new System.Windows.Forms.Panel(); this.toolboxPanel.Controls.Add(tilePanel); this.toolboxPanel.Controls.Add(toolstrip); }
public MapEditor(MapFile file) : base(file) { map = file; this.tileset = map.TilesetFile[map.TilesetID]; mapPanel = new MapPanel(map.Layers, tileset); mapPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.Controls.Add(mapPanel); this.KeyPreview = true; this.KeyDown += new System.Windows.Forms.KeyEventHandler(MapEditor_KeyDown); this.mapPanel.MouseDown += new System.Windows.Forms.MouseEventHandler(mapPanel_MouseDown); this.mapPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(mapPanel_MouseMove); tilePanel = new TilePanel(tileset); tilePanel.TileSelected += new EventHandler <TilePanel.TileSelectedArgs>(tilePanel_TileSelected); tilePanel.Dock = System.Windows.Forms.DockStyle.Fill; toolstrip = new System.Windows.Forms.ToolStrip(); toolstrip.Dock = System.Windows.Forms.DockStyle.Top; toolstrip.Stretch = true; toolstrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; buttonSelected = new System.Windows.Forms.ToolStripButton(); buttonSelected.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.SizeToFit; buttonSelected.AutoSize = true; buttonSelected.Image = tileset[0]; buttonSelected.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; toolstrip.Items.Add(buttonSelected); toolstrip.Items.Add(new System.Windows.Forms.ToolStripSeparator()); buttonLayers = new List <System.Windows.Forms.ToolStripButton>(); for (int i = 0; i < this.map.Layers.Count; i++) { var laybtn = new System.Windows.Forms.ToolStripButton(); laybtn.Text = string.Format("{0}", i + 1); laybtn.Tag = i; laybtn.Click += new EventHandler(laybtn_Click); if (this.map.Layers[i].Type == MapLayerType.HalfBlockShadow) { laybtn.Text = "阴影"; } toolstrip.Items.Add(laybtn); buttonLayers.Add(laybtn); } toolboxPanel = new System.Windows.Forms.Panel(); this.toolboxPanel.Controls.Add(tilePanel); this.toolboxPanel.Controls.Add(toolstrip); }