public MessageAttachment(string attachmentString)
 {
     Match matches = Regex.Match(attachmentString, @"^(?<type>[a-z])(?<userid>[\d]+)\_(?<mediaid>[\d]+)");
     this.Type = (AttachmentType)Convert.ToInt32(matches.Groups["type"].Value);
     this.UserId = Convert.ToInt32(matches.Groups["userid"].Value);
     this.MediaId = Convert.ToInt32( matches.Groups["mediaid"].Value);
 }
    // this is the attachment loader which will hook into Futile's AtlasManager for the attachment/element data
    public Attachment NewAttachment(Skin skin, AttachmentType type, String name)
    {
        switch(type){
            case AttachmentType.region:

                FAtlasElement element = Futile.atlasManager.GetElementWithName(name);
                RegionAttachment attachment = new RegionAttachment(name);

                if(element != null){
                    attachment.Texture = element;
                    attachment.SetUVs(element.uvBottomLeft.x, element.uvBottomLeft.y, element.uvTopRight.x, element.uvTopRight.y, false);
                    attachment.RegionOffsetX = 0.0f;
                    attachment.RegionOffsetY = 0.0f;
                    attachment.RegionWidth = element.sourceSize.x;
                    attachment.RegionHeight = element.sourceSize.y;
                    attachment.RegionOriginalWidth = element.sourceSize.x;
                    attachment.RegionOriginalHeight = element.sourceSize.y;

                }else{
                    attachment.Texture = null;
                    attachment.SetUVs(0.0f, 0.0f, 0.0f, 0.0f, false);
                    attachment.RegionOffsetX = 0.0f;
                    attachment.RegionOffsetY = 0.0f;
                    attachment.RegionWidth = 0.0f;
                    attachment.RegionHeight = 0.0f;
                    attachment.RegionOriginalWidth = 0.0f;
                    attachment.RegionOriginalHeight = 0.0f;

                    Debug.Log("Element [" + name + "] not found in Futile.AtlasManager");
                }
                return attachment;
        }
        throw new Exception("Unknown attachment type: " + type);
    }
        /// <summary>
        /// New Attachment.
        /// </summary>
        /// <param name="skin">The skin.</param>
        /// <param name="type">The attachmentType.</param>
        /// <param name="name">The name.</param>
        /// <returns>May be null to not load any attachment.</returns>
        /// <exception cref="System.Exception">Region not found in atlas:  + name +  ( + type + )</exception>
        public Attachment NewAttachment(Skin skin, AttachmentType type, string name)
        {
            if (type == AttachmentType.region)
            {
                AtlasRegion region = this.atlas.FindRegion(name);
                if (region == null)
                {
                    throw new Exception("Region not found in atlas: " + name + " (" + type + ")");
                }

                RegionAttachment attachment = new RegionAttachment(name);
                attachment.Texture = region.Page.Texture;
                attachment.SetUVs(region.U, region.V, region.U2, region.V2, region.Rotate);
                attachment.RegionOffsetX = region.OffsetX;
                attachment.RegionOffsetY = region.OffsetY;
                attachment.RegionWidth = region.Width;
                attachment.RegionHeight = region.Height;
                attachment.RegionOriginalWidth = region.OriginalWidth;
                attachment.RegionOriginalHeight = region.OriginalHeight;

                return attachment;
            }
            else
            {
                throw new Exception("Unknown attachment type: " + type);
            }
        }
