Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string[] icons = body.StringBlock.Split('\0');
- int iconIndex = 1;
- int columnsUsed = icons.Length / 11;
- int rowsToDo = columnsUsed / 2;
- for (int j = -rowsToDo; j <= rowsToDo; ++j) // Rows
- {
- for (int i = -5; i < 6; ++i) // Columns
- {
- if (iconIndex >= icons.Length - 1)
- break;
- if (!File.Exists(icons[iconIndex] + ".blp"))
- {
- Console.WriteLine("Warning: Icon not found: " + icons[iconIndex] + ".blp");
- ++iconIndex;
- continue;
- }
- file = new FileStream(icons[iconIndex++] + ".blp", FileMode.Open);
- image = new SereniaBLPLib.BlpFile(file);
- bit = image.getBitmap(0);
- Task.Factory.StartNew(() =>
- {
- System.Windows.Controls.Image temp = new System.Windows.Controls.Image();
- temp.Width = 64;
- temp.Height = 64;
- temp.Margin = new System.Windows.Thickness(139 * i, 139 * j, 0, 0);
- temp.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
- bit.GetHbitmap(),
- IntPtr.Zero,
- System.Windows.Int32Rect.Empty,
- BitmapSizeOptions.FromWidthAndHeight(bit.Width, bit.Height));
- temp.Name = "Index_" + iconIndex;
- temp.MouseDown += this.imageDown;
- main.IconGrid.Children.Add(temp);
- }, CancellationToken.None, TaskCreationOptions.None, main.uiScheduler);
- file.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment