Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();
            web.Source=new Uri("http://soft.ceve-market.org/bilibili_dm/app.htm?"+DateTime.Now.Ticks); //f**k you IE cache
            b.Disconnected += b_Disconnected;
            b.ReceivedDanmaku += b_ReceivedDanmaku;
            b.ReceivedRoomCount += b_ReceivedRoomCount;
            try
            {
                IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
                                                                            IsolatedStorageScope.Domain |
                                                                            IsolatedStorageScope.Assembly, null, null);
                System.Xml.Serialization.XmlSerializer settingsreader =
                    new System.Xml.Serialization.XmlSerializer(typeof (StoreModel));
                StreamReader reader = new StreamReader(new IsolatedStorageFileStream(
                    "settings.xml", FileMode.Open, isoStore));
                settings = (StoreModel) settingsreader.Deserialize(reader);
                reader.Close();
                
            }
            catch (Exception)
            {
                settings=new StoreModel();
                
            }
            settings.SaveConfig();
            settings.toStatic();
            OptionDialog.LayoutRoot.DataContext = settings;

            timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, FuckMicrosoft,
                this.Dispatcher);
            timer.Start();
            
            DataGrid.ItemsSource = Ranking;
            DataGrid2.ItemsSource = SessionItems;
//            fulloverlay.Show();
            logging("投喂记录不会在弹幕模式上出现, 这不是bug");
//            for (int i = 0; i < 150; i++)
//            {
//                logging("投喂记录不会在弹幕模式上出现, 这不是bug");
//            }
        }
        public MainWindow()
        {
            InitializeComponent();
            DateTime dt = new DateTime(2000, 1, 1);
            Assembly assembly = Assembly.GetExecutingAssembly();
            String version = assembly.FullName.Split(',')[1];

            String fullversion = version.Split('=')[1];
            int dates = int.Parse(fullversion.Split('.')[2]);

            int seconds = int.Parse(fullversion.Split('.')[3]);
            dt = dt.AddDays(dates);
            dt = dt.AddSeconds(seconds * 2);
            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                this.Title += "   版本号: " +
                System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
            }
            else
            {
                this.Title += "   *傻逼版本*";
            }
            this.Title += "   编译时间: " + dt.ToString();

            InitPlugins();
            this.Closed += MainWindow_Closed;
            web.Source=new Uri("http://soft.ceve-market.org/bilibili_dm/app.htm?"+DateTime.Now.Ticks); //f**k you IE cache
            b.Disconnected += b_Disconnected;
            b.ReceivedDanmaku += b_ReceivedDanmaku;
            b.ReceivedRoomCount += b_ReceivedRoomCount;
            try
            {
                IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
                                                                            IsolatedStorageScope.Domain |
                                                                            IsolatedStorageScope.Assembly, null, null);
                System.Xml.Serialization.XmlSerializer settingsreader =
                    new System.Xml.Serialization.XmlSerializer(typeof (StoreModel));
                StreamReader reader = new StreamReader(new IsolatedStorageFileStream(
                    "settings.xml", FileMode.Open, isoStore));
                settings = (StoreModel) settingsreader.Deserialize(reader);
                reader.Close();
                
            }
            catch (Exception)
            {
                settings=new StoreModel();
                
            }
            settings.SaveConfig();
            settings.toStatic();
            OptionDialog.LayoutRoot.DataContext = settings;

            timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, FuckMicrosoft,
                this.Dispatcher);
            timer.Start();
            
            DataGrid.ItemsSource = Ranking;
            DataGrid2.ItemsSource = SessionItems;
//            fulloverlay.Show();
            logging("投喂记录不会在弹幕模式上出现, 这不是bug");
//            for (int i = 0; i < 150; i++)
//            {
//                logging("投喂记录不会在弹幕模式上出现, 这不是bug");
//            }
            PluginGrid.ItemsSource = Plugins;
        }
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            //Full.IsChecked = _fulloverlayEnabled;
            SideBar.IsChecked   = _overlayEnabled;
            SaveLog.IsChecked   = _savelogEnabled;
            SSTP.IsChecked      = _sendsspEnabled;
            ShowItem.IsChecked  = _showvipEnabled;
            ShowError.IsChecked = _showerrorEnabled;
            WindowTop.IsChecked = Topmost;
            var sc = Log.Template.FindName("LogScroll", Log) as ScrollViewer;

            sc?.ScrollToEnd();

            var shit = new Thread(() =>
            {
                var bbb = 5;
                while (true)
                {
                    var r = new Random();

                    lock (_danmakuQueue)
                    {
                        for (var i = 0; i < bbb; i++)
                        {
                            var a1 = r.NextDouble().ToString();
                            var b1 = r.NextDouble().ToString();
                            _danmakuQueue.Enqueue(new DanmakuModel

                            {
                                CommentUser = "******",
                                CommentText = b1,
                                MsgType     = MsgTypeEnum.Comment
                            });
                        }
                    }
                    lock (_static)
                    {
                        _static.DanmakuCountRaw += bbb;
                    }

                    Thread.Sleep(1000);
                }
            }
                                  );

            shit.IsBackground = true;

            //            shit.Start();



            try
            {
                var isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
                                                            IsolatedStorageScope.Domain |
                                                            IsolatedStorageScope.Assembly, null, null);
                var settingsreader =
                    new XmlSerializer(typeof(StoreModel));
                var reader = new StreamReader(new IsolatedStorageFileStream(
                                                  "settings.xml", FileMode.Open, isoStore));
                _settings = (StoreModel)settingsreader.Deserialize(reader);
                reader.Close();
            }
            catch (Exception)
            {
                _settings = new StoreModel();
            }
            _settings.SaveConfig();
            _settings.toStatic();
            OptionDialog.LayoutRoot.DataContext = _settings;
            // Full overlay need be loaded after _settings
            Full.IsChecked = _fulloverlayEnabled;
        }