Exemple #4
0
 public void Delete(int idx, AttachmentType tipo)
 {
     if (tipo == AttachmentType.Font)
         Fonts.RemoveAt(idx);
     else if (tipo == AttachmentType.Graphic)
         Graphics.RemoveAt(idx);
 }
    public Attachment NewAttachment(Skin skin, AttachmentType type, String name)
    {
        if (type != AttachmentType.region)
            throw new Exception("Unknown attachment type: " + type);

        // Strip folder names.
        int index = name.LastIndexOfAny(new char[] {'/', '\\'});
        if (index != -1)
            name = name.Substring(index + 1);

        tk2dSpriteDefinition def = sprites.GetSpriteDefinition(name);

        if (def == null)
            throw new Exception("Sprite not found in atlas: " + name + " (" + type + ")");
        if (def.complexGeometry)
            throw new NotImplementedException("Complex geometry is not supported: " + name + " (" + type + ")");
        if (def.flipped == tk2dSpriteDefinition.FlipMode.TPackerCW)
            throw new NotImplementedException("Only 2D Toolkit atlases are supported: " + name + " (" + type + ")");

        RegionAttachment attachment = new RegionAttachment(name);

        Vector2 minTexCoords = Vector2.one;
        Vector2 maxTexCoords = Vector2.zero;
        for (int i = 0; i < def.uvs.Length; ++i) {
            Vector2 uv = def.uvs[i];
            minTexCoords = Vector2.Min(minTexCoords, uv);
            maxTexCoords = Vector2.Max(maxTexCoords, uv);
        }
        bool rotated = def.flipped == tk2dSpriteDefinition.FlipMode.Tk2d;
        if (rotated) {
            float temp = minTexCoords.x;
            minTexCoords.x = maxTexCoords.x;
            maxTexCoords.x = temp;
        }
        attachment.SetUVs(
            minTexCoords.x,
            maxTexCoords.y,
            maxTexCoords.x,
            minTexCoords.y,
            rotated
        );

        attachment.RegionOriginalWidth = (int)(def.untrimmedBoundsData[1].x / def.texelSize.x);
        attachment.RegionOriginalHeight = (int)(def.untrimmedBoundsData[1].y / def.texelSize.y);

        attachment.RegionWidth = (int)(def.boundsData[1].x / def.texelSize.x);
        attachment.RegionHeight = (int)(def.boundsData[1].y / def.texelSize.y);

        float x0 = def.untrimmedBoundsData[0].x - def.untrimmedBoundsData[1].x / 2;
        float x1 = def.boundsData[0].x - def.boundsData[1].x / 2;
        attachment.RegionOffsetX = (int)((x1 - x0) / def.texelSize.x);

        float y0 = def.untrimmedBoundsData[0].y - def.untrimmedBoundsData[1].y / 2;
        float y1 = def.boundsData[0].y - def.boundsData[1].y / 2;
        attachment.RegionOffsetY = (int)((y1 - y0) / def.texelSize.y);

        attachment.RendererObject = def.material;

        return attachment;
    }
    public Attachment NewAttachment(Skin skin, AttachmentType type, String name)
    {
        if (type != AttachmentType.region) throw new Exception("Unknown attachment type: " + type);

        // Strip folder names.
        int index = name.LastIndexOfAny(new char[] {'/', '\\'});
        if (index != -1) name = name.Substring(index + 1);

        tk2dSpriteDefinition attachmentParameters = null;
        for (int i = 0; i < sprites.inst.spriteDefinitions.Length; ++i) {
            tk2dSpriteDefinition def = sprites.inst.spriteDefinitions[i];
            if (def.name == name) {
                attachmentParameters = def;
                break;
            }
        }

        if (attachmentParameters == null) throw new Exception("Sprite not found in atlas: " + name + " (" + type + ")");
        if (attachmentParameters.complexGeometry) throw new NotImplementedException("Complex geometry is not supported: " + name + " (" + type + ")");
        if (attachmentParameters.flipped == tk2dSpriteDefinition.FlipMode.TPackerCW) throw new NotImplementedException("Only 2D Toolkit atlases are supported: " + name + " (" + type + ")");

        Vector2 minTexCoords = Vector2.one;
        Vector2 maxTexCoords = Vector2.zero;
        for (int i = 0; i < attachmentParameters.uvs.Length; ++i) {
            Vector2 uv = attachmentParameters.uvs[i];
            minTexCoords = Vector2.Min(minTexCoords, uv);
            maxTexCoords = Vector2.Max(maxTexCoords, uv);
        }

        Texture texture = attachmentParameters.material.mainTexture;
        int width = (int)(Mathf.Abs(maxTexCoords.x - minTexCoords.x) * texture.width);
        int height = (int)(Mathf.Abs(maxTexCoords.y - minTexCoords.y) * texture.height);

        bool rotated = (attachmentParameters.flipped == tk2dSpriteDefinition.FlipMode.Tk2d);

        if (rotated) {
            float temp = minTexCoords.x;
            minTexCoords.x = maxTexCoords.x;
            maxTexCoords.x = temp;
        }

        RegionAttachment attachment = new RegionAttachment(name);

        attachment.SetUVs(
            minTexCoords.x,
            maxTexCoords.y,
            maxTexCoords.x,
            minTexCoords.y,
            rotated
        );

        // TODO - Set attachment.RegionOffsetX/Y. What units does attachmentParameters.untrimmedBoundsData use?!
        attachment.RegionWidth = width;
        attachment.RegionHeight = height;
        attachment.RegionOriginalWidth = width;
        attachment.RegionOriginalHeight = height;

        return attachment;
    }
Exemple #7
0
 public void Attach(AttachmentType slot, Attachment attachment)
 {
     Noise += attachment.NoiseModifier;
     ClipSize += attachment.ClipSizeModifier;
     if (attachments.ContainsKey(slot))
         attachments.Remove(slot);
     attachments.Add(slot, attachment);
 }
Exemple #8
0
        public void ExtractToFile(int idx, AttachmentType tipo, string filename)
        {
            attachmentASS a = (tipo == AttachmentType.Font) ? (attachmentASS)Fonts[idx] : (attachmentASS)Graphics[idx];
            byte[] bdest = a.Decode();

            FileStream fs = new FileStream(filename, FileMode.Create);
            fs.Write(bdest, 0, bdest.Length);
            fs.Close();
        }
        public MessageAttachment(long messageId, AttachmentType type, string path, string originalFilename)
        {
            MessageId = messageId;

            Type = type;

            Path = path;

            OriginalFilename = originalFilename;
        }
    public Attachment NewAttachment(Skin skin,AttachmentType type,String name)
    {
        if(type != AttachmentType.region) throw new Exception("Unknown attachment type: " + type);

        tk2dSpriteDefinition attachmentParameters = null;
        for(int i = 0; i < sprites.spriteDefinitions.Length; ++i) {
            tk2dSpriteDefinition def = sprites.spriteDefinitions[i];
            if(def.name == name) {
                attachmentParameters = def;
                break;
            }
        }

        if(attachmentParameters == null ) throw new Exception("Sprite not found in atlas: " + name + " (" + type + ")");
        if(attachmentParameters.complexGeometry) throw new NotImplementedException("Complex geometry is not supported: " + name + " (" + type + ")");
        if(attachmentParameters.flipped == tk2dSpriteDefinition.FlipMode.TPackerCW) throw new NotImplementedException("Only 2d toolkit atlases are supported: " + name + " (" + type + ")");
        Texture tex = attachmentParameters.material.mainTexture;

        Vector2 minTexCoords = Vector2.one;
        Vector2 maxTexCoords = Vector2.zero;
        for(int i = 0; i < attachmentParameters.uvs.Length; ++i) {
            Vector2 uv = attachmentParameters.uvs[i];
            minTexCoords = Vector2.Min(minTexCoords,uv);
            maxTexCoords = Vector2.Max(maxTexCoords,uv);
        }

        int width = (int)(Mathf.Abs(maxTexCoords.x - minTexCoords.x) * tex.width);
        int height = (int)(Mathf.Abs(maxTexCoords.y - minTexCoords.y) * tex.height);

        bool rotated = (attachmentParameters.flipped == tk2dSpriteDefinition.FlipMode.Tk2d);

        if(rotated) {
            float temp = minTexCoords.x;
            minTexCoords.x = maxTexCoords.x;
            maxTexCoords.x = temp;
        }

        RegionAttachment attachment = new RegionAttachment(name);

        attachment.SetUVs(
            minTexCoords.x,
            maxTexCoords.y,
            maxTexCoords.x,
            minTexCoords.y,
            rotated
        );

        attachment.RegionWidth = width;
        attachment.RegionHeight = height;
        attachment.RegionOriginalWidth = width;
        attachment.RegionOriginalHeight = height;

        return attachment;
    }
 public Attachment NewAttachment(AttachmentType type, String name)
 {
     switch (type) {
     case AttachmentType.region:
         AtlasRegion region = atlas.FindRegion(name);
         if (region == null) throw new Exception("Region not found in atlas: " + name + " (" + type + ")");
         RegionAttachment attachment = new RegionAttachment(name);
         attachment.Region = region;
         return attachment;
     }
     throw new Exception("Unknown attachment type: " + type);
 }
        public Attachment NewAttachment(AttachmentType attachmentType, String name)
        {
            switch (attachmentType) {
                case AttachmentType.Region:
                    return this.CreateRegionAttachment(name);

                case AttachmentType.RegionSequence:
                    throw new NotImplementedException("Not yet supported by Spine - Future development required");

                default:
                    throw new ArgumentException("Unknown attachment type: " + attachmentType);
            }
        }
 public AttachmentViewModel(int mid, int owner_id, int a_id, AttachmentType type, string uri, string description,
     BitmapImage photo, IList<MessageViewModel> fwdMessages, Action handler)
 {
     OwnerId = owner_id;
     Aid = a_id;
     Mid = mid;
     _uri = uri;
     _description = description;
     _photo = photo;
     _messages = fwdMessages;
     _handler = handler;
     Type = type;
 }
