private void OnDraw(object sender, DrawToolTipEventArgs e) // use this event to customise the tool tip { // Set our background Graphics g = e.Graphics; var n = BackgroundImage.Clone() as Bitmap; var rectSz = e.Bounds.Size; n = ResizeBitmap(n, rectSz.Width, rectSz.Height); g.Clear(Color.FromArgb(50, 50, 50)); g.DrawImage(n, 0, 0); e.DrawBorder(); // Draw our ToolTip title var rectF = new RectangleF(new PointF(8, TitleFont.Height + 10), new Size(tSize.Width - 8, tSize.Height)); if (MaxWidth != 0) { g.DrawString(ToolTipDescription, DescriptionFont, DescriptionBrush, rectF); } else { g.DrawString(ToolTipDescription, DescriptionFont, DescriptionBrush, rectF.Location); }; g.DrawString((Prefix + this.ToolTipTitle + Suffix).Trim('\n'), TitleFont, TitleBrush, new PointF(6, 4)); }
public object Clone() { PmsPageSplitter layout = new PmsPageSplitter(); layout.Name = Name; layout.AutoSize = AutoSize; layout.BackColor = BackColor; if (null != BackgroundImage) { layout.BackgroundImage = BackgroundImage.Clone() as Image; } layout.BackgroundImageLayout = BackgroundImageLayout; if (null != Border) { layout.Border = Border.Clone() as ElementBorder; layout.Border.OwnerElement = layout; } layout.BorderName = BorderName; if (null != ExternDatas) { layout.ExternDatas = new List <ExternData>(); foreach (ExternData ed in ExternDatas) { object value = ed.Value; if (null != value && value is ICloneable) { value = ((ICloneable)value).Clone(); } layout.ExternDatas.Add(new ExternData(ed.Key, value)); } } if (null != Font) { layout.Font = Font.Clone() as Font; } layout.HasBorder = HasBorder; layout.HasBottomBorder = HasBottomBorder; layout.HasLeftBorder = HasLeftBorder; layout.HasRightBorder = HasRightBorder; layout.HasTopBorder = HasTopBorder; layout.Height = Height; layout.HorizontalScale = HorizontalScale; layout.Location = Location; layout.MESType = MESType; layout.MoveX = MoveX; layout.MoveY = MoveY; layout.Text = Text; layout.VerticalScale = VerticalScale; layout.Width = Width; layout.Visible = Visible; layout.MESType = MESType; layout.EnableSplitter = EnableSplitter; layout.VisibleExpression = VisibleExpression; if (null != ((IElement)this).ExtendObject) { ((IElement)layout).ExtendObject = ((IElement)this).ExtendObject.Clone() as ExtendObject; } return(layout); }
private void Undo() { if (OperateStack.Count > 0) { BackgroundImage = OperateStack.Pop(); } if (OperateStack.Count == 0) { OperateStack.Push((Image)BackgroundImage.Clone()); } }
/// <summary> /// Paints the background of the control. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"/> that contains the event data.</param> /// <remarks>Documented by Dev07, 2009-05-05</remarks> protected override void OnPaintBackground(PaintEventArgs e) { if (ComponentsHelper.IsResizing) { if (BackgroundImage != null) { BackupBackgroundImage = BackgroundImage.Clone() as Image; BackgroundImage = null; } base.OnPaintBackground(e); } else if (!ComponentsHelper.IsResizing) { if (BackupBackgroundImage != null) { BackgroundImage = BackupBackgroundImage; BackupBackgroundImage = null; } base.OnPaintBackground(e); using (Graphics g = e.Graphics) { //paint Image if (imageRightCorner != null) { Size size = new Size(imageRightCorner.Width, imageRightCorner.Height); Point start = new Point(this.Width - size.Width - 5, this.Height - size.Height - 10); if (this.Width < imageRightCorner.Width) { do { double factor = 0.5; size = new Size((int)(imageRightCorner.Width * factor), (int)(imageRightCorner.Height * factor)); start = new Point(this.Width - size.Width - 5, this.Height - size.Height - 10); } while (this.Width <= size.Width); } Rectangle dest = new Rectangle(start, size); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.DrawImage(imageRightCorner, dest); } } } }
/// <summary> /// 绘制终止 /// </summary> private void EndDrawSomething() { backPrinter = Graphics.FromImage(BackgroundImage); switch (paintType) { case PaintType.Rectangle: backPrinter.DrawRectangle(pen, getRectangle(lineStart, lineEnd)); break; case PaintType.Ellipse: backPrinter.DrawEllipse(pen, getRectangleF(lineStart, lineEnd)); break; case PaintType.Arrow: backPrinter.DrawLine(getArrowPen(pen), lineStart, lineEnd); break; case PaintType.StraightLine: backPrinter.DrawLine(pen, lineStart, lineEnd); break; case PaintType.Dashed: backPrinter.DrawLine(getDashPen(pen), lineStart, lineEnd); break; case PaintType.Lines: if (points.Count >= 2) { backPrinter.DrawCurve(pen, points.ToArray()); } break; } painter.Clear(Color.Transparent); backPrinter.Flush(); var img = (Image)BackgroundImage.Clone(); OperateStack.Push(img); points = new List <PointF>(); }
/// <summary> /// 克隆 /// </summary> /// <returns>对象</returns> public object Clone() { BarCodeWrapper bcw = new BarCodeWrapper(); bcw.Name = Name; bcw.AutoSize = AutoSize; bcw.BackColor = BackColor; if (null != BackgroundImage) { bcw.BackgroundImage = BackgroundImage.Clone() as Image; } bcw.BackgroundImageLayout = BackgroundImageLayout; if (null != Border) { bcw.Border = Border.Clone() as ElementBorder; bcw.Border.OwnerElement = bcw; } bcw.BorderName = BorderName; if (null != ExternDatas) { bcw.ExternDatas = new List <ExternData>(); foreach (ExternData ed in ExternDatas) { object value = ed.Value; if (null != value && value is ICloneable) { value = ((ICloneable)value).Clone(); } bcw.ExternDatas.Add(new ExternData(ed.Key, value)); } } if (null != Font) { bcw.Font = Font.Clone() as Font; } bcw.HasBorder = HasBorder; bcw.HasBottomBorder = HasBottomBorder; bcw.HasLeftBorder = HasLeftBorder; bcw.HasRightBorder = HasRightBorder; bcw.HasTopBorder = HasTopBorder; bcw.Height = Height; bcw.HorizontalScale = HorizontalScale; bcw.Location = Location; bcw.MESType = MESType; bcw.MoveX = MoveX; bcw.MoveY = MoveY; bcw.Parent = Parent; bcw.Text = Text; bcw.VerticalScale = VerticalScale; bcw.Width = Width; if (null != SourceField) { bcw.SourceField = SourceField.Clone(); } bcw.EnableMapping = EnableMapping; bcw.MappingTable = MappingTable; bcw.Expression = Expression; bcw.RealText = RealText; bcw.IncludeLabel = IncludeLabel; bcw.BarCodeAlign = BarCodeAlign; bcw.BarCodeType = BarCodeType; bcw.Visible = Visible; bcw.MESType = MESType; if (null != ((IElement)this).ExtendObject) { ((IElement)bcw).ExtendObject = ((IElement)this).ExtendObject.Clone() as ExtendObject; } return(bcw); }
public IControlTranslator ToElement(bool transferChild) { PmsEditWrapper edit = new PmsEditWrapper(); edit.Name = Name; edit.AutoSize = AutoSize; edit.BackColor = BackColor; if (null != BackgroundImage) { edit.BackgroundImage = BackgroundImage.Clone() as Image; } edit.BackgroundImageLayout = BackgroundImageLayout; if (null != ((IElement)this).Border) { edit.Border = ((IElement)this).Border.Clone() as ElementBorder; edit.Border.OwnerElement = edit; } edit.BorderName = ((IElement)this).BorderName; if (null != ((IElement)this).ExternDatas) { edit.ExternDatas = new List <ExternData>(); foreach (ExternData ed in ((IElement)this).ExternDatas) { object value = ed.Value; if (null != value && value is ICloneable) { value = ((ICloneable)value).Clone(); } edit.ExternDatas.Add(new ExternData(ed.Key, value)); } } if (_orginalFontSize > 0) { edit.Font = new Font(Font.FontFamily, _orginalFontSize); } else { edit.Font = new Font(this.Font.FontFamily, this.Font.Size); } edit.VerticalScale = 1f; edit.HorizontalScale = 1f; edit.HasBorder = ((IElement)this).HasBorder; edit.HasBottomBorder = ((IElement)this).HasBottomBorder; edit.HasLeftBorder = ((IElement)this).HasLeftBorder; edit.HasRightBorder = ((IElement)this).HasRightBorder; edit.HasTopBorder = ((IElement)this).HasTopBorder; edit.Visible = Visible; edit.MESType = MESType; if (_orginalHeight > 0) { edit.Height = this._orginalHeight; } else { edit.Height = this.Height; } if (_orginalWidth > 0) { edit.Width = _orginalWidth; } else { edit.Width = this.Width; } //edit.VerticalScale = this.VerticalScale; //edit.HorizontalScale = this.HorizontalScale; if (_orginalLocation != Point.Empty) { edit.Location = this._orginalLocation; } else { edit.Location = this.Location; } edit.MESType = MESType; edit.MoveX = ((IElement)this).MoveX; edit.MoveY = ((IElement)this).MoveY; edit.Text = Text; edit.VerticalScale = VerticalScale; edit.RealText = RealText; edit.BorderStyle = BorderStyle; edit.Var = Var; if (null != ((IElement)this).ExtendObject) { ((IElement)edit).ExtendObject = ((IElement)this).ExtendObject.Clone() as ExtendObject; } return(edit); }
public IControlTranslator ToElement(bool transferChild) { PmsFlowLayoutWrapper layout = new PmsFlowLayoutWrapper(); layout.Name = Name; layout.AutoSize = AutoSize; layout.BackColor = BackColor; if (null != BackgroundImage) { layout.BackgroundImage = BackgroundImage.Clone() as Image; } layout.BackgroundImageLayout = BackgroundImageLayout; if (null != Border) { layout.Border = Border.Clone() as ElementBorder; } layout.BorderName = BorderName; if (null != ExternDatas) { layout.ExternDatas = new List <ExternData>(); foreach (ExternData ed in ExternDatas) { object value = ed.Value; if (null != value && value is ICloneable) { value = ((ICloneable)value).Clone(); } layout.ExternDatas.Add(new ExternData(ed.Key, value)); } } layout.ObjectPadding = this.ObjectPadding; layout.RowPadding = this.RowPadding; layout.IsVerticalLayout = IsVerticalLayout; if (_orginalFontSize > 0) { layout.Font = new Font(Font.FontFamily, _orginalFontSize); } else { layout.Font = new Font(this.Font.FontFamily, this.Font.Size); } layout.VerticalScale = 1f; layout.HorizontalScale = 1f; layout.HasBorder = HasBorder; layout.HasBottomBorder = HasBottomBorder; layout.HasLeftBorder = HasLeftBorder; layout.HasRightBorder = HasRightBorder; layout.HasTopBorder = HasTopBorder; layout.Location = Location; layout.MESType = MESType; layout.MoveX = MoveX; layout.MoveY = MoveY; layout.Text = Text; layout.Visible = Visible; layout.MESType = MESType; if (_orginalHeight > 0) { layout.Height = this._orginalHeight; } else { layout.Height = this.Height; } if (_orginalWidth > 0) { layout.Width = _orginalWidth; } else { layout.Width = this.Width; } //layout.VerticalScale = this.VerticalScale; //layout.HorizontalScale = this.HorizontalScale; if (_orginalLocation != Point.Empty) { layout.Location = this._orginalLocation; } else { layout.Location = this.Location; } layout.MESMargin = new Padding(MESMargin.Left, MESMargin.Top, MESMargin.Right, MESMargin.Bottom); if (null != ((IElement)this).ExtendObject) { ((IElement)layout).ExtendObject = ((IElement)this).ExtendObject.Clone() as ExtendObject; } return(layout); }
private void InitializeWindow() { //全屏 var sc = Screen.PrimaryScreen.Bounds; this.Size = sc.Size; this.WindowState = FormWindowState.Maximized; var screen = new ScreenCapture(); this.BackgroundImage = screen.CaptureScreen(); OperateStack.Push((Image)BackgroundImage.Clone()); this.printer.Image = new Bitmap(sc.Width, sc.Height); painter = Graphics.FromImage(printer.Image); //painter. this.KeyPress += Drawer_KeyPress; printer.MouseDown += Printer_MouseDown; printer.MouseUp += Printer_MouseUp; printer.MouseMove += Printer_MouseMove; pen = new Pen(Color.RoyalBlue, 5); PointF p1 = new PointF(0, 0); PointF p2 = new PointF(100, 100); //PathGradientBrush pathGradientBrush = new PathGradientBrush(new[] { new PointF(0, 0), new PointF(0, 100), new PointF(100, 100), new PointF(100, 0) }); //pathGradientBrush.CenterColor = Color.Red; //pathGradientBrush.CenterPoint = new PointF(50, 50); //******************************************************************* //Blend blend = new Blend(); //// Create point and positions arrays //float[] factArray = { 0.0f, 0.3f, 0.5f, 1.0f }; //float[] posArray = { 0.0f, 0.2f, 0.6f, 1.0f }; //// Set Factors and Positions properties of Blend //blend.Factors = factArray; //blend.Positions = posArray; //// Create path and add a rectangle //GraphicsPath path = new GraphicsPath(); //Rectangle rect = new Rectangle(10, 20, 200, 200); //path.AddRectangle(rect); //// Create path gradient brush //PathGradientBrush rgBrush = // new PathGradientBrush(path); //// Set Blend and FocusScales properties //rgBrush.Blend = blend; //rgBrush.FocusScales = new PointF(0.6f, 0.2f); //Color[] colors = { Color.Green }; //// Set CenterColor and SurroundColors properties //rgBrush.CenterColor = Color.Red; //rgBrush.SurroundColors = colors; //****************************************************************** PenAlpha = 125; pen = new Pen(Color.FromArgb(120, 255, 0, 0), 5); }
public IControlTranslator ToElement(bool transferChild) { QRCodeWrapper bcw = new QRCodeWrapper(); bcw.Name = Name; bcw.AutoSize = AutoSize; bcw.BackColor = BackColor; if (null != BackgroundImage) { bcw.BackgroundImage = BackgroundImage.Clone() as Image; } bcw.BackgroundImageLayout = BackgroundImageLayout; if (null != Border) { bcw.Border = Border.Clone() as ElementBorder; bcw.Border.OwnerElement = bcw; } bcw.BorderName = BorderName; if (null != ExternDatas) { bcw.ExternDatas = new List <ExternData>(); foreach (ExternData ed in ExternDatas) { object value = ed.Value; if (null != value && value is ICloneable) { value = ((ICloneable)value).Clone(); } bcw.ExternDatas.Add(new ExternData(ed.Key, value)); } } bcw.Font = Font.Clone() as Font; bcw.HasBorder = HasBorder; bcw.HasBottomBorder = HasBottomBorder; bcw.HasLeftBorder = HasLeftBorder; bcw.HasRightBorder = HasRightBorder; bcw.HasTopBorder = HasTopBorder; // bcw.Height = Height; bcw.HorizontalScale = 1f; //bcw.Location = Location; bcw.MESType = MESType; bcw.MoveX = MoveX; bcw.MoveY = MoveY; //bcw.Parent = Parent; bcw.Text = Text; bcw.VerticalScale = 1f; bcw.Visible = Visible; bcw.MESType = MESType; //bcw.Width = Width; if (null != SourceField) { bcw.SourceField = SourceField.Clone(); } if (_orginalHeight > 0) { bcw.Height = this._orginalHeight; } else { bcw.Height = this.Height; } if (_orginalWidth > 0) { bcw.Width = _orginalWidth; } else { bcw.Width = this.Width; } //label.VerticalScale = this.VerticalScale; //label.HorizontalScale = this.HorizontalScale; if (_orginalLocation != Point.Empty) { bcw.Location = this._orginalLocation; } else { bcw.Location = this.Location; } bcw.EnableMapping = EnableMapping; bcw.MappingTable = MappingTable; bcw.Expression = Expression; bcw.RealText = RealText; bcw.IncludeLabel = IncludeLabel; bcw.CorrectionLevel = CorrectionLevel; bcw.EncodedMode = EncodedMode; if (null != ((IElement)this).ExtendObject) { bcw.ExtendObject = ((IElement)this).ExtendObject.Clone() as ExtendObject; } return(bcw); }
//protected override void OnNotifyMessage(Message m) //{ // base.OnNotifyMessage(m); //} protected override void OnPaintBackground(PaintEventArgs e) { if (BackgroundImage == null) { base.OnPaintBackground(e); return; } var bufferedGraphicsContext = new BufferedGraphicsContext(); BufferedGraphics bufferedGraphics = bufferedGraphicsContext.Allocate(e.Graphics, e.ClipRectangle); using (Graphics g = bufferedGraphics.Graphics) { g.CompositingQuality = CompositingQuality.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBilinear; g.SmoothingMode = SmoothingMode.AntiAlias; //IntPtr graphicsBufferHfc; //IntPtr hdcIntPtr; switch (BackgroundImageLayout) { case ImageLayout.None: break; case ImageLayout.Tile: break; case ImageLayout.Center: break; case ImageLayout.Stretch: float scaleX = BackgroundImage.Width / (float)Width; float scaleY = BackgroundImage.Height / (float)Height; //if (y > 0) //{ // y = y * (BackgroundImage.Width / e.ClipRectangle.Width); //} var srcRect = new Rectangle(Convert.ToInt32(scaleX * e.ClipRectangle.X), Convert.ToInt32(scaleY * e.ClipRectangle.Y), Convert.ToInt32(e.ClipRectangle.Width * scaleX), Convert.ToInt32(e.ClipRectangle.Height * scaleY)); g.DrawImage(BackgroundImage, e.ClipRectangle, srcRect, GraphicsUnit.Pixel); break; case ImageLayout.Zoom: var renderImage = (Image)BackgroundImage.Clone(); g.Clear(Color.White); g.DrawImageUnscaled(renderImage, 0, 0, renderImage.Width, renderImage.Height); g.ScaleTransform(BackgroundImage.Width / (float)Width, renderImage.Height / (float)Height, MatrixOrder.Prepend); //hdcIntPtr = e.Graphics.GetHdc(); bufferedGraphics.Render(e.Graphics); //e.Graphics.ReleaseHdc(hdcIntPtr); break; default: throw new ArgumentOutOfRangeException(); } bufferedGraphics.Render(); bufferedGraphics.Dispose(); } //bufferedGraphics.Graphics.ReleaseHdc(graphicsBufferHfc); //bufferedGraphics.Graphics.Dispose(); bufferedGraphicsContext.Dispose(); //bufferedGraphicsContext.Invalidate(); //base.OnPaintBackground(e); }
/// <summary> /// 克隆 /// </summary> /// <returns>对象</returns> public object Clone() { PmsEditWrapper edit = new PmsEditWrapper(); edit.Name = Name; edit.AutoSize = AutoSize; edit.BackColor = BackColor; if (null != BackgroundImage) { edit.BackgroundImage = BackgroundImage.Clone() as Image; } edit.BackgroundImageLayout = BackgroundImageLayout; if (null != Border) { edit.Border = Border.Clone() as ElementBorder; edit.Border.OwnerElement = edit; } edit.BorderName = BorderName; if (null != ExternDatas) { edit.ExternDatas = new List <ExternData>(); foreach (ExternData ed in ExternDatas) { object value = ed.Value; if (null != value && value is ICloneable) { value = ((ICloneable)value).Clone(); } edit.ExternDatas.Add(new ExternData(ed.Key, value)); } } if (null != Font) { edit.Font = Font.Clone() as Font; } edit.HasBorder = HasBorder; edit.HasBottomBorder = HasBottomBorder; edit.HasLeftBorder = HasLeftBorder; edit.HasRightBorder = HasRightBorder; edit.HasTopBorder = HasTopBorder; edit.Height = Height; edit.HorizontalScale = HorizontalScale; edit.Location = Location; edit.MESType = MESType; edit.MoveX = MoveX; edit.MoveY = MoveY; edit.Parent = Parent; edit.Text = Text; edit.VerticalScale = VerticalScale; edit.Width = Width; edit.RealText = RealText; edit.BorderStyle = BorderStyle; edit.Var = Var; edit.Visible = Visible; edit.MESType = MESType; if (null != ((IElement)this).ExtendObject) { ((IElement)edit).ExtendObject = ((IElement)this).ExtendObject.Clone() as ExtendObject; } return(edit); }