AdvancedLauncher.UI.Controls.NewsBlock.NewsBlock C# (CSharp) Method

NewsBlock() public method

public NewsBlock ( ) : System
return System
        public NewsBlock()
        {
            InitializeComponent();
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject())) {
                ProfileManager.ProfileChanged += ReloadNews;
                LanguageManager.LanguageChanged += OnLanguageChanged;
                TwitterNewsList.DataContext = TwitterVM;
                ServerNewsList.DataContext = ServerVM;

                //Init animations for News
                DoubleAnimation dShowServerNews = new DoubleAnimation(1, new Duration(TimeSpan.FromMilliseconds(AnimSpeed)));
                Storyboard.SetTarget(dShowServerNews, ServerNewsList);
                Storyboard.SetTargetProperty(dShowServerNews, new PropertyPath(OpacityProperty));
                DoubleAnimation dShowTwitter = new DoubleAnimation(1, new Duration(TimeSpan.FromMilliseconds(AnimSpeed)));
                Storyboard.SetTarget(dShowTwitter, TwitterNewsList);
                Storyboard.SetTargetProperty(dShowTwitter, new PropertyPath(OpacityProperty));

                ShowServerNews.Children.Add(dShowServerNews);
                ShowTwitter.Children.Add(dShowTwitter);

                bwLoadTwitter.RunWorkerCompleted += (s, e) => {
                    this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => {
                        ShowTwitter.Begin();
                        IsTwitterLoadingAnim(false);
                    }));
                };

                bwLoadTwitter.DoWork += (s1, e1) => {
                    if (!TwitterVM.IsDataLoaded || _jsonUrlLoaded != _jsonUrl) {
                        IsTwitterLoadingAnim(true);
                        this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => {
                            TwitterVM.UnLoadData();
                        }));
                        GetTwitterNewsAPI11(_jsonUrl);
                        this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new DoLoadTwitter((list) => {
                            TwitterVM.LoadData(list);
                        }), TwitterStatuses);
                        _jsonUrlLoaded = _jsonUrl;
                    }
                };

                bwLoadServerNews.RunWorkerCompleted += (s, e) => {
                    this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => {
                        ShowServerNews.Begin();
                        IsServerNewsLoadingAnim(false);
                    }));
                };
                bwLoadServerNews.DoWork += (s1, e1) => {
                    if (!ServerVM.IsDataLoaded) {
                        IsServerNewsLoadingAnim(true);
                        GetServerNews();
                        this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new DoLoadServerNews((list) => {
                            if (list != null)
                                ServerVM.LoadData(list);
                        }), ServerNews);
                    }
                };
                ReloadNews(this, BaseEventArgs.Empty);
            }
        }