Exemple #14
0
 public static bool isToggleable(AttachmentType type)
 {
     switch (type) {
     case AttachmentType.Flashlight: return true;
     case AttachmentType.Laser: 		return true;
     case AttachmentType.Foregrip: 	return false;
     case AttachmentType.Scope: 		return false;
     case AttachmentType.IronSight: 	return false;
     case AttachmentType.Silencer: 	return false;
     case AttachmentType.Grip: 		return false;
     }
     return false;
 }
        internal AttachmentData(string name, string contentType, AttachmentType type, string serializedContents, byte[] bytes)
        {
            if (name == null)
                throw new ArgumentNullException("name");
            if (contentType == null)
                throw new ArgumentNullException("contentType");

            ContentDisposition = AttachmentContentDisposition.Inline;
            this.name = name;
            this.contentType = contentType;
            this.Type = type;
            this.serializedContents = serializedContents;
            this.bytes = bytes;
        }
        public AttachmentViewModel(int mid, int owner_id, int a_id, AttachmentType type, string uri, string description,
            BitmapImage photo, IList<MessageViewModel> fwdMessages, Action handler, string title, string author, int duration)
            : this(mid, owner_id, a_id, type, uri, description, photo, fwdMessages, handler)
        {
            _title = title;
            _author = author;

            TimeSpan ts = new TimeSpan(0, 0, duration);

            if (ts.Hours >= 1)
                Duration = String.Format("{0:HH:mm:ss}", ts);
            else
                Duration = String.Format("{0:MM:ss}", ts);
        }
        public void SendEmailWithAttachmentDifferentName()
        {
            const string endpointConfigurationName = "EmailPusherService_basicHttpBinding";
            IEmailPusherService emailPusher = new EmailPusherServiceClient(endpointConfigurationName);

            var recipients = new string[1] { "*****@*****.**" };
            var cc = new string[1] { "*****@*****.**" };
            var attachments = new string[1] { @"\\pbsw23it\it\1.jpg" };
            var attachmentName = new AttachmentType[1] {new AttachmentType() {OldFileName = attachments[0], NewFileName = "file1.jpg"}};

           
             var response = emailPusher.AddNewMessageWithAttachmentNameGetAddNewMessageResponse(recipients, null, attachmentName, "subject",
                    "body", "*****@*****.**");

             // user this runs under probably wont hava access to file so error is correct, shows web services is working correctly
             Assert.That(response.ErrorList[0], Is.EqualTo(@"File Doesnt Exist : \\pbsw23it\it\1.jpg"));
        }
 public Attachment NewAttachment(Skin skin, AttachmentType type, String name)
 {
     switch (type) {
     case AttachmentType.region:
         AtlasRegion region = atlas.FindRegion(name);
         if (region == null) throw new Exception("Region not found in atlas: " + name + " (" + type + ")");
         RegionAttachment attachment = new RegionAttachment(name);
         attachment.RendererObject = region.page.rendererObject;
         attachment.SetUVs(region.u, region.v, region.u2, region.v2, region.rotate);
         attachment.RegionOffsetX = region.offsetX;
         attachment.RegionOffsetY = region.offsetY;
         attachment.RegionWidth = region.width;
         attachment.RegionHeight = region.height;
         attachment.RegionOriginalWidth = region.originalWidth;
         attachment.RegionOriginalHeight = region.originalHeight;
         return attachment;
     }
     throw new Exception("Unknown attachment type: " + type);
 }
        // not a suitable holder in email type for our use of attachment
        public void SendWithDifferentAttachmentName(RazorEmailResult email, AttachmentType[] attachments)
        {
            var sr = new StreamReader(email.Mail.AlternateViews[0].ContentStream);
            var body = sr.ReadToEnd();
            email.Mail.AlternateViews[0].ContentStream.Position = 0;

            const string endpointConfigurationName = "EmailPusherService_basicHttpBinding";
            IEmailPusherService emailPusher = new EmailPusherServiceClient(endpointConfigurationName);

            Log4NetHelper.Log.Debug("EmailSenderHelper EmailPusherServiceClient Binding : " + endpointConfigurationName);
            
            var response = emailPusher.AddNewMessageWithAttachmentNameGetAddNewMessageResponse(email.Mail.To.Select(x => x.Address).ToArray(),
                                                              email.Mail.CC.Select(x => x.ToString()).ToArray(),
                                                              attachments,
                                                              email.Mail.Subject,
                                                              body,
                                                              email.Mail.From.Address
                );

            Log4NetHelper.Log.Info("EmailSenderHelper Send Completed For Email : " + string.Join( ";", email.Mail.To.Select(x => x.Address) ) + "messageId" + response.MessageId); 
        }
