private async void SelectButton_Click(object sender, RoutedEventArgs e) { var item = (ListBoxItem)DisplaysListBox.SelectedValue; if (item != null) { SelectButton.IsEnabled = false; var name = (string)item.Content; var deviceId = (string)item.Tag; using (ClaimedLineDisplay lineDisplay = await ClaimedLineDisplay.FromIdAsync(deviceId)) { if (lineDisplay != null) { await lineDisplay.DefaultWindow.TryClearTextAsync(); rootPage.NotifyUser($"Selected: {name}", NotifyType.StatusMessage); // Save this device ID for other scenarios. rootPage.LineDisplayId = deviceId; } else { rootPage.NotifyUser("Unable to claim the Line Display", NotifyType.ErrorMessage); } } SelectButton.IsEnabled = true; } }
private async Task InitializeAsync() { lineDisplay = await rootPage.ClaimScenarioLineDisplayAsync(); BlinkCheckBox.IsEnabled = (lineDisplay != null) && (lineDisplay.Capabilities.CanBlink != LineDisplayTextAttributeGranularity.NotSupported); DisplayTextButton.IsEnabled = (lineDisplay != null); }
private async Task InitializeAsync() { ResetButton.IsEnabled = false; SupportedGlyphsComboBox.Items.Clear(); lineDisplay = await rootPage.ClaimScenarioLineDisplayAsync(); if ((lineDisplay != null) && lineDisplay.Capabilities.CanDisplayCustomGlyphs) { string sampleText = "ABC"; foreach (uint glyphCode in lineDisplay.CustomGlyphs.SupportedGlyphCodes) { string glyphString = Char.ConvertFromUtf32((int)glyphCode); SupportedGlyphsComboBox.Items.Add(new ComboBoxItem { Content = $"Code {glyphCode} (UTF-32 '{glyphString}')", Tag = glyphCode }); if (sampleText.Length < 10) { sampleText += glyphString; } } if (SupportedGlyphsComboBox.Items.Count > 0) { SupportedGlyphsComboBox.SelectedIndex = 0; } Size glyphSize = lineDisplay.CustomGlyphs.SizeInPixels; glyphBuffer = CreateSolidGlyphBuffer((int)glyphSize.Width, (int)glyphSize.Height); await lineDisplay.DefaultWindow.TryDisplayTextAsync(sampleText); } ResetButton.IsEnabled = true; }
protected override void OnNavigatedFrom(NavigationEventArgs e) { horizontalScrollableWindow?.Dispose(); horizontalScrollableWindow = null; verticalScrollableWindow?.Dispose(); verticalScrollableWindow = null; lineDisplay?.Dispose(); lineDisplay = null; }
private async Task InitializeAsync() { lineDisplay = await rootPage.ClaimScenarioLineDisplayAsync(); maxWindows = (lineDisplay == null) ? 0 : lineDisplay.Capabilities.SupportedWindows; if (maxWindows >= 1) { // Create an entry to represent the default window. WindowList.Add(new WindowInfo(lineDisplay.DefaultWindow, nextWindowId)); nextWindowId++; } }
private async Task InitializeAsync() { UpdateButton.IsEnabled = false; DisplayTextButton.IsEnabled = false; ResetButton.IsEnabled = false; CursorTypeComboBox.Items.Clear(); lineDisplay = await rootPage.ClaimScenarioLineDisplayAsync(); CursorTypeComboBox.IsEnabled = (lineDisplay != null) && lineDisplay.DefaultWindow.Cursor.CanCustomize; if (CursorTypeComboBox.IsEnabled) { if (lineDisplay.DefaultWindow.Cursor.IsBlockSupported) { CursorTypeComboBox.Items.Add(LineDisplayCursorType.Block); } if (lineDisplay.DefaultWindow.Cursor.IsHalfBlockSupported) { CursorTypeComboBox.Items.Add(LineDisplayCursorType.HalfBlock); } if (lineDisplay.DefaultWindow.Cursor.IsOtherSupported) { CursorTypeComboBox.Items.Add(LineDisplayCursorType.Other); } if (lineDisplay.DefaultWindow.Cursor.IsReverseSupported) { CursorTypeComboBox.Items.Add(LineDisplayCursorType.Reverse); } if (lineDisplay.DefaultWindow.Cursor.IsUnderlineSupported) { CursorTypeComboBox.Items.Add(LineDisplayCursorType.Underline); } if (CursorTypeComboBox.Items.Count > 0) { CursorTypeComboBox.SelectedIndex = 0; } } IsAutoAdvanceEnabledCheckbox.IsEnabled = (lineDisplay != null); IsBlinkEnabledCheckbox.IsEnabled = (lineDisplay != null) && lineDisplay.DefaultWindow.Cursor.IsBlinkSupported; SetCursorPositionCheckbox.IsEnabled = (lineDisplay != null); UpdateButton.IsEnabled = (lineDisplay != null); DisplayTextButton.IsEnabled = (lineDisplay != null); ResetButton.IsEnabled = true; }
private async void DisplayTextButton_Click(object sender, RoutedEventArgs e) { string text = "Hello from UWP"; using (ClaimedLineDisplay lineDisplay = await ClaimedLineDisplay.FromIdAsync(rootPage.LineDisplayId)) { if (lineDisplay != null) { var position = new Point(0, 0); if (CenterCheckBox.IsChecked.Value) { var length = text.Length; if (length < lineDisplay.DefaultWindow.SizeInCharacters.Width) { position.X = ((int)lineDisplay.DefaultWindow.SizeInCharacters.Width - length) / 2; } } LineDisplayTextAttribute attribute = LineDisplayTextAttribute.Normal; // If blinking is requested, verify that the device supports blinking. if (BlinkCheckBox.IsChecked.Value) { if (lineDisplay.Capabilities.CanBlink == LineDisplayTextAttributeGranularity.NotSupported) { BlinkNotSupportedText.Visibility = Visibility.Visible; } else { // Device supports blinking. attribute = LineDisplayTextAttribute.Blink; } } if (await lineDisplay.DefaultWindow.TryClearTextAsync() && await lineDisplay.DefaultWindow.TryDisplayTextAsync(text, attribute, position)) { rootPage.NotifyUser("Text displayed successfully", NotifyType.StatusMessage); } else { // We probably lost our claim. rootPage.NotifyUser("Unable to display text", NotifyType.ErrorMessage); } } else { rootPage.NotifyUser("Unable to claim the Line Display", NotifyType.ErrorMessage); } } }
public async Task <ClaimedLineDisplay> ClaimScenarioLineDisplayAsync() { ClaimedLineDisplay lineDisplay = null; if (String.IsNullOrEmpty(LineDisplayId)) { NotifyUser("You must use scenario 1 to select a line display", NotifyType.ErrorMessage); } else { lineDisplay = await ClaimedLineDisplay.FromIdAsync(LineDisplayId); if (lineDisplay == null) { NotifyUser("Unable to claim selected LineDisplay from id.", NotifyType.ErrorMessage); } } return(lineDisplay); }
private async Task InitializeAsync() { lineDisplay = await rootPage.ClaimScenarioLineDisplayAsync(); BlinkRateSlider.IsEnabled = (lineDisplay != null) && lineDisplay.Capabilities.CanChangeBlinkRate; BrightnessSlider.IsEnabled = (lineDisplay != null) && lineDisplay.Capabilities.IsBrightnessSupported; SupportedScreenSizesComboBox.IsEnabled = (lineDisplay != null) && lineDisplay.Capabilities.CanChangeScreenSize; if (SupportedScreenSizesComboBox.IsEnabled) { foreach (Size screenSize in lineDisplay.SupportedScreenSizesInCharacters) { SupportedScreenSizesComboBox.Items.Add(new ComboBoxItem { Content = $"{screenSize.Width} x {screenSize.Height}", Tag = screenSize }); } if (SupportedScreenSizesComboBox.Items.Count > 0) { SupportedScreenSizesComboBox.SelectedIndex = 0; } } CharacterSetMappingEnabledCheckbox.IsEnabled = (lineDisplay != null) && lineDisplay.Capabilities.CanMapCharacterSets; UpdateButton.IsEnabled = (lineDisplay != null); if (UpdateButton.IsEnabled) { SetValuesFromLineDisplay(); if (lineDisplay.Capabilities.CanBlink == LineDisplayTextAttributeGranularity.NotSupported) { await lineDisplay.DefaultWindow.TryDisplayTextAsync("Regular Text"); } else { await lineDisplay.DefaultWindow.TryDisplayTextAsync("Blinking Text", LineDisplayTextAttribute.Blink); } } }
private async Task InitializeAsync() { lineDisplay = await rootPage.ClaimScenarioLineDisplayAsync(); if (lineDisplay != null) { Size screenSize = lineDisplay.GetAttributes().ScreenSizeInCharacters; int windowCount = 1; if (lineDisplay.Capabilities.IsHorizontalMarqueeSupported && (windowCount < lineDisplay.Capabilities.SupportedWindows)) { // Create a horizontal scrollable window by creating a window // whose width is wider than the viewport. horizontalScrollableWindow = await lineDisplay.TryCreateWindowAsync( new Rect() { X = 0, Y = 0, Width = screenSize.Width, Height = screenSize.Height }, new Size() { Width = screenSize.Width * 2, Height = screenSize.Height }); if (horizontalScrollableWindow != null) { windowCount++; ScrollDirectionComboBox.Items.Add(LineDisplayScrollDirection.Left); ScrollDirectionComboBox.Items.Add(LineDisplayScrollDirection.Right); } } if (lineDisplay.Capabilities.IsVerticalMarqueeSupported && (windowCount < lineDisplay.Capabilities.SupportedWindows)) { // Create a vertical scrollable window by creating a window // whose height is taller than the viewport. verticalScrollableWindow = await lineDisplay.TryCreateWindowAsync( new Rect() { X = 0, Y = 0, Width = screenSize.Width, Height = screenSize.Height }, new Size() { Width = screenSize.Width, Height = screenSize.Height * 2 }); if (verticalScrollableWindow != null) { windowCount++; ScrollDirectionComboBox.Items.Add(LineDisplayScrollDirection.Up); ScrollDirectionComboBox.Items.Add(LineDisplayScrollDirection.Down); } } } if (ScrollDirectionComboBox.Items.Count > 0) { ScrollDirectionComboBox.SelectedIndex = 0; StartScrollingButton.IsEnabled = true; StopScrollingButton.IsEnabled = true; } }
protected override void OnNavigatedFrom(NavigationEventArgs e) { lineDisplay?.Dispose(); lineDisplay = null; }