Beispiel #1
0
        /// <summary>
        /// Change alignment of all TextBlocks in GridHT and GridLT.
        /// </summary>
        /// <param name="enumPositionLabelsNew">New label position.</param>
        private void ColorBarsLabelsPosition(EnumPositionLabels enumPositionLabelsNew)
        {
            HorizontalAlignment horizontalAlignment;

            switch (enumPositionLabelsNew)
            {
            case EnumPositionLabels.center:
                horizontalAlignment = HorizontalAlignment.Center;
                break;

            case EnumPositionLabels.right:
                horizontalAlignment = HorizontalAlignment.Right;
                break;

            case EnumPositionLabels.left:
                horizontalAlignment = HorizontalAlignment.Left;
                break;

            case EnumPositionLabels.off:
                return;         // Return if labels are off.

            default:            // Throw exception so error can be discovered and corrected.
                throw new NotSupportedException($"ShowBars.ColorBarsLabelsPosition(): Match for enumPositionLabelsNew={enumPositionLabelsNew} not found in switch statement.");
            }
            TextBlock textBlock;

            // Change alignment of all TextBlocks in GridHT.
            foreach (UIElement uIElement in GridHT.Children)
            {
                textBlock = uIElement as TextBlock;
                textBlock.HorizontalAlignment = horizontalAlignment;
            }
            // Change alignment of TextBlock in GridLT.
            LargeRectText.HorizontalAlignment = horizontalAlignment;
        }
Beispiel #2
0
        /*** Public methods follow *********************************************************************************************/

        /// <summary>
        /// Method called from mainPage.ButLabels_Click(). Toggle position of color bar labels when User clicks on Labels button.
        /// </summary>
        public void ShowBarsLabels()
        {
            switch (enumPositionLabels)
            {
            case EnumPositionLabels.center:
                enumPositionLabels = EnumPositionLabels.right;
                ColorBarsLabelsPosition(enumPositionLabels);            // Change label position.
                break;

            case EnumPositionLabels.right:
                enumPositionLabels = EnumPositionLabels.off;
                ColorBarsLabelsCollapse();                              // Labels were on, so turn them off.
                break;

            case EnumPositionLabels.off:
                enumPositionLabels = EnumPositionLabels.left;
                ColorBarsLabelsVisible();                               // Labels were off, so turn them on.
                ColorBarsLabelsPosition(enumPositionLabels);            // Change label position.
                break;

            case EnumPositionLabels.left:
                enumPositionLabels = EnumPositionLabels.center;
                ColorBarsLabelsPosition(enumPositionLabels);            // Change label position.
                break;

            default:        // Throw exception so error can be discovered and corrected.
                throw new NotSupportedException($"ShowBars.ShowBarsLabels(): Match for enumPositionLabels={enumPositionLabels} not found in switch statement.");
            }
        }