Exemple #20
0
 public Attachment GetAttachment(AttachmentType slot)
 {
     if (attachments == null)
         attachments = new Dictionary<AttachmentType, Attachment>();
     if (attachments.ContainsKey(slot))
         return attachments[slot];
     return null;
 }
Exemple #21
0
 public static MvcHtmlString LabelWithSugarFor(this HtmlHelper html, AttachmentType attachmentType, DisplayStyle displayStyle)
 {
     return(LabelWithSugarFor(attachmentType, attachmentType.AttachmentTypeName.Replace(" ", ""), DefaultPopupWidth, displayStyle, false, attachmentType.AttachmentTypeName, attachmentType.GetContentUrl()));
 }
Exemple #22
0
 public attachmentASS GetAttachment(int idx, AttachmentType tipo)
 {
     attachmentASS a = (tipo == AttachmentType.Font) ? (attachmentASS)Fonts[idx] : (attachmentASS)Graphics[idx];
     return a;
 }
Exemple #23
0
 public string GetFileName(int idx, AttachmentType tipo)
 {
     attachmentASS a = (tipo == AttachmentType.Font) ? (attachmentASS)Fonts[idx] : (attachmentASS)Graphics[idx];
     return a.FileName;
 }
 void ExecuteAddMediaCommand(AttachmentType attachmentType)
 {
     _eventAggregator.GetEvent <MediaRequestedMessage>().Publish(attachmentType);
 }
Exemple #25
0
 public static Optional <Attachment> GetWeaponAttachment(Item weaponItem, AttachmentType type)
 {
     return(GetWeaponAttachment(weaponItem.metadata, type));
 }
 public GetAttachmentsOperation(IEnumerable <AttachmentRequest> attachments, AttachmentType type)
 {
     _type        = type;
     _attachments = attachments;
 }
Exemple #27
0
 public static MvcHtmlString LabelWithSugarFor(this HtmlHelper html, AttachmentType attachmentType)
 {
     return(LabelWithSugarFor(html, attachmentType, DisplayStyle.HelpIconWithLabel));
 }
            public GetAttachmentCommand(JsonOperationContext context, string documentId, string name, AttachmentType type, string changeVector)
            {
                if (string.IsNullOrWhiteSpace(documentId))
                {
                    throw new ArgumentNullException(nameof(documentId));
                }
                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentNullException(nameof(name));
                }

                if (type != AttachmentType.Document && changeVector == null)
                {
                    throw new ArgumentNullException(nameof(changeVector), $"Change Vector cannot be null for attachment type {type}");
                }

                _context      = context;
                _documentId   = documentId;
                _name         = name;
                _type         = type;
                _changeVector = changeVector;

                ResponseType = RavenCommandResponseType.Empty;
            }
 partial void OnTypeChanging(AttachmentType value);
 public Attachment(AttachmentType aType, long owner, long media)
 {
     type = aType;
     ownerId = owner;
     mediaId = media;
 }
    public Attachment NewAttachment(Skin skin, AttachmentType type, String name)
    {
        if (type != AttachmentType.region)
        {
            throw new Exception("Unknown attachment type: " + type);
        }

        // Strip folder names.
        int index = name.LastIndexOfAny(new char[] { '/', '\\' });

        if (index != -1)
        {
            name = name.Substring(index + 1);
        }

        tk2dSpriteDefinition def = sprites.inst.GetSpriteDefinition(name);

        if (def == null)
        {
            throw new Exception("Sprite not found in atlas: " + name + " (" + type + ")");
        }
        if (def.complexGeometry)
        {
            throw new NotImplementedException("Complex geometry is not supported: " + name + " (" + type + ")");
        }
        if (def.flipped == tk2dSpriteDefinition.FlipMode.TPackerCW)
        {
            throw new NotImplementedException("Only 2D Toolkit atlases are supported: " + name + " (" + type + ")");
        }

        RegionAttachment attachment = new RegionAttachment(name);

        Vector2 minTexCoords = Vector2.one;
        Vector2 maxTexCoords = Vector2.zero;

        for (int i = 0; i < def.uvs.Length; ++i)
        {
            Vector2 uv = def.uvs[i];
            minTexCoords = Vector2.Min(minTexCoords, uv);
            maxTexCoords = Vector2.Max(maxTexCoords, uv);
        }
        bool rotated = def.flipped == tk2dSpriteDefinition.FlipMode.Tk2d;

        if (rotated)
        {
            float temp = minTexCoords.x;
            minTexCoords.x = maxTexCoords.x;
            maxTexCoords.x = temp;
        }
        attachment.SetUVs(
            minTexCoords.x,
            maxTexCoords.y,
            maxTexCoords.x,
            minTexCoords.y,
            rotated
            );

        attachment.RegionOriginalWidth  = (int)(def.untrimmedBoundsData[1].x / def.texelSize.x);
        attachment.RegionOriginalHeight = (int)(def.untrimmedBoundsData[1].y / def.texelSize.y);

        attachment.RegionWidth  = (int)(def.boundsData[1].x / def.texelSize.x);
        attachment.RegionHeight = (int)(def.boundsData[1].y / def.texelSize.y);

        float x0 = def.untrimmedBoundsData[0].x - def.untrimmedBoundsData[1].x / 2;
        float x1 = def.boundsData[0].x - def.boundsData[1].x / 2;

        attachment.RegionOffsetX = (int)((x1 - x0) / def.texelSize.x);

        float y0 = def.untrimmedBoundsData[0].y - def.untrimmedBoundsData[1].y / 2;
        float y1 = def.boundsData[0].y - def.boundsData[1].y / 2;

        attachment.RegionOffsetY = (int)((y1 - y0) / def.texelSize.y);

        attachment.RendererObject = def.material;

        return(attachment);
    }
