private void btnCreateTileset_Click(object sender, EventArgs e) { if (m_strFileName != null) { NCellWidth = (int)nudCellWidth.Value; NCellHeight = (int)nudCellHeight.Value; if (NCellWidth >= nudCellWidth.Minimum && NCellWidth <= nudCellWidth.Maximum && NCellHeight >= nudCellHeight.Minimum && m_nCellHeight <= nudCellHeight.Maximum) { m_ts = new CTileset(m_nImageID, m_clrKey, (int)nudImageWidth.Value, (int)nudImageHeight.Value, NCellWidth, NCellHeight, m_strFileName); if (createPushed != null) createPushed(this, new EventArgs()); } } else { MessageBox.Show("You have not loaded an image", "Please load an image", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddTileset(int nImageID, Color clrKey, int nImageWidth, int nImageHeight, int nCellWidth, int nCellHeight, string strFilename) { m_nYScrollOffset = 140; m_nXScrollOffset = 10; string choppedFileName = Path.GetFileNameWithoutExtension(strFilename); if (choppedFileName.Length > 10) { choppedFileName = choppedFileName.Remove(10, choppedFileName.Length - 10); tabControl1.TabPages.Add(choppedFileName); } else tabControl1.TabPages.Add(choppedFileName); for (int i = 0; i < MAX_NUM_TILESETS; ++i ) { if (m_tsTileset[i] == null) { m_tsTileset[i] = new CTileset(nImageID, clrKey, nImageWidth, nImageHeight, nCellWidth, nCellHeight, strFilename); m_nCurrTilesetIndex = i; break; } } //m_tsTileset[tabControl1.TabCount - 2] = new CTileset(nImageID, clrKey, nImageWidth, nImageHeight, nCellWidth, nCellHeight, strFilename); //m_nCurrTilesetIndex = tabControl1.TabCount - 2; m_tsTileset[m_nCurrTilesetIndex].NCurrSelectedTile = m_tCurrTile.NSourceID; m_tsTileset[m_nCurrTilesetIndex].NTilesetImageID = nImageID; m_tsTileset[m_nCurrTilesetIndex].SetSelectionRect(); m_tsTileset[m_nCurrTilesetIndex].NPanelWidth = splitContainer1.Panel1.Width; m_tsTileset[m_nCurrTilesetIndex].NPanelHeight = splitContainer1.Panel1.Height; m_tsTileset[m_nCurrTilesetIndex].GTilesetGrid.ZeroOffset(); //m_tsTileset[m_nCurrTilesetIndex].GTilesetGrid.Offset(m_nXScrollOffset, m_nYScrollOffset); m_tsTileset[m_nCurrTilesetIndex].ZeroScrollOS(); tbAnchorX.Text = m_tCurrTile.AnchorX.ToString(); tbAnchorY.Text = m_tCurrTile.AnchorY.ToString(); // set up the tileset's components m_tsComponents[m_nCurrTilesetIndex] = new TilesetComponents(); m_tsComponents[m_nCurrTilesetIndex].AddAll(tabControl1.TabPages[tabControl1.TabCount-1], this.toolTip1, this); ////////////////////////////////////////////////////////////////////////// // Set up the components for the new tileset // add default flags to cbTileFlags m_tsComponents[m_nCurrTilesetIndex].cbTileFlag.Items.Add(m_str0); m_tsComponents[m_nCurrTilesetIndex].cbTileFlag.Items.Add(m_str1); m_tsComponents[m_nCurrTilesetIndex].cbTileFlag.Items.Add(m_str2); m_tsComponents[m_nCurrTilesetIndex].cbTileFlag.Items.Add(m_str3); m_tsComponents[m_nCurrTilesetIndex].cbTileFlag.Items.Add(m_str4); m_tsComponents[m_nCurrTilesetIndex].cbTileFlag.Items.Add(m_str5); m_tsComponents[m_nCurrTilesetIndex].cbTileFlag.SelectedIndex = 0; m_tsComponents[m_nCurrTilesetIndex].nudImageWidth.Value = nImageWidth; m_tsComponents[m_nCurrTilesetIndex].nudImageHeight.Value = nImageHeight; nudAdjustRectX.Maximum = m_tsComponents[m_nCurrTilesetIndex].nudImageWidth.Value; nudAdjustRectY.Maximum = m_tsComponents[m_nCurrTilesetIndex].nudImageHeight.Value; m_tsComponents[m_nCurrTilesetIndex].nudCellWidth.Value = nCellWidth; m_tsComponents[m_nCurrTilesetIndex].nudCellHeight.Value = nCellHeight; bNewTS = true; m_tsComponents[m_nCurrTilesetIndex].nudTilesetGridWidth.Value = nImageWidth / nCellWidth; m_tsComponents[m_nCurrTilesetIndex].nudTilesetGridHeight.Value = nImageHeight / nCellHeight; bNewTS = false; m_tsComponents[m_nCurrTilesetIndex].m_nScrollX = 0; m_tsComponents[m_nCurrTilesetIndex].m_nScrollY = 0; ////////////////////////////////////////////////////////////////////////// m_bJustClick = true; tabControl1.SelectedIndex = tabControl1.TabCount - 1; m_bAddTileset = false; m_bDrawMarquee = m_bMarqueeSelect = false; if ((splitContainer1.Panel1.AutoScrollMinSize.Width < nImageWidth + m_nTilesetXoffset) || (splitContainer1.Panel1.AutoScrollMinSize.Height < nImageHeight + m_nTilesetYoffset + 5)) { splitContainer1.Panel1.AutoScrollMinSize = new Size(nImageWidth + m_nTilesetXoffset, nImageHeight + m_nTilesetYoffset + 5); } m_nXScrollOffset = m_nYScrollOffset = 0; splitContainer1.Panel1.VerticalScroll.Value = 0; splitContainer1.Panel1.HorizontalScroll.Value = 0; splitContainer1.Panel1.VerticalScroll.Value = 0; splitContainer1.Panel1.HorizontalScroll.Value = 0; m_bDontDraw = false; if (tabControl1.TabCount == 2) btnAddTileset.Visible = false; }