Ejemplo n.º 1
0
        private void InitializeContributeTextBlock()
        {
            var    resProvider             = AppResourceProvider.GetInstance();
            string contributeHyperlinkText = resProvider.GetResourceString("AboutControlContribute");

            // The resource string has the 'GitHub' hyperlink wrapped with '%HL%'.
            // Break the string and assign pieces appropriately.
            string delimiter       = "%HL%";
            int    delimiterLength = delimiter.Length;

            // Find the delimiters.
            int firstSplitPosition = contributeHyperlinkText.IndexOf(delimiter, 0);

            Debug.Assert(firstSplitPosition != -1);
            int secondSplitPosition = contributeHyperlinkText.IndexOf(delimiter, firstSplitPosition + 1);

            Debug.Assert(secondSplitPosition != -1);
            int hyperlinkTextLength = secondSplitPosition - (firstSplitPosition + delimiterLength);

            // Assign pieces.
            var contributeTextBeforeHyperlink = contributeHyperlinkText.Substring(0, firstSplitPosition);
            var contributeTextLink            = contributeHyperlinkText.Substring(firstSplitPosition + delimiterLength, hyperlinkTextLength);
            var contributeTextAfterHyperlink  = contributeHyperlinkText.Substring(secondSplitPosition + delimiterLength);

            ContributeRunBeforeLink.Text = contributeTextBeforeHyperlink;
            ContributeRunLink.Text       = contributeTextLink;
            ContributeRunAfterLink.Text  = contributeTextAfterHyperlink;
        }
Ejemplo n.º 2
0
        private void SetVersionString()
        {
            PackageVersion version = Package.Current.Id.Version;
            string         appName = AppResourceProvider.GetInstance().GetResourceString("AppName");

            AboutBuildVersion.Text = appName + " " + version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision;
        }
Ejemplo n.º 3
0
        public Calculator()
        {
            this.InitializeComponent();

            m_doAnimate = false;
            m_isLastAnimatedInScientific = false;
            m_isLastAnimatedInProgrammer = false;
            m_resultAnimate      = false;
            HistoryButtonPressed = new DelegateCommand(ToggleHistoryFlyout);

            SetFontSizeResources();
            LoadResourceStrings();

            if (LocalizationService.GetInstance().IsRtlLayout())
            {
                HistoryButton.HorizontalAlignment = HorizontalAlignment.Left;
            }

            m_displayFlyout = (MenuFlyout)(Resources["DisplayContextMenu"]);
            var resLoader = AppResourceProvider.GetInstance();

            // UNO TODO
            // CopyMenuItem.Text = resLoader.GetResourceString("copyMenuItem");
            // PasteMenuItem.Text = resLoader.GetResourceString("pasteMenuItem");
        }
Ejemplo n.º 4
0
        public static String GetTracingLegend(bool?isTracing)
        {
            var resProvider = AppResourceProvider.GetInstance();

            return(isTracing != null && isTracing.Value ? resProvider.GetResourceString("disableTracingButtonToolTip")
                                                        : resProvider.GetResourceString("enableTracingButtonToolTip"));
        }
Ejemplo n.º 5
0
        void SetHeaderAutomationName()
        {
            ViewMode mode        = m_model.Mode;
            var      resProvider = AppResourceProvider.GetInstance();

            String name;

            if (NavCategory.IsDateCalculatorViewMode(mode))
            {
                name = resProvider.GetResourceString("HeaderAutomationName_Date");
            }
            else
            {
                string full = "";
                if (NavCategory.IsCalculatorViewMode(mode))
                {
                    full = resProvider.GetResourceString("HeaderAutomationName_Calculator");
                }
                else if (NavCategory.IsConverterViewMode(mode))
                {
                    full = resProvider.GetResourceString("HeaderAutomationName_Converter");
                }

                full = full.Replace("%1", m_model.CategoryName);

                name = full;
            }

            AutomationProperties.SetName(Header, name);
        }