Exemple #32
0
        private Attachment ReadAttachment(Stream input, Skin skin, int slotIndex, String attachmentName, bool nonessential)
        {
            float scale = Scale;

            String name = ReadString(input);

            if (name == null)
            {
                name = attachmentName;
            }

            AttachmentType type = (AttachmentType)input.ReadByte();

            switch (type)
            {
            case AttachmentType.region: {
                String path     = ReadString(input);
                float  rotation = ReadFloat(input);
                float  x        = ReadFloat(input);
                float  y        = ReadFloat(input);
                float  scaleX   = ReadFloat(input);
                float  scaleY   = ReadFloat(input);
                float  width    = ReadFloat(input);
                float  height   = ReadFloat(input);
                int    color    = ReadInt(input);

                if (path == null)
                {
                    path = name;
                }
                RegionAttachment region = attachmentLoader.NewRegionAttachment(skin, name, path);
                if (region == null)
                {
                    return(null);
                }
                region.Path     = path;
                region.x        = x * scale;
                region.y        = y * scale;
                region.scaleX   = scaleX;
                region.scaleY   = scaleY;
                region.rotation = rotation;
                region.width    = width * scale;
                region.height   = height * scale;
                region.r        = ((color & 0xff000000) >> 24) / 255f;
                region.g        = ((color & 0x00ff0000) >> 16) / 255f;
                region.b        = ((color & 0x0000ff00) >> 8) / 255f;
                region.a        = ((color & 0x000000ff)) / 255f;
                region.UpdateOffset();
                return(region);
            }

            case AttachmentType.boundingbox: {
                float[] vertices          = ReadFloatArray(input, ReadVarint(input, true) * 2, scale);
                BoundingBoxAttachment box = attachmentLoader.NewBoundingBoxAttachment(skin, name);
                if (box == null)
                {
                    return(null);
                }
                box.vertices = vertices;
                return(box);
            }

            case AttachmentType.mesh: {
                String  path           = ReadString(input);
                int     color          = ReadInt(input);
                int     hullLength     = 0;
                int     verticesLength = ReadVarint(input, true) * 2;
                float[] uvs            = ReadFloatArray(input, verticesLength, 1);
                int[]   triangles      = ReadShortArray(input);
                float[] vertices       = ReadFloatArray(input, verticesLength, scale);
                hullLength = ReadVarint(input, true);
                int[] edges = null;
                float width = 0, height = 0;
                if (nonessential)
                {
                    edges  = ReadShortArray(input);
                    width  = ReadFloat(input);
                    height = ReadFloat(input);
                }

                if (path == null)
                {
                    path = name;
                }
                MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path);
                if (mesh == null)
                {
                    return(null);
                }
                mesh.Path      = path;
                mesh.r         = ((color & 0xff000000) >> 24) / 255f;
                mesh.g         = ((color & 0x00ff0000) >> 16) / 255f;
                mesh.b         = ((color & 0x0000ff00) >> 8) / 255f;
                mesh.a         = ((color & 0x000000ff)) / 255f;
                mesh.vertices  = vertices;
                mesh.triangles = triangles;
                mesh.regionUVs = uvs;
                mesh.UpdateUVs();
                mesh.HullLength = hullLength;
                if (nonessential)
                {
                    mesh.Edges  = edges;
                    mesh.Width  = width * scale;
                    mesh.Height = height * scale;
                }
                return(mesh);
            }

            case AttachmentType.linkedmesh: {
                String path = ReadString(input);
                int    color = ReadInt(input);
                String skinName = ReadString(input);
                String parent = ReadString(input);
                bool   inheritFFD = ReadBoolean(input);
                float  width = 0, height = 0;
                if (nonessential)
                {
                    width  = ReadFloat(input);
                    height = ReadFloat(input);
                }

                if (path == null)
                {
                    path = name;
                }
                MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path);
                if (mesh == null)
                {
                    return(null);
                }
                mesh.Path       = path;
                mesh.r          = ((color & 0xff000000) >> 24) / 255f;
                mesh.g          = ((color & 0x00ff0000) >> 16) / 255f;
                mesh.b          = ((color & 0x0000ff00) >> 8) / 255f;
                mesh.a          = ((color & 0x000000ff)) / 255f;
                mesh.inheritFFD = inheritFFD;
                if (nonessential)
                {
                    mesh.Width  = width * scale;
                    mesh.Height = height * scale;
                }
                linkedMeshes.Add(new SkeletonJson.LinkedMesh(mesh, skinName, slotIndex, parent));
                return(mesh);
            }

            case AttachmentType.weightedmesh: {
                String  path        = ReadString(input);
                int     color       = ReadInt(input);
                int     vertexCount = ReadVarint(input, true);
                float[] uvs         = ReadFloatArray(input, vertexCount * 2, 1);
                int[]   triangles   = ReadShortArray(input);
                var     weights     = new List <float>(uvs.Length * 3 * 3);
                var     bones       = new List <int>(uvs.Length * 3);
                for (int i = 0; i < vertexCount; i++)
                {
                    int boneCount = (int)ReadFloat(input);
                    bones.Add(boneCount);
                    for (int ii = 0; ii < boneCount; ii++)
                    {
                        bones.Add((int)ReadFloat(input));
                        weights.Add(ReadFloat(input) * scale);
                        weights.Add(ReadFloat(input) * scale);
                        weights.Add(ReadFloat(input));
                    }
                }
                int   hullLength = ReadVarint(input, true);
                int[] edges = null;
                float width = 0, height = 0;
                if (nonessential)
                {
                    edges  = ReadShortArray(input);
                    width  = ReadFloat(input);
                    height = ReadFloat(input);
                }

                if (path == null)
                {
                    path = name;
                }
                WeightedMeshAttachment mesh = attachmentLoader.NewWeightedMeshAttachment(skin, name, path);
                if (mesh == null)
                {
                    return(null);
                }
                mesh.Path      = path;
                mesh.r         = ((color & 0xff000000) >> 24) / 255f;
                mesh.g         = ((color & 0x00ff0000) >> 16) / 255f;
                mesh.b         = ((color & 0x0000ff00) >> 8) / 255f;
                mesh.a         = ((color & 0x000000ff)) / 255f;
                mesh.bones     = bones.ToArray();
                mesh.weights   = weights.ToArray();
                mesh.triangles = triangles;
                mesh.regionUVs = uvs;
                mesh.UpdateUVs();
                mesh.HullLength = hullLength * 2;
                if (nonessential)
                {
                    mesh.Edges  = edges;
                    mesh.Width  = width * scale;
                    mesh.Height = height * scale;
                }
                //
                return(mesh);
            }

            case AttachmentType.weightedlinkedmesh: {
                String path = ReadString(input);
                int    color = ReadInt(input);
                String skinName = ReadString(input);
                String parent = ReadString(input);
                bool   inheritFFD = ReadBoolean(input);
                float  width = 0, height = 0;
                if (nonessential)
                {
                    width  = ReadFloat(input);
                    height = ReadFloat(input);
                }

                if (path == null)
                {
                    path = name;
                }
                WeightedMeshAttachment mesh = attachmentLoader.NewWeightedMeshAttachment(skin, name, path);
                if (mesh == null)
                {
                    return(null);
                }
                mesh.Path       = path;
                mesh.r          = ((color & 0xff000000) >> 24) / 255f;
                mesh.g          = ((color & 0x00ff0000) >> 16) / 255f;
                mesh.b          = ((color & 0x0000ff00) >> 8) / 255f;
                mesh.a          = ((color & 0x000000ff)) / 255f;
                mesh.inheritFFD = inheritFFD;
                if (nonessential)
                {
                    mesh.Width  = width * scale;
                    mesh.Height = height * scale;
                }
                linkedMeshes.Add(new SkeletonJson.LinkedMesh(mesh, skinName, slotIndex, parent));
                return(mesh);
            }
            }
            return(null);
        }
