Beispiel #1
0
		private async void button1_Click(object sender, RoutedEventArgs e)
		{
			Logger.Debug("Begin TPA Jump Call...");
			_myrescue = (Datum) RescueGrid.SelectedItem;
			if (_myrescue == null)
			{
				AppendStatus("Null myrescue! Failing.");
				return;
			}
			if (_myrescue != null && _myrescue.id == null)
			{
				Logger.Debug("Rescue ID is null!");
				return;
			}
			if (_myrescue.Client == null)
			{
				AppendStatus("Null client.");
				return;
			}

			if (_myrescue.System == null)
			{
				AppendStatus("Null system.");
				return;
			}
			Logger.Debug("Null tests completed");
			AppendStatus("Tracking rescue. System: " + _myrescue.System + " Client: " + _myrescue.Client);
			MyClient = new ClientInfo
			{
				ClientName = _myrescue.Client,
				Rescue = _myrescue,
				ClientSystem = _myrescue.System
			};
			Logger.Debug("Client info loaded:"+MyClient.ClientName+" in "+MyClient.ClientSystem);
			_overlay?.SetCurrentClient(MyClient);
			ClientDistance distance = await GetDistanceToClient(MyClient.ClientSystem);
			//ClientDistance distance = new ClientDistance {Distance = 500};
			AppendStatus("Sending jumps to IRC...");
			Logger.Debug("Constructing TPA message...");
			var jumpmessage = new TPAMessage();
			Logger.Debug("Setting action.");
			jumpmessage.action = "CallJumps:update";
			jumpmessage.applicationId = "0xDEADBEEF";
			Logger.Debug("Set appID");
			Logger.Debug("Constructing TPA for "+_myrescue.id+" with "+_myplayer.RatId.First());
			jumpmessage.data = new Dictionary<string, string> {
					{"CallJumps", Math.Ceiling(distance.Distance/_myplayer.JumpRange).ToString(CultureInfo.InvariantCulture)},
					{"RescueID", _myrescue.id},
					{"RatID", _myplayer.RatId.FirstOrDefault()},
					{"Lightyears", distance.Distance.ToString(CultureInfo.InvariantCulture)},
					{"SourceCertainty", distance.SourceCertainty},
					{"DestinationCertainty", distance.TargetCertainty}
			};
			Logger.Debug("Sending TPA message");
			_apworker.SendTpaMessage(jumpmessage);
		}
Beispiel #2
0
		public void SetCurrentClient(ClientInfo client)
		{
			this.ClientInfo = client;
            // TODO: Link the panels and button visibility properties in WPF instead.
            if (client.Rat2.RatName == null || client.Rat2.RatName=="")
            {
                Rat2Panel.Visibility = Visibility.Hidden;
                Rat2Buttons.Visibility = Visibility.Hidden;
            }
            if (client.Rat3.RatName == null || client.Rat3.RatName=="")
            {
                Rat3Panel.Visibility = Visibility.Hidden;
                Rat3Buttons.Visibility = Visibility.Hidden;
            }
		}
Beispiel #3
0
		private async void RescueGrid_SelectionChanged(object sender, EventArgs e)
		{
			if (RescueGrid.SelectedItem == null)
				return;
			/*			BackgroundWorker bgworker = new BackgroundWorker() {WorkerReportsProgress = true};
						bgworker.DoWork += (s, e2) => {
							RecalculateJumps();
						};
						bgworker.RunWorkerAsync();
						*/
			/* The shit I do for you, Marenthyu. Update the grid to show the selection, reset labels and
			 * manually redraw one frame before the thread goes into background work. Yeesh. :P
			 */
			Datum myrow = (Datum)RescueGrid.SelectedItem;
			//Logger.Debug("Client is " + myrow.Client);

			var rats = Rats.Where(r => myrow.Rats.Contains(r.Key)).Select(r => r.Value.CmdrName).ToList();
			var count = rats.Count;

			/* TODO: Fix this. Needs to be smrt about figuring out if your own ratID is assigned. */
			MyClient = new ClientInfo { Rescue = myrow };
			if (count > 0)
			{
				MyClient.Self.RatName = rats[0]; // Nope! We have no guarantee that the first listed rat in the rescue is ourself.
			}
			if (count > 1)
			{
				MyClient.Rat2.RatName = rats[1];
			}
			if (count > 2)
			{
				MyClient.Rat3.RatName = rats[2];
			}

			Dispatcher disp = Dispatcher;
			await disp.BeginInvoke(DispatcherPriority.Normal, (Action)(() => ClientName.Text = myrow.Client));
			//ClientName.Text = myrow.Client;

			AssignedRats = myrow.Rats.Any()
				? string.Join(", ", rats)
				: string.Empty;
			await disp.BeginInvoke(DispatcherPriority.Normal, (Action)(() => SystemName.Text = myrow.System));
			DistanceToClient = -1;
			DistanceToClientString = "Calculating...";
			JumpsToClient = "Calculating...";
			DispatcherFrame frame = new DispatcherFrame();
			await Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(delegate (object parameter) {
				frame.Continue = false;
				return null;
			}), null);
			Dispatcher.PushFrame(frame);
			await RecalculateJumps(myrow.System);
		}
Beispiel #4
0
		public void SetCurrentClient(ClientInfo client)
		{
			this.ClientInfo = client;
		}