/// <summary>
        /// This is the click handler for the 'Default' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses the Windows.Globalization.DateTimeFormatting.DateTimeFormatter class
            // in order to display dates and times using basic formatters.

            // We keep results in this variable
            StringBuilder results = new StringBuilder();
            results.AppendLine("Current application context language: " + ApplicationLanguages.Languages[0]);
            results.AppendLine();

            // Create basic date/time formatters.
            DateTimeFormatter[] basicFormatters = new[]
            {
                // Default date formatters
                new DateTimeFormatter("shortdate"),
                new DateTimeFormatter("longdate"),

                // Default time formatters
                new DateTimeFormatter("shorttime"),
                new DateTimeFormatter("longtime"),
             };

            // Create date/time to format and display.
            DateTime dateTime = DateTime.Now;

            // Format and display date/time. Calendar will always support Now. Otherwise you may need to verify dateTime is in supported range.
            foreach (DateTimeFormatter formatter in basicFormatters)
            {
                // Format and display date/time.
                results.AppendLine(formatter.Template + ": " + formatter.Format(dateTime));
            }

            // Display the results
            OutputTextBlock.Text = results.ToString();
        }
Exemplo n.º 2
0
        internal static async Task Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Jupiter.Shapes.Path path)
        {
            var rect = path.GetBoundingRect(rootElement).ToSharpDX();
            var fill = await path.Fill.ToSharpDX(renderTarget, rect);
            var stroke = await path.Stroke.ToSharpDX(renderTarget, rect);

            var layer = path.CreateAndPushLayerIfNecessary(renderTarget, rootElement);
            var oldTransform = renderTarget.Transform;
            renderTarget.Transform = new Matrix3x2(
                1, 0, 0, 1, rect.Left, rect.Top);
            //renderTarget.PushLayer(ref layerParameters, layer);

            var d2dGeometry = path.Data.ToSharpDX(compositionEngine.D2DFactory, rect);

            if (fill != null)
            {
                renderTarget.FillGeometry(d2dGeometry, fill, null);
            }

            if (stroke != null &&
                path.StrokeThickness > 0)
            {
                renderTarget.DrawGeometry(
                d2dGeometry,
                stroke,
                (float)path.StrokeThickness,
                path.GetStrokeStyle(compositionEngine.D2DFactory));}

            //if (path.StrokeThickness > 0 &&
            //    stroke != null)
            //{
            //    var halfThickness = (float)(path.StrokeThickness * 0.5);
            //    roundedRect.Rect = rect.Eroded(halfThickness);

            //    if (fill != null)
            //    {
            //        renderTarget.FillRoundedRectangle(roundedRect, fill);
            //    }

            //    renderTarget.DrawRoundedRectangle(
            //        roundedRect,
            //        stroke,
            //        (float)path.StrokeThickness,
            //        path.GetStrokeStyle(compositionEngine.D2DFactory));
            //}
            //else
            //{
            //    renderTarget.FillRoundedRectangle(roundedRect, fill);
            //}

            if (layer != null)
            {
                renderTarget.PopLayer();
                layer.Dispose();
            }

            renderTarget.Transform = oldTransform;
        }
        /// <summary>
        /// This is the click handler for the 'Display' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses language tags with unicode extensions to construct and use the various 
            // formatters and NumeralSystemTranslator in Windows.Globalization.NumberFormatting to format numbers 

            // Keep results of the scenario in a StringBuilder
            StringBuilder results = new StringBuilder();

            // Create number to format.
            double randomNumber = (new Random().NextDouble() * 100000);
            results.AppendLine("Random number used by formatters: " + randomNumber);
            // Create a string to translate
            String stringToTranslate = "These are the 10 digits of a numeral system: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9";
            results.AppendLine("String used by NumeralSystemTranslater: " + stringToTranslate);
            // Create the rounder and set its increment to 0.01
            IncrementNumberRounder rounder = new Windows.Globalization.NumberFormatting.IncrementNumberRounder();
            rounder.Increment = 0.001;
            results.AppendLine("CurrencyFormatter will be using Euro symbol and all formatters rounding to 0.001 increments");
            results.AppendLine();

            // The list of language tags with unicode extensions we want to test
            String[] languages = new[] { "de-DE-u-nu-telu-ca-buddist-co-phonebk-cu-usd", "ja-jp-u-nu-arab"};
            
            // Create the various formatters, now using the language list with unicode extensions            
            results.AppendLine("Creating formatters using following languages in the language list:");
            foreach(String language in languages)
            {
                results.AppendLine("\t" + language);
            }
            results.AppendLine();

            // Create the various formatters.
            DecimalFormatter decimalFormatter = new DecimalFormatter(languages, "ZZ");
            decimalFormatter.NumberRounder = rounder; decimalFormatter.FractionDigits = 2;
            CurrencyFormatter currencyFormatter = new CurrencyFormatter(CurrencyIdentifiers.EUR, languages, "ZZ");
            currencyFormatter.NumberRounder = rounder; currencyFormatter.FractionDigits = 2;
            PercentFormatter percentFormatter = new PercentFormatter(languages, "ZZ");
            percentFormatter.NumberRounder = rounder; percentFormatter.FractionDigits = 2;
            PermilleFormatter permilleFormatter = new PermilleFormatter(languages, "ZZ");
            permilleFormatter.NumberRounder = rounder; permilleFormatter.FractionDigits = 2;
            NumeralSystemTranslator numeralTranslator = new NumeralSystemTranslator(languages);

            results.AppendLine("Using resolved language  " + decimalFormatter.ResolvedLanguage + "  : (note that all extension tags other than nu are ignored)");
            // Format using formatters and translate using NumeralSystemTranslator.
            results.AppendLine("Decimal Formatted:   " + decimalFormatter.Format(randomNumber));
            results.AppendLine("Currency formatted:   " + currencyFormatter.Format(randomNumber));
            results.AppendLine("Percent formatted:   " + percentFormatter.Format(randomNumber));
            results.AppendLine("Permille formatted:   " + permilleFormatter.Format(randomNumber));
            results.AppendLine("NumeralTranslator translated:   " + numeralTranslator.TranslateNumerals(stringToTranslate));
            results.AppendLine();

            // Display the results
            OutputTextBlock.Text = results.ToString();
        }
