示例#1
0
 public static SkypePostcard CreateRaiseSelectFileCard(Photo photo)
 {
     var r = new SkypePostcard();
     r.Command = RAISE_SELECT_FILE;
     r.Message = SkypeMessageUniqueFile.CreateFrom(photo);
     return r;
 }
示例#2
0
文件: Enlisters.cs 项目: mitim/sps
 public void BroadcastPhoto(Photo photo)
 {
     Parallel.ForEach(_enlisters, current =>
     {
         current.SendPhoto(photo);
     });
 }
示例#3
0
 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)));
 }
示例#4
0
 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;
 }
示例#5
0
文件: SkypeCargo.cs 项目: mitim/sps
 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);
 }
示例#6
0
 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);
 }
示例#7
0
 public void ScaleToOriginalSize(Photo photo, Rect winSize)
 {
     double os = photo.Scale;
     photo.Scale = ORIGINAL_SCALE;
     FitMapRectWithScale(photo, os);
     CorrectScrollStop(photo, winSize);
 }
示例#8
0
 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);
 }
示例#9
0
 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);
 }
示例#10
0
文件: Photo.cs 项目: mitim/sps
 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;
 }
示例#11
0
 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);
 }
示例#12
0
 public static void AddFromOnline(Photo photo)
 {
     _instance.Add(photo);
 }
示例#13
0
 public void FlipVertical(Photo photo)
 {
     photo.FlipVertical *= -1;
 }
示例#14
0
 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;
 }
示例#15
0
 private Rect GetOriginalRect(Photo p)
 {
     return new Rect(
         p.MapLeft,
         p.MapTop,
         p.Image.PixelWidth,
         p.Image.PixelHeight
     );
 }
示例#16
0
 private void AidAutoSave(Photo item)
 {
     if (!Configuration.Instance.AutoSave) return;
     item.Save();
 }
示例#17
0
文件: Enlister.cs 项目: mitim/sps
 public void SendPhoto(Photo photo)
 {
     Delivery.Send(photo);
     Delivery.PostChatMessage(string.Format(Properties.Resources.CHAT_SENT_PHOTO, Owner.Name, photo.FileName));
 }
示例#18
0
 public void Remove(Photo item)
 {
     if (item == null) return;
     item.Close();
     _photos.Remove(item);
 }
示例#19
0
 public bool HasSameItem(Photo item)
 {
     foreach (var p in _photos)
     {
         if (p.IsSame(item)) return true;
     }
     return false;
 }
示例#20
0
 public void Add(Photo item)
 {
     if (item == null) return;
     if (HasSameItem(item)) return;
     _photos.Add(item);
     UpdateControlFlags();
     AidAutoSave(item);
 }
示例#21
0
 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);
 }
示例#22
0
 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);
 }
示例#23
0
 private void FitMapRectWithScale(Photo photo, double oldscale)
 {
     photo.MapRect = FitRectWithScale( photo.MapRect, oldscale, photo.Scale);
 }
示例#24
0
文件: Photo.cs 项目: mitim/sps
 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;
 }
示例#25
0
 private void ScrollToViewWindowOffsets(Photo p)
 {
     ViewWindow.ScrollToHorizontalOffset(p.WindowPosition.X);
     ViewWindow.ScrollToVerticalOffset(p.WindowPosition.Y);
 }
示例#26
0
 private void SetVMapPoint(Photo p)
 {
     Canvas.SetLeft(ViewImage, p.MapLeft);
     Canvas.SetTop(ViewImage, p.MapTop);
 }
示例#27
0
 public void FlipHorizontal(Photo photo)
 {
     photo.FlipHorizontal *= -1;
 }
示例#28
0
 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);
 }
示例#29
0
        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);
        }
示例#30
0
文件: Photo.cs 项目: mitim/sps
 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;
 }