public UnitConverter() { m_meteredConnectionOverride = false; m_layoutDirection = LocalizationService.GetInstance().GetFlowDirection(); m_FlowDirectionHorizontalAlignment = m_layoutDirection == FlowDirection.RightToLeft ? HorizontalAlignment.Right : HorizontalAlignment.Left; InitializeComponent(); // adding ESC key shortcut binding to clear button ClearEntryButtonPos0.SetValue(KeyboardShortcutManager.VirtualKeyProperty, MyVirtualKey.Escape); // Is currency symbol preference set to right side bool preferRight = LocalizationSettings.GetInstance().GetCurrencySymbolPrecedence() == 0; VisualStateManager.GoToState(this, preferRight ? "CurrencySymbolRightState" : "CurrencySymbolLeftState", false); var resLoader = AppResourceProvider.GetInstance(); m_chargesMayApplyText = resLoader.GetResourceString("DataChargesMayApply"); m_failedToRefreshText = resLoader.GetResourceString("FailedToRefresh"); InitializeOfflineStatusTextBlock(); if (Resources.TryGetValue("CalculationResultContextMenu", out var value)) { m_resultsFlyout = (MenuFlyout)value; } CopyMenuItem.Text = resLoader.GetResourceString("copyMenuItem"); PasteMenuItem.Text = resLoader.GetResourceString("pasteMenuItem"); }
private void InitializeOfflineStatusTextBlock() { var resProvider = AppResourceProvider.GetInstance(); string offlineStatusHyperlinkText = resProvider.GetResourceString("OfflineStatusHyperlinkText"); // The resource string has the 'NetworkSettings' hyperlink wrapped with '%HL%'. // Break the string and assign pieces appropriately. const string delimiter = "%HL%"; int delimiterLength = delimiter.Length; // Find the delimiters. int firstSplitPosition = offlineStatusHyperlinkText.IndexOf(delimiter); Debug.Assert(firstSplitPosition != -1); int secondSplitPosition = offlineStatusHyperlinkText.IndexOf(delimiter, firstSplitPosition + 1); Debug.Assert(secondSplitPosition != -1); int hyperlinkTextLength = secondSplitPosition - (firstSplitPosition + delimiterLength); // Assign pieces. var offlineStatusTextBeforeHyperlink = offlineStatusHyperlinkText.Substring(0, firstSplitPosition); var offlineStatusTextLink = offlineStatusHyperlinkText.Substring(firstSplitPosition + delimiterLength, hyperlinkTextLength); var offlineStatusTextAfterHyperlink = offlineStatusHyperlinkText.Substring(secondSplitPosition + delimiterLength); OfflineRunBeforeLink.Text = offlineStatusTextBeforeHyperlink; OfflineRunLink.Text = offlineStatusTextLink; OfflineRunAfterLink.Text = offlineStatusTextAfterHyperlink; AutomationProperties.SetName(OfflineBlock, offlineStatusTextBeforeHyperlink + " " + offlineStatusTextLink + " " + offlineStatusTextAfterHyperlink); }
public object Convert(Object value, Type targetType, Object parameter, String language) { var boxedInt = (RADIX_TYPE)(int)value; string convertedValue = ""; var resourceLoader = AppResourceProvider.GetInstance(); switch (boxedInt) { case RADIX_TYPE.BIN_RADIX: convertedValue = resourceLoader.GetResourceString("Bin"); break; case RADIX_TYPE.OCT_RADIX: convertedValue = resourceLoader.GetResourceString("Oct"); break; case RADIX_TYPE.DEC_RADIX: convertedValue = resourceLoader.GetResourceString("Dec"); break; case RADIX_TYPE.HEX_RADIX: convertedValue = resourceLoader.GetResourceString("Hex"); break; default: break; } ; return(convertedValue); }
LocalizationService() { #if HAS_UNO m_language = "en-US"; m_flowDirection = FlowDirection.LeftToRight; #else m_language = ApplicationLanguages.Languages[0]; m_flowDirection = ResourceContext.GetForCurrentView().QualifierValues["LayoutDirection"] != "LTR" ? FlowDirection.RightToLeft : FlowDirection.LeftToRight; #endif var resourceLoader = AppResourceProvider.GetInstance(); m_fontFamilyOverride = resourceLoader.GetResourceString("LocalizedFontFamilyOverride"); string reserved = "RESERVED_FOR_FONTLOC"; m_overrideFontApiValues = ((m_fontFamilyOverride != null) && (m_fontFamilyOverride != reserved)); if (m_overrideFontApiValues) { string localizedUICaptionFontSizeFactorOverride = resourceLoader.GetResourceString("LocalizedUICaptionFontSizeFactorOverride"); string localizedUITextFontSizeFactorOverride = resourceLoader.GetResourceString("LocalizedUITextFontSizeFactorOverride"); string localizedFontWeightOverride = resourceLoader.GetResourceString("LocalizedFontWeightOverride"); // If any of the font overrides are modified then all of them need to be modified Debug.Assert(localizedFontWeightOverride != reserved); Debug.Assert(localizedUITextFontSizeFactorOverride != reserved); Debug.Assert(localizedUICaptionFontSizeFactorOverride != reserved); m_fontWeightOverride = ParseFontWeight(localizedFontWeightOverride); m_uiTextFontScaleFactorOverride = double.Parse(localizedUITextFontSizeFactorOverride); m_uiCaptionFontScaleFactorOverride = double.Parse(localizedUICaptionFontSizeFactorOverride); } m_fontGroup = new LanguageFontGroup(m_language); }
public object Convert(object value, Type targetType, object parameter, string language) { var resourceLoader = AppResourceProvider.GetInstance(); // initialising the updated display with 64 bits of zeros char[] updatedBinaryDisplay = new char[64]; var localizationSettings = LocalizationSettings.GetInstance(); char ch0 = localizationSettings.GetDigitSymbolFromEnUsDigit('0'); char ch1 = localizationSettings.GetDigitSymbolFromEnUsDigit('1'); string indexName = resourceLoader.GetResourceString((string)(parameter)); string bitName = resourceLoader.GetResourceString("BitAutomationName"); string valueName = resourceLoader.GetResourceString("ValueAutomationName"); string zero = resourceLoader.GetResourceString("BinaryZeroValueAutomationName"); string one = resourceLoader.GetResourceString("BinaryOneValueAutomationName"); if ((value != null) && (parameter != null)) { string binaryDisplay = (string)value; string indexString = (string)parameter; int index = int.Parse(indexString); int binaryLength = 0; // remove all the characters except 0 and 1 from the array. foreach (char bit in binaryDisplay) { if ((bit == ch1) || (bit == ch0)) { updatedBinaryDisplay[binaryLength++] = bit; } if (binaryLength == 63) { break; } } // return if binaryDisplay is empty if (binaryLength == 0) { return(indexName + bitName + valueName + zero); } // if index is more than the length of binary display return automation name with zero if (index >= binaryLength) { return(indexName + bitName + valueName + zero); } // if bit is set return automation name with one else return zero if (updatedBinaryDisplay[binaryLength - index - 1] == ch1) { return(indexName + bitName + valueName + one); } } return(indexName + bitName + valueName + zero); }
static void EnsureInitialization(string resourceKey, string formatVariable) { if (resourceKey == null || string.IsNullOrEmpty(resourceKey)) { return; } // If the formatVariable already has a value, we don't need to set it again. Simply return. if (formatVariable != null && !string.IsNullOrEmpty(formatVariable)) { return; } formatVariable = AppResourceProvider.GetInstance().GetResourceString(resourceKey); }
public object Convert(object value, Type targetType, object parameter, string language) { var boxedInt = (value as int?); string convertedValue = null; var resourceLoader = AppResourceProvider.GetInstance(); switch (boxedInt.Value) { case (int)RadixType.Binary: { convertedValue = resourceLoader.GetResourceString("Bin"); break; } case (int)RadixType.Octal: { convertedValue = resourceLoader.GetResourceString("Oct"); break; } case (int)RadixType.Decimal: { convertedValue = resourceLoader.GetResourceString("Dec"); break; } case (int)RadixType.Hex: { convertedValue = resourceLoader.GetResourceString("Hex"); break; } default: break; } return(convertedValue); }
private static void OnKeyDownHandler(CoreWindow sender, KeyEventArgs args) { if (args.Handled) { return; } var key = args.VirtualKey; int viewId = Utilities.GetWindowId(); bool isControlKeyPressed = (Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Control) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down; bool isShiftKeyPressed = (Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Shift) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down; bool isAltKeyPressed = (Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Menu) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down; // Handle Ctrl + E for DateCalculator if ((key == Windows.System.VirtualKey.E) && isControlKeyPressed && !isShiftKeyPressed && !isAltKeyPressed) { var lookupMap = GetCurrentKeyDictionary(isControlKeyPressed, isShiftKeyPressed, false); if (lookupMap == null) { return; } var buttons = EqualRange(lookupMap, (MyVirtualKey)key); var navView = buttons.ElementAt(0).Target as MUXC.NavigationView; var appViewModel = (navView.DataContext as ApplicationViewModel); appViewModel.Mode = ViewMode.Date; var categoryName = AppResourceProvider.GetInstance().GetResourceString("DateCalculationModeText"); appViewModel.CategoryName = categoryName; var menuItems = ((ObservableCollection <object>)navView.MenuItemsSource); var flatIndex = NavCategory.GetFlatIndex(ViewMode.Date); navView.SelectedItem = menuItems[flatIndex]; return; } if (s_ignoreNextEscape.TryGetValue(viewId, out var currentIgnoreNextEscape)) { if (currentIgnoreNextEscape && key == Windows.System.VirtualKey.Escape) { if (s_keepIgnoringEscape.TryGetValue(viewId, out var currentKeepIgnoringEscape)) { if (!currentKeepIgnoringEscape) { HonorEscape(); } return; } } } if (s_fHonorShortcuts.TryGetValue(viewId, out var currentHonorShortcuts)) { if (currentHonorShortcuts) { var myVirtualKey = key; var lookupMap = GetCurrentKeyDictionary(isControlKeyPressed, isShiftKeyPressed, isAltKeyPressed); if (lookupMap == null) { return; } var buttons = EqualRange(lookupMap, (MyVirtualKey)myVirtualKey); if (buttons.Count() <= 0) { return; } KeyboardShortcutManagerLocals.RunFirstEnabledButtonCommand(buttons); // Ctrl+C and Ctrl+V shifts focus to some button because of which enter doesn't work after copy/paste. So don't shift focus if Ctrl+C or Ctrl+V // is pressed. When drop down is open, pressing escape shifts focus to clear button. So dont's shift focus if drop down is open. Ctrl+Insert is // equivalent to Ctrl+C and Shift+Insert is equivalent to Ctrl+V //var currentIsDropDownOpen = s_IsDropDownOpen.find(viewId); if (!s_IsDropDownOpen.TryGetValue(viewId, out var currentIsDropDownOpen) || !currentIsDropDownOpen) { // Do not Light Up Buttons when Ctrl+C, Ctrl+V, Ctrl+Insert or Shift+Insert is pressed if (!(isControlKeyPressed && (key == Windows.System.VirtualKey.C || key == Windows.System.VirtualKey.V || key == Windows.System.VirtualKey.Insert)) & !(isShiftKeyPressed && (key == Windows.System.VirtualKey.Insert))) { KeyboardShortcutManagerLocals.LightUpButtons(buttons); } } } } }