/// <summary> /// Save object to serialization stream /// </summary> /// <param name="info">The data being written to disk</param> /// <param name="orderNumber">Index of the Layer being saved</param> /// <param name="objectIndex">Index of the object on the Layer</param> public virtual void SaveToStream(SerializationInfo info, int orderNumber, int objectIndex) { info.AddValue( String.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryColor, orderNumber, objectIndex), Color.ToArgb()); info.AddValue( String.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryPenWidth, orderNumber, objectIndex), PenWidth); info.AddValue( string.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryPen, orderNumber, objectIndex), PenType); info.AddValue( string.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryBrush, orderNumber, objectIndex), BrushType); info.AddValue( String.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryFillColor, orderNumber, objectIndex), FillColor.ToArgb()); info.AddValue( String.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryFilled, orderNumber, objectIndex), Filled); info.AddValue( String.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryZOrder, orderNumber, objectIndex), ZOrder); info.AddValue( String.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryRotation, orderNumber, objectIndex), Rotation); info.AddValue( String.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryTipText, orderNumber, objectIndex), tipText); }
public override void Fill(BitmapWrap bmp, Point startingPoint) { if (startingPoint.X < 0 || startingPoint.X >= bmp.Width || startingPoint.Y < 0 || startingPoint.Y >= bmp.Height) { return; } Color startingColor = bmp.GetPixel(startingPoint.X, startingPoint.Y); if (startingColor.ToArgb() == FillColor.ToArgb()) { return; } Point point = startingPoint; Queue <Point> pointsToCheck = new Queue <Point>(); pointsToCheck.Enqueue(point); while (pointsToCheck.Count > 0) { point = new Point(pointsToCheck.Peek().X, pointsToCheck.Peek().Y); pointsToCheck.Dequeue(); if (point.X > 0 && bmp.GetPixel(point.X - 1, point.Y).ToArgb() == startingColor.ToArgb()) { bmp.SetPixel(point.X - 1, point.Y, FillColor); pointsToCheck.Enqueue(new Point(point.X - 1, point.Y)); } if (point.X < bmp.Width - 1 && bmp.GetPixel(point.X + 1, point.Y).ToArgb() == startingColor.ToArgb()) { bmp.SetPixel(point.X + 1, point.Y, FillColor); pointsToCheck.Enqueue(new Point(point.X + 1, point.Y)); } if (point.Y > 0 && bmp.GetPixel(point.X, point.Y - 1).ToArgb() == startingColor.ToArgb()) { bmp.SetPixel(point.X, point.Y - 1, FillColor); pointsToCheck.Enqueue(new Point(point.X, point.Y - 1)); } if (point.Y < bmp.Height - 1 && bmp.GetPixel(point.X, point.Y + 1).ToArgb() == startingColor.ToArgb()) { bmp.SetPixel(point.X, point.Y + 1, FillColor); pointsToCheck.Enqueue(new Point(point.X, point.Y + 1)); } } }
protected override void Render(System.Web.UI.HtmlTextWriter writer) { if (!_bound) { this.DataBind(); } if (memberRow == null) { return; } MembersManager mMgr = new MembersManager(); //why we have to get the member row again??? i couldn't find a reason. //memberRow = mMgr.GetMemberProfile((int)memberRow["MemberId"]); string picture = ""; if (memberRow["Picture"] != System.DBNull.Value && !String.IsNullOrEmpty(memberRow["Picture"].ToString())) { picture = memberRow["Picture"].ToString(); } int MemberId = (int)memberRow["MemberId"]; int privacy = 0; if (memberRow["Privacy"] != DBNull.Value) { privacy = (int)memberRow["Privacy"]; } string image = ""; PrivacySettingsManager psMgr = new PrivacySettingsManager(); if (MemberId != WebContext.Profile.UserId) { switch (psMgr.CheckMemberProperty("ProfilePicture", privacy)) { case PrivacyOptions.OnlyMe: picture = ""; break; case PrivacyOptions.Friends: lw.Base.CustomPage page = this.Page as lw.Base.CustomPage; DataTable MyFriends = FriendsManager.GetMyFriends(page); if (MyFriends.Select(string.Format("FriendId={0} and Status=1", memberRow["MemberId"])).Length == 0) { picture = ""; } break; default: break; } if (!Visible) { return; } } if (picture != "") { if (useGUID) { image = string.Format("{0}/{2}/{1}", MembersSettings.MemberPicturesFolder, picture, StringUtils.ToURL(memberRow["Geuid"])); } else { image = string.Format("{0}/{2}/{1}", MembersSettings.MemberPicturesFolder, picture, StringUtils.ToURL(memberRow["UserName"])); } } else { if (NoPicture != "") { image = NoPicture; this._Src = NoPicture; } else { if (NoFPicture != "" && NoMPicture != "") { Gender?_gender = Gender.Male; try { _gender = (lw.Members.Gender)Enum.Parse(typeof(lw.Members.Gender), memberRow["Gender"].ToString()); } catch { } if (_gender == lw.Members.Gender.Male) { image = NoMPicture; this._Src = NoMPicture; } else { image = NoFPicture; this._Src = NoFPicture; } } } } //this.Alt = memberRow["Name"].ToString(); this.Alt = memberRow["FirstName"].ToString() + " " + memberRow["LastName"].ToString(); switch (MemberImageType) { case ImageType.Crop: case ImageType.Resize: if (_width > 0) { if (MemberImageType == ImageType.Resize) { this._Src = string.Format("{4}/prv/handlers/ImageResizer.ashx?src={0}&width={1}&height={2}&fillColor={3}", image, _Width, _Height, FillColor.ToArgb(), WebContext.Root); } else { this._Src = string.Format("{4}/prv/handlers/ImageCropper.ashx?src={0}&width={1}&height={2}&fillColor={3}", image, _Width, _Height, FillColor.ToArgb()); } } else { this._Src = string.Format("{0}/{1}", WebContext.Root, image); } break; case ImageType.NewResize: this._Src = string.Format("{3}prv/handlers/ResizeImage.ashx?img={0}&w={1}&h={2}", image, _Width, _Height, WebContext.Root); break; case ImageType.Large: this._Src = image; break; case ImageType.Medium: if (picture != "") { this._Src = image.ToLower().Replace(".jpg", "-m.jpg"); } else { this._Src = NoPicture; } break; case ImageType.Thumb: if (picture != "") { this._Src = image.ToLower().Replace(".jpg", "-s.jpg?" + DateTime.Now.ToFileTime()); // Datetime added to prevent cashing } else { this._Src = NoPicture; } break; default: break; } if (this._Src != "") { this.Src = WebContext.Root + "/" + this._Src; base.Render(writer); } }
public override void DataBind() { if (this._bound) { return; } _bound = true; _itemUniqueName = ControlUtils.GetBoundedDataField(this.NamingContainer, "UniqueName").ToString(); if (_Image == null) { if (ThumbImage) { _Image = ControlUtils.GetBoundedDataField(this.NamingContainer, "ThumbImage"); } else { _Image = ControlUtils.GetBoundedDataField(this.NamingContainer, "Image" + number.ToString()); } } if (_Image != null && _Image.ToString() != "") { switch (Type) { case ImageType.Resize: bigImage = string.Format("{0}/{3}/{1}/{2}", lw.CTE.Folders.ProductsImages, "Large", _Image, _itemUniqueName ); this._Src = string.Format("ImageResizer.axd?src={0}&width={1}&height={2}&fillColor={3}", bigImage, this.Width, this.Height, FillColor.ToArgb(), WebContext.Root); break; case ImageType.Thumb: case ImageType.Medium: case ImageType.Large: default: this._Src = string.Format("{4}/{0}/{3}/{1}/{2}", lw.CTE.Folders.ProductsImages, this.Type, _Image, _itemUniqueName, WebContext.Root ); break; } } else if (Type == ImageType.Thumb) { if (HideIfNoImage) { this.Visible = false; } this._Src = "/images/image-not-available.gif"; } if (_Title == null) { _Title = ControlUtils.GetBoundedDataField(this.NamingContainer, "Title"); } if (_Title != null) { this.Attributes["Title"] = _Title.ToString(); } base.DataBind(); }
public override void DataBind() { if (!NoResize) { this.Attributes.Add("src", string.Format("{4}/ImageResizer.axd?src={0}&width={1}&height={2}&fillColor={3}&crop={5}", src, this.Width.Value, this.Height.Value, FillColor.ToArgb(), WebContext.Root, Crop)); } else { this.Attributes.Add("src", Src); } base.DataBind(); }