/* * 12 Gif */ public static Gif newGif(DControl ctl, StorageGif storageGif, Boolean isDesign) { string imgPath = FileUtil.notExistsShowDefault(storageGif?.url, Params.GifNotExists); string imgFullPath = AppDomain.CurrentDomain.BaseDirectory + imgPath; DControlDto dto = DControlUtil.convert(ctl); dto.url = imgFullPath; Gif gif = new Gif(imgPath, isDesign); gif.HorizontalAlignment = HorizontalAlignment.Left; gif.VerticalAlignment = VerticalAlignment.Top; gif.Margin = new Thickness(ctl.left, ctl.top, 0, 0); gif.Width = ctl.width; gif.Height = ctl.height; gif.Background = Brushes.Transparent; gif.Opacity = ctl.opacity / 100.0; Panel.SetZIndex(gif, ctl.idx); gif.Focusable = false; gif.Tag = dto; TransformGroup group = new TransformGroup(); gif.RenderTransform = group; gif.RenderTransformOrigin = new Point(0.5, 0.5); RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group); rotateTransform.Angle = ctl.rotateAngle; gif.Visibility = Visibility.Visible; return(gif); }
/* * 1 插入图片 */ public static Button newImage(DControl ctl, StorageImage storageImage) { string imgFullPath = FileUtil.notExistsShowDefault(storageImage?.url, Params.ImageNotExists); DControlDto dto = DControlUtil.convert(ctl); dto.url = imgFullPath; Button imageButton = new Button(); imageButton.Name = ctl.type + dto.id; imageButton.Content = ctl.content; //imageButton.Background = new ImageBrush //{ // ImageSource = FileUtil.readImage2(AppDomain.CurrentDomain.BaseDirectory + imgFullPath, ctl.width) // , // Stretch = Stretch.Fill //}; imageButton.Background = Brushes.Transparent; FileUtil.readImage2Button(imageButton, AppDomain.CurrentDomain.BaseDirectory + imgFullPath, ctl.width, Stretch.Fill); imageButton.BorderThickness = new Thickness(0); imageButton.Margin = new Thickness(ctl.left, ctl.top, 0, 0); imageButton.Width = ctl.width; imageButton.Height = ctl.height; imageButton.HorizontalAlignment = HorizontalAlignment.Left; imageButton.VerticalAlignment = VerticalAlignment.Top; imageButton.Opacity = ctl.opacity / 100.0; Panel.SetZIndex(imageButton, ctl.idx); imageButton.Tag = dto; imageButton.Focusable = false; TransformGroup group = new TransformGroup(); RotateTransform rotateTransform = TransformGroupUtil.GetRotateTransform(group); rotateTransform.Angle = ctl.rotateAngle; imageButton.RenderTransform = group; imageButton.RenderTransformOrigin = new Point(0.5, 0.5); return(imageButton); }