Exemplo n.º 4
0
        /// <summary>
        /// This is the click handler for the 'Default' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses the Windows.Globalization.DateTimeFormatting.DateTimeFormatter class
            // in order to display dates and times using basic formatters.

            // We keep results in this variable
            StringBuilder results = new StringBuilder();
            results.AppendLine("Current application context language: " + ApplicationLanguages.Languages[0]);
            results.AppendLine();

            // Create basic date/time formatters.
            DateTimeFormatter[] basicFormatters = new[]
            {
                // Default date formatters
                new DateTimeFormatter("shortdate"),
                new DateTimeFormatter("longdate"),

                // Default time formatters
                new DateTimeFormatter("shorttime"),
                new DateTimeFormatter("longtime"),
             };

            // Create date/time to format and display.
            DateTime dateTime = DateTime.Now;

            // Try to format and display date/time if calendar supports it.
            foreach (DateTimeFormatter formatter in basicFormatters)
            {
                try
                {
                    // Format and display date/time.
                    results.AppendLine(formatter.Template + ": " + formatter.Format(dateTime));
                }
                catch (ArgumentException)
                {
                    // Retrieve and display formatter properties. 
                    results.AppendLine(String.Format(
                        "Unable to format Gregorian DateTime {0} using formatter with template {1} for languages [{2}], region {3}, calendar {4} and clock {5}",
                        dateTime,
                        formatter.Template,
                        string.Join(",", formatter.Languages),
                        formatter.GeographicRegion,
                        formatter.Calendar,
                        formatter.Clock));
                }
            }

            // Display the results
            rootPage.NotifyUser(results.ToString(), NotifyType.StatusMessage);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates and pushes a D2D layer if necessary. Returns the layer or null if not required.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="renderTarget">The render target.</param>
        /// <param name="rootElement"></param>
        /// <returns></returns>
        public static D2D.Layer CreateAndPushLayerIfNecessary(this Jupiter.FrameworkElement element, D2D.RenderTarget renderTarget, Jupiter.FrameworkElement rootElement)
        {
            if (element.Opacity >= 1)
                //element.Clip == null &&
                //element.RenderTransform == null)
            {
                return null;
            }

            var layer = new D2D.Layer(renderTarget);
            var layerParameters = new D2D.LayerParameters();
            layerParameters.Opacity = (float)element.Opacity;
            layerParameters.ContentBounds = element.GetBoundingRect(rootElement).ToSharpDX();
            renderTarget.PushLayer(ref layerParameters, layer);

            return layer;
        }
