public static SkypePostcard CreateRaiseSelectFileCard(Photo photo) { var r = new SkypePostcard(); r.Command = RAISE_SELECT_FILE; r.Message = SkypeMessageUniqueFile.CreateFrom(photo); return r; }
public void BroadcastPhoto(Photo photo) { Parallel.ForEach(_enlisters, current => { current.SendPhoto(photo); }); }
public void InitializeViewPos(Photo photo, Vector windowSize, Vector mapSize) { if (!photo.WindowPosition.Equals(Photo.UNINITIALIZED_POINT)) return; var x = (mapSize.X - windowSize.X) / 2; var y = (mapSize.Y - photo.Image.PixelHeight) / 2; photo.WindowPosition = new Point(x, y); CorrectScrollStop(photo, new Rect(photo.WindowPosition, Point.Add(photo.WindowPosition, windowSize))); }
public static SkypeMessageUniqueFile CreateFrom(Photo photo) { var r = new SkypeMessageUniqueFile(); r.FileName = photo.FileName; r.Size = photo.Image.StreamSource.Length; r.CreateTime = photo.CreateTime; r.UpdateTime = photo.UpdateTime; return r; }
public SkypeCargo(Photo photo) { FileName = photo.FileName; CreateTime = photo.CreateTime; UpdateTime = photo.UpdateTime; AccessTime = photo.AccessTime; Size = photo.Image.StreamSource.Length; SetData((MemoryStream)photo.Image.StreamSource); }
public void CorrectScaledOffset(Photo photo, Point winPos, Point mapPos, Rect winSize) { if (Mode != EffectMode.SCALE) return; double x = (mapPos.X * photo.Scale) - winPos.X; double y = (mapPos.Y * photo.Scale) - winPos.Y; photo.WindowPosition = new Point(x, y); winSize.X = photo.WindowPosition.X; winSize.Y = photo.WindowPosition.Y; CorrectScrollStop(photo, winSize); }
public void ScaleToOriginalSize(Photo photo, Rect winSize) { double os = photo.Scale; photo.Scale = ORIGINAL_SCALE; FitMapRectWithScale(photo, os); CorrectScrollStop(photo, winSize); }
public void Scale(Photo photo, double delta) { Mode = EffectMode.SCALE; double os = photo.Scale; double ns = photo.Scale + ZoomDelta(delta); photo.Scale = (ns > ZOOM_DELTA) ? ns : ZOOM_DELTA; FitMapRectWithScale(photo, os); }
public void ScaleToFitSize(Photo photo, Rect winSize) { double os = photo.Scale; var xs = winSize.Width / photo.Image.PixelWidth; var ys = winSize.Height / photo.Image.PixelHeight; var ns = xs <= ys ? xs : ys; photo.Scale = (ns <= ORIGINAL_SCALE) ? ns : ORIGINAL_SCALE; FitMapRectWithScale(photo, os); CorrectScrollStop(photo, winSize); }
public static Photo Create(SkypeCargo data, Enlister own) { Photo p = new Photo(data.GetData(), data.FileName, own); p.CreateTime = data.CreateTime; p.UpdateTime = data.UpdateTime; p.AccessTime = data.AccessTime; p.CanSave = true; return p; }
public void RotateTo(Photo photo,double angle, Rect windowOffset) { photo.Rotate = angle; photo.MapRect = RecalcShowRect(GetOriginalRect(photo), photo.Scale, ConvertAngleToRad(photo.Rotate)); CorrectScrollStop(photo, windowOffset); }
public static void AddFromOnline(Photo photo) { _instance.Add(photo); }
public void FlipVertical(Photo photo) { photo.FlipVertical *= -1; }
private void ShowCenterScope(Photo p) { Canvas.SetLeft(CenterScope, (p.MapLeft + p.CenterX) - 5); Canvas.SetTop(CenterScope, (p.MapTop + p.CenterY) - 5); CenterScope.Visibility = Visibility.Visible; }
private Rect GetOriginalRect(Photo p) { return new Rect( p.MapLeft, p.MapTop, p.Image.PixelWidth, p.Image.PixelHeight ); }
private void AidAutoSave(Photo item) { if (!Configuration.Instance.AutoSave) return; item.Save(); }
public void SendPhoto(Photo photo) { Delivery.Send(photo); Delivery.PostChatMessage(string.Format(Properties.Resources.CHAT_SENT_PHOTO, Owner.Name, photo.FileName)); }
public void Remove(Photo item) { if (item == null) return; item.Close(); _photos.Remove(item); }
public bool HasSameItem(Photo item) { foreach (var p in _photos) { if (p.IsSame(item)) return true; } return false; }
public void Add(Photo item) { if (item == null) return; if (HasSameItem(item)) return; _photos.Add(item); UpdateControlFlags(); AidAutoSave(item); }
public void ScrollTo(Photo photo, Point outcome, Rect winSize) { if (Mode != EffectMode.SCROLL) return; var dx = PrevMousePos.X - outcome.X; var dy = PrevMousePos.Y - outcome.Y; PrevMousePos = outcome; var ns = Rect.Offset(winSize, new Vector(dx, dy)); photo.WindowPosition = new Point(ns.X, ns.Y); CorrectScrollStop(photo, ns); }
public void CorrectScrollStop(Photo photo, Rect windowOffset) { var x = CorrectOffset(photo.MapRect.Left, photo.MapRect.Width, windowOffset.Left, windowOffset.Width); var y = CorrectOffset(photo.MapRect.Top, photo.MapRect.Height, windowOffset.Top, windowOffset.Height); photo.WindowPosition = new Point(x, y); }
private void FitMapRectWithScale(Photo photo, double oldscale) { photo.MapRect = FitRectWithScale( photo.MapRect, oldscale, photo.Scale); }
public bool IsSame(Photo p) { if (!FileName.Equals(p.FileName)) return false; if (!CreateTime.Equals(p.CreateTime)) return false; if (!UpdateTime.Equals(p.UpdateTime)) return false; if (Image.StreamSource.Length != p.Image.StreamSource.Length) return false; return true; }
private void ScrollToViewWindowOffsets(Photo p) { ViewWindow.ScrollToHorizontalOffset(p.WindowPosition.X); ViewWindow.ScrollToVerticalOffset(p.WindowPosition.Y); }
private void SetVMapPoint(Photo p) { Canvas.SetLeft(ViewImage, p.MapLeft); Canvas.SetTop(ViewImage, p.MapTop); }
public void FlipHorizontal(Photo photo) { photo.FlipHorizontal *= -1; }
public void RotateTo(Photo photo, Rect mapRect, Point outcome, Rect windowOffset) { if (Mode != EffectMode.ROTATE) return; var r1 = CalcRad(mapRect, PrevMousePos); var r2 = CalcRad(mapRect, outcome); photo.Rotate = (photo.Rotate + (ConvertRadToAngle(r2 - r1) * ROTATE_VALUE) + 360) % 360; PrevMousePos = outcome; photo.MapRect = RecalcShowRect(GetOriginalRect(photo), photo.Scale, ConvertAngleToRad(photo.Rotate)); CorrectScrollStop(photo, windowOffset); }
private void ResetViewTransforms(Photo p) { if (p == null) return; SetVMapPoint(p); Effector.InitializeViewPos( p, new Vector(ViewWindow.ActualWidth, ViewWindow.ActualHeight), new Vector(p.MapSpan, p.MapSpan) ); ScrollToViewWindowOffsets(p); }
public static Photo Create(string path, Enlister own) { Photo p = null; using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { try { p = new Photo(fs, path, own); log.Debug(p.Owner.Handle + "'s " + p.Path + " is " + (p.Image != null ? "exist." : "missing.")); log.Debug("Bitmap size is x:" + p.Image.PixelWidth + " y:" + p.Image.PixelHeight); } catch (Exception ex) { log.Error("Local file '" + path + "' can't open.", ex); throw ex; } } p.CreateTime = File.GetCreationTime(path); p.UpdateTime = File.GetLastWriteTime(path); p.AccessTime = File.GetLastAccessTime(path); p.CanSave = true; if (path.StartsWith(Configuration.Instance.SaveFolder)) p.CanSave = false; return p; }