Exemple #33
0
 public void Detach(AttachmentType slot)
 {
     if (attachments.ContainsKey(slot))
     {
         Noise -= attachments[slot].NoiseModifier;
         ClipSize -= attachments[slot].ClipSizeModifier;
         attachments.Remove(slot);
     }
 }
        public static AttachmentData GetAttachment(AttachmentType type, XmlNode attachmentData)
        {
            XmlUtils.UseNode(attachmentData);
            switch (type)
            {
                case AttachmentType.Application:
                    {
                        AttachmentApplication a = new AttachmentApplication();
                        a.Id = XmlUtils.Int("app_id");
                        a.Name = XmlUtils.String("app_name");
                        a.PictureUrl = XmlUtils.String("src_big");
                        a.ThumbnailUrl = XmlUtils.String("src");
                        return a;
                    }

                case AttachmentType.Audio:
                    {
                        AttachmentAudio a = new AttachmentAudio();
                        a.Id = XmlUtils.Int("aid");
                        a.OwnerId = XmlUtils.Int("owner_id");
                        a.Performer = XmlUtils.String("performer");
                        a.Title = XmlUtils.String("title");
                        a.Duration = XmlUtils.Int("duration");
                        return a;
                    }

                case AttachmentType.Checkin:
                    {
                        break;
                    }

                case AttachmentType.Graffiti:
                    {
                        AttachmentGraffiti a = new AttachmentGraffiti();
                        a.Id= XmlUtils.Int("gid");
                        a.OwnerId= XmlUtils.Int("owner_id");
                        a.PictureUrl = XmlUtils.String("src_big");
                        a.ThumbnailUrl = XmlUtils.String("src");
                        return a;
                    }

                case AttachmentType.Note:
                    {
                        AttachmentNote a = new AttachmentNote();
                        a.Id = XmlUtils.Int("nid");
                        a.OwnerId = XmlUtils.Int("owner_id");
                        a.Title = XmlUtils.String("title");
                        a.CommentsCount = XmlUtils.Int("ncom");
                        return a;
                    }

                case AttachmentType.Photo:
                    {
                        AttachmentPhoto a = new AttachmentPhoto();
                        a.Id = XmlUtils.Int("pid");
                        a.OwnerId = XmlUtils.Int("owner_id");
                        a.PictureUrl = XmlUtils.String("src_big");
                        a.ThumbnailUrl = XmlUtils.String("src");
                        return a;
                    }

                case AttachmentType.PostedPhoto:
                    {
                        AttachmentPhoto a = new AttachmentPhoto();
                        a.Id = XmlUtils.Int("pid");
                        a.OwnerId = XmlUtils.Int("owner_id");
                        a.PictureUrl = XmlUtils.String("src_big");
                        a.ThumbnailUrl = XmlUtils.String("src");
                        return a;
                    }

                case AttachmentType.Poll:
                    {
                        AttachmentPoll a = new AttachmentPoll();
                        a.Question = XmlUtils.String("question");
                        return a;
                    }

                case AttachmentType.Share:
                    {

                        break;
                    }

                case AttachmentType.Video:
                    {
                        AttachmentVideo a = new AttachmentVideo();
                        a.Id = XmlUtils.Int("vid");
                        a.OwnerId = XmlUtils.Int("owner_id");
                        a.Title = XmlUtils.String("title");
                        a.Duration = XmlUtils.Int("duration");
                        return a;
                    }

                case AttachmentType.Url:
                    {
                        AttachmentUrl a = new AttachmentUrl();
                        a.Url = XmlUtils.String("url");
                        a.Title = XmlUtils.String("title");
                        a.Description = XmlUtils.String("description");
                        a.ThumbnailUrl = XmlUtils.String("image_src");
                        return a;
                    }
            }
            return null;
        }
