private void ConnectButtonClicked(object sender, EventArgs e) { if (IpEntry.Text != null && PortEntry.Text != null) { try { if (MenuPage.SourceApp.Client.Client.Connected) { MenuPage.SourceApp.Client.Client.Close(); } MenuPage.IPAddress = IPAddress.Parse(IpEntry.Text); MenuPage.PortNumber = Int32.Parse(PortEntry.Text); MenuPage.SourceApp.Client = new TcpClient(); var result = MenuPage.SourceApp.Client.BeginConnect(MenuPage.IPAddress, MenuPage.PortNumber, null, null); var success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(1)); if (!success) { DisplayAlert("Error", "Failed to connect to ip: " + MenuPage.IPAddress + ":" + MenuPage.PortNumber, "OK"); throw new Exception("Failed to connect."); } MenuPage.SourceApp.Client.EndConnect(result); UserSettings.ConnectionSettingsDefaultIP = IpEntry.Text; UserSettings.ConnectionSettingsDefaultPort = Int32.Parse(PortEntry.Text); MenuPage.ReceiveData(); MenuPage.SendData("GETTOTALLEDCOUNT()"); MenuPage.TotalLEDCount = Int32.Parse(MenuPage.ReceiveData()); MenuPage.SendData("GETSERVERNAME()"); MenuPage.ServerIDLabel.Text = "Connected to server: " + MenuPage.ReceiveData(); Application.Current.MainPage.Navigation.PopAsync(); } catch { Console.WriteLine("Error in input!"); } } }
public AnimationSettingsPage(MainMenuPage _MainMenu) { InitializeComponent(); MainMenu = _MainMenu; MainMenu.SendData("GETANIMATIONCONFIGS()"); string Response = MainMenu.ReceiveData(); AnimationConfigNamePicker.Items.Clear(); AnimationConfigNamePicker.Items.Add("None"); AnimationConfigNamePicker.SelectedIndex = 0; foreach (string Config in Response.Split(';')) { if (Config != "") { AnimationConfigNamePicker.Items.Add(Config); } } }
public InstructionsPage(MainMenuPage _MainMenu) { InitializeComponent(); MainMenu = _MainMenu; MainMenu.SendData("GETINSTRUCTIONSCONFIGS()"); string Response = MainMenu.ReceiveData(); InstructionsConfigNamePicker.Items.Clear(); InstructionsConfigNamePicker.Items.Add("None"); InstructionsConfigNamePicker.SelectedIndex = 0; foreach (string Config in Response.Split(';')) { if (Config != "") { InstructionsConfigNamePicker.Items.Add(Config); } } }
public VisualizerSettingsPage(MainMenuPage _MainMenu) { InitializeComponent(); MainMenu = _MainMenu; MainMenu.SendData("GETVISUALIZERCONFIGS()$"); string Response = MainMenu.ReceiveData(); VisualizerConfigNamePicker.Items.Clear(); VisualizerConfigNamePicker.Items.Add("None"); VisualizerConfigNamePicker.SelectedIndex = 0; foreach (string Config in Response.Split(';')) { if (Config != "") { VisualizerConfigNamePicker.Items.Add(Config); } } }
public AmbilightSettingsPage(MainMenuPage _MainMenu) { InitializeComponent(); MainMenu = _MainMenu; MainMenu.SendData("GETAMBILIGHTCONFIGS()"); string Response = MainMenu.ReceiveData(); AmbilightConfigNamePicker.Items.Clear(); AmbilightConfigNamePicker.Items.Add("None"); AmbilightConfigNamePicker.SelectedIndex = 0; foreach (string Config in Response.Split(';')) { if (Config != "") { AmbilightConfigNamePicker.Items.Add(Config); } } AmbilightConfigNamePicker.Items.RemoveAt(AmbilightConfigNamePicker.Items.Count - 1); }
public FadeColorsPage(MainMenuPage _MainMenu) { InitializeComponent(); MainMenu = _MainMenu; FadeSpeedPicker.Items.Clear(); FadeFactorPicker.Items.Clear(); FromIDPicker.Items.Clear(); ToIDPicker.Items.Clear(); for (int i = 0; i < 100; i++) { FadeSpeedPicker.Items.Add(i.ToString()); } for (double i = 0; i <= 1; i += 0.05) { FadeFactorPicker.Items.Add(i.ToString()); } for (int i = 0; i < MainMenu.TotalLEDCount; i++) { FromIDPicker.Items.Add(i.ToString()); } for (int i = -1; i < MainMenu.TotalLEDCount; i++) { ToIDPicker.Items.Add(i.ToString()); } MainMenu.SendData("GETTRACKBARVALUE(FadeColorsRedTrackBar,0)"); RedSlider.Value = Convert.ToDouble(MainMenu.ReceiveData()); MainMenu.SendData("GETTRACKBARVALUE(FadeColorsGreenTrackBar,0)"); GreenSlider.Value = Convert.ToDouble(MainMenu.ReceiveData()); MainMenu.SendData("GETTRACKBARVALUE(FadeColorsBlueTrackBar,0)"); BlueSlider.Value = Convert.ToDouble(MainMenu.ReceiveData()); MainMenu.SendData("GETCONTROLTEXT(FadeColorsFadeSpeedNumericUpDown,0)"); string Recived = MainMenu.ReceiveData(); for (int i = 0; i < FadeSpeedPicker.Items.Count; i++) { if (FadeSpeedPicker.Items[i].ToString() == Recived) { FadeSpeedPicker.SelectedIndex = i; break; } } MainMenu.SendData("GETCONTROLTEXT(FadeColorsFadeFactorNumericUpDown,0)"); Recived = MainMenu.ReceiveData(); for (int i = 0; i < FadeFactorPicker.Items.Count; i++) { if (Convert.ToDouble(FadeFactorPicker.Items[i].ToString().Replace(',', '.')) == Convert.ToDouble(Recived.Replace(',', '.'))) { FadeFactorPicker.SelectedIndex = i; break; } else if (Convert.ToDouble(FadeFactorPicker.Items[i].ToString().Replace('.', ',')) == Convert.ToDouble(Recived.Replace('.', ','))) { FadeFactorPicker.SelectedIndex = i; break; } } MainMenu.SendData("GETCONTROLTEXT(FadeLEDPanelFromIDNumericUpDown,0)"); Recived = MainMenu.ReceiveData(); for (int i = 0; i < FromIDPicker.Items.Count; i++) { if (FromIDPicker.Items[i].ToString() == Recived) { FromIDPicker.SelectedIndex = i; break; } } MainMenu.SendData("GETCONTROLTEXT(FadeLEDPanelToIDNumericUpDown,0)"); Recived = MainMenu.ReceiveData(); for (int i = 0; i < ToIDPicker.Items.Count; i++) { if (ToIDPicker.Items[i].ToString() == Recived) { ToIDPicker.SelectedIndex = i; break; } } RedSliderValueLabel.Text = Math.Round(RedSlider.Value, 0).ToString(); GreenSliderValueLabel.Text = Math.Round(GreenSlider.Value, 0).ToString(); BlueSliderValueLabel.Text = Math.Round(BlueSlider.Value, 0).ToString(); Loading = false; }