public async System.Threading.Tasks.Task AfterOpen() { CanvasCase canvasCase = currentController.CurrentCanvasCase; DocumentTitle.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Name"), Source = canvasCase, Mode = BindingMode.TwoWay }); DCUI_Canvas.SetCanvasCase(canvasCase); LayoutsPanel.SetCanvasCase(canvasCase); BrushPanel.SetCanvasCase(canvasCase); ColorAndOtherPanel.SetCanvasCase(canvasCase); BlendModePanel.SetCanvasCase(canvasCase); LayoutInfoPanel.SetCanvasCase(canvasCase); foreach (Core.Brush brush in canvasCase.PaintAgent.brushes) { if (!string.IsNullOrEmpty(brush.ImagePath)) { try { StorageFile f = await currentController.CurrentDCDocument.brushesFolder.GetFileAsync(brush.ImagePath); BitmapImage image = new BitmapImage(); image.SetSource(await f.OpenReadAsync()); ImageBrush imageBrush = new ImageBrush { ImageSource = image }; brush.UIBrush = imageBrush; } catch { brush.UIBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(0xFF, 0xC0, 0xC0, 0xC0)); } } else { brush.UIBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(0xFF, 0xC0, 0xC0, 0xC0)); } for (int i = 0; i < Core.Brush.c_refTextureCount; i++) { if (!string.IsNullOrEmpty(brush.RefTexturePath[i])) { try { StorageFile f = await currentController.CurrentDCDocument.brushesFolder.GetFileAsync(brush.RefTexturePath[i]); var stream = await f.OpenReadAsync(); byte[] array = new byte[stream.Size]; DataReader dataReader = new DataReader(stream); await dataReader.LoadAsync((uint)stream.Size); dataReader.ReadBytes(array); brush.refTexture[i] = RenderTexture.LoadFromBytes(canvasCase.DeviceResources, array, currentController.CImport); } catch { } } } } }
/// <summary> /// 创建一个新的绘画代理。 /// </summary> public PaintAgent(CanvasCase canvasCase) { CanvasCase = canvasCase; }
public ViewRenderer(CanvasCase canvasCase) { CanvasCase = canvasCase; }