Exemple #1
0
        public MainWindow()
        {
            m_MapLayerContainer = new ArenaNetMapLayerContainer();

            InitializeComponent();

            m_Link    = new MumbleLink();
            m_MapData = new Dictionary <int, FloorMapDetails>();

            m_FollowPlayer      = false;
            m_Player            = new PlayerPushpin();
            m_Player.Visibility = Visibility.Hidden;
            Map.Children.Add(m_Player);

            Map.Children.Add(m_MapLayerContainer);

            new MapFloorRequest(1, 2).ExecuteAsync(floor =>
            {
                if (floor != null)
                {
                    foreach (FloorRegion region in floor.Regions.Values)
                    {
                        foreach (int mid in region.Maps.Keys)
                        {
                            FloorMapDetails map = region.Maps[mid];
                            m_MapData.Add(mid, map);
                        }
                    }

                    m_MapDataLoaded.Set();

                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        foreach (KeyValuePair <int, FloorMapDetails> entry in m_MapData)
                        {
                            m_MapLayerContainer.LoadFloorMapDetails(entry.Key, entry.Value);
                        }
                    }), DispatcherPriority.Background);
                }
            });

            m_MapLayerContainer.LoadBounties();

            new EventDetailsRequest().ExecuteAsync(events =>
            {
                if (events != null)
                {
                    new ChampionEventsRequest().ExecuteAsync(championEvents =>
                    {
                        IDictionary <Guid, EventDetails> evDetails = new Dictionary <Guid, EventDetails>();
                        IDictionary <Guid, bool> evChamps          = new Dictionary <Guid, bool>();

                        foreach (KeyValuePair <Guid, EventDetails> entry in events.Events)
                        {
                            Guid eid        = entry.Key;
                            EventDetails ev = entry.Value;
                            if (!ev.Name.StartsWith("skill challenge: ", StringComparison.InvariantCultureIgnoreCase) && m_MapData.ContainsKey(ev.MapId))
                            {
                                evDetails[eid] = ev;
                                evChamps[eid]  = championEvents.ChampionEvents.Contains(eid);
                            }
                        }

                        // ensure map data is loaded
                        m_MapDataLoaded.WaitOne();

                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            foreach (KeyValuePair <Guid, EventDetails> entry in evDetails)
                            {
                                m_MapLayerContainer.LoadEvent(entry.Key, entry.Value, m_MapData[entry.Value.MapId], evChamps[entry.Key]);
                            }

                            m_EventDataLoaded.Set();
                        }), DispatcherPriority.Background);
                    });
                }
            });

            m_EventTimerBoxes = new Dictionary <string, EventTimerBox>();
            new EventTimerRequest().ExecuteAsync(timerData =>
            {
                if (timerData != null)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        foreach (MetaEventStatus e in timerData.Events)
                        {
                            EventTimerBox box = new EventTimerBox();
                            box.SetData(e);
                            m_EventTimerBoxes.Add(e.Id, box);

                            switch (e.StageTypeEnum)
                            {
                            case MetaEventStage.StageType.Boss:
                                EventTimerItems_Boss.Children.Add(box);
                                break;

                            case MetaEventStage.StageType.PreEvent:
                                EventTimerItems_PreEvent.Children.Add(box);
                                break;

                            default:
                                EventTimerItems_Other.Children.Add(box);
                                break;
                            }
                        }

                        m_TimerDataLoaded.Set();
                    }), DispatcherPriority.Background);
                }
            });

            MouseDown += DrawPolyMouseDownHandler;
            KeyDown   += DrawPolyKeyDownHandler;
            KeyUp     += DrawPolyKeyUpHandler;

            m_Running            = true;
            m_Canceled           = new ManualResetEvent(false);
            m_PlayerWorkerThread = new Thread(PlayerWorkerThread);
            m_PlayerWorkerThread.Start();
            m_EventWorkerThread = new Thread(EventWorkerThread);
            m_EventWorkerThread.Start();
            m_EventTimerWorkerThread = new Thread(EventTimerWorkerThread);
            m_EventTimerWorkerThread.Start();
        }
        public MainWindow()
        {
            m_MapLayerContainer = new ArenaNetMapLayerContainer();

            InitializeComponent();

            m_Link = new MumbleLink();
            m_MapData = new Dictionary<int, FloorMapDetails>();

            m_FollowPlayer = false;
            m_Player = new PlayerPushpin();
            m_Player.Visibility = Visibility.Hidden;
            Map.Children.Add(m_Player);

            Map.Children.Add(m_MapLayerContainer);

            new MapFloorRequest(1, 2).ExecuteAsync(floor =>
                {
                    if (floor != null)
                    {
                        foreach (FloorRegion region in floor.Regions.Values)
                        {
                            foreach (int mid in region.Maps.Keys)
                            {
                                FloorMapDetails map = region.Maps[mid];
                                m_MapData.Add(mid, map);
                            }
                        }

                        m_MapDataLoaded.Set();

                        Dispatcher.BeginInvoke(new Action(() =>
                            {
                                foreach (KeyValuePair<int, FloorMapDetails> entry in m_MapData)
                                {
                                    m_MapLayerContainer.LoadFloorMapDetails(entry.Key, entry.Value);
                                }
                            }), DispatcherPriority.Background);
                    }
                });

            m_MapLayerContainer.LoadBounties();

            new EventDetailsRequest().ExecuteAsync(events =>
                {
                    if (events != null)
                    {
                        new ChampionEventsRequest().ExecuteAsync(championEvents =>
                        {
                            IDictionary<Guid, EventDetails> evDetails = new Dictionary<Guid, EventDetails>();
                            IDictionary<Guid, bool> evChamps = new Dictionary<Guid, bool>();

                            foreach (KeyValuePair<Guid, EventDetails> entry in events.Events)
                            {
                                Guid eid = entry.Key;
                                EventDetails ev = entry.Value;
                                if (!ev.Name.StartsWith("skill challenge: ", StringComparison.InvariantCultureIgnoreCase) && m_MapData.ContainsKey(ev.MapId))
                                {
                                    evDetails[eid] = ev;
                                    evChamps[eid] = championEvents.ChampionEvents.Contains(eid);
                                }
                            }

                            // ensure map data is loaded
                            m_MapDataLoaded.WaitOne();

                            Dispatcher.BeginInvoke(new Action(() =>
                                {
                                    foreach (KeyValuePair<Guid, EventDetails> entry in evDetails)
                                    {
                                        m_MapLayerContainer.LoadEvent(entry.Key, entry.Value, m_MapData[entry.Value.MapId], evChamps[entry.Key]);
                                    }

                                    m_EventDataLoaded.Set();
                                }), DispatcherPriority.Background);
                        });
                    }
                });

            m_EventTimerBoxes = new Dictionary<string, EventTimerBox>();
            new EventTimerRequest().ExecuteAsync(timerData =>
                {
                    if (timerData != null)
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                            {
                                foreach (MetaEventStatus e in timerData.Events)
                                {
                                    EventTimerBox box = new EventTimerBox();
                                    box.SetData(e);
                                    m_EventTimerBoxes.Add(e.Id, box);

                                    switch (e.StageTypeEnum)
                                    {
                                        case MetaEventStage.StageType.Boss:
                                            EventTimerItems_Boss.Children.Add(box);
                                            break;
                                        case MetaEventStage.StageType.PreEvent:
                                            EventTimerItems_PreEvent.Children.Add(box);
                                            break;
                                        default:
                                            EventTimerItems_Other.Children.Add(box);
                                            break;
                                    }
                                }

                                m_TimerDataLoaded.Set();
                            }), DispatcherPriority.Background);
                    }
                });

            MouseDown += DrawPolyMouseDownHandler;
            KeyDown += DrawPolyKeyDownHandler;
            KeyUp += DrawPolyKeyUpHandler;

            m_Running = true;
            m_Canceled = new ManualResetEvent(false);
            m_PlayerWorkerThread = new Thread(PlayerWorkerThread);
            m_PlayerWorkerThread.Start();
            m_EventWorkerThread = new Thread(EventWorkerThread);
            m_EventWorkerThread.Start();
            m_EventTimerWorkerThread = new Thread(EventTimerWorkerThread);
            m_EventTimerWorkerThread.Start();
        }