public MainWindow()
        {
            try
            {
                InitializeComponent();

                rPictureBoxes = new Rectangle[] { recItemImg1, recItemImg2, recItemImg3, recItemImg4, recItemImg5, recItemImg6 };
                //register the events for the item boxes
                for (int i = 0; i < rPictureBoxes.Length; i++)
                {
                    rPictureBoxes[i].Tag = i;
                    rPictureBoxes[i].MouseEnter += new MouseEventHandler(rPictureBoxes_MouseEnter);
                    rPictureBoxes[i].MouseLeave += new MouseEventHandler(rPictureBoxes_MouseLeave);
                    rPictureBoxes[i].MouseDown += new MouseButtonEventHandler(rPictureBoxes_MouseDown);
                }




                //  button1.Image = Bitmap.FromFile("button.png");

                //compile the list of items
                //use regex...just for the hell of it
                Dictionary<string, string> championNames = new Dictionary<string, string>();
                Regex r = new Regex(@"""(\w+)_(\w+)"" = ""([^""]+)");
                foreach (string s in File.ReadAllLines(LeagueUtils.FileFinder.fontConfigFinder()))
                {
                    Match m = r.Match(s);
                    if (m.Success)
                    {

                        string infoType = m.Groups[1].Value;
                        string infoID = m.Groups[2].Value;
                        string infoValue = m.Groups[3].Value;
                        if (infoType == "game_item_displayname")
                        {
                            itemData[infoID].name = infoValue;
                        }
                        else if (infoType == "game_character_lore" && infoValue.Length > 50
                            && File.Exists(LeagueUtils.FileFinder.findChampImageFolder() + "\\" + infoID + "_Square_0.png"))
                        {
                            heroData[infoID] = new HeroData(infoID, championNames[infoID]);
                        }
                        else if (infoType == "game_item_description")
                        {
                            itemData[infoID] = new ItemData(infoID);
                            itemData[infoID].description = infoValue;
                        }
                        else if (infoType == "game_character_displayname")
                            championNames[infoID] = infoValue;

                    }

                }

                foreach (string item in LeagueUtils.FileFinder.findInibinFiles())
                {

                    int zero = 0;
                    string d = item.Substring(item.LastIndexOf("\\") + 1);
                    string itemID = new String(d.ToCharArray(), 0, 4);
                    if (itemData.ContainsKey(itemID))
                    {
                        byte[] b = File.ReadAllBytes(item);
                        for (int i = 0; i < b.Length - 3; i++)
                        {
                            if (b[i] == 0)
                            {
                                zero = i;
                                continue;

                            }

                            if ((b[i] == ('d') && b[i + 1] == 'd' && b[i + 2] == 's') ||
                                (b[i] == 't' && b[i + 1] == 'g' && b[i + 2] == 'a') ||
                                (b[i] == 'D' && b[i + 1] == 'D' && b[i + 2] == 'S'))
                            {
                                itemData[itemID].iconFile = System.Text.ASCIIEncoding.ASCII.GetString(b, zero + 1, i - zero - 2) + ".png";

                                break;
                            }

                        }
                    }

                }

                //cache the hero icons
                foreach (KeyValuePair<string, HeroData> kvp in heroData)
                {

                    kvp.Value.icon = new BitmapImage(new Uri(LeagueUtils.FileFinder.findChampImageFolder() + "\\" + kvp.Key + "_Square_0.png"));
                }


                backgroundImage = new Image();
                backgroundImage.Width = Width;
                backgroundImage.Height = Height;
                Canvas.SetLeft(backgroundImage, 0);
                Canvas.SetTop(backgroundImage, -20);
                Canvas.SetZIndex(backgroundImage, -10);
                mainCanvas.Children.Add(backgroundImage);

                its = new ItemSelect(this);
                mainCanvas.Children.Add(its);
                Canvas.SetLeft(its, 20);
                Canvas.SetTop(its, 30);
                Canvas.SetZIndex(its, 0);
                its.Visibility = System.Windows.Visibility.Visible;

                //make Champion select and position, probably not pretty how i do it butttt its a start
                cs = new ChampionSelect(this);
                mainCanvas.Children.Add(cs);
                Canvas.SetLeft(cs, 0);
                Canvas.SetTop(cs, 0);
                Canvas.SetZIndex(cs, 20);
                cs.Visibility = System.Windows.Visibility.Hidden;



                //  hs.Show();
                hs = new HelpScreen(this);
                mainCanvas.Children.Add(hs);
                Canvas.SetZIndex(hs, 20);
                hs.Visibility = System.Windows.Visibility.Hidden;


                //init the item tooltip
                itemToolTip = new ItemToolTip();
                mainCanvas.Children.Add(itemToolTip);
                Canvas.SetZIndex(itemToolTip, 8);
                itemToolTip.Visibility = System.Windows.Visibility.Hidden;

                //init the dragging picturebox
                draggingItemPic = new Rectangle();
                draggingItemPic.Width = 50;
                draggingItemPic.Height = 50;
                draggingItemPic.RadiusX = 8;
                draggingItemPic.RadiusY = 8;
                draggingItemPic.Stroke = new SolidColorBrush(Colors.White);
                draggingItemPic.StrokeThickness = 2;
                draggingItemPic.Visibility = System.Windows.Visibility.Hidden;
                draggingItemPic.IsHitTestVisible = false;
                Canvas.SetZIndex(draggingItemPic, 9);
                mainCanvas.Children.Add(draggingItemPic);


                //autoAbilityTool
                autoAbilityTool = new AutoAbilityTool(this);
                Canvas.SetLeft(autoAbilityTool, 570);
                Canvas.SetTop(autoAbilityTool, 280);
                autoAbilityTool.Visibility = System.Windows.Visibility.Visible;
                Canvas.SetZIndex(autoAbilityTool, 1);
                mainCanvas.Children.Add(autoAbilityTool);

                //set manager
                setManager = new SetManager(this);
                Canvas.SetLeft(setManager,
                    Canvas.GetLeft(rPictureBoxes[0]) +
                    ((Canvas.GetLeft(rPictureBoxes[5]) + rPictureBoxes[5].Width - Canvas.GetLeft(rPictureBoxes[0])) -
                    setManager.Width) / 2);
                Canvas.SetTop(setManager, Canvas.GetTop(rPictureBoxes[0]) - setManager.Height - 2);
                setManager.Visibility = System.Windows.Visibility.Hidden;
                Canvas.SetZIndex(setManager, 2);
                mainCanvas.Children.Add(setManager);

                abilityManager = new AbilityManager(this);
                abilityManager.Visibility = Visibility.Hidden;
                Canvas.SetLeft(abilityManager, 600);
                Canvas.SetTop(abilityManager, 310);
                Canvas.SetZIndex(abilityManager, 1);
                mainCanvas.Children.Add(abilityManager);

                //saving overlay
                savingOverlay = new SavingOverlay();
                savingOverlay.Visibility = System.Windows.Visibility.Hidden;
                Canvas.SetZIndex(savingOverlay, 20);
                mainCanvas.Children.Add(savingOverlay);




                //background worker
                savingThread = new BackgroundWorker();
                savingThread.DoWork += new DoWorkEventHandler(savingThread_DoWork);
                savingThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(savingThread_RunWorkerCompleted);

                //dragging timer
                draggingTimer = new DispatcherTimer();
                draggingTimer.Interval = TimeSpan.FromMilliseconds(30);
                draggingTimer.Tick += new EventHandler(draggingTimer_Tick);

                selectChampion(this.heroData.ElementAt(0).Value.codeName);
            }
            catch (Exception e)
            {
                new LeagueOverlay.ScriptControl(null).log("[ERROR] (" + e.Source + "): " + e.Message + "\n" + e.StackTrace);
                throw;
            }
        }
 public void setItem(ItemData item)
 {
     itemNameLbl.Content = item.name;
     itemDescriptionLbl.Text = item.description;
     this.Height = 60 + (itemDescriptionLbl.Text.Length / 10 + 1) * 3;
 }