Ejemplo n.º 1
1
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            產生手寫軌跡的測試資料();
            solidColorBrush1 = new SolidColorBrush(ColorsHelper.Parse("ff1a1a1a"));
            solidColorBrush2 = new SolidColorBrush(ColorsHelper.Parse("ff999999"));
            solidColorBrush3 = new SolidColorBrush(ColorsHelper.Parse("ffff0000"));
            solidColorBrush4 = new SolidColorBrush(ColorsHelper.Parse("ff006cff"));
            solidColorBrush5 = new SolidColorBrush(ColorsHelper.Parse("ff0da522"));

            wbContentImage = BitmapFactory.New(768, 1024);
            wbContentImage.Clear(Colors.Transparent);
            cnUsingWriteableBitmap.Source = wbContentImage;


            d2dBrush = new ImageBrush();
            cnUsingGeometries.Background = d2dBrush;

            // Safely dispose any previous instance
            // Creates a new DeviceManager (Direct3D, Direct2D, DirectWrite, WIC)
            deviceManager = new DeviceManager();

            shapeRenderer = new ShapeRenderer();
            DisplayInformation DisplayInformation = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();
            int pixelWidth = (int)(cnUsingGeometries.Width * DisplayInformation.LogicalDpi / 96.0);
            int pixelHeight = (int)(cnUsingGeometries.Height * DisplayInformation.LogicalDpi / 96.0);

            d2dTarget = new SurfaceImageSourceTarget(pixelWidth, pixelHeight);
            d2dBrush.ImageSource = d2dTarget.ImageSource;
            imgUsingInkManager.Source = d2dTarget.ImageSource;

            // Add Initializer to device manager
            deviceManager.OnInitialize += d2dTarget.Initialize;
            deviceManager.OnInitialize += shapeRenderer.Initialize;

            // Render the cube within the CoreWindow
            d2dTarget.OnRender += shapeRenderer.Render;

            // Initialize the device manager and all registered deviceManager.OnInitialize 
            deviceManager.Initialize(DisplayProperties.LogicalDpi);

            // Setup rendering callback
            //CompositionTarget.Rendering += CompositionTarget_Rendering;

            // Callback on DpiChanged
            DisplayProperties.LogicalDpiChanged += DisplayProperties_LogicalDpiChanged;

            #region Scenario1
            Scenario1Drawing = new Scenario1ImageSource((int)cnUsingDirectXs.Width, (int)cnUsingDirectXs.Height, true);

            // Use Scenario1Drawing as a source for the Ellipse shape's fill
            cnUsingDirectXs.Background = new ImageBrush() { ImageSource = Scenario1Drawing };
            #endregion
        }
Ejemplo n.º 2
0
        public Scenario1()
        {
            this.InitializeComponent();

            Scenario1Drawing = new Scenario1ImageSource((int)Image1.Width, (int)Image1.Height, true);

            // Use Scenario1Drawing as a source for the Image control
            Image1.Source = Scenario1Drawing;
            // Use Scenario1Drawing as a source for the Ellipse shape's fill
            Ellipse1.Fill = new ImageBrush() { ImageSource = Scenario1Drawing };
        }