Beispiel #1
0
        public static void ProcessMembersPhoto(DataTable employees)
        {
            for (int i = 0; i < employees.Rows.Count; i++)
            {
                var row       = employees.Rows[i];
                var bytes     = row["Photo"];
                var fullImage = ByteImageConverter.FromByteArray(bytes as byte[]);

                var   size   = new Size(40, 40);
                float scaleX = ((float)size.Width) / fullImage.Width;
                float scaleY = ((float)size.Height) / fullImage.Height;
                float scale  = scaleX > scaleY ? scaleX : scaleY;

                var resizedImage = new Bitmap(size.Width, size.Height);
                using (Graphics g = Graphics.FromImage(resizedImage)) {
                    size = new Size(
                        (int)(fullImage.Width * scale + 0.5f),
                        (int)(fullImage.Height * scale + 0.5f));
                    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                    g.DrawImage(fullImage, new Rectangle(Point.Empty, size));
                }
                var          opt = new PictureEditOptionsMask(null);
                var          img = PictureMaskHelper.CreateCircleMaskImage(resizedImage, opt);
                MemoryStream ms  = new MemoryStream();
                img.Save(ms, ImageFormat.Png);
                var result = ms.ToArray();
                ms.Close();
                row["Photo"] = result;
            }
        }
Beispiel #2
0
 public Agent(DataRow person)
 {
     this.person = person;
     if (!(person["Photo"] is DBNull))
     {
         photo = ByteImageConverter.FromByteArray((byte[])person["Photo"]);
     }
 }
Beispiel #3
0
 public Home(DataRow row)
 {
     this.row = row;
     features = DataHelper.GetFeaturesFormat(string.Format("{0}", row["Features"]));
     if (!(row["Photo"] is DBNull))
     {
         photo = ByteImageConverter.FromByteArray((byte[])row["Photo"]);
     }
 }
 Image CreateImage(byte[] data)
 {
     if (data == null)
     {
         return(ResourceImageHelper.CreateImageFromResourcesEx("DevExpress.DevAV.Resources.Unknown-user.png", typeof(Employee).Assembly));
     }
     else
     {
         return(ByteImageConverter.FromByteArray(data));
     }
 }
Beispiel #5
0
 internal static Image CreateImage(this Picture picture, string defaultImage = null)
 {
     if (picture == null)
     {
         if (string.IsNullOrEmpty(defaultImage))
         {
             defaultImage = DefaultPic;
         }
         return(ResourceImageHelper.CreateImageFromResourcesEx(defaultImage, typeof(Picture).Assembly));
     }
     return(ByteImageConverter.FromByteArray(picture.Data));
 }
Beispiel #6
0
        List <TileViewItemElement> GetMembersElements(string taskId)
        {
            var memberRows = membersData.Select("TaskID = " + taskId);
            var result     = new List <TileViewItemElement>();

            foreach (var memberRow in memberRows)
            {
                var photoBytes = employeesData.Rows.Find(memberRow["MemberID"])["Photo"];
                var element    = new TileViewItemElement();
                element.Image = ByteImageConverter.FromByteArray(photoBytes as byte[]);
                result.Add(element);
            }
            return(result);
        }
Beispiel #7
0
        internal static List <Image> GetPhotos(Home home)
        {
            List <Image> ret = new List <Image>();

            ret.Add(home.Photo);
            foreach (DataRow row in PhotosTable.Rows)
            {
                int id = home.ID % 7 + 1;
                if (id.Equals(row["ParentID"]))
                {
                    ret.Add(ByteImageConverter.FromByteArray((byte[])row["Photo"]));
                }
            }
            return(ret);
        }
Beispiel #8
0
        static List <Vehicle> InitMDBData(string connectionString)
        {
            string Model     = "Model";
            string Trademark = "Trademark";

            DataSet ds = new DataSet();

            FillTable(Model, connectionString, ds);
            FillTable(Trademark, connectionString, ds);

            List <Trademark> listTrademarks = new List <Trademark>();

            foreach (DataRow row in ds.Tables[Trademark].Rows)
            {
                listTrademarks.Add(new Trademark()
                {
                    ID   = (int)(long)row["ID"],
                    Name = (string)row["Name"],
                });
            }

            var listModels = new List <Vehicle>();

            foreach (DataRow row in ds.Tables[Model].Rows)
            {
                listModels.Add(new Vehicle()
                {
                    ID                 = (int)(long)row["ID"],
                    Name               = (string)row["Name"],
                    Trademark          = (int)(long)row["TrademarkID"],
                    Modification       = (string)row["Modification"],
                    MPGCity            = System.DBNull.Value.Equals(row["MPG City"]) ? null : (int?)(long)row["MPG City"],
                    MPGHighway         = System.DBNull.Value.Equals(row["MPG City"]) ? null : (int?)(long)row["MPG Highway"],
                    Doors              = (int)(long)row["Doors"],
                    Cylinders          = (int)(long)row["Cylinders"],
                    Horsepower         = (string)row["Horsepower"],
                    Torque             = (string)row["Torque"],
                    TransmissionSpeeds = Convert.ToInt32(row["Transmission Speeds"]),
                    TransmissionType   = (int)(long)row["Transmission Type"],
                    Description        = string.Format("{0}", row["Description"]),
                    Photo              = ByteImageConverter.FromByteArray((byte[])row["Photo"]),
                    TrademarkName      = GetTrademarkName(ds.Tables[Trademark], (int)(long)row["TrademarkID"])
                });
            }
            return(listModels);
        }
