Пример #1
0
		private View createBottomPanel ()
		{
			symbolPicker = new Picker {
				Title = "Symbol",
				HorizontalOptions = LayoutOptions.StartAndExpand
			};
			symbolPicker.SelectedIndexChanged += (object sender, EventArgs e) => {
				if (symbolPicker.SelectedIndex > -1) {
					currentSymbol = symbols[symbolPicker.SelectedIndex];
					tradingAPI.SendSubscribeForSpotsRequest (currentTradingAccount.AccountId, currentSymbol.SymbolName);
					refreshPlotView();
				}
			};
			Picker volumePicker = new Picker {
				Title = "Volume",
				HorizontalOptions = LayoutOptions.StartAndExpand
			};
			foreach (string volumeLabel in nameToVolume.Keys) {
				volumePicker.Items.Add (volumeLabel);
			}
			volumePicker.SelectedIndex = 0;
			buyButton.HorizontalOptions = LayoutOptions.End;
			buyButton.Clicked += (object sender, EventArgs e) => tradingAPI.SendMarketOrderRequest(currentTradingAccount.AccountId, currentSymbol.SymbolName, ProtoTradeSide.BUY, nameToVolume[volumePicker.Items[volumePicker.SelectedIndex]]);

			sellButton.HorizontalOptions = LayoutOptions.End;
			sellButton.Clicked += (object sender, EventArgs e) => tradingAPI.SendMarketOrderRequest(currentTradingAccount.AccountId, currentSymbol.SymbolName, ProtoTradeSide.SELL, nameToVolume[volumePicker.Items[volumePicker.SelectedIndex]]);

			StackLayout panel = new StackLayout {
				Spacing = 5,
				Orientation = StackOrientation.Horizontal,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Children = {
					this.symbolPicker,
					volumePicker,
					buyButton,
					sellButton,
				}
			};
			return panel;
		}
Пример #2
0
		private void fillSymbols ()
		{
			string oldSymbol = null;
			if (symbolPicker.Items.Count > 0) {
				oldSymbol = symbolPicker.Items [symbolPicker.SelectedIndex];
				symbolPicker.Items.Clear ();
			}
			symbols = accountsAPI.getSymbols (currentTradingAccount.AccountId);
			int selectedIndex = 0;
			foreach (SymbolJson symbol in symbols) {
				symbolPicker.Items.Add (symbol.SymbolName);
				if (symbol.SymbolName.Equals(oldSymbol)) {
					selectedIndex = symbolPicker.Items.Count - 1;
				}
			}
			symbolPicker.SelectedIndex = selectedIndex;
			currentSymbol = symbols[symbolPicker.SelectedIndex];
		}