예제 #1
0
        private void lbBitmaps_SelectedIndexChanged(object sender, EventArgs e)
        {
            cbBitmapIndex.Enabled = false;
            cbBitmapIndex.Items.Clear();
            
            screenData paneBitmapSelections = (screenData)lbScreensList.SelectedItem;
            if (paneBitmapSelections.link == null)
                paneBitmapSelections.link = new int[lbPanes.Items.Count];
            ((int[])paneBitmapSelections.link)[lbPanes.SelectedIndex] = lbBitmaps.SelectedIndex;

            if (lbBitmaps.SelectedIndex < 1 || lbBitmaps.SelectedItem == null)
            {
                tbXPos.Enabled = false;
                tbYPos.Enabled = false;
                tbXScroll.Enabled = false;
                tbYScroll.Enabled = false;
                tbRenderDepth.Enabled = false;
                cbBitmapIdent.Enabled = false;
                cbBitmapIdent.SelectedIndex = 0;
                return;
            }
            else
            {
                tbXPos.Enabled = true;
                tbYPos.Enabled = true;
                tbXScroll.Enabled = true;
                tbYScroll.Enabled = true;
                tbRenderDepth.Enabled = true;
                cbBitmapIdent.Enabled = true;
            }

            // Actually update ListBox with data source
            ((CurrencyManager)lbBitmaps.BindingContext[lbBitmaps.DataSource]).Refresh();
            bitmapData bd = (bitmapData)lbBitmaps.SelectedItem;
            //bitmapData bd = ((List<bitmapData>)lbBitmaps.DataSource)[lbBitmaps.SelectedIndex];
            
            tbXPos.Text = bd.left.ToString();
            tbYPos.Text = bd.top.ToString();
            tbXScroll.Text = bd.horizontalWrapsPerSec.ToString();
            tbYScroll.Text = bd.verticalWrapsPerSec.ToString();
            tbRenderDepth.Text = bd.renderDepth.ToString();
            if (bd.bitmIdent != -1)
            {
                cbBitmapIdent.Text = map.FileNames.Name[(int)map.MetaInfo.identHT[bd.bitmIdent]];
            }
            else
                cbBitmapIdent.Text = "null";
            if (bd.link != null)
            {
                baseData sd = (baseData)cbBitmapIdent.SelectedItem;
                ParsedBitmap pm = new ParsedBitmap(ref bd.meta, map);
                bitmapInfo bi = (bitmapInfo)sd.link;
                if (bi == null)
                {
                    bi = new bitmapInfo();
                    bi.BitmapIndex = bd.bitmNumber;
                    bi.BitmapIndexMax = (short)pm.Properties.Length;
                    bi.Image = (Bitmap)bd.link;
                    sd.link = bi;
                }
                if (bi.BitmapIndex != bd.bitmNumber)
                {
                    bi.BitmapIndex = bd.bitmNumber;
                    bi.Image = (Bitmap)bd.link;
                }
                if (bi.BitmapIndexMax > 1) 
                    cbBitmapIndex.Enabled = true;
                for (int i = 0; i < bi.BitmapIndexMax; i++)
                    cbBitmapIndex.Items.Add(i.ToString());
                cbBitmapIndex.SelectedIndex = Math.Min(bd.bitmNumber, bi.BitmapIndexMax - 1);
            }
        }
예제 #2
0
        private void cbBitmapIdent_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!cbBitmapIdent.Focused)
                return;
            baseData sd = (baseData)cbBitmapIdent.SelectedItem;
            bitmapInfo bi = (bitmapInfo)sd.link;
            bitmapData bsd = (bitmapData)lbBitmaps.SelectedItem;
            if (sd.meta == null)
            {
                sd.meta = new Meta(map);
                map.OpenMap(MapTypes.MainMenu);
                sd.meta.ReadMetaFromMap(sd.offset, false);
                map.CloseMap();
                sd.title = sd.meta.name;

                sd.link = bi = new bitmapInfo();
                ParsedBitmap pm = new ParsedBitmap(ref sd.meta, map);
                bi.BitmapIndexMax = (short)pm.Properties.Length;
                bi.BitmapIndex = 0;
                bi.Image = pm.FindChunkAndDecode(bi.BitmapIndex, 0, 0, ref sd.meta, map, 0, 0);
                sd.link = bi;
            }
            bsd.bitmNumber = bi.BitmapIndex;
            bsd.link = bi.Image;
            bsd.meta = sd.meta;
            bsd.bitmIdent = bsd.meta.ident;
            bsd.title = sd.title.Substring(sd.title.LastIndexOf('\\') + 1);

            #region do this to update text in listbox, otherwise although changed, it doesn't show
            Control control = this.ActiveControl;
            while (control is ContainerControl)
            {
                control = ((ContainerControl)control).ActiveControl;
            }

            int selIndex = lbBitmaps.SelectedIndex;
            ((bitmapData)lbBitmaps.SelectedItem).title = bsd.title;
            // Actually update ListBox with data source
            ((CurrencyManager)lbBitmaps.BindingContext[lbBitmaps.DataSource]).Refresh();
            #endregion
        }