Exemplo n.º 6
0
        internal static async Task Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, Jupiter.FrameworkElement rootElement, Jupiter.Controls.Image image)
        {
            var rect = image.GetBoundingRect(rootElement).ToSharpDX();
            if (rect.Width == 0 ||
                rect.Height == 0)
            {
                return;
            }

            var bitmap = await image.Source.ToSharpDX(renderTarget);

            if (bitmap == null)
            {
                return;
            }

            try
            {
                var layer = image.CreateAndPushLayerIfNecessary(renderTarget, rootElement);

                renderTarget.DrawBitmap(
                    bitmap,
                    rect,
                    (float)image.Opacity,
                    D2D.BitmapInterpolationMode.Linear);

                if (layer != null)
                {
                    renderTarget.PopLayer();
                    layer.Dispose();
                }
            }
            finally
            {
                bitmap.Dispose();
            }
        }
        public static void AddEllipseGeometry(
            this D2D.GeometrySink sink, Jupiter.Media.EllipseGeometry ellipseGeometry)
        {
            // Start the ellipse at 9 o'clock.
            sink.BeginFigure(
                new DrawingPointF(
                    (float)(ellipseGeometry.Center.X - ellipseGeometry.RadiusX),
                    (float)(ellipseGeometry.Center.Y)),
                    D2D.FigureBegin.Filled);


            // Do almost full ellipse in one arc (there is .00001 pixel size missing)
            sink.AddArc(
                new D2D.ArcSegment
                {
                    Point = new DrawingPointF(
                        (float)(ellipseGeometry.Center.X - ellipseGeometry.RadiusX),
                        (float)(ellipseGeometry.Center.Y + 0.00001)),
                    Size = new DrawingSizeF(
                        (float)(ellipseGeometry.RadiusX * 2),
                        (float)(ellipseGeometry.RadiusY * 2)),
                    RotationAngle = 0,
                    SweepDirection = D2D.SweepDirection.Clockwise,
                    ArcSize = D2D.ArcSize.Large
                });

            // Close the ellipse
            sink.EndFigure(D2D.FigureEnd.Closed);
        }
        public static void AddPathGeometry(
            this D2D.GeometrySink sink, Jupiter.Media.PathGeometry pathGeometry)
        {
            sink.SetFillMode(pathGeometry.FillRule.ToSharpDX());

            foreach (var childFigure in pathGeometry.Figures)
            {
                sink.AddPathFigure(childFigure);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// This is the click handler for the 'Default' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses the Windows.Globalization.DateTimeFormatting.DateTimeFormatter class
            // to format a date/time via a string template.  Note that the order specifed in the string pattern does
            // not determine the order of the parts of the formatted string.  The user's language and region preferences will
            // determine the pattern of the date returned based on the specified parts.

            // Create template-based date/time formatters.
            DateTimeFormatter[] dateFormatters = new[]
            {
                // Formatters for dates.
                new DateTimeFormatter("month day"),
                new DateTimeFormatter("month year"),
                new DateTimeFormatter("month day year"),
                new DateTimeFormatter("month day dayofweek year"),
                new DateTimeFormatter("dayofweek.abbreviated"),
                new DateTimeFormatter("month.abbreviated"),
                new DateTimeFormatter("year.abbreviated")
            };

            // Create template-based date/time formatters.
            DateTimeFormatter[] timeFormatters = new[]
            {
                // Formatters for time.
                new DateTimeFormatter("hour minute"),
                new DateTimeFormatter("hour minute second"),
                new DateTimeFormatter("hour")
            };

            // Create template-based date/time formatters.
            DateTimeFormatter[] timezoneFormatters = new[]
            {
                // Formatters for timezone.
                new DateTimeFormatter("timezone"),
                new DateTimeFormatter("timezone.full"),
                new DateTimeFormatter("timezone.abbreviated")
            };
                
            // Create template-based date/time formatters.
            DateTimeFormatter[] combinationFormatters = new[]
            {
                // Formatters for combinations.
                new DateTimeFormatter("hour minute second timezone.full"),
                new DateTimeFormatter("day month year hour minute timezone"),
                new DateTimeFormatter("dayofweek day month year hour minute second"),
                new DateTimeFormatter("dayofweek.abbreviated day month hour minute"),
                new DateTimeFormatter("dayofweek day month year hour minute second timezone.abbreviated"),
             };

            // Create date/time to format and display.
            DateTime dateTime = DateTime.Now;

            // We keep results in this variable
            StringBuilder results = new StringBuilder();
            results.AppendLine("Current application context language: " + ApplicationLanguages.Languages[0]);
            results.AppendLine();
            results.AppendLine("Formatted Dates:");

            // Format and display date/time. Calendar always supports Now. Otherwise you may need to verify dateTime is in supported range.
            foreach (DateTimeFormatter formatter in dateFormatters)
            {
                // Format and display date/time.
                results.AppendLine(formatter.Template + ": " + formatter.Format(dateTime));
            }

            results.AppendLine();
            results.AppendLine("Formatted Times:");

            // Format and display date/time. Calendar always supports Now. Otherwise you may need to verify dateTime is in supported range.
            foreach (DateTimeFormatter formatter in timeFormatters)
            {
                // Format and display date/time.
                results.AppendLine(formatter.Template + ": " + formatter.Format(dateTime));
            }

            results.AppendLine();
            results.AppendLine("Formatted timezones:");

            // Format and display date/time. Calendar always supports Now. Otherwise you may need to verify dateTime is in supported range.
            foreach (DateTimeFormatter formatter in timezoneFormatters)
            {
                // Format and display date/time.
                results.AppendLine(formatter.Template + ": " + formatter.Format(dateTime));
            }

            results.AppendLine();
            results.AppendLine("Formatted Date and Time Combinations:");

            // Format and display date/time. Calendar always supports Now. Otherwise you may need to verify dateTime is in supported range.
            foreach (DateTimeFormatter formatter in combinationFormatters)
            {
                // Format and display date/time.
                results.AppendLine(formatter.Template + ": " + formatter.Format(dateTime));
            }

            // Display the results
            OutputTextBlock.Text = results.ToString();
        }
Exemplo n.º 10
0
        /// <summary>
        /// This is the click handler for the 'Default' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses the Windows.Globalization.DateTimeFormatting.DateTimeFormatter class
            // to format a date/time by specifying a template via parameters.  Note that the user's language
            // and region preferences will determine the pattern of the date returned based on the
            // specified parts.

            // We keep results in this variable
            StringBuilder results = new StringBuilder();
            results.AppendLine("Current application context language: " + ApplicationLanguages.Languages[0]);
            results.AppendLine();

            // Create formatters with individual format specifiers for date/time elements.
            DateTimeFormatter[] templateFormatters = new[]
            {
                // Example formatters for dates.
                new DateTimeFormatter(
                    YearFormat.Full, 
                    MonthFormat.Abbreviated, 
                    DayFormat.Default, 
                    DayOfWeekFormat.Abbreviated),
                new DateTimeFormatter(
                    YearFormat.Abbreviated, 
                    MonthFormat.Abbreviated, 
                    DayFormat.Default, 
                    DayOfWeekFormat.None),
                new DateTimeFormatter(
                    YearFormat.Full, 
                    MonthFormat.Full, 
                    DayFormat.None, 
                    DayOfWeekFormat.None),
                new DateTimeFormatter(
                    YearFormat.None, 
                    MonthFormat.Full, 
                    DayFormat.Default, 
                    DayOfWeekFormat.None),

                // Example formatters for times.
                new DateTimeFormatter(
                    HourFormat.Default, 
                    MinuteFormat.Default, 
                    SecondFormat.Default),
                new DateTimeFormatter(
                    HourFormat.Default, 
                    MinuteFormat.Default, 
                    SecondFormat.None),
                new DateTimeFormatter(
                    HourFormat.Default, 
                    MinuteFormat.None, 
                    SecondFormat.None),
             };

            // Create date/time to format and display.
            DateTime dateTime = DateTime.Now;

            // Try to format and display date/time if calendar supports it.
            foreach (DateTimeFormatter formatter in templateFormatters)
            {
                try
                {
                    // Format and display date/time.
                    results.AppendLine(formatter.Template + ": " + formatter.Format(dateTime));
                }
                catch (ArgumentException)
                {
                    // Retrieve and display formatter properties. 
                    results.AppendLine(String.Format(
                        "Unable to format Gregorian DateTime {0} using formatter with template {1} for languages [{2}], region {3}, calendar {4} and clock {5}",
                        dateTime,
                        formatter.Template,
                        string.Join(",", formatter.Languages),
                        formatter.GeographicRegion,
                        formatter.Calendar,
                        formatter.Clock));
                }
            }

            // Display the results
            rootPage.NotifyUser(results.ToString(), NotifyType.StatusMessage);
        }
        public static void AddPathFigure(
            this D2D.GeometrySink sink, Jupiter.Media.PathFigure pathFigure)
        {
            sink.BeginFigure(
                pathFigure.StartPoint.ToSharpDX(),
                pathFigure.IsFilled ? D2D.FigureBegin.Filled : D2D.FigureBegin.Hollow);

            foreach (var segment in pathFigure.Segments)
            {
                sink.AddPathFigureSegment(segment);
            }

            sink.EndFigure(pathFigure.IsClosed ? D2D.FigureEnd.Closed : D2D.FigureEnd.Open);
        }
