private void DisplayMemoryRow(string header, int value, int total, IGridList <View> gridList, int rowIndex) { AddLabel(header, gridList, rowIndex, 0, 2); AddLabel(value.ToString(), gridList, rowIndex, 2, 1); string percent = string.Format("{0:0.00}%", (100.0 * value / total)); AddLabel(percent, gridList, rowIndex, 3, 1); }
private void DisplayCpuRow(string id, CpuData cpu, IGridList <View> gridList, int rowIndex) { AddLabel(id, gridList, rowIndex, 0, 1); AddLabel(cpu.Usage.ToString(), gridList, rowIndex, 1, 1); AddLabel(cpu.UserUsage.ToString(), gridList, rowIndex, 2, 1); AddLabel(cpu.SystemUsage.ToString(), gridList, rowIndex, 3, 1); AddLabel(cpu.Idle.ToString(), gridList, rowIndex, 4, 1); }
private void AddHeaders(IGridList <View> gridList, int rowIndex) { GridUtil.AddLabel("Pin#", gridList, rowIndex, 0, 0, 1, Color.Blue, false, LayoutOptions.Start); GridUtil.AddLabel("Mode", gridList, rowIndex, 0, 1, 1, Color.Blue, false, LayoutOptions.Start); GridUtil.AddLabel("Value", gridList, rowIndex, 0, 2, 1, Color.Blue, false, LayoutOptions.Start); GridUtil.AddLabel("Value", gridList, rowIndex, 0, 3, 1, Color.Blue, false, LayoutOptions.Start); GridUtil.AddLabel("Mode", gridList, rowIndex, 0, 4, 1, Color.Blue, false, LayoutOptions.Start); GridUtil.AddLabel("Pin#", gridList, rowIndex, 0, 5, 1, Color.Blue, false, LayoutOptions.Start); }
private void Display() { IGridList <View> gridList = piStatsGrid.Children; gridList.Clear(); int rowIndex = 0; if (_piSystem == null) { AddLabel($"Service {_monitorTopic.Name} is not available at {_monitorTopic.Server}.", gridList, rowIndex++, 0, 5); AbortRefresh(); return; } HttpResponse response = _piSystem.CpuClient.GetResponse(); if (!response.Success) { AddLabel($"Error getting data for {_monitorTopic.Name} at {_monitorTopic.Server}", gridList, rowIndex++, 0, 5); GridUtil.AddLabel(response.ErrorMessage, gridList, rowIndex++, 0, 5, 10, Color.Default, false, LayoutOptions.End); StopRefresh(); return; } _piSystem.MemoryClient.Get(); CpuData cpu = _piSystem.CpuClient.CpuData; MemoryData memory = _piSystem.MemoryClient.MemoryData; DisplayHeaderAndValueRow("Server Address", _monitorTopic.Server, gridList, rowIndex++, 3); DisplayHeaderAndValueRow("CPU Core Temperature", cpu.Temperature.ToString(), gridList, rowIndex++, 3); AddLabel("Usage", gridList, rowIndex, 1, 1); AddLabel("User", gridList, rowIndex, 2, 1); AddLabel("System", gridList, rowIndex, 3, 1); AddLabel("Idle", gridList, rowIndex, 4, 1); rowIndex++; DisplayCpuRow(_monitorTopic.Name, cpu, gridList, rowIndex++); if (cpu.Cores != null) { foreach (var data in cpu.Cores) { DisplayCpuRow(data.Key, data.Value, gridList, rowIndex++); } } DisplayHeaderAndValueRow("Total Memory (MB)", memory.Total.ToString(), gridList, rowIndex++, 2); DisplayMemoryRow("Used Memory (MB)", memory.Used, memory.Total, gridList, rowIndex++); DisplayMemoryRow("Cached Memory (MB)", memory.Cached, memory.Total, gridList, rowIndex++); DisplayMemoryRow("Free Memory (MB)", memory.Free, memory.Total, gridList, rowIndex++); DisplayMemoryRow("Available Memory (MB)", memory.Available, memory.Total, gridList, rowIndex++); if (_hygroThermoSensor != null) { string json = _hygroThermoSensor.Get(); DisplayHeaderAndValueRow("Humidity (%)", _hygroThermoSensor.HygroThermoData.Humidity.ToString(), gridList, rowIndex++, 2); DisplayHeaderAndValueRow("Temperature (C)", _hygroThermoSensor.HygroThermoData.Temperature.ToString(), gridList, rowIndex++, 2); } }
private void Display() { _gpio.Get(); IGridList <View> gridList = piGpioGrid.Children; foreach (GpioPinData pin in _gpio.GpioData.Pins) { DisplayPinMode(pin); DisplayPinValue(pin); } //gridList.Clear(); //int rowIndex = 0; //AddHeaders(gridList, rowIndex++); }
public Game() { InitializeComponent(); PlayerColor = Color.Green; Title.Text = "Green's turn"; CreateBoard("WRWBWGWGRWRWBWGWWRWBWGWGRWRWBWGWWRWBWGWGRWRWBWGWWRWBWGWGRWRWBWGW"); CreateInterface(); frames = grid.Children; wigth = grid.Width / 8; height = grid.Height / 8; CreateTabEvents(); }
public Game(string str, string whoMove) { InitializeComponent(); PlayerColor = whoMove == "Green's turn" ? Color.Green : Color.Red; Title.Text = whoMove; TitleBoxView.BackgroundColor = PlayerColor; CreateBoard(str); CreateInterface(); frames = grid.Children; wigth = grid.Width / 8; height = grid.Height / 8; CheackForBeating(); CheckingBeatOfTheQueen(); CreateTabEvents(); }
private void Display() { IGridList <View> gridList = dataGrid.Children; gridList.Clear(); int rowIndex = 0; DisplayHeaderAndValueRow("Device Name", _phoneService.DeviceInfo.Name, gridList, rowIndex++); string display = $"{_phoneService.DeviceInfo.Height:0.} x {_phoneService.DeviceInfo.Width:0.}"; DisplayHeaderAndValueRow("Display", display, gridList, rowIndex++); DisplayHeaderAndValueRow("Version", _phoneService.DeviceInfo.VersionString, gridList, rowIndex++); string hostName = Dns.GetHostName(); // Retrive the Name of HOST DisplayHeaderAndValueRow("Host Name", hostName, gridList, rowIndex++); // Get the IP var entry = Dns.GetHostEntry(hostName); string myIP = entry.AddressList[0].ToString(); DisplayHeaderAndValueRow("IP Address", myIP, gridList, rowIndex++); try { DisplayHeaderAndValueRow("Acceleration", ToText(_phoneService.Accelerometer.Acceleration.Value), gridList, rowIndex++); DisplayHeaderAndValueRow("Pressure", ToText(_phoneService.Barometer.Pressure.Value), gridList, rowIndex++); DisplayHeaderAndValueRow("Heading", ToText(_phoneService.Compass.Heading.Value), gridList, rowIndex++); DisplayHeaderAndValueRow("Angular Velocity", ToText(_phoneService.Gyroscope.AngularVelocity.Value), gridList, rowIndex++); DisplayHeaderAndValueRow("Magnetic Field", ToText(_phoneService.Magnetometer.MagneticField.Value), gridList, rowIndex++); DisplayHeaderAndValueRow("Orientation", ToText(_phoneService.OrientationSensor.Orientation.Value), gridList, rowIndex++); Location location = _phoneService.GpsLocation.Location.Value; DisplayHeaderAndValueRow("Latitude", location != null? ToTextLong(location.Latitude) : string.Empty, gridList, rowIndex++); DisplayHeaderAndValueRow("Longitude", location != null ? ToTextLong(location.Longitude) : string.Empty, gridList, rowIndex++); DisplayHeaderAndValueRow("Altitude", location != null ? ToText(location.Altitude) : string.Empty, gridList, rowIndex++); DisplayHeaderAndValueRow("Accuracy", location != null ? ToText(location.Accuracy) : string.Empty, gridList, rowIndex++); DisplayHeaderAndValueRow("Speed", location != null ? ToText(location.Speed) : string.Empty, gridList, rowIndex++); } catch (Exception err) { rowIndex++; DisplayHeaderAndValueRow("Exception", "Check for permissions", gridList, rowIndex++); } }
private void InitializeCommandsGrid() { // determine custom commands from settings IEnumerable <SettingGroup> groups = DeviceSettings.Instance.GetSettingGroups("Type", "PiCommand"); if (groups != null) { int index = 0; foreach (SettingGroup group in groups) { string topicId; if (group.Settings.TryGetValue("Topic", out topicId)) { if (!string.Equals(_monitorTopic.Id, topicId, StringComparison.OrdinalIgnoreCase)) { continue; } } string name; string cmd; string confirm; group.Settings.TryGetValue("Name", out name); group.Settings.TryGetValue("Command", out cmd); group.Settings.TryGetValue("Confirm", out confirm); if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(cmd)) { continue; } IGridList <View> gridList = CommandsGrid.Children; CommandButton button = CreateCommandButton(name, cmd, confirm); if (button != null) { int row = index / 2; int col = index % 2; gridList.Add(button, col, col + 1, row, row + 1); index++; } } } }
private void AddLabel(string text, IGridList <View> gridList, int row, int col, int colSpan = 1) { GridUtil.AddLabel("Pin#", gridList, row, 0, 1, 1, Color.Blue, false, LayoutOptions.Start); Label label = GridUtil.AddLabel(text, gridList, row, col, colSpan); }
private void AddLabel(string text, IGridList <View> gridList, int row, int col, int colSpan = 1) { Label label = GridUtil.AddLabel(text, gridList, row, col, colSpan); }
private void DisplayHeaderAndValueRow(string header, string value, IGridList <View> gridList, int rowIndex, int valueColumn = 2) { AddLabel(header, gridList, rowIndex, 0, valueColumn); AddLabel(value.ToString(), gridList, rowIndex, valueColumn, 2); }
private void Display() { IGridList <View> gridList = dataGrid.Children; gridList.Clear(); int rowIndex = 0; if (_hs1xxClient == null) { AddLabel($"Smart Plug {_DeviceTopic.Name} is not available at {_DeviceTopic.Server}.", gridList, rowIndex++, 0, 2); _initialized = false; return; } HttpResponse response = _hs1xxClient.System.GetResponse(); if (!response.Success) { AddLabel($"Error getting data for {_DeviceTopic.Name} at {_DeviceTopic.Server}", gridList, rowIndex++, 0, 2); GridUtil.AddLabel(response.ErrorMessage, gridList, rowIndex++, 0, 2, 10, Color.Default, false, LayoutOptions.End); return; } string timeJson = _hs1xxClient.Time.Get(); KasaHs1xxSystemData systemData = _hs1xxClient.System.SystemData; KasaHs1xxTimeData timeData = _hs1xxClient.Time.TimeData; if (systemData.Relay_state == 0) { OnOffToolbarItem.Text = "On"; } else { OnOffToolbarItem.Text = "Off"; } if (systemData.Led_off == 0) { LedOffToolbarItem.Text = "LedOff"; } else { LedOffToolbarItem.Text = "LedOn"; } DisplayHeaderAndValueRow("IP Address", systemData.Ipaddress, gridList, rowIndex++); DisplayHeaderAndValueRow("Alias", systemData.Alias, gridList, rowIndex++); DisplayHeaderAndValueRow("Time", timeData.Time, gridList, rowIndex++); DisplayHeaderAndValueRow("Relay State", systemData.Relay_state == 1 ? "On" : "Off", gridList, rowIndex++); DisplayHeaderAndValueRow("On Time", SecondToString(systemData.On_time), gridList, rowIndex++); DisplayHeaderAndValueRow("LED Always Off", systemData.Led_off == 1 ? "True" : "False", gridList, rowIndex++); DisplayHeaderAndValueRow("Next Action", systemData.next_action.Action.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Next Action Time", SecondToString(systemData.next_action.schd_sec), gridList, rowIndex++); DisplayHeaderAndValueRow("Next Action Type", systemData.next_action.Type.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("WIFI Signal", systemData.Rssi.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Active Mode", systemData.Active_mode, gridList, rowIndex++); DisplayHeaderAndValueRow("Device Name", systemData.Dev_name, gridList, rowIndex++); DisplayHeaderAndValueRow("Error Code", systemData.Err_code.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Feature", systemData.Feature, gridList, rowIndex++); DisplayHeaderAndValueRow("HW Version", systemData.hw_ver, gridList, rowIndex++); DisplayHeaderAndValueRow("Icon Hash", systemData.Icon_hash, gridList, rowIndex++); DisplayHeaderAndValueRow("Latitude", systemData.Latitude_i.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Longitude", systemData.Longitude_i.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Mac Address", systemData.Mac, gridList, rowIndex++); DisplayHeaderAndValueRow("NTC State", systemData.Ntc_state.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Software Version", systemData.Sw_ver, gridList, rowIndex++); DisplayHeaderAndValueRow("Status", systemData.Status, gridList, rowIndex++); DisplayHeaderAndValueRow("Updating", systemData.Updating.ToString(), gridList, rowIndex++); // display IDs - 1st row for label 2nd row for data AddLabel("Device ID", gridList, rowIndex++, 0); GridUtil.AddLabel(systemData.DeviceId, gridList, rowIndex++, 0, 2, 1, Color.Default, false, LayoutOptions.End); AddLabel("Hardware ID", gridList, rowIndex++, 0); GridUtil.AddLabel(systemData.HwId, gridList, rowIndex++, 0, 2, 1, Color.Default, false, LayoutOptions.End); AddLabel("OEM ID", gridList, rowIndex++, 0); GridUtil.AddLabel(systemData.OemId, gridList, rowIndex++, 0, 2, 1, Color.Default, false, LayoutOptions.End); AddLabel("Next Action ID", gridList, rowIndex++, 0); GridUtil.AddLabel(systemData.next_action.Id, gridList, rowIndex++, 0, 2, 1, Color.Default, false, LayoutOptions.End); }
private void DisplayHeaderAndValueRow(string header, string value, IGridList <View> gridList, int rowIndex) { AddLabel(header, gridList, rowIndex, 0); AddLabel(value.ToString(), gridList, rowIndex, 1); }