Пример #1
0
        public void Search(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker       worker     = sender as BackgroundWorker;
            List <SimpleLoLRecord> resultList = new List <SimpleLoLRecord>();

            e.Result = resultList;

            for (int i = 0; i < records.Count; i++)
            {
                SimpleLoLRecord slr = records[i];
                if (slr == null)
                {
                    continue;
                }
                if (!slr.IsRecording)
                {
                    if (BaronReplays.Helper.FileHelper.GetFileName(slr.FileName).IndexOf(searchKeyWords, StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        resultList.Add(slr);
                        continue;
                    }
                }
                if (slr.Search(searchKeyWords))
                {
                    resultList.Add(slr);
                }
            }
        }
Пример #2
0
        public static SimpleLoLRecord GetSimpleLoLRecord(LoLRecord record)
        {
            if (record.IsBroken)
            {
                return(null);
            }

            SimpleLoLRecord slr = new SimpleLoLRecord();

            try
            {
                slr.GameId       = record.GameId;
                slr.GamePlatform = new String(record.gamePlatform);
                slr.FileName     = record.relatedFileName;
                slr.LoLVersion   = record.LoLVersion;
            }
            catch (Exception ex)
            {
                Logger.Instance.WriteLog(String.Format("Failed on get simple record: {0}", ex.Message));
                return(null);
            }
            try
            {
                slr.BlueTeamPlayerInfo   = record.GetTeamInfo(100);
                slr.PurpleTeamPlayerInfo = record.GetTeamInfo(200);
            }
            catch (Exception ex)
            {
                Logger.Instance.WriteLog(String.Format("Failed on get simple record team info: {0}", ex.Message));
                return(slr);
            }
            return(slr);
        }
Пример #3
0
        private void FavoriteIcon_Clicked(object sender, EventArgs e)
        {
            SimpleLoLRecord slr = this.DataContext as SimpleLoLRecord;

            slr.Favorite          = !slr.Favorite;
            FavoriteIcon.LockDown = slr.Favorite;
        }
Пример #4
0
 private void RemoveRecoder(LoLRecorder recoder, Boolean force = false)
 {
     if (!Dispatcher.CheckAccess())
     {
         RemoveRecoderDelegate refresh = new RemoveRecoderDelegate(RemoveRecoder);
         Dispatcher.BeginInvoke(refresh, recoder, force);
     }
     else
     {
         if (Recorders.ContainsKey(recoder))
         {
             Thread t = this.Recorders[recoder];
             if (t.IsAlive && force)
             {
                 t.Abort();
                 recoder.removeFromList();
             }
             this.Recorders.Remove(recoder);
             SimpleLoLRecord slr = replayManager.GetRecordFromRecorder(recoder);
             if (slr != null)
             {
                 this.replayManager.RemoveRecord(slr);
             }
             UpdateStatusBar();
         }
     }
 }
Пример #5
0
        private void RecordsListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (RecordsListBox.SelectedItem == null)
            {
                return;
            }
            SimpleLoLRecord slr = RecordsListBox.SelectedItem as SimpleLoLRecord;

            if (slr.RecoringRecorder != null)
            {
                GameInfoView giv = new GameInfoView();
                giv.DataContext = slr.RecoringRecorder.GameInfo;
                SwitchMainContent(giv);
                return;
            }

            LoLRecord lr = new LoLRecord();

            lr.readFromFile(slr.FileName, false);
            if (lr.HasResult)
            {
                lr.gameStats.DecodeData();
            }
            if (lr.gameStats == null)
            {
                ShowNoData();
            }
            else
            {
                UserControl ui = new RecordDetail();
                ui.DataContext = lr.gameStats;
                SwitchMainContent(ui);
            }
        }
Пример #6
0
        public void PlayRecord(SimpleLoLRecord slr)
        {
            if (!Dispatcher.CheckAccess())
            {
                RecordDelegate prd = new RecordDelegate(PlayRecord);
                Dispatcher.Invoke(prd, slr);
                return;
            }
            Logger.Instance.WriteLog(String.Format("Play record: {0}", slr.FileName));
            if (_launcher == null)
            {
                if (slr.RecoringRecorder != null)
                {
                    StartLoLLauncher(new LoLLauncher(slr.RecoringRecorder));
                }
                else
                {
                    StartLoLLauncher(new LoLLauncher(slr));
                }
            }

            else
            {
                PopupWindow.ShowMessage(this, Utilities.GetString("AlreadyPlaying") as string);
            }
        }
Пример #7
0
        private void LoadRecords(object sender, DoWorkEventArgs e)
        {
            System.Diagnostics.Stopwatch loadWatch = new System.Diagnostics.Stopwatch();
            DirectoryInfo          loldir          = new DirectoryInfo(DirectoryPath);
            List <SimpleLoLRecord> tempList        = new List <SimpleLoLRecord>();

            try
            {
                FileInfo[] files = loldir.GetFiles("*.lpr").OrderByDescending(x => x.LastWriteTime).ToArray();
                loadWatch.Start();
                foreach (FileInfo f in files)
                {
                    SimpleLoLRecord slr = ReadRecord(f.FullName, false);
                    if (slr != null)
                    {
                        tempList.Add(slr);
                    }
                    if (loadWatch.ElapsedMilliseconds > 500)
                    {
                        //add into view
                        InsertMultiRecordUIThread(tempList);
                        tempList.Clear();
                        loadWatch.Restart();
                    }
                }
                InsertMultiRecordUIThread(tempList);
                loadWatch.Stop();
            }
            catch (Exception)
            {
            }
            CheckDatabase();
        }
