Пример #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
        }
Пример #2
0
        public void 左邊頁面繪圖裝置初始化()
        {
            d2dBrush = new ImageBrush();
            canvas左邊手寫畫板.Background = d2dBrush;

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

            頁面手寫物件軌跡ShapeRender_左 = new 頁面手寫物件軌跡ShapeRender();
            頁面手寫物件軌跡ShapeRender_左.頁面手寫物件軌跡 = 頁面手寫物件軌跡_左;

            //Rect cnUsingGeometries = new Rect();
            //cnUsingGeometries.Width = 1024;
            //cnUsingGeometries.Height = 768;
            DisplayInformation DisplayInformation = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();
            Debug.WriteLine("DPI {0}", DisplayInformation.LogicalDpi);
            int pixelWidth = (int)(canvas左邊手寫畫板.Width * DisplayInformation.LogicalDpi / 96.0);
            int pixelHeight = (int)(canvas左邊手寫畫板.Height * DisplayInformation.LogicalDpi / 96.0);

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

            // Add Initializer to device manager
            deviceManager.OnInitialize += d2dTarget.Initialize;
            deviceManager.OnInitialize += 頁面手寫物件軌跡ShapeRender_左.Initialize;

            // Render the cube within the CoreWindow
            d2dTarget.OnRender += 頁面手寫物件軌跡ShapeRender_左.Render;

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

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

            // Callback on DpiChanged
        }