/// <summary> /// Default constructor. /// </summary> // public SmtpAttachment():base(){} /// <summary> /// Constructor for passing all information at once. /// </summary> /// <param name="fileName">File to send.</param> /// <param name="contentType">Content type of file (application/octet-stream for regular attachments.)</param> /// <param name="location">Where to put the attachment.</param> public MimeAttachment(string fileName, ContentType contentType, AttachmentLocation location) : base(fileName) { FileName = fileName; ContentType = contentType; Location = location; }
/// <summary> /// Default constructor. /// </summary> // public SmtpAttachment():base(){} /// <summary> /// Constructor for passing all information at once. /// </summary> /// <param name="fileName">File to send.</param> /// <param name="contentType">Content type of file (application/octet-stream for regular attachments.)</param> /// <param name="location">Where to put the attachment.</param> public MimeAttachment(string fileName, ContentType contentType, AttachmentLocation location) : base(fileName) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentException(nameof(fileName)); } FileName = fileName; ContentType = contentType; Location = location; }
/// <summary> /// Attach a <see cref="Renderbuffer"/> object to the currently bound framebuffer object. /// </summary> /// <param name="target"></param> /// <param name="renderbuffer"></param> /// <param name="location"></param> public void Attach(FramebufferTarget target, Renderbuffer renderbuffer, AttachmentLocation location) { switch (location) { case AttachmentLocation.Depth: { if (this.depthBuffer != null) { throw new Exception("Depth buffer already exists!"); } glFramebufferRenderbuffer((uint)target, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, renderbuffer.Id); this.depthBuffer = renderbuffer; } break; case AttachmentLocation.Stencil: { if (this.stencilBuffer != null) { throw new Exception("Stencil buffer already exists!"); } glFramebufferRenderbuffer((uint)target, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, renderbuffer.Id); this.stencilBuffer = renderbuffer; } break; case AttachmentLocation.DepthStencil: { if (this.depthBuffer != null) { throw new Exception("Depth buffer already exists!"); } if (this.stencilBuffer != null) { throw new Exception("Stencil buffer already exists!"); } glFramebufferRenderbuffer((uint)target, GL.GL_DEPTH_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, renderbuffer.Id); this.depthBuffer = renderbuffer; this.stencilBuffer = renderbuffer; } break; default: throw new NotDealWithNewEnumItemException(typeof(AttachmentLocation)); } }
/// <summary> /// Send any attachments. /// </summary> /// <param name="buf">String work area.</param> /// <param name="type">Attachment type to send.</param> private void SendAttachments(StringBuilder buf, AttachmentLocation type) { //declare mime info for attachment byte[] fbuf = new byte[2048]; int num; SmtpAttachment attachment; string seperator = type == AttachmentLocation.Attachment ? "\r\n--#SEPERATOR1#" : "\r\n--#SEPERATOR2#"; buf.Length = 0; foreach (object o in files) { attachment = (SmtpAttachment)o; if (attachment.Location != type) { continue; } CryptoStream cs = new CryptoStream( new FileStream(attachment.FileName, FileMode.Open, FileAccess.Read, FileShare.Read), new ToBase64Transform(), CryptoStreamMode.Read); con.SendCommand(seperator); buf.Append("Content-Type: "); buf.Append(attachment.ContentType); buf.Append("; name="); buf.Append(Path.GetFileName(attachment.FileName)); con.SendCommand(buf.ToString()); con.SendCommand("Content-Transfer-Encoding: base64"); buf.Length = 0; buf.Append("Content-Disposition: attachment; filename="); buf.Append(Path.GetFileName(attachment.FileName)); con.SendCommand(buf.ToString()); buf.Length = 0; buf.Append("Content-ID: "); buf.Append(Path.GetFileNameWithoutExtension(attachment.FileName)); buf.Append("\r\n"); con.SendCommand(buf.ToString()); buf.Length = 0; num = cs.Read(fbuf, 0, 2048); while (num > 0) { con.SendData(Encoding.ASCII.GetChars(fbuf, 0, num), 0, num); //con.SendData( Encoding.Unicode.GetChars(fbuf, 0, num), 0, num); num = cs.Read(fbuf, 0, 2048); } cs.Close(); con.SendCommand(""); } }
/// <summary> /// Attach a single layer of a <paramref name="cubemapArrayTexture"/> to the currently bound framebuffer object. /// <para>Bind() this framebuffer before invoking this method.</para> /// </summary> /// <param name="target">GL_FRAMEBUFFER is equivalent to GL_DRAW_FRAMEBUFFER</param> /// <param name="cubemapArrayTexture">texture must either be null or an existing cube map array texture.</param> /// <param name="location">attachment point.</param> /// <param name="layer">Specifies the layer of <paramref name="cubemapArrayTexture"/> to attach.</param> /// <param name="face">Specifies the face of <paramref name="cubemapArrayTexture"/> to attach.</param> /// <param name="mipmapLevel">Specifies the mipmap level of <paramref name="cubemapArrayTexture"/> to attach.</param> public void Attach(FramebufferTarget target, Texture cubemapArrayTexture, AttachmentLocation location, int layer, CubemapFace face, int mipmapLevel = 0) { this.Attach(target, cubemapArrayTexture, location, (layer * 6 + (int)((uint)face - GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X)), mipmapLevel); }
/// <summary> /// Attach a level of the <paramref name="texture"/> as a logical buffer to the currently bound framebuffer object. /// If there are multiple images in one mipmap level of the <paramref name="texture"/>, then we will start 'layered rendering'. /// <para>Bind() this framebuffer before invoking this method.</para> /// </summary> /// <param name="target">GL_FRAMEBUFFER is equivalent to GL_DRAW_FRAMEBUFFER</param> /// <param name="texture">Specifies the texture object to attach to the framebuffer attachment point named by <paramref name="location"/>.</param> /// <param name="location">Specifies the attachment point of the framebuffer.</param> /// <param name="mipmapLevel">Specifies the mipmap level of <paramref name="texture"/> to attach.</param> public void Attach(FramebufferTarget target, Texture texture, AttachmentLocation location, int mipmapLevel = 0) { glFramebufferTexture((uint)target, (uint)location, texture != null ? texture.Id : 0u, mipmapLevel); }
private void drawFilterAttachment(Vec attachmentCenter, Canvas c, AttachmentLocation attachmentLocation) { var filterLinkViewModel = DataContext as FilterLinkViewModel; var sourceCount = filterLinkViewModel.FilterLinkModels.Count(lvm => lvm.LinkType == LinkType.Filter); var c1 = new Border(); c1.Width = _attachmentRectHalfSize * 2; c1.Height = _attachmentRectHalfSize * 2; c1.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize, Y = attachmentCenter.Y - _attachmentRectHalfSize }; c.Children.Add(c1); c1.Background = _lightBrush; var outline = _backgroundBrush; var thickness = 4; var overlap = 2; if (attachmentLocation == AttachmentLocation.Left) { var r1 = new Rectangle(); r1.Fill = outline; r1.Width = _attachmentRectHalfSize * 2 + thickness - overlap; r1.Height = thickness; r1.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize - thickness, Y = attachmentCenter.Y + _attachmentRectHalfSize }; c.Children.Add(r1); var r2 = new Rectangle(); r2.Fill = outline; r2.Width = _attachmentRectHalfSize * 2 + thickness - overlap; r2.Height = thickness; r2.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize - thickness, Y = attachmentCenter.Y - _attachmentRectHalfSize - thickness }; c.Children.Add(r2); var r3 = new Rectangle(); r3.Fill = outline; r3.Width = thickness; r3.Height = _attachmentRectHalfSize * 2 + thickness - overlap; r3.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize - thickness, Y = attachmentCenter.Y - _attachmentRectHalfSize }; c.Children.Add(r3); } if (attachmentLocation == AttachmentLocation.Right) { var r1 = new Rectangle(); r1.Fill = outline; r1.Width = _attachmentRectHalfSize * 2 + thickness - overlap; r1.Height = thickness; r1.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize + overlap, Y = attachmentCenter.Y + _attachmentRectHalfSize }; c.Children.Add(r1); var r2 = new Rectangle(); r2.Fill = outline; r2.Width = _attachmentRectHalfSize * 2 + thickness - overlap; r2.Height = thickness; r2.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize + overlap, Y = attachmentCenter.Y - _attachmentRectHalfSize - thickness }; c.Children.Add(r2); var r3 = new Rectangle(); r3.Fill = outline; r3.Width = thickness; r3.Height = _attachmentRectHalfSize * 2 + thickness * 2; r3.RenderTransform = new TranslateTransform { X = attachmentCenter.X + _attachmentRectHalfSize, Y = attachmentCenter.Y - _attachmentRectHalfSize - thickness }; c.Children.Add(r3); } if (attachmentLocation == AttachmentLocation.Top) { var r1 = new Rectangle(); r1.Fill = outline; r1.Width = _attachmentRectHalfSize * 2 + thickness * 2; r1.Height = thickness; r1.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize - thickness, Y = attachmentCenter.Y - _attachmentRectHalfSize - thickness }; c.Children.Add(r1); var r2 = new Rectangle(); r2.Fill = outline; r2.Width = thickness; r2.Height = _attachmentRectHalfSize * 2 + thickness - overlap; r2.RenderTransform = new TranslateTransform { X = attachmentCenter.X + _attachmentRectHalfSize, Y = attachmentCenter.Y - _attachmentRectHalfSize - thickness }; c.Children.Add(r2); var r3 = new Rectangle(); r3.Fill = outline; r3.Width = thickness; r3.Height = _attachmentRectHalfSize * 2 + thickness - overlap; r3.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize - thickness, Y = attachmentCenter.Y - _attachmentRectHalfSize - thickness }; c.Children.Add(r3); } if (attachmentLocation == AttachmentLocation.Bottom) { var r1 = new Rectangle(); r1.Fill = outline; r1.Width = _attachmentRectHalfSize * 2 + thickness * 2; r1.Height = thickness; r1.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize - thickness, Y = attachmentCenter.Y + _attachmentRectHalfSize }; c.Children.Add(r1); var r2 = new Rectangle(); r2.Fill = outline; r2.Width = thickness; r2.Height = _attachmentRectHalfSize * 2 + thickness - overlap; r2.RenderTransform = new TranslateTransform { X = attachmentCenter.X + _attachmentRectHalfSize, Y = attachmentCenter.Y - _attachmentRectHalfSize }; c.Children.Add(r2); var r3 = new Rectangle(); r3.Fill = outline; r3.Width = thickness; r3.Height = _attachmentRectHalfSize * 2 + thickness - overlap; r3.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize - thickness, Y = attachmentCenter.Y - _attachmentRectHalfSize }; c.Children.Add(r3); } var filterIcon = new Polygon(); filterIcon.Points = new PointCollection(); filterIcon.Points.Add(new Windows.Foundation.Point(0, 0)); filterIcon.Points.Add(new Windows.Foundation.Point(15, 0)); filterIcon.Points.Add(new Windows.Foundation.Point(10, 6)); filterIcon.Points.Add(new Windows.Foundation.Point(10, 14)); filterIcon.Points.Add(new Windows.Foundation.Point(5, 12)); filterIcon.Points.Add(new Windows.Foundation.Point(5, 6)); filterIcon.Fill = sourceCount > 1 ? _highlightFaintBrush : _highlightBrush; filterIcon.Width = _attachmentRectHalfSize * 2; filterIcon.Height = _attachmentRectHalfSize * 2; var mat = Mat.Translate(attachmentCenter.X - _attachmentRectHalfSize + 6, attachmentCenter.Y - _attachmentRectHalfSize + 7 + (sourceCount > 1 ? 0 : 0)) * Mat.Scale(1.2, 1.2); filterIcon.RenderTransform = new MatrixTransform { Matrix = mat }; c.Children.Add(filterIcon); if (sourceCount > 1) { var label = new TextBlock(); if (((IFilterConsumerOperationModel)filterLinkViewModel.ToOperationViewModel.OperationModel).FilteringOperation == FilteringOperation.AND) { label.Text = "AND"; } else if (((IFilterConsumerOperationModel)filterLinkViewModel.ToOperationViewModel.OperationModel).FilteringOperation == FilteringOperation.OR) { label.Text = "OR"; } label.TextAlignment = TextAlignment.Center; label.FontSize = 9; label.FontWeight = FontWeights.Bold; label.Width = _attachmentRectHalfSize * 2; label.Foreground = _highlightBrush; label.Height = _attachmentRectHalfSize * 2; c.UseLayoutRounding = false; label.RenderTransform = new TranslateTransform { X = attachmentCenter.X - _attachmentRectHalfSize, Y = attachmentCenter.Y - _attachmentRectHalfSize + 10 }; c.Children.Add(label); } var t = attachmentCenter - new Vec(_attachmentRectHalfSize, _attachmentRectHalfSize); var r = new Rct(new Pt(t.X, t.Y), new Vec(_attachmentRectHalfSize * 2, _attachmentRectHalfSize * 2)); _linkViewGeometry = r.GetPolygon().Buffer(3); }
/// <summary> /// Constructor for passing all information at once. /// </summary> /// <param name="fileName">File to send.</param> /// <param name="contentType">Content type of file (application/octet-stream for regular attachments.)</param> /// <param name="location">Where to put the attachment.</param> public SmtpAttachment(string fileName, string contentType, AttachmentLocation location) { this.FileName = fileName; this.ContentType = contentType; this.Location = location; }
public MimeAttachment(Stream contentStream, string name) : base(contentStream, Path.GetFileName(name)) { this.Location = AttachmentLocation.Attachmed; }
/// <summary> /// Send any attachments. /// </summary> /// <param name="buf">String work area.</param> /// <param name="type">Attachment type to send.</param> private void SendAttachments(StringBuilder buf, AttachmentLocation type) { //declare mime info for attachment byte[] fbuf = new byte[2048]; int num; SmtpAttachment attachment; string seperator = type == AttachmentLocation.Attachment ? "\r\n--#SEPERATOR1#" : "\r\n--#SEPERATOR2#"; buf.Length = 0; foreach(object o in files) { attachment = (SmtpAttachment) o; if(attachment.Location != type) { continue; } CryptoStream cs = new CryptoStream( new FileStream(attachment.FileName, FileMode.Open, FileAccess.Read, FileShare.Read), new ToBase64Transform(), CryptoStreamMode.Read ); con.SendCommand(seperator); buf.Append("Content-Type: "); buf.Append(attachment.ContentType); buf.Append("; name="); buf.Append(Path.GetFileName(attachment.FileName)); con.SendCommand(buf.ToString()); con.SendCommand("Content-Transfer-Encoding: base64"); buf.Length = 0; buf.Append("Content-Disposition: attachment; filename="); buf.Append(Path.GetFileName(attachment.FileName)); con.SendCommand(buf.ToString()); buf.Length = 0; buf.Append("Content-ID: "); buf.Append(Path.GetFileNameWithoutExtension(attachment.FileName)); buf.Append("\r\n"); con.SendCommand(buf.ToString()); buf.Length = 0; num = cs.Read(fbuf, 0, 2048); while(num > 0) { con.SendData( Encoding.ASCII.GetChars(fbuf, 0, num), 0, num); //con.SendData( Encoding.Unicode.GetChars(fbuf, 0, num), 0, num); num = cs.Read(fbuf, 0, 2048); } cs.Close(); con.SendCommand(""); } }
/// <summary> /// Constructor for passing stream attachments. /// </summary> /// <param name="contentStream">Stream to the attachment contents</param> /// <param name="name">Name of the attachment as it will appear on the e-mail</param> /// <param name="contentStream">Where to put the attachment</param> public MimeAttachment(Stream contentStream, string name, AttachmentLocation location = AttachmentLocation.Attachmed) : this(contentStream, name, new ContentType(MediaTypeNames.Application.Octet), location) { }
/// <summary> /// Constructor for passing stream attachments. /// </summary> /// <param name="contentStream">Stream to the attachment contents</param> /// <param name="name">Name of the attachment as it will appear on the e-mail</param> /// <param name="contentType">Content type of the attachment</param> /// <param name="contentStream">Where to put the attachment</param> public MimeAttachment(Stream contentStream, string name, ContentType contentType, AttachmentLocation location = AttachmentLocation.Attachmed) : base(contentStream, name) { Location = location; ContentType = contentType; }
/// <summary> /// Shortcut constructor for passing regular style attachments. /// </summary> /// <param name="filename">File to send.</param> public MimeAttachment(string filename) : this(filename, new ContentType(MediaTypeNames.Application.Octet), AttachmentLocation.Attachmed) { Location = Location; }