Beispiel #9
0
        public Contacto(DataRow customer, DataRow person)
        {
            this.customer = customer;
            this.person   = person;
            if (!(customer["foto"] is DBNull))
            {
                foto     = ByteImageConverter.FromByteArray((byte[])customer["foto"]);
                hay_foto = true;
            }
            //else foto = global::DevExpress.MailClient.Win.Properties.Resources.Unknown_user;

            name             = new NombreCompleto(string.Format("{0}", person["FirstName"]), string.Format("{0}", customer["MiddleName"]), string.Format("{0}", person["LastName"]));
            email            = string.Format("{0}", customer["Email"]).Replace("dxvideorent.com", "dxmail.net");
            genero           = (eGenero)person["Gender"];
            fecha_nacimiento = (DateTime?)person["BirthDate"];
            telefono         = string.Format("{0}", customer["Phone"]);
            direccion        = new Address(string.Format("{0}", customer["Address"]));
        }
Beispiel #10
0
 public Contact(DataRow customer, DataRow person)
 {
     this.customer = customer;
     this.person   = person;
     if (!(customer["Photo"] is DBNull))
     {
         photo    = ByteImageConverter.FromByteArray((byte[])customer["Photo"]);
         hasPhoto = true;
     }
     else
     {
         photo = global::DevExpress.MailClient.Win.Properties.Resources.Unknown_user;
     }
     name      = new FullName(string.Format("{0}", person["FirstName"]), string.Format("{0}", customer["MiddleName"]), string.Format("{0}", person["LastName"]));
     email     = string.Format("{0}", customer["Email"]).Replace("dxvideorent.com", "dxmail.net");
     gender    = (ContactGender)person["Gender"];
     birthDate = (DateTime?)person["BirthDate"];
     phone     = string.Format("{0}", customer["Phone"]);
     address   = new Address(string.Format("{0}", customer["Address"]));
 }
Beispiel #11
0
        public UserInfo(DataRow customer, DataRow person)
        {
            this.customer = customer;
            this.person   = person;
            if (!(customer["Photo"] is DBNull))
            {
                photo    = ByteImageConverter.FromByteArray((byte[])customer["Photo"]);
                hasPhoto = true;
            }
            else
            {
                photo = global::DevExpress.ProductsDemo.Win.Properties.Resources.Unknown_user;
            }



            name = string.Format("{0}", person["Name"]);

            phone = string.Format("{0}", customer["Phone"]);
        }
        protected override void OnEditValueChanged()
        {
            if (!(EditValue is EditValueInstance))
            {
                return;
            }
            if ((EditValue != null) && (EditValue as EditValueInstance).Image != null)
            {
                this.image = ByteImageConverter.FromByteArray(ByteImageConverter.ToByteArray((EditValue as EditValueInstance).Image));
            }
            Point offset = new Point(0, 0);

            if ((EditValue as EditValueInstance) != null)
            {
                offset = (EditValue as EditValueInstance).Offset;
            }
            if ((EditValue != null) && (offset != null))
            {
                this.HorizontOffset = offset.X;
                this.VerticalOffset = offset.Y;
            }
        }
Beispiel #13
0
        void PopulateMembers()
        {
            tileGroup.Items.Clear();
            addMemberItem.Visible = true;
            tileGroup.Items.Add(addMemberItem);

            var memberIDs = GetMemeberIDs();

            foreach (var memberId in memberIDs)
            {
                var bytes = Employees.Rows.Find(memberId)["Photo"];
                var item  = new TileItem();
                item.Image          = ByteImageConverter.FromByteArray(bytes as byte[]);
                item.ImageAlignment = TileItemContentAlignment.MiddleCenter;
                var superTip = new SuperToolTip();
                superTip.Items.AddTitle(GetEmployeeFullName(memberId));
                item.SuperTip = superTip;
                item.Tag      = memberId;
                tileGroup.Items.Insert(0, item);
                addMemberItem.Visible = tileGroup.Items.Count == 5 ? false : true;
            }
        }
        protected virtual Image GetImage()
        {
            Image      img = null;
            MyTreeList mtl = TreeList as MyTreeList;

            if (mtl.AvatarImageFieldName == string.Empty)
            {
                return(img);
            }

            try
            {
                DevExpress.XtraTreeList.Columns.TreeListColumn col = TreeList.Columns[mtl.AvatarImageFieldName];
                byte[] buffer = (byte[])GetValue(TreeList.Columns.IndexOf(col));
                img = ByteImageConverter.FromByteArray(buffer);
            }
            catch
            {
                img = null;
            }

            return(img);
        }
 internal Image ByteArrayToImage(byte[] inp)
 {
     return(ByteImageConverter.FromByteArray(ByteImageConverter.ToByteArray(inp)));
 }
 public static Image GetImage(byte[] array)
 {
     return(ByteImageConverter.FromByteArray(array));
 }