stoneharry

Untitled

Apr 20th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1.             string[] icons = body.StringBlock.Split('\0');
  2.             int iconIndex = 1;
  3.  
  4.             int columnsUsed = icons.Length / 11;
  5.             int rowsToDo = columnsUsed / 2;
  6.  
  7.             for (int j = -rowsToDo; j <= rowsToDo; ++j) // Rows
  8.             {
  9.                 for (int i = -5; i < 6; ++i) // Columns
  10.                 {
  11.                     if (iconIndex >= icons.Length - 1)
  12.                         break;
  13.                     if (!File.Exists(icons[iconIndex] + ".blp"))
  14.                     {
  15.                         Console.WriteLine("Warning: Icon not found: " + icons[iconIndex] + ".blp");
  16.                         ++iconIndex;
  17.                         continue;
  18.                     }
  19.                     file = new FileStream(icons[iconIndex++] + ".blp", FileMode.Open);
  20.                    
  21.                     image = new SereniaBLPLib.BlpFile(file);
  22.                     bit = image.getBitmap(0);
  23.  
  24.                     Task.Factory.StartNew(() =>
  25.                     {
  26.                         System.Windows.Controls.Image temp = new System.Windows.Controls.Image();
  27.                         temp.Width = 64;
  28.                         temp.Height = 64;
  29.                         temp.Margin = new System.Windows.Thickness(139 * i, 139 * j, 0, 0);
  30.                         temp.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
  31.                            bit.GetHbitmap(),
  32.                            IntPtr.Zero,
  33.                            System.Windows.Int32Rect.Empty,
  34.                            BitmapSizeOptions.FromWidthAndHeight(bit.Width, bit.Height));
  35.                         temp.Name = "Index_" + iconIndex;
  36.                         temp.MouseDown += this.imageDown;
  37.                         main.IconGrid.Children.Add(temp);
  38.                     }, CancellationToken.None, TaskCreationOptions.None, main.uiScheduler);
  39.  
  40.                     file.Close();
  41.                 }
  42.             }
Advertisement
Add Comment
Please, Sign In to add comment