context: using System;
  using System.Collections.Generic;
  using System.Drawing;
  using LeagueSharp.Common;
  using Leblanc.Champion;
  using Leblanc.Common;
  using PortAIO.Properties;
  using SharpDX;
  using SharpDX.Direct3D9;
  using Color = System.Drawing.Color;
  using CommonGeometry = Leblanc.Common.CommonGeometry;
  using Font = SharpDX.Direct3D9.Font;
  
  using EloBuddy; 
   using LeagueSharp.Common; 
   namespace Leblanc.Modes
  {
      using System.Linq;
      using LeagueSharp;
      internal class LeblancQ
      {
          public GameObject Object { get; set; }
          public float NetworkId { get; set; }
          public Vector3 QPos { get; set; }
          public double ExpireTime { get; set; }
      }
  
      internal class LeblancViciousStrikes
      {
          public static float StartTime { get; set; }
          public static float EndTime { get; set; }
      }
  
  
      internal class LeblancRagnarok
      {
          public static float StartTime { get; set; }
          public static float EndTime { get; set; }
  
      }
  
      enum PcMode
      {
          NewComputer,
          NormalComputer,
          OldComputer
      }
  
      internal class ModeDraw
      {
          public static Menu MenuLocal { get; private set; }
          public static Menu SubMenuSpells { get; private set; }
          public static Menu SubMenuBuffs { get; private set; }
          public static Menu SubMenuTimers { get; private set; }
          public static Menu SubMenuManaBarIndicator { get; private set; }
          private static Spell Q => Champion.PlayerSpells.Q;
          private static Spell W => Champion.PlayerSpells.W;
          private static Spell E => Champion.PlayerSpells.E;
          private static Spell R => Champion.PlayerSpells.R;
          private static Spell Q2 => Champion.PlayerSpells.Q2;
          private static Spell W2 => Champion.PlayerSpells.W2;
          private static Spell E2 => Champion.PlayerSpells.E2;
          public static PcMode PcMode { get; set; }
  
          private static readonly List<MenuItem> MenuLocalSubMenuItems = new List<MenuItem>();
  
          private static readonly string[] pcMode = new[] { "newpc.", "oldpc." };
  
          private static readonly List<LeblancQ> LeblancQ = new List<LeblancQ>();
          public void Init()
          {
              MenuLocal = new Menu("Drawings", "Drawings");
              {
                  MenuLocal.AddItem(new MenuItem("Draw.Enable", "Enable/Disable Drawings:").SetValue(true)).SetFontStyle(FontStyle.Bold, SharpDX.Color.GreenYellow);
                  MenuLocal.AddItem(new MenuItem("DrawPc.Mode", "Adjust settings to your own computer:").SetValue(new StringList(new[] { "New Computer", "Old Computer" }, 0)).SetFontStyle(FontStyle.Regular, SharpDX.Color.Coral)).ValueChanged +=
                   (sender, args) =>
                   {
                       InitRefreshMenuItems();
                   };
  
                  SubMenuManaBarIndicator = new Menu("Mana Bar Combo Indicator", "ManaBarIndicator");
                  {
                      for (int i = 0; i < 2; i++)
                      {
                          SubMenuManaBarIndicator.AddItem(new MenuItem(pcMode[i] + "DrawManaBar.Q", "Q:").SetValue(true).SetFontStyle(FontStyle.Regular, Q.MenuColor()));
                          SubMenuManaBarIndicator.AddItem(new MenuItem(pcMode[i] + "DrawManaBar.W", "W:").SetValue(true).SetFontStyle(FontStyle.Regular, W.MenuColor()));
                          SubMenuManaBarIndicator.AddItem(new MenuItem(pcMode[i] + "DrawManaBar.E", "E:").SetValue(true).SetFontStyle(FontStyle.Regular, E.MenuColor()));
                      }
                      MenuLocal.AddSubMenu(SubMenuManaBarIndicator);
                  }
  
  
                  SubMenuSpells = new Menu("Spell Ranges", "DrawSpellRanges");
                  {
                      for (int i = 0; i < 2; i++)
                      {
                          SubMenuSpells.AddItem(new MenuItem(pcMode[i] + "Draw.Q", "Q:").SetValue(new Circle(false, Color.FromArgb(255, 255, 255, 255))).SetFontStyle(FontStyle.Regular, Q.MenuColor()));
                          SubMenuSpells.AddItem(new MenuItem(pcMode[i] + "Draw.W", "W:").SetValue(new Circle(false, Color.FromArgb(255, 255, 255, 255))).SetFontStyle(FontStyle.Regular, W.MenuColor()));
                          SubMenuSpells.AddItem(new MenuItem(pcMode[i] + "Draw.E", "E:").SetValue(new Circle(false, Color.FromArgb(255, 255, 255, 255))).SetFontStyle(FontStyle.Regular, E.MenuColor()));
                          SubMenuSpells.AddItem(new MenuItem(pcMode[i] + "Draw.R", "R:").SetValue(new Circle(false, Color.FromArgb(255, 255, 255, 255))).SetFontStyle(FontStyle.Regular, R.MenuColor()));
                      }
                      MenuLocal.AddSubMenu(SubMenuSpells);
                  }
  
                  SubMenuBuffs = new Menu("Buff Times", "DrawBuffTimes");
                  {
                      for (int i = 0; i < 2; i++)
                      {
                          SubMenuBuffs.AddItem(new MenuItem(pcMode[i] + "DrawBuffs", "Show Red/Blue/Baron Time Circle").SetValue(true));
                      }
                      MenuLocal.AddSubMenu(SubMenuBuffs);
                  }
  
                  SubMenuTimers = new Menu("W-R Objects", "DrawSpellTimes");
                  {
                      for (int i = 0; i < 2; i++)
                      {
                          SubMenuTimers.AddItem(new MenuItem(pcMode[i] + "Draw.W.BuffTime", "W: Show Time Circle").SetValue(new StringList(new[] { "Off", "On" }, 1)).SetFontStyle(FontStyle.Regular, R.MenuColor()));
                          SubMenuTimers.AddItem(new MenuItem(pcMode[i] + "Draw.R.BuffTime", "R: Show Time Circle").SetValue(new StringList(new[] { "Off", "On" }, 1)).SetFontStyle(FontStyle.Regular, E.MenuColor()));
                      }
                      MenuLocal.AddSubMenu(SubMenuTimers);
                  }
  
                  for (int i = 0; i < 2; i++)
                  {
                      MenuLocal.AddItem(new MenuItem(pcMode[i] + "DrawKillableEnemy", "Killable Enemy Notification").SetValue(true));
                      MenuLocal.AddItem(new MenuItem(pcMode[i] + "DrawKillableEnemyMini", "Killable Enemy [Mini Map]").SetValue(new Circle(true, Color.GreenYellow)));
                  }
  
                  for (int i = 0; i < 2; i++)
                  {
                      MenuLocal.AddItem(new MenuItem(pcMode[i] + "Draw.MinionLastHit", "Draw Minion Last Hit").SetValue(new StringList(new []{ "Off", "Auto Attack", "Q Damage" }, 2)));
                  }
  
  
                  for (int i = 0; i < 2; i++)
                  {
                      var dmgAfterComboItem = new MenuItem(pcMode[i] + "DrawDamageAfterCombo", "Combo Damage").SetValue(true);
                      {
                          MenuLocal.AddItem(dmgAfterComboItem);
  
                          //LeagueSharp.Common.Utility.HpBarDamageIndicator.DamageToUnit = Common.CommonMath.GetComboDamage;
                          LeagueSharp.Common.Utility.HpBarDamageIndicator.DamageToUnit = Modes.ModeCombo.GetComboDamage;
                          LeagueSharp.Common.Utility.HpBarDamageIndicator.Enabled = dmgAfterComboItem.GetValue<bool>();
                          dmgAfterComboItem.ValueChanged += delegate (object sender, OnValueChangeEventArgs eventArgs)
                          {
                              LeagueSharp.Common.Utility.HpBarDamageIndicator.Enabled = eventArgs.GetNewValue<bool>();
                          };
                      }
                  }
  
                  CommonManaBar.Init(MenuLocal);
              }
              ModeConfig.MenuConfig.AddSubMenu(MenuLocal);
              InitRefreshMenuItems();
  
  
              Game.OnUpdate += GameOnOnUpdate;
         
              Drawing.OnDraw += Drawing_OnDraw;
              Drawing.OnEndScene += DrawingOnOnEndScene;
          }
  
          private void GameOnOnUpdate(EventArgs args)
          {
              //if (SubMenuTimers.Item(GetPcModeStringValue + "Draw.W.BuffTime").GetValue<StringList>().SelectedIndex == 1 && CommonBuffs.LeblancHaveFrenziedStrikes)
              //{
              //    BuffInstance b = ObjectManager.Player.Buffs.Find(buff => buff.DisplayName == "LeblancFrenziedStrikes");
              //    if (LeblancViciousStrikes.EndTime < Game.Time || b.EndTime > LeblancViciousStrikes.EndTime)
              //    {
              //        LeblancViciousStrikes.StartTime = b.StartTime;
              //        LeblancViciousStrikes.EndTime = b.EndTime;
              //    }
              //}
              
              //if (SubMenuTimers.Item(GetPcModeStringValue + "Draw.R.BuffTime").GetValue<StringList>().SelectedIndex == 1 & CommonBuffs.LeblancHaveRagnarok)
              //{
              //    BuffInstance b = ObjectManager.Player.Buffs.Find(buff => buff.DisplayName == "LeblancRagnarok");
              //    if (LeblancRagnarok.EndTime < Game.Time || b.EndTime > LeblancRagnarok.EndTime)
              //    {
              //        LeblancRagnarok.StartTime = b.StartTime;
              //        LeblancRagnarok.EndTime = b.EndTime;
              //    }
              //}
          }
  
          private static MenuItem GetMenuItems(Menu menu)
          {
              foreach (var j in menu.Children.Cast<Menu>().SelectMany(GetMenu).SelectMany(i => i.Items))
              {
                  MenuLocalSubMenuItems.Add(j);
              }
  
              foreach (var j in menu.Items)
              {
                  MenuLocalSubMenuItems.Add(j);
              }
              return null;
          }
          private static IEnumerable<Menu> GetMenu(Menu menu)
          {
              yield return menu;
  
  
gt:             foreach (var childChild in menu.Children.SelectMany(GetMenu))