Пример #8
0
        private void ReplayDirectoryWatcher_Deleted(object sender, FileSystemEventArgs e)
        {
            SimpleLoLRecord slr = QueryByFileName(e.FullPath);

            if (slr != null)
            {
                RemoveRecord(slr);
            }
        }
Пример #9
0
        private void ReadRecordFile(object sender, DoWorkEventArgs e)
        {
            SimpleLoLRecord slr = e.Argument as SimpleLoLRecord;
            LoLRecord       lr  = new LoLRecord();

            lr.readFromFile((e.Argument as SimpleLoLRecord).FileName, false);
            if (lr.HasResult)
            {
                lr.gameStats.DecodeData();
            }
            e.Result = lr;
        }
Пример #10
0
 public void UpdateRecordingRecord(LoLRecorder recorder)
 {
     if (recorderToRecords.ContainsKey(recorder))
     {
         recorderToRecords[recorder].UpdateSummonerData();
     }
     else
     {
         SimpleLoLRecord slr = ReadRecord(recorder.record, true);
         slr.RecoringRecorder = recorder;
         recorderToRecords.Add(recorder, slr);
     }
 }
Пример #11
0
 private void InitSimpleRecord(SimpleLoLRecord slr)
 {
     slr.DeleteClickEvent += DeleteRecord;
     if (PlayRecordEvent != null)
     {
         slr.WatchClickEvent += PlayRecordEvent;
     }
     if (ExportRecordEvent != null)
     {
         slr.ExportClickEvent += ExportRecordEvent;
     }
     slr.GetGameFromDB();
 }
Пример #12
0
 public LoLLauncher(SimpleLoLRecord simpleRecord)
 {
     if (simpleRecord.RecoringRecorder == null)
     {
         _record = new LoLRecord();
         _record.readFromFile(simpleRecord.FileName, false);
         _checkVersion = true;
     }
     else
     {
         _record = simpleRecord.RecoringRecorder.record;
     }
     _localPlay = true;
 }
Пример #13
0
        public SimpleLoLRecord ReadRecord(LoLRecord record, Boolean addToList)
        {
            SimpleLoLRecord slr = LoLRecord.GetSimpleLoLRecord(record);

            if (slr != null)
            {
                InitSimpleRecord(slr);
                if (addToList)
                {
                    InsertRecordUIThread(slr);
                }
            }
            return(slr);
        }
Пример #14
0
 public void DeleteRecord(SimpleLoLRecord slr)
 {
     if (slr.RecoringRecorder == null)
     {
         if (File.Exists(slr.FileName))
         {
             File.Delete(slr.FileName);
         }
     }
     else
     {
         StopRecordingEvent(slr.RecoringRecorder, true);
         RemoveRecord(slr);
         recorderToRecords.Remove(slr.RecoringRecorder);
     }
 }
Пример #15
0
        private void ReplayDirectoryWatcher_Renamed(object sender, RenamedEventArgs e)
        {
            SimpleLoLRecord slr = QueryByFileName(e.OldFullPath);

            if (slr != null)
            {
                slr.FileName = e.FullPath;
            }
            else
            {
                slr = QueryByFileName(e.FullPath);//如果是BR改的,simple record的名字就已經是改過的了
                if (slr == null)
                {
                    ReadRecord(e.FullPath, true);
                }
            }
        }
Пример #16
0
 public void RemoveRecord(SimpleLoLRecord slr)
 {
     if (!CheckAccess())
     {
         Dispatcher.Invoke(new RecordUIThreadDelegte(RemoveRecord), slr);
     }
     else
     {
         if (records.Contains(slr))
         {
             records.Remove(slr);
         }
         if (searchResult.Contains(slr))
         {
             searchResult.Remove(slr);
         }
     }
 }
Пример #17
0
 private void InsertRecordUIThread(SimpleLoLRecord slr)
 {
     if (!CheckAccess())
     {
         Dispatcher.Invoke(new RecordUIThreadDelegte(InsertRecordUIThread), slr);
     }
     else
     {
         records.Insert(0, slr);
         if (IsSearching)
         {
             if (slr.Search(searchKeyWords))
             {
                 searchResult.Insert(0, slr);
             }
         }
     }
 }
Пример #18
0
        public void ExportRecord(SimpleLoLRecord slr)
        {
            if (!Dispatcher.CheckAccess())
            {
                RecordDelegate prd = new RecordDelegate(ExportRecord);
                Dispatcher.Invoke(prd, slr);
                return;
            }
            if (videoRecordingController != null)
            {
                if (videoRecordingController.LoLStarted)
                {
                    bool?answer = YesNoPopupWindow.AskQuestion(this, Utilities.GetString("VideoRecordingExitCheck"));
                    if (answer.HasValue)
                    {
                        if (answer.Value)
                        {
                            EndVideoRecordingMode();
                        }
                    }
                }
                else
                {
                    EndVideoRecordingMode();
                }
                return;
            }
            toExport = slr;
            MovieConfiguration configurater = new MovieConfiguration();

            if (toExport != null)
            {
                configurater.FileNameBox.Text = slr.FileNameShort.Remove(slr.FileNameShort.Length - 4);
            }
            configurater.Done += MovieConfigurationDone;
            SwitchMainContent(configurater);
        }