private void Preview_Load(object sender, EventArgs e) { this.CenterToParent(); cbBanner.Items.Clear(); cbIcon.Items.Clear(); int startIndex = -1; List <TplImage> bannerImages = new List <TplImage>(); List <TplImage> iconImages = new List <TplImage>(); for (int i = 0; i < bannerBin.NumOfNodes; i++) { if (bannerBin.StringTable[i].ToLower().EndsWith(".tpl")) { TplImage tmpImage = new TplImage(); TPL tmpTpl = TPL.Load(bannerBin.Data[i]); if (i == 10) { } tmpImage.fileName = bannerBin.StringTable[i]; tmpImage.tplFormat = tmpTpl.GetTextureFormat(0).ToString(); tmpImage.tplImage = tmpTpl.ExtractTexture(); tmpImage.checkerBoard = createCheckerBoard(tmpImage.tplImage.Width, tmpImage.tplImage.Height); if (tmpImage.tplFormat.StartsWith("CI")) { tmpImage.tplFormat += " + " + tmpTpl.GetPaletteFormat(0); } bannerImages.Add(tmpImage); } } for (int i = 0; i < iconBin.NumOfNodes; i++) { if (iconBin.StringTable[i].ToLower().EndsWith(".tpl")) { TplImage tmpImage = new TplImage(); TPL tmpTpl = TPL.Load(iconBin.Data[i]); tmpImage.fileName = iconBin.StringTable[i]; tmpImage.tplFormat = tmpTpl.GetTextureFormat(0).ToString(); tmpImage.tplImage = tmpTpl.ExtractTexture(); tmpImage.checkerBoard = createCheckerBoard(tmpImage.tplImage.Width, tmpImage.tplImage.Height); if (tmpImage.tplFormat.StartsWith("CI")) { tmpImage.tplFormat += " + " + tmpTpl.GetPaletteFormat(0); } iconImages.Add(tmpImage); } } images[0] = bannerImages.ToArray(); images[1] = iconImages.ToArray(); for (int i = 0; i < images[0].Length; i++) { cbBanner.Items.Add(images[0][i].fileName); if (!startIcon) { if (images[0][i].fileName.ToLower() == startTPL.ToLower()) { startIndex = i; } } } for (int i = 0; i < images[1].Length; i++) { cbIcon.Items.Add(images[1][i].fileName); if (startIcon) { if (images[1][i].fileName.ToLower() == startTPL.ToLower()) { startIndex = i; } } } try { if (startIndex != -1) { if (!startIcon) { cbBanner.SelectedIndex = startIndex; } else { cbIcon.SelectedIndex = startIndex; } } } catch { } if (cbBanner.SelectedIndex != -1) { cbBanner.Select(); } else if (cbIcon.SelectedIndex != -1) { cbIcon.Select(); } tipTimer.Interval = 7000; tipTimer.Tag = 0; tipTimer.Tick += new EventHandler(tipTimer_Tick); }
private void Preview_Load(object sender, EventArgs e) { this.CenterToParent(); cbBanner.Items.Clear(); cbIcon.Items.Clear(); int startIndex = -1; List<TplImage> bannerImages = new List<TplImage>(); List<TplImage> iconImages = new List<TplImage>(); for (int i = 0; i < bannerBin.NumOfNodes; i++) { if (bannerBin.StringTable[i].ToLower().EndsWith(".tpl")) { TplImage tmpImage = new TplImage(); TPL tmpTpl = TPL.Load(bannerBin.Data[i]); if (i == 10) { } tmpImage.fileName = bannerBin.StringTable[i]; tmpImage.tplFormat = tmpTpl.GetTextureFormat(0).ToString(); tmpImage.tplImage = tmpTpl.ExtractTexture(); tmpImage.checkerBoard = createCheckerBoard(tmpImage.tplImage.Width, tmpImage.tplImage.Height); if (tmpImage.tplFormat.StartsWith("CI")) tmpImage.tplFormat += " + " + tmpTpl.GetPaletteFormat(0); bannerImages.Add(tmpImage); } } for (int i = 0; i < iconBin.NumOfNodes; i++) { if (iconBin.StringTable[i].ToLower().EndsWith(".tpl")) { TplImage tmpImage = new TplImage(); TPL tmpTpl = TPL.Load(iconBin.Data[i]); tmpImage.fileName = iconBin.StringTable[i]; tmpImage.tplFormat = tmpTpl.GetTextureFormat(0).ToString(); tmpImage.tplImage = tmpTpl.ExtractTexture(); tmpImage.checkerBoard = createCheckerBoard(tmpImage.tplImage.Width, tmpImage.tplImage.Height); if (tmpImage.tplFormat.StartsWith("CI")) tmpImage.tplFormat += " + " + tmpTpl.GetPaletteFormat(0); iconImages.Add(tmpImage); } } images[0] = bannerImages.ToArray(); images[1] = iconImages.ToArray(); for (int i = 0; i < images[0].Length; i++) { cbBanner.Items.Add(images[0][i].fileName); if (!startIcon) if (images[0][i].fileName.ToLower() == startTPL.ToLower()) startIndex = i; } for (int i = 0; i < images[1].Length; i++) { cbIcon.Items.Add(images[1][i].fileName); if (startIcon) if (images[1][i].fileName.ToLower() == startTPL.ToLower()) startIndex = i; } try { if (startIndex != -1) if (!startIcon) cbBanner.SelectedIndex = startIndex; else cbIcon.SelectedIndex = startIndex; } catch { } if (cbBanner.SelectedIndex != -1) cbBanner.Select(); else if (cbIcon.SelectedIndex != -1) cbIcon.Select(); tipTimer.Interval = 7000; tipTimer.Tag = 0; tipTimer.Tick += new EventHandler(tipTimer_Tick); }