Пример #1
0
        public static Penalty Create()
        {
            var penalty = new Penalty();

            var guid = Guid.NewGuid();
            penalty.Id = new ShortGuid(guid).ToString();
            return penalty;
        }
Пример #2
0
        public static Penalty Create()
        {
            var penalty = new Penalty();

            var guid = Guid.NewGuid();

            penalty.Id = new ShortGuid(guid).ToString();
            return(penalty);
        }
 public static SyncStateCommand EditPenalty(Penalty penalty)
 {
     var command = new SyncStateCommand();
     command.StateUpdateType = SyncStateCommand.StateUpdateTypes.EditPenalty;
     command.Data = new
     {
         Penalty = penalty
     };
     return command;
 }
        public EditPenaltyWindow(Penalty penalty)
        {
            InitializeComponent();

            _penalty = penalty;
            this.DataContext = penalty;

            this.KeyUp += OnKeyUp;

            cboReason.ItemsSource = new[]
                                    {
                                        "Avoidable contact",
                                        "Dangerous driving",
                                        "Ignoring track limits",
                                        "Incorrectly served penalty",
                                        "Ignoring admin warning"
                                    };
        }
Пример #5
0
        private void UpdatePenalty(Penalty penalty)
        {
            Debug.WriteLine(">>>>>>>>>>>>>>>> Penalty updated: " + penalty.Id);
            var existing = this.State.Penalties.SingleOrDefault(p => p.Id == penalty.Id);
            if (existing != null)
            {
                this.State.Penalties.Remove(existing);
            }

            this.State.Penalties.Add(penalty);
        }
Пример #6
0
        public void EditPenalty(Penalty penalty)
        {
            var selected = this.SelectedPenalty;
            this.SelectedPenalty = null;

            // Edit penalty details 
            var dialog = new EditPenaltyWindow(penalty);
            App.Instance.MainModel.ShowDialog(dialog);

            SyncManager.Instance.SendPenaltyUpdate(penalty);

            this.SelectedPenalty = selected;
        }
Пример #7
0
        public void JoinPenalty(Penalty penalty)
        {
            var user = SyncManager.Instance.User;

            // If penalty is already decided - ignore
            if (!penalty.IsUnderInvestigation) return;

            if (penalty.Users.Contains(user))
            {
                // If we are already investigating - leave
                penalty.Users.Remove(user);
            }
            else
            {
                // If we are not yet investigating - join
                penalty.JoinUser(user);

                // Sync camera
                CameraControl.ChangeCamera(penalty.Camera);
            }

            SyncManager.Instance.SendPenaltyUpdate(penalty);
            this.PenaltiesView.Refresh();
        }
Пример #8
0
                public static LiveAdminPenalty FromPenalty(Penalty penalty)
                {
                    var p = new LiveAdminPenalty();
                    p.Id = penalty.Id;

                    var admin = penalty.Users.FirstOrDefault();
                    if (admin != null)
                    {
                        p.AdminId = admin.CustId;
                        p.AdminName = admin.Name;
                        p.AdminShortName = admin.ShortName;
                    }

                    p.InvestigatedDrivers = new List<LiveAdminDriver>();
                    if (penalty.IsUnderInvestigation)
                    {
                        foreach (var id in penalty.DriverIds)
                        {
                            var driver = Simulator.Instance.Drivers.FromId(id);
                            if (driver != null)
                            {
                                p.InvestigatedDrivers.Add(LiveAdminDriver.FromDriver(driver.Driver));
                            }

                            p.InvestigatedDriversDisplay = string.Join("<br />",
                                p.InvestigatedDrivers.Select(d => d.Display));
                        }
                    }
                    else
                    {
                        var driver = Simulator.Instance.Drivers.FromId(penalty.Result.DriverId);
                        if (driver != null)
                        {
                            p.OffendingDriver = LiveAdminDriver.FromDriver(driver.Driver);
                        }
                        p.InvestigatedDriversDisplay = p.OffendingDriver.Display;
                    }

                    DateTime time = penalty.StartInvestigationTime.HasValue
                        ? penalty.StartInvestigationTime.Value
                        : _epoch;
                    p.TimeGMT = (time - _epoch).TotalMilliseconds;
                    p.Lap = penalty.Lap;
                    p.Turn = penalty.Turn;

                    //p.RuleId = ...
                    p.Decided = !penalty.IsUnderInvestigation;
                    p.Reason = penalty.Reason;
                    p.Result = penalty.Result.DisplayLong;
                    p.ResultShort = penalty.Result.DisplayShort;
                    p.ResultDecidedLap = penalty.DecidedLap;
                    p.Served = penalty.Result.Served;

                    return p;
                }
 public static SyncStateCommand DeletePenalty(Penalty penalty)
 {
     var command = new SyncStateCommand();
     command.StateUpdateType = SyncStateCommand.StateUpdateTypes.DeletePenalty;
     command.Data = new
     {
         PenaltyId = penalty.Id
     };
     return command;
 }
Пример #10
0
 public void SendPenaltyDelete(Penalty penalty)
 {
     var command = SyncCommandHelper.DeletePenalty(penalty);
     Debug.WriteLine(">> Sending penalty update: " + command);
     this.SendCommand(command);
 }
Пример #11
0
 public PenaltyContainer(Penalty penalty)
 {
     _penalty = penalty;
     _drivers = new ObservableCollection<DriverContainer>();
 }