private void MainForm_Load(object sender, EventArgs e) { // update UI based on config streamerModeToolStripMenuItem.Checked = Config.StreamerMode; autoTrackingToolStripMenuItem.Checked = Config.AutoTrackingEnabled; MainFormLayoutUpdate(); // hide enemy panel initially EnemyPanel.Visible = false; // draw rounded background box for enemy image PictureBox pb = EnemyPanelPictureBox; Rectangle r = new Rectangle(0, 0, pb.Width, pb.Height); GraphicsPath gp = new GraphicsPath(); int d = 20; gp.AddArc(r.X, r.Y, d, d, 180, 90); gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270, 90); gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0, 90); gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90, 90); pb.Region = new Region(gp); // set the hero's name Hero.NameChanged += (sender, e) => { this.Invoke(() => StatPanel.Title = Hero.Name); }; //Set initial UI for hero stats for (int i = 0; i < Hero.DisplayStats.Length; i++) { DWStat stat = Hero.DisplayStats[i]; DWLabel nameLabel = new DWLabel { Text = stat.Name.ToUpper() }; DWLabel valueLabel = new DWLabel { Text = stat.Value.ToString(), TextAlign = ContentAlignment.MiddleRight }; StatTableLayout.Controls.Add(nameLabel, 0, i); StatTableLayout.Controls.Add(valueLabel, 1, i); stat.ValueChanged += (sender, e) => { this.Invoke(() => valueLabel.Text = stat.Value.ToString()); }; } // create spell labels for (int i = 0; i < Hero.Spells.Length; i++) { DWSpell spell = Hero.Spells[i]; DWSpellLabel label = new DWSpellLabel(spell); // position spell in panel SpellPanel.Controls.Add(label); label.Top = i * 26 + 26; label.Left = 15; label.Width = SpellPanel.Width; // update color on spell value change spell.ValueChanged += (sender, e) => { this.Invoke(() => label.ForeColor = spell.HasSpell ? Color.FromArgb(255, 255, 255) : Color.FromArgb(60, 60, 60)); }; } // set initial UI for all items foreach (DWItem item in Hero.QuestItems) { DWItemBox itemBox = new DWItemBox(item); if (item.IsFirstHalfQuestItem) { Hero.RainbowDrop.ValueChanged += (sender, e) => { this.Invoke(() => itemBox.Visible = Hero.RainbowDrop.Value == 0); }; } RequiredItemFlowPanel.Controls.Add(itemBox); } foreach (DWItem item in Hero.BattleGear) { BattleItemFlowPanel.Controls.Add(new DWItemBox(item)); } foreach (DWItem item in Hero.OtherItems) { OptionalItemFlowPanel.Controls.Add(new DWItemBox(item)); } // game state update timer System.Timers.Timer timer = new System.Timers.Timer(200); timer.Elapsed += CheckGameState; timer.Start(); }
public ItemPictureBox(DWItem item, DWItemBox itemBox) { Item = item; ItemBox = itemBox; }