コード例 #1
0
		//[DebuggerStepThrough]
		void OnSelectPicture()
		{
			var openFileDialog = new OpenFileDialog();
			openFileDialog.Filter = ImageExtensions.GraphicFilter;
			if (openFileDialog.ShowDialog().Value)
				using (new WaitWrapper())
				{
					_newImage = true;
					_sourceName = openFileDialog.FileName;
					if (ImageExtensions.IsSVGGraphics(_sourceName))
					{
						_drawing = SVGConverters.ReadDrawing(_sourceName);
						_wmf = null;
						ImageBrush = new DrawingBrush(_drawing);
						_imageType = ResourceType.Drawing;
						_svg = File.ReadAllBytes(_sourceName);
					}
					else if (ImageExtensions.IsWMFGraphics(_sourceName))
					{
						_wmf = WMFConverter.ReadWMF(_sourceName);
						_drawing = _wmf == null ? null : _wmf.ToDrawing();
						if (_drawing == null)
						{
							ImageBrush = new VisualBrush(_wmf.Canvas);
							_imageType = ResourceType.Visual;
						}
						else
						{
							_wmf = null;
							ImageBrush = new DrawingBrush(_drawing);
							_imageType = ResourceType.Drawing;
						}
					}
					else
					{
						_drawing = null;
						_wmf = null;

						if (new FileInfo(_sourceName).Length > 0)
						{
							ImageBrush = new ImageBrush(new BitmapImage(new Uri(_sourceName)));
							_imageType = ResourceType.Image;
						}
						else
						{
							MessageBoxService.Show("Невозможно загрузить пустое изображение");
							return;
						}

					}
					OnPropertyChanged(() => ImageBrush);
					if (UpdateProperty != null)
						UpdateProperty(false);
				}
		}
コード例 #2
0
		void OnSelectPicture()
		{
			var openFileDialog = new OpenFileDialog();
			openFileDialog.Filter = ImageExtensions.GraphicFilter;
			if (openFileDialog.ShowDialog().Value)
				using (new WaitWrapper())
				{
					_sourceName = openFileDialog.FileName;
					if (ImageExtensions.IsSVGGraphics(_sourceName))
					{
						_drawing = SVGConverters.ReadDrawing(_sourceName);
						_wmf = null;
						ImageBrush = new DrawingBrush(_drawing);
						_svg = File.ReadAllBytes(_sourceName);
					}
					else if (ImageExtensions.IsWMFGraphics(_sourceName))
					{
						_wmf = WMFConverter.ReadWMF(_sourceName);
						_drawing = _wmf == null ? null : _wmf.ToDrawing();
						if (_drawing == null)
							ImageBrush = new VisualBrush(_wmf.Canvas);
						else
						{
							_wmf = null;
							ImageBrush = new DrawingBrush(_drawing);
						}
					}
					else
					{
						_drawing = null;
						_wmf = null;
						ImageBrush = new ImageBrush(new BitmapImage(new Uri(_sourceName)));
					}
					_imageChanged = true;
				}
		}