示例#1
0
 private bool Load_Replay_Params(FileManager.File.Info info)
 {
     try
     {
         var dic = Replayer_Replay_Params_Manager.LoadObjectFromFile(typeof(Dictionary <IPandPort, Tuple <IPandPort, bool> >))
                   as Dictionary <IPandPort, Tuple <IPandPort, bool> >;
         Replayer_Map.Items.Clear();
         foreach (var item in dic)
         {
             var rcv_point = new IPEndPoint(IPAddress.Parse(item.Key.IP), item.Key.Port);
             if (!info.points.Contains(rcv_point))
             {
                 return(false);
             }
             var bu = new Replayer_Map_Item(Replayer_Map.Items.Count, rcv_point);
             bu.Point.Set_IPPORT(item.Value.Item1);
             bu.Valid.IsChecked = item.Value.Item2;
             Replayer_Map.Items.Add(bu);
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
示例#2
0
        private void Replayer_Button_Play_Click(object sender, RoutedEventArgs e)
        {
            if (_replayer == null)
            {
                MessageBox.Show("Please select file firstly!");
                return;
            }

            // not playing
            // paused or stoped
            if (!_replayer.IsPlaying)
            {
                // Check map
                Replayer_Map_Item buff = null;
                Dictionary <IPEndPoint, IPEndPoint> map = new Dictionary <IPEndPoint, IPEndPoint>();
                try
                {
                    foreach (Replayer_Map_Item item in Replayer_Map.Items)
                    {
                        buff = item;

                        // ignore
                        if (!(bool)item.Valid.IsChecked)
                        {
                            continue;
                        }

                        var point = item.Point.Get_IPEND();

                        map.Add(item._point, point);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Wrong Input!\nCheck the Map List At " + buff?.Num.Text);
                    Recorder_Stop();
                    return;
                }

                _replayer.Initial(map,
                                  (Core.ReplayCore.SendInfo msg) =>
                {
                    _sender.Send(msg.bytes.ToArray(), msg.point);
                },
                                  (Core.ReplayCore.ReplayInfo info) =>
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        var finfo = _replayer.FileInfo;
                        if (info.index == finfo.totalIndex - 1)
                        {
                            if ((bool)Replayer_Flag_Loop.IsChecked)
                            {
                                _replayer.JumpTo(0);
                            }
                        }
                        if (!Replayer_Flag_IsDraging)
                        {
                            Replayer_Slider.Value = info.index;
                        }
                        Replayer_Info.Text = info.time.AddHours(8) + " Progress Percentage: " + (100.0 * (double)info.index / ((double)finfo.totalIndex - 1)).ToString("f2") + "%"
                                             + "\nProgress Index: " + info.index + " Total Index: " + finfo.totalIndex + " Cost Time:" + info.pkgCostTime;
                    });
                });


                _replayer.P();
                Replayer_IsPlaying();

                // save params
                Save_Replay_Params();
            }
            else
            {
                _replayer.P();
                Replayer_NotPlaying();
            }
        }