Exemple #35
0
 public void OnLimbRemoved(RobotComponent limb, AttachmentSlot slot, AttachmentType type)
 {
     if (LimbRemoved != null)
     {
         LimbRemoved(limb, slot, type);
     }
 }
        public VehicleAttachment(DocumentParser doc)
        {
            string s = doc.ReadNextLine();

            switch (s)
            {
                case "DynamicsWheels":
                    this.attachmentType = AttachmentType.DynamicsWheels;
                    break;

                case "ComplicatedWheels":
                    this.attachmentType = AttachmentType.ComplicatedWheels;
                    this.wheels = new VehicleAttachmentComplicatedWheels();

                    while (!doc.NextLineIsASection())
                    {
                        var cw = doc.ReadStringArray(2);

                        switch (cw[0])
                        {
                            case "fl_wheel_folder_name":
                                this.wheels.FLWheel = cw[1];
                                break;

                            case "fr_wheel_folder_name":
                                this.wheels.FRWheel = cw[1];
                                break;

                            case "rl_wheel_folder_name":
                                this.wheels.RLWheel = cw[1];
                                break;

                            case "rr_wheel_folder_name":
                                this.wheels.RRWheel = cw[1];
                                break;

                            case "wheel_folder_name":
                                this.wheels.FLWheel = cw[1];
                                this.wheels.FRWheel = cw[1];
                                this.wheels.RLWheel = cw[1];
                                this.wheels.RRWheel = cw[1];
                                break;

                            default:
                                throw new NotImplementedException("Unknown ComplicatedWheels parameter: " + cw[0]);
                        }
                    }
                    break;

                case "DynamicsFmodEngine":
                    this.attachmentType = AttachmentType.DynamicsFmodEngine;
                    this.engine = new VehicleAttachmentFModEngine();

                    while (!doc.NextLineIsASection())
                    {
                        var dfe = doc.ReadStringArray(2);

                        switch (dfe[0])
                        {
                            case "engine":
                                this.engine.Engine = dfe[1];
                                break;

                            case "rpmsmooth":
                                this.engine.RPMSmooth = Single.Parse(dfe[1], ToxicRagers.Culture);
                                break;

                            case "onloadsmooth":
                                this.engine.OnLoadSmooth = Single.Parse(dfe[1], ToxicRagers.Culture);
                                break;

                            case "offloadsmooth":
                                this.engine.OffLoadSmooth = Single.Parse(dfe[1], ToxicRagers.Culture);
                                break;

                            case "max_revs":
                                this.engine.MaxRevs = int.Parse(dfe[1]);
                                break;

                            case "min_revs":
                                this.engine.MinRevs = int.Parse(dfe[1]);
                                break;

                            default:
                                throw new NotImplementedException("Unknown DynamicsFmodEngine parameter: " + dfe[0]);
                        }
                    }
                    break;

                case "Horn":
                    this.attachmentType = AttachmentType.Horn;

                    var h = doc.ReadStringArray(2);
                    this.horn = h[1];
                    break;

                case "ExhaustParticles":
                    this.attachmentType = AttachmentType.ExhaustParticles;
                    this.exhaust = new VehicleAttachmentExhaust();

                    while (!doc.NextLineIsASection())
                    {
                        var ep = doc.ReadStringArray(2);

                        switch (ep[0])
                        {
                            case "vfx":
                                this.exhaust.VFX = ep[1];
                                break;

                            case "underwater_vfx":
                                this.exhaust.UnderwaterVFX = ep[1];
                                break;

                            case "anchor":
                                this.exhaust.Anchor = ep[1];
                                break;

                            default:
                                throw new NotImplementedException("Unknown ExhaustParticle parameter: " + ep[0]);
                        }
                    }
                    break;

                case "ReverseLightSound":
                    this.attachmentType = AttachmentType.ReverseLightSound;

                    var rl = doc.ReadStringArray(2);
                    this.reverseLightSound = rl[1];
                    break;

                case "ContinuousSound":
                    this.attachmentType = AttachmentType.ContinuousSound;

                    while (!doc.NextLineIsASection())
                    {
                        var cs = doc.ReadStringArray(2);

                        switch (cs[0])
                        {
                            case "sound":
                                this.continuousSound = cs[1];
                                break;

                            case "lump":
                                this.continuousSoundLump = cs[1];
                                break;

                            default:
                                throw new NotImplementedException("Unknown ContinuousSound parameter: " + cs[0]);
                        }
                    }
                    break;

                default:
                    throw new NotImplementedException("Unknown AttachmentType: " + s);
            }
        }
 private void VerifyMimeTypeMatchesExpected(string mimeTypeInput, AttachmentType typeExpected)
 {
     TextMessageReaderiOS6_Accessor reader = new TextMessageReaderiOS6_Accessor(@"C:\fakepath\");
     AttachmentType typeActual = reader.ParseAttachmentType(mimeTypeInput);
     Assert.AreEqual(typeExpected, typeActual);
 }
Exemple #38
0
        public bool Attach(
            int RunId,
            AttachmentType Type,
            string Path,
            string Description = default(string),
            string Name        = default(string))
        {
            bool success = false;

            try
            {
                if (!Connect(ServerUrl, Username, Password, Domain, Project))
                {
                    return(false);
                }

                RunFactory runFact = tdc.RunFactory;
                Run        testRun = runFact[RunId];

                //ALM bug allows selection of invalid runid; use name to catch it
                string runName = testRun.Name;

                AttachmentFactory attachFact = testRun.Attachments;

                Attachment attach = attachFact.AddItem(DBNull.Value);
                attach.FileName = Path;

                TDAPI_ATTACH_TYPE attachType = TDAPI_ATTACH_TYPE.TDATT_FILE;

                switch (Type)
                {
                case AttachmentType.File:
                case AttachmentType.file:
                    attachType = TDAPI_ATTACH_TYPE.TDATT_FILE;
                    break;

                case AttachmentType.URL:
                case AttachmentType.url:
                    attachType = TDAPI_ATTACH_TYPE.TDATT_INTERNET;
                    break;
                }

                attach.Type = (int)attachType;

                if (Description != default(string))
                {
                    attach.Description = Description;
                }

                //Post will not fail if attachment is bad (different than attaching to test set)
                attach.Post();

                int attachId = 0;
                attachId = attach.ID;
                //Console.Out.WriteLine(attachId);

                if ((Name != default(string)) && (attachType == TDAPI_ATTACH_TYPE.TDATT_FILE) && attach.ID > 0)
                {
                    attach.Rename(Name);
                    attach.Post();
                }

                //If the file path is invalid and the attachment never uploads, ALM throws an error but posts the attachment anyways
                //returning no attachment object. So the only way to detect this is to look for 0 sized attachments and delete them
                attach.Refresh();

                if (attach.FileSize == 0 && attach.Type == (int)TDAPI_ATTACH_TYPE.TDATT_FILE)
                {
                    attachFact.RemoveItem(attach.ID);
                    success = false;
                }
                else
                {
                    success = true;
                }
            }
            catch (COMException ce)
            {
                rr.AddErrorLine(HandleException(ce));
            }
            finally { Disconnect(); }


            return(success);
        }
Exemple #39
0
 private AttachmentData getAttachmentData(AttachmentType type, XmlNode attachmentData)
 {
     return AttachmentFactory.GetAttachment(type, attachmentData);
 }
        private async void downloadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string attachmentId = "";

            if (dataGridView_AttachmentList.SelectedRows == null || dataGridView_AttachmentList.SelectedRows.Count == 0)
            {
                if (dataGridView_AttachmentList.SelectedCells == null || dataGridView_AttachmentList.SelectedCells.Count == 0)
                {
                    // Attachment is not selected.
                    return;
                }
                else
                {
                    // Cell is selected but row is not selected.

                    // Select the row.
                    dataGridView_AttachmentList.Rows[dataGridView_AttachmentList.SelectedCells[0].RowIndex].Selected = true;

                    // Get the attachment ID of the selected row.
                    attachmentId = dataGridView_AttachmentList.SelectedRows[0].Tag.ToString();

                    currentId = attachmentId;

                    // Reset rows.
                    dataGridView_ItemProps.Rows.Clear();
                    foreach (DataGridViewColumn col in dataGridView_ItemProps.Columns)
                    {
                        col.HeaderCell.SortGlyphDirection = SortOrder.None;
                    }

                    // Display the details of the selected attachment.
                    await ShowAttachmentDetailAsync(attachmentId);
                }
            }

            attachmentId = dataGridView_AttachmentList.SelectedRows[0].Tag.ToString();

            // Get the type of attachment.

            AttachmentType attachmentType = AttachmentType.FileAttachment;

            try
            {
                attachmentType = GetAttachmentTypeOfSelectedAttachment();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Office365APIEditor");
                return;
            }

            switch (attachmentType)
            {
            case AttachmentType.ItemAttachment:
                if (Util.UseMicrosoftGraphInMailboxViewer)
                {
                    saveFileDialog1.FileName = dataGridView_AttachmentList.SelectedRows[0].Cells[0].Value.ToString() + ".eml";

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        string rawContent = "";

                        try
                        {
                            rawContent = await viewerRequestHelper.GetAttachmentRawContentAsync(targetFolder.Type, targetItemId, attachmentId);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Office365APIEditor");
                            return;
                        }

                        try
                        {
                            using (StreamWriter streamWriter = new StreamWriter(saveFileDialog1.FileName, false, System.Text.Encoding.UTF8))
                            {
                                streamWriter.Write(rawContent);
                            }

                            MessageBox.Show("The attachment file was saved successfully.", "Office365APIEditor");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("The selected attachment is Item Attachment. You can not download this type of attachment using Office365APIEditor", "Office365APIEditor");

                    // The request to get MIME content of itemAttachment will be like below.
                    // https://outlook.office.com/api/beta/Users('6fc42d08-123b-405e-904d-545882e8922f@6d046331-5ea5-4306-87ae-8d51f3dcc71e')/Messages('AAMkAGYxOTczODY2LTQwYzktNDFmYS05ZTIzLWZmNjAxYmM1MWYwZABGAAAAAACmFAp715xPRpcdN7o1X1D7BwDKF8masRMzQ4BmqIbV6OsxAAAAAAEMAADKF8masRMzQ4BmqIbV6OsxAAM85mvEAAA=')/Attachments('AAMkAGYxOTczODY2LTQwYzktNDFmYS05ZTIzLWZmNjAxYmM1MWYwZABGAAAAAACmFAp715xPRpcdN7o1X1D7BwDKF8masRMzQ4BmqIbV6OsxAAAAAAEMAADKF8masRMzQ4BmqIbV6OsxAAM85mvEAAABEgAQAJHp5fRvE4ZIjU_j3_4mUYI=')/$value
                }

                break;

            case AttachmentType.FileAttachment:
                saveFileDialog1.FileName = dataGridView_AttachmentList.SelectedRows[0].Cells[0].Value.ToString();

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string rawContentBytes = "";

                    try
                    {
                        rawContentBytes = GetContentBytesOfSelectedAttachment();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Office365APIEditor");
                        return;
                    }

                    try
                    {
                        byte[] bytes = Convert.FromBase64String(rawContentBytes);

                        using (FileStream fileStream = new FileStream(saveFileDialog1.FileName, FileMode.Create, FileAccess.Write))
                        {
                            fileStream.Write(bytes, 0, bytes.Length);
                        }

                        MessageBox.Show("The attachment file was saved successfully.", "Office365APIEditor");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                break;

            case AttachmentType.ReferenceAttachment:
                string sourceUrl = "";

                try
                {
                    sourceUrl = GetSourceUrlOfSelectedAttachment();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Office365APIEditor");
                    return;
                }

                try
                {
                    Process.Start(sourceUrl);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                break;

            default:
                break;
            }
        }