Ejemplo n.º 6
0
        void OnLoaded(object sender, RoutedEventArgs args)
        {
            Model.PropertyChanged   += OnCalcPropertyChanged;
            Model.HideMemoryClicked += OnHideMemoryClicked;

            InitializeHistoryView(Model.HistoryVM);
            String historyPaneName = AppResourceProvider.GetInstance().GetResourceString("HistoryPane");

            HistoryFlyout.FlyoutPresenterStyle.Setters.Append(new Setter(AutomationProperties.NameProperty, historyPaneName));
            String memoryPaneName = AppResourceProvider.GetInstance().GetResourceString("MemoryPane");

            MemoryFlyout.FlyoutPresenterStyle.Setters.Append(new Setter(AutomationProperties.NameProperty, memoryPaneName));

            if (Windows.Foundation.Metadata.ApiInformation.IsEventPresent("Windows.UI.Xaml.Controls.Primitives.FlyoutBase", "Closing"))
            {
                HistoryFlyout.Closing += HistoryFlyout_Closing;
                MemoryFlyout.Closing  += OnMemoryFlyoutClosing;
            }

            // Delay load things later when we get a chance.
            var _ = Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal, () =>
            {
                // if (// TraceLogger.GetInstance().UpdateWindowIdLog(ApplicationView.GetApplicationViewIdForWindow(CoreWindow.GetForCurrentThread())))
                {
                    // var refThis = weakThis.Resolve<Calculator>();
                    // if (refThis != null)
                    {
                        this.GetMemory();
                    }
                }
            });
        }
Ejemplo n.º 7
0
        private void AnnouncePageOpened()
        {
            string announcementText           = AppResourceProvider.GetInstance().GetResourceString("SettingsPageOpenedAnnouncement");
            NarratorAnnouncement announcement = CalculatorAnnouncement.GetSettingsPageOpenedAnnouncement(announcementText);

            NarratorNotifier.Announce(announcement);
        }
        private string GenerateAutomationPropertiesName(int position, bool value)
        {
            var    resourceLoader         = AppResourceProvider.GetInstance();
            string automationNameTemplate = resourceLoader.GetResourceString("BitFlipItemAutomationName");
            string bitPosition;

            if (position == 0)
            {
                bitPosition = resourceLoader.GetResourceString("LeastSignificantBit");
            }
            else
            {
                int lastPosition = -1;
                if (Model != null)
                {
                    lastPosition = GetIndexOfLastBit(Model.ValueBitLength);
                }

                if (position == lastPosition)
                {
                    bitPosition = resourceLoader.GetResourceString("MostSignificantBit");
                }
                else
                {
                    string indexName           = resourceLoader.GetResourceString(position.ToString());
                    string bitPositionTemplate = resourceLoader.GetResourceString("BitPosition");
                    bitPosition = LocalizationStringUtil.GetLocalizedString(bitPositionTemplate, indexName);
                }
            }
            return(LocalizationStringUtil.GetLocalizedString(automationNameTemplate, bitPosition, value ? "1" : "0"));
        }
Ejemplo n.º 9
0
        public DateCalculator()
        {
            InitializeComponent();

            // Set Calendar Identifier
            DateDiff_FromDate.CalendarIdentifier = localizationSettings.GetCalendarIdentifier();
            DateDiff_ToDate.CalendarIdentifier   = localizationSettings.GetCalendarIdentifier();

            // Setting the FirstDayofWeek
            DateDiff_FromDate.FirstDayOfWeek = localizationSettings.GetFirstDayOfWeek();
            DateDiff_ToDate.FirstDayOfWeek   = localizationSettings.GetFirstDayOfWeek();

            // Setting the Language explicitly is not required,
            // this is a workaround for the bug in the control due to which
            // the displayed date is incorrect for non Gregorian Calendar Systems
            // The displayed date doesn't honor the shortdate format, on setting the Language the format is refreshed
            DateDiff_FromDate.Language = localizationSettings.GetLocaleName();
            DateDiff_ToDate.Language   = localizationSettings.GetLocaleName();

            // Set Min and Max Dates according to the Gregorian Calendar(1601 & 9999)
            var calendar = new Calendar();
            var today    = calendar.GetDateTime();

            calendar.ChangeCalendarSystem(CalendarIdentifiers.Gregorian);
            calendar.Day   = 1;
            calendar.Month = 1;
            calendar.Year  = c_minYear;
            var minYear = calendar.GetDateTime(); // 1st January, 1601

            DateDiff_FromDate.MinDate = minYear;
            DateDiff_ToDate.MinDate   = minYear;

            calendar.Day   = 31;
            calendar.Month = 12;
            calendar.Year  = c_maxYear;
            var maxYear = calendar.GetDateTime(); // 31st December, 9878

            DateDiff_FromDate.MaxDate = maxYear;
            DateDiff_ToDate.MaxDate   = maxYear;

            // Set the PlaceHolderText for CalendarDatePicker
            DateTimeFormatter dateTimeFormatter = LocalizationService.GetInstance().GetRegionalSettingsAwareDateTimeFormatter(
                "day month year",
                localizationSettings.GetCalendarIdentifier(),
                ClockIdentifiers.TwentyFourHour); // Clock Identifier is not used

            DateDiff_FromDate.DateFormat = "day month year";
            DateDiff_ToDate.DateFormat   = "day month year";

            var placeholderText = dateTimeFormatter.Format(today);

            DateDiff_FromDate.PlaceholderText = placeholderText;
            DateDiff_ToDate.PlaceholderText   = placeholderText;

            CopyMenuItem.Text = AppResourceProvider.GetInstance().GetResourceString("copyMenuItem");
            DateCalculationOption.SelectionChanged += DateCalcOption_Changed;
        }