Exemplo n.º 12
0
        /// <summary>
        /// This is the click handler for the 'Default' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses the Windows.Globalization.DateTimeFormatting.DateTimeFormatter class
            // to format a date/time by using a formatter that provides specific languages,
            // geographic region, calendar and clock

            // We keep results in this variable
            StringBuilder results = new StringBuilder();
            results.AppendLine("Current default application context language: " + ApplicationLanguages.Languages[0]);
            results.AppendLine();

            // Create formatters with individual format specifiers for date/time elements.
            DateTimeFormatter[] templateFormatters = new[]
            {
                // Example formatters for dates using string templates.
                new DateTimeFormatter("longdate", new[] { "ja-JP", "en-US" }, "JP", CalendarIdentifiers.Japanese, ClockIdentifiers.TwelveHour),
                new DateTimeFormatter("month day", new[] { "fr-FR", "en-US" }, "FR", CalendarIdentifiers.Gregorian, ClockIdentifiers.TwentyFourHour),    

                // Example formatters using paranetrized date templates.
                new DateTimeFormatter(YearFormat.Abbreviated, 
                    MonthFormat.Abbreviated, 
                    DayFormat.Default, 
                    DayOfWeekFormat.None,
                    HourFormat.None,
                    MinuteFormat.None,
                    SecondFormat.None,
                    new[] { "de-DE", "en-US" },
                    "DE",
                    CalendarIdentifiers.Gregorian,
                    ClockIdentifiers.TwelveHour), 
            
                // Example formatters for times.
                new DateTimeFormatter("longtime", new[] { "ja-JP", "en-US" }, "JP", CalendarIdentifiers.Japanese, ClockIdentifiers.TwelveHour),
                new DateTimeFormatter("hour minute", new[] { "fr-FR", "en-US" }, "FR", CalendarIdentifiers.Gregorian, ClockIdentifiers.TwentyFourHour),    
                
                // Example formatters using paranetrized time templates.
                new DateTimeFormatter(YearFormat.None, 
                    MonthFormat.None, 
                    DayFormat.None, 
                    DayOfWeekFormat.None,
                    HourFormat.Default,
                    MinuteFormat.Default,
                    SecondFormat.None,
                    new[] { "de-DE" },
                    "DE",
                    CalendarIdentifiers.Gregorian,
                    ClockIdentifiers.TwelveHour),
             };

            // Create date/time to format and display.
            DateTime dateTime = DateTime.Now;

            // Try to format and display date/time if calendar supports it.
            foreach (DateTimeFormatter formatter in templateFormatters)
            {
                try
                {
                    // Format and display date/time.
                    results.AppendLine(formatter.Template + ": (" + formatter.ResolvedLanguage + ") " + formatter.Format(dateTime));
                }
                catch (ArgumentException)
                {
                    // Retrieve and display formatter properties. 
                    results.AppendLine(String.Format("Unable to format Gregorian DateTime {0} using formatter with template {1} for languages [{2}], region {3}, calendar {4} and clock {5}",
                        dateTime,
                        formatter.Template,
                        string.Join(",", formatter.Languages),
                        formatter.GeographicRegion,
                        formatter.Calendar,
                        formatter.Clock));
                }
            }

            // Display the results
            rootPage.NotifyUser(results.ToString(), NotifyType.StatusMessage);
        }
