public void LoadTradeSkills()
 {
     try
     {
         lock (TradeSkillList)
         {
             TradeSkillList.Clear();
             foreach (WoWSkill skill in SupportedTradeSkills)
             {
                 Log("Adding TradeSkill {0}", skill.Name);
                 TradeSkill ts = TradeSkillFrame.Instance.GetTradeSkill((SkillLine)skill.Id, true);
                 if (ts != null)
                 {
                     TradeSkillList.Add(ts);
                 }
                 else
                 {
                     IsTradeSkillsLoaded = false;
                     Log("Unable to load tradeskill {0}", (SkillLine)skill.Id);
                     return;
                 }
             }
         }
         IsTradeSkillsLoaded = true;
         if (OnTradeSkillsLoaded != null)
         {
             OnTradeSkillsLoaded(this, null);
         }
     }
     catch (Exception ex) { Logging.Write(System.Drawing.Color.Red, ex.ToString()); }
 }
Exemple #2
0
        public void LoadTradeSkills()
        {
            new Timer(state =>
            {
                try
                {
                    lock (TradeSkillList)
                    {
                        TradeSkillList.Clear();
                        //IEnumerable<WoWSkill> skillList = from skill in TradeSkill.SupportedSkills
                        //                                  select Me.GetSkill(skill);

                        //foreach (WoWSkill skill in skillList)
                        //{
                        //    Log("Adding TradeSkill {0}", skill.Name);
                        //    TradeSkill ts = TradeSkill.GetTradeSkill((SkillLine)skill.Id);
                        //    if (ts != null)
                        //    {
                        //        TradeSkillList.Add(ts);
                        //    }
                        //    else
                        //    {
                        //        IsTradeSkillsLoaded = false;
                        //        Log("Unable to load tradeskill {0}", (SkillLine)skill.Id);
                        //        return;
                        //    }
                        //}
                        foreach (WoWSkill skill in SupportedTradeSkills)
                        {
                            Log("Adding TradeSkill {0}", skill.Name);
                            TradeSkill ts = TradeSkill.GetTradeSkill((SkillLine)skill.Id);
                            if (ts != null)
                            {
                                TradeSkillList.Add(ts);
                            }
                            else
                            {
                                IsTradeSkillsLoaded = false;
                                Log("Unable to load tradeskill {0}", (SkillLine)skill.Id);
                                return;
                            }
                        }
                    }
                    Log("Done Loading Tradeskills.");
                    IsTradeSkillsLoaded = true;
                    if (OnTradeSkillsLoaded != null)
                    {
                        OnTradeSkillsLoaded(this, null);
                    }
                }
                catch (Exception ex)
                {
                    Logging.Write(Color.Red, ex.ToString());
                }
            }, null, 0, Timeout.Infinite);
        }
 private void OnSkillUpdate(object obj, LuaEventArgs args)
 {
     if (_onSkillUpdateTimer.IsFinished)
     {
         try
         {
             lock (tradeSkillLocker)
             {
                 UpdateMaterials();
                 // check if there was any tradeskills added or removed.
                 WoWSkill[] skills  = SupportedTradeSkills;
                 bool       changed = skills.Count(s => TradeSkillList.Count(l => l.SkillLine == (SkillLine)s.Id) == 1) !=
                                      TradeSkillList.Count ||
                                      skills.Length != TradeSkillList.Count;
                 if (changed)
                 {
                     PBLog.Debug("A profession was added or removed. Reloading Tradeskills (OnSkillUpdateTimerCB)");
                     OnTradeSkillsLoaded += Professionbuddy_OnTradeSkillsLoaded;
                     LoadTradeSkills();
                 }
                 else
                 {
                     PBLog.Debug("Updated tradeskills from OnSkillUpdateTimerCB");
                     foreach (TradeSkill ts in TradeSkillList)
                     {
                         ts.PulseSkill();
                     }
                     if (MainForm.IsValid)
                     {
                         MainForm.Instance.RefreshTradeSkillTabs();
                         MainForm.Instance.RefreshActionTree(typeof(CastSpellAction));
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             PBLog.Warn(ex.ToString());
         }
         _onSkillUpdateTimer.Reset();
     }
 }
Exemple #4
0
 private void OnSkillUpdateTimerCB()
 {
     Lua.Events.AttachEvent("SKILL_LINES_CHANGED", OnSkillUpdate);
     try
     {
         UpdateMaterials();
         // check if there was any tradeskills added or removed.
         WoWSkill[] skills  = SupportedTradeSkills;
         bool       changed = skills.
                              Count(s => TradeSkillList.Count(l => l.SkillLine == (SkillLine)s.Id) == 1) !=
                              TradeSkillList.Count ||
                              skills.Length != TradeSkillList.Count;
         if (changed)
         {
             Debug("A profession was added or removed. Reloading Tradeskills (OnSkillUpdateTimerCB)");
             OnTradeSkillsLoaded += Professionbuddy_OnTradeSkillsLoaded;
             LoadTradeSkills();
         }
         else
         {
             Debug("Updated tradeskills from OnSkillUpdateTimerCB");
             foreach (TradeSkill ts in TradeSkillList)
             {
                 ts.PulseSkill();
             }
             if (MainForm.IsValid)
             {
                 MainForm.Instance.RefreshTradeSkillTabs();
                 MainForm.Instance.RefreshActionTree(typeof(CastSpellAction));
             }
         }
     }
     catch (Exception ex)
     {
         Err(ex.ToString());
     }
 }