Ejemplo n.º 10
0
 public static string GetInfoForSwitchModeToggleButton(bool isChecked)
 {
     if (isChecked)
     {
         return(AppResourceProvider.GetInstance().GetResourceString("GraphSwitchToGraphMode"));
     }
     else
     {
         return(AppResourceProvider.GetInstance().GetResourceString("GraphSwitchToEquationMode"));
     }
 }
Ejemplo n.º 11
0
        void LoadResourceStrings()
        {
            var resProvider = AppResourceProvider.GetInstance();

            m_openMemoryFlyoutAutomationName   = resProvider.GetResourceString("MemoryButton_Open");
            m_closeMemoryFlyoutAutomationName  = resProvider.GetResourceString("MemoryButton_Close");
            m_openHistoryFlyoutAutomationName  = resProvider.GetResourceString("HistoryButton_Open");
            m_closeHistoryFlyoutAutomationName = resProvider.GetResourceString("HistoryButton_Close");
            AutomationProperties.SetName(MemoryButton, m_openMemoryFlyoutAutomationName);
            AutomationProperties.SetName(HistoryButton, m_openHistoryFlyoutAutomationName);
        }
Ejemplo n.º 12
0
        private void SetContentLinks()
        {
            string eula = AppResourceProvider.GetInstance().GetResourceString(AboutEULA.Name + "/Text");

            AboutEULA.Text = eula;
            string agreement = AppResourceProvider.GetInstance().GetResourceString(AboutControlServicesAgreement.Name + "/Text");

            AboutControlServicesAgreement.Text = agreement;
            string privacyState = AppResourceProvider.GetInstance().GetResourceString(AboutControlPrivacyStatement.Name + "/Text");

            AboutControlPrivacyStatement.Text = privacyState;
        }
Ejemplo n.º 13
0
        private void SwitchModeToggleButton_Toggled(object sender, RoutedEventArgs e)
        {
            var    narratorNotifier = new NarratorNotifier();
            String announcementText;

            if (SwitchModeToggleButton.IsOn)
            {
                announcementText = AppResourceProvider.GetInstance().GetResourceString("GraphSwitchedToEquationModeAnnouncement");
            }
            else
            {
                announcementText = AppResourceProvider.GetInstance().GetResourceString("GraphSwitchedToGraphModeAnnouncement");
            }

            var announcement = CalculatorAnnouncement.GetGraphModeChangedAnnouncement(announcementText);

            narratorNotifier.Announce(announcement);
        }
Ejemplo n.º 14
0
        public Settings()
        {
            var locService     = LocalizationService.GetInstance();
            var resourceLoader = AppResourceProvider.GetInstance();

            InitializeComponent();

            Language = locService.GetLanguage();

            InitializeAboutContentTextBlock();

            var copyrightText =
                LocalizationStringUtil.GetLocalizedString(resourceLoader.GetResourceString("AboutControlCopyright"), BUILD_YEAR);

            AboutControlCopyrightRun.Text = copyrightText;

            InitializeContributeTextBlock();
        }
Ejemplo n.º 15
0
        public TitleBar()
        {
            m_coreTitleBar          = CoreApplication.GetCurrentView().TitleBar;
            m_uiSettings            = new UISettings();
            m_accessibilitySettings = new AccessibilitySettings();
            InitializeComponent();

            m_coreTitleBar.ExtendViewIntoTitleBar = true;
            Window.Current.SetTitleBar(BackgroundElement);

            Loaded   += OnLoaded;
            Unloaded += OnUnloaded;
#if IS_STORE_BUILD
            AppName.Text = AppResourceProvider.GetInstance().GetResourceString("AppName");
#else
            AppName.Text = AppResourceProvider.GetInstance().GetResourceString("DevAppName");
#endif
        }
Ejemplo n.º 16
0
        public static string GetLineAutomationName(object line)
        {
            var resourceLoader = AppResourceProvider.GetInstance();
            var lineStyle      = ((EquationLineStyle?)line).Value;

            switch (lineStyle)
            {
            case EquationLineStyle.Dot:
                return(resourceLoader.GetResourceString("dotLineStyleAutomationName"));

            case EquationLineStyle.Dash:
                return(resourceLoader.GetResourceString("dashLineStyleAutomationName"));

            case EquationLineStyle.Solid:
            default:
                return(resourceLoader.GetResourceString("solidLineStyleAutomationName"));
            }
        }
Ejemplo n.º 17
0
        private void EquationTextBox_RemoveButtonClicked(object sender, RoutedEventArgs e)
        {
            var eq    = GetViewModelFromEquationTextBox(sender);
            int index = Equations.IndexOf(eq);

            if (index >= 0)
            {
                // Prevent removing the last equation
                if (index == Equations.Count - 1)
                {
                    return;
                }

                Equations.RemoveAt(index);

                var narratorNotifier = new NarratorNotifier();
                var announcement     =
                    CalculatorAnnouncement.GetFunctionRemovedAnnouncement(AppResourceProvider.GetInstance().GetResourceString("FunctionRemovedAnnouncement"));
                narratorNotifier.Announce(announcement);

                int lastIndex = Equations.Count - 1;

                if (Equations.Count <= 1)
                {
                    m_lastFunctionLabelIndex = 1;
                }
                else
                {
                    m_lastFunctionLabelIndex = Equations[lastIndex - 1].FunctionLabelIndex + 1;
                }

                Equations[lastIndex].FunctionLabelIndex = m_lastFunctionLabelIndex;

                // Focus the next equation after the one we just removed. There should always be at least one ghost equation,
                // but check to make sure that there is an equation we can focus in the index where we just removed an equation.
                if (index < Equations.Count)
                {
                    FocusEquationTextBox(Equations[index]);
                }
            }
        }
Ejemplo n.º 18
0
        public static string GetLineWidthAutomationName(double width)
        {
            var resourceLoader = AppResourceProvider.GetInstance();

            if (width == 1.0)
            {
                return(resourceLoader.GetResourceString("SmallLineWidthAutomationName"));
            }
            else if (width == 2.0)
            {
                return(resourceLoader.GetResourceString("MediumLineWidthAutomationName"));
            }
            else if (width == 3.0)
            {
                return(resourceLoader.GetResourceString("LargeLineWidthAutomationName"));
            }
            else
            {
                return(resourceLoader.GetResourceString("ExtraLargeLineWidthAutomationName"));
            }
        }
Ejemplo n.º 19
0
        private void GraphViewButton_Click(object sender, RoutedEventArgs e)
        {
            var    narratorNotifier = new NarratorNotifier();
            string announcementText;

            if (IsManualAdjustment)
            {
                announcementText = AppResourceProvider.GetInstance().GetResourceString("GraphViewManualAdjustmentAnnouncement");
            }
            else
            {
                announcementText  = AppResourceProvider.GetInstance().GetResourceString("GraphViewAutomaticBestFitAnnouncement");
                announcementText += AppResourceProvider.GetInstance().GetResourceString("GridResetAnnouncement");
                GraphingControl.ResetGrid();
            }

            var announcement = CalculatorAnnouncement.GetGraphViewBestFitChangedAnnouncement(announcementText);

            narratorNotifier.Announce(announcement);

            CalculatorApp.ViewModel.Common.TraceLogger.GetInstance().LogGraphButtonClicked(
                GraphButton.GraphView, IsManualAdjustment ? GraphButtonValue.ManualAdjustment : GraphButtonValue.AutomaticBestFit);
        }
Ejemplo n.º 20
0
        public Calculator()
        {
            m_doAnimate = false;
            m_isLastAnimatedInScientific = false;
            m_isLastAnimatedInProgrammer = false;
            m_resultAnimate = false;

            SetFontSizeResources();
            InitializeComponent();
            LoadResourceStrings();

            if (LocalizationService.GetInstance().IsRtlLayout())
            {
                HistoryButton.HorizontalAlignment = HorizontalAlignment.Left;
            }

            m_displayFlyout = (MenuFlyout)Resources["DisplayContextMenu"];
            var resLoader = AppResourceProvider.GetInstance();

            CopyMenuItem.Text  = resLoader.GetResourceString("copyMenuItem");
            PasteMenuItem.Text = resLoader.GetResourceString("pasteMenuItem");

            this.SizeChanged += Calculator_SizeChanged;
        }
Ejemplo n.º 21
0
        private void UpdateGraphAutomationName()
        {
            int    numEquations = 0;
            double xAxisMin, xAxisMax, yAxisMin, yAxisMax;

            // Only count equations that are graphed
            foreach (var equation in ViewModel.Equations)
            {
                if (equation.GraphEquation.IsValidated)
                {
                    numEquations++;
                }
            }

            GraphingControl.GetDisplayRanges(out xAxisMin, out xAxisMax, out yAxisMin, out yAxisMax);

            GraphControlAutomationName = LocalizationStringUtil.GetLocalizedString(
                AppResourceProvider.GetInstance().GetResourceString("graphAutomationName"),
                xAxisMin.ToString(),
                xAxisMax.ToString(),
                yAxisMin.ToString(),
                yAxisMax.ToString(),
                numEquations.ToString());
        }
Ejemplo n.º 22
0
        public static string GetColorAutomationName(Windows.UI.Xaml.Media.Brush brush)
        {
            var resourceLoader = AppResourceProvider.GetInstance();
            var color          = ((SolidColorBrush)brush);

            var lightDictionary = (ResourceDictionary)(Application.Current.Resources.ThemeDictionaries["Light"]);
            var darkDictionary  = (ResourceDictionary)(Application.Current.Resources.ThemeDictionaries["Default"]);
            var highContrast    = (ResourceDictionary)(Application.Current.Resources.ThemeDictionaries["HighContrast"]);

            if (color == (SolidColorBrush)(lightDictionary["EquationBrush1"]) ||
                color == (SolidColorBrush)(darkDictionary["EquationBrush1"]))
            {
                return(resourceLoader.GetResourceString("equationColor1AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush2"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush2"]))
            {
                return(resourceLoader.GetResourceString("equationColor2AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush3"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush3"]))
            {
                return(resourceLoader.GetResourceString("equationColor3AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush4"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush4"]))
            {
                return(resourceLoader.GetResourceString("equationColor4AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush5"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush5"]))
            {
                return(resourceLoader.GetResourceString("equationColor5AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush6"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush6"]))
            {
                return(resourceLoader.GetResourceString("equationColor6AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush7"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush7"]))
            {
                return(resourceLoader.GetResourceString("equationColor7AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush8"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush8"]))
            {
                return(resourceLoader.GetResourceString("equationColor8AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush9"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush9"]))
            {
                return(resourceLoader.GetResourceString("equationColor9AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush10"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush10"]))
            {
                return(resourceLoader.GetResourceString("equationColor10AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush11"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush11"]))
            {
                return(resourceLoader.GetResourceString("equationColor11AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush12"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush12"]))
            {
                return(resourceLoader.GetResourceString("equationColor12AutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush13"]) ||
                     color == (SolidColorBrush)(darkDictionary["EquationBrush13"]))
            {
                return(resourceLoader.GetResourceString("equationColor13AutomationName"));
            }
            else if (color == (SolidColorBrush)(darkDictionary["EquationBrush14"]))
            {
                return(resourceLoader.GetResourceString("equationColor14WhiteAutomationName"));
            }
            else if (color == (SolidColorBrush)(lightDictionary["EquationBrush14"]))
            {
                return(resourceLoader.GetResourceString("equationColor14BlackAutomationName"));
            }
            else if (color == (SolidColorBrush)(highContrast["EquationBrush1"]))
            {
                return(resourceLoader.GetResourceString("equationHighContrastColor1AutomationName"));
            }
            else if (color == (SolidColorBrush)(highContrast["EquationBrush2"]))
            {
                return(resourceLoader.GetResourceString("equationHighContrastColor2AutomationName"));
            }
            else if (color == (SolidColorBrush)(highContrast["EquationBrush3"]))
            {
                return(resourceLoader.GetResourceString("equationHighContrastColor3AutomationName"));
            }
            else
            {
                return(resourceLoader.GetResourceString("equationHighContrastColor4AutomationName"));
            }
        }
        public CalculatorProgrammerOperators()
        {
            InitializeComponent();

            CopyMenuItem.Text = AppResourceProvider.GetInstance().GetResourceString("copyMenuItem");
        }