Exemplo n.º 13
0
        /// <summary>
        /// This is the click handler for the 'Default' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses the Windows.Globalization.DateTimeFormatting.DateTimeFormatter class
            // to format a date/time by using a formatter that provides specific languages,
            // geographic region, calendar and clock

            // We keep results in this variable
            StringBuilder results = new StringBuilder();
            results.AppendLine("Current default application context language: " + ApplicationLanguages.Languages[0]);
            results.AppendLine();

            // Create formatters with individual format specifiers for date/time elements.
            DateTimeFormatter[] templateFormatters = new[]
            {
                // Example formatters for dates using string templates.
                new DateTimeFormatter("longdate", new[] { "ja-JP", "en-US" }, "JP", CalendarIdentifiers.Japanese, ClockIdentifiers.TwelveHour),
                new DateTimeFormatter("month day", new[] { "fr-FR", "en-US" }, "FR", CalendarIdentifiers.Gregorian, ClockIdentifiers.TwentyFourHour),    

                // Example formatters using paranetrized date templates.
                new DateTimeFormatter(YearFormat.Abbreviated, 
                    MonthFormat.Abbreviated, 
                    DayFormat.Default, 
                    DayOfWeekFormat.None,
                    HourFormat.None,
                    MinuteFormat.None,
                    SecondFormat.None,
                    new[] { "de-DE", "en-US" },
                    "DE",
                    CalendarIdentifiers.Gregorian,
                    ClockIdentifiers.TwelveHour), 
            
                // Example formatters for times.
                new DateTimeFormatter("longtime", new[] { "ja-JP", "en-US" }, "JP", CalendarIdentifiers.Japanese, ClockIdentifiers.TwelveHour),
                new DateTimeFormatter("hour minute", new[] { "fr-FR", "en-US" }, "FR", CalendarIdentifiers.Gregorian, ClockIdentifiers.TwentyFourHour),    
                
                // Example formatters using paranetrized time templates.
                new DateTimeFormatter(YearFormat.None, 
                    MonthFormat.None, 
                    DayFormat.None, 
                    DayOfWeekFormat.None,
                    HourFormat.Default,
                    MinuteFormat.Default,
                    SecondFormat.None,
                    new[] { "de-DE" },
                    "DE",
                    CalendarIdentifiers.Gregorian,
                    ClockIdentifiers.TwelveHour),
             };

            // Create date/time to format and display.
            DateTime dateTime = DateTime.Now;

            // Format and display date/time. Calendar always supports Now. Otherwise you may need to verify dateTime is in supported range.
            foreach (DateTimeFormatter formatter in templateFormatters)
            {
                // Format and display date/time.
                results.AppendLine(formatter.Template + ": (" + formatter.ResolvedLanguage + ") " + formatter.Format(dateTime));
            }

            // Display the results
            OutputTextBlock.Text = results.ToString();
        }
        /// <summary>
        /// This is the click handler for the 'Default' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses the Windows.Globalization.DateTimeFormatting.DateTimeFormatter class
            // to format a date/time by using a formatter that uses Unicode extenstion in the specified
            // language name

            // We keep results in this variable
            StringBuilder results = new StringBuilder();
            results.AppendLine("Current default application context language: " + ApplicationLanguages.Languages[0]);
            results.AppendLine();

            // Create formatters using various types of constructors specifying Language list with unicode extension in language names
            DateTimeFormatter[] unicodeExtensionFormatters = new[]
            {
                // Default application context  
                new DateTimeFormatter("longdate longtime"),
                // Telugu language, Gregorian Calendar and Latin Numeral System
                new DateTimeFormatter("longdate longtime", new[] { "te-in-u-ca-gregory-nu-latn", "en-US" }),
                // Hebrew language and Arabic Numeral System - calendar NOT specified in constructor
                new DateTimeFormatter(YearFormat.Default, 
                    MonthFormat.Default, 
                    DayFormat.Default, 
                    DayOfWeekFormat.Default,
                    HourFormat.Default,
                    MinuteFormat.Default,
                    SecondFormat.Default,
                    new[] { "he-IL-u-nu-arab", "en-US" }),             
                // Hebrew language and calendar - calendar specified in constructor
                // also, which overrides the one specified in Unicode extension
                new DateTimeFormatter(YearFormat.Default, 
                    MonthFormat.Default, 
                    DayFormat.Default, 
                    DayOfWeekFormat.Default,
                    HourFormat.Default,
                    MinuteFormat.Default,
                    SecondFormat.Default,
                    new[] { "he-IL-u-ca-hebrew-co-phonebk", "en-US" },
                    "US",
                    CalendarIdentifiers.Gregorian,
                    ClockIdentifiers.TwentyFourHour), 
             };

            // Create date/time to format and display.
            DateTime dateTime = DateTime.Now;

            // Format and display date/time along with other relevant properites
            foreach (DateTimeFormatter formatter in unicodeExtensionFormatters)
            {
                // Format and display date/time.
                results.AppendLine("Using DateTimeFormatter with Language List:   " + string.Join(", ", formatter.Languages));
                results.AppendLine("\t Template:   " + formatter.Template);
                results.AppendLine("\t Resolved Language:   " + formatter.ResolvedLanguage);
                results.AppendLine("\t Calendar System:   " + formatter.Calendar);
                results.AppendLine("\t Numeral System:   " + formatter.NumeralSystem);
                results.AppendLine("Formatted DateTime:   " + formatter.Format(dateTime));
                results.AppendLine();
            }

            // Display the results
            OutputTextBlock.Text = results.ToString();
        }
 public static void AddLineGeometry(
     this D2D.GeometrySink sink, Jupiter.Media.LineGeometry lineGeometry)
 {
     sink.BeginFigure(
         lineGeometry.StartPoint.ToSharpDX(),
         D2D.FigureBegin.Hollow);
     sink.AddLine(
         lineGeometry.EndPoint.ToSharpDX());
     sink.EndFigure(D2D.FigureEnd.Open);
 }
 public static void AddRectangleGeometry(
     this D2D.GeometrySink sink, Jupiter.Media.RectangleGeometry rectangleGeometry)
 {
     sink.BeginFigure(
         new DrawingPointF(
             (float)(rectangleGeometry.Rect.Left),
             (float)(rectangleGeometry.Rect.Top)),
             D2D.FigureBegin.Filled);
     sink.AddLines(
         new []
         {
             new DrawingPointF(
                 (float)(rectangleGeometry.Rect.Right),
                 (float)(rectangleGeometry.Rect.Top)),
             new DrawingPointF(
                 (float)(rectangleGeometry.Rect.Right),
                 (float)(rectangleGeometry.Rect.Bottom)),
             new DrawingPointF(
                 (float)(rectangleGeometry.Rect.Left),
                 (float)(rectangleGeometry.Rect.Bottom)),
         });
     sink.EndFigure(D2D.FigureEnd.Closed);
 }
        /// <summary>
        /// Initializes the scenario
        /// </summary>
        /// <returns></returns>
        private async Task InitializeAsync(CancellationToken cancel = default(CancellationToken))
        {
            var streamFilteringCriteria = new
            {
                //AspectRatio = 1.333333333333333,
                HorizontalResolution = (uint)480,
                SubType = "YUY2"
            };
            currentState = State.Initializing;
            device = new CaptureDevice();

            CameraPreview.Visibility = Visibility.Collapsed;
            PreviewPoster.Visibility = Visibility.Visible;
            Preview.Content = "Start Preview";
            LoopbackClient.IsEnabled = false;

            mode = defaultMode;
            LatencyModeToggle.IsOn = (mode == LatencyMode.LowLatency);
            LatencyModeToggle.IsEnabled = false;

            await device.InitializeAsync();
            var setting = await device.SelectPreferredCameraStreamSettingAsync(MediaStreamType.VideoPreview, ((x) =>
            {
                var previewStreamEncodingProperty = x as Windows.Media.MediaProperties.VideoEncodingProperties;

                return (previewStreamEncodingProperty.Width >= streamFilteringCriteria.HorizontalResolution &&
                    previewStreamEncodingProperty.Subtype == streamFilteringCriteria.SubType);
            }));

            previewEncodingProperties = setting as VideoEncodingProperties;

            PreviewSetupCompleted();
        }
        public static void AddPathFigureSegment(
            this D2D.GeometrySink sink, Jupiter.Media.PathSegment segment)
        {
            var bezierSegment = segment as BezierSegment;

            if (bezierSegment != null)
            {
                sink.AddBezier(
                    new D2D.BezierSegment
                    {
                        Point1 = bezierSegment.Point1.ToSharpDX(),
                        Point2 = bezierSegment.Point2.ToSharpDX(),
                        Point3 = bezierSegment.Point3.ToSharpDX()
                    });
                return;
            }

            var lineSegment = segment as LineSegment;

            if (lineSegment != null)
            {
                sink.AddLine(
                    lineSegment.Point.ToSharpDX());
                return;
            }

            var polyBezierSegment = segment as PolyBezierSegment;

            if (polyBezierSegment != null)
            {
                var beziers = new D2D.BezierSegment[polyBezierSegment.Points.Count / 3];

                for (int i = 0; i < beziers.Length; i++)
                {
                    beziers[i].Point1 = polyBezierSegment.Points[i * 3].ToSharpDX();
                    beziers[i].Point2 = polyBezierSegment.Points[i * 3 + 1].ToSharpDX();
                    beziers[i].Point3 = polyBezierSegment.Points[i * 3 + 2].ToSharpDX();
                }

                sink.AddBeziers(beziers);
                return;
            }

            var polyLineSegment = segment as PolyLineSegment;

            if (polyLineSegment != null)
            {
                var lines = new SharpDX.DrawingPointF[polyLineSegment.Points.Count];

                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = polyLineSegment.Points[i].ToSharpDX();
                }

                sink.AddLines(lines);
                return;
            }

            var quadraticBezierSegment = segment as QuadraticBezierSegment;

            if (quadraticBezierSegment != null)
            {
                sink.AddQuadraticBezier(
                    new D2D.QuadraticBezierSegment
                    {
                        Point1 = quadraticBezierSegment.Point1.ToSharpDX(),
                        Point2 = quadraticBezierSegment.Point2.ToSharpDX()
                    });
                return;
            }

            var polyQuadraticBezierSegment = segment as PolyQuadraticBezierSegment;

            if (polyQuadraticBezierSegment != null)
            {
                var quadraticBeziers = new D2D.QuadraticBezierSegment[polyBezierSegment.Points.Count / 2];

                for (int i = 0; i < quadraticBeziers.Length; i++)
                {
                    quadraticBeziers[i].Point1 = polyBezierSegment.Points[i * 2].ToSharpDX();
                    quadraticBeziers[i].Point2 = polyBezierSegment.Points[i * 2 + 1].ToSharpDX();
                }

                sink.AddQuadraticBeziers(quadraticBeziers);
                return;
            }

            var arcSegment = segment as ArcSegment;

            if (arcSegment != null)
            {
                sink.AddArc(
                    new D2D.ArcSegment
                    {
                        Point = arcSegment.Point.ToSharpDX(),
                        Size = arcSegment.Size.ToSharpDX(),
                        RotationAngle = (float)arcSegment.RotationAngle,
                        SweepDirection = arcSegment.SweepDirection.ToSharpDX(),
                        ArcSize = arcSegment.IsLargeArc ? D2D.ArcSize.Large : D2D.ArcSize.Small
                    });
                return;
            }
        }
        /// <summary>
        /// This is the click handler for the 'Default' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses the Windows.Globalization.DateTimeFormatting.DateTimeFormatter class
            // to format a date/time by specifying a template via parameters.  Note that the user's language
            // and region preferences will determine the pattern of the date returned based on the
            // specified parts.

            // We keep results in this variable
            StringBuilder results = new StringBuilder();
            results.AppendLine("Current application context language: " + ApplicationLanguages.Languages[0]);
            results.AppendLine();

            // Create formatters with individual format specifiers for date/time elements.
            DateTimeFormatter[] dateFormatters = new[]
            {
                // Example formatters for dates.
                new DateTimeFormatter(
                    YearFormat.Full, 
                    MonthFormat.Abbreviated, 
                    DayFormat.Default, 
                    DayOfWeekFormat.Abbreviated),
                new DateTimeFormatter(
                    YearFormat.Abbreviated, 
                    MonthFormat.Abbreviated, 
                    DayFormat.Default, 
                    DayOfWeekFormat.None),
                new DateTimeFormatter(
                    YearFormat.Full, 
                    MonthFormat.Full, 
                    DayFormat.None, 
                    DayOfWeekFormat.None),
                new DateTimeFormatter(
                    YearFormat.None, 
                    MonthFormat.Full, 
                    DayFormat.Default, 
                    DayOfWeekFormat.None)
            };

            // Create formatters with individual format specifiers for time elements.
            DateTimeFormatter[] timeFormatters = new[]
            {
                // Example formatters for times.
                new DateTimeFormatter(
                    HourFormat.Default, 
                    MinuteFormat.Default, 
                    SecondFormat.Default),
                new DateTimeFormatter(
                    HourFormat.Default, 
                    MinuteFormat.Default, 
                    SecondFormat.None),
                new DateTimeFormatter(
                    HourFormat.Default, 
                    MinuteFormat.None, 
                    SecondFormat.None),
             };

            // Create date/time to format and display.
            DateTime dateTime = DateTime.Now;

            results.AppendLine("Formatted Dates:");
            results.AppendLine();

            // Format and display date/time. Calendar always supports Now. Otherwise you may need to verify dateTime is in supported range.
            foreach (DateTimeFormatter formatter in dateFormatters)
            {
                // Format and display date/time.
                results.AppendLine(formatter.Template + ": " + formatter.Format(dateTime));
            }

            results.AppendLine();
            results.AppendLine("Formatted Times:");
            results.AppendLine();

            // Format and display date/time. Calendar always supports Now. Otherwise you may need to verify dateTime is in supported range.
            foreach (DateTimeFormatter formatter in timeFormatters)
            {
                // Format and display date/time.
                results.AppendLine(formatter.Template + ": " + formatter.Format(dateTime));
            }

            // Display the results
            OutputTextBlock.Text = results.ToString();
        }