public void AddAnnotation(Annotation a)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                Point pos;
                if (GetPressScatterViewItemPosition(a.Press, out pos))
                {
                    PostIt postIt = new PostIt();
                    postIt.Text = a.Comment;
                    postIt.User = a.User;

                    ScatterViewItem svi = new ScatterViewItem();
                    svi.Content = postIt;
                    svi.Center = GetPostItStartPosition(a.User);
                    svi.CanScale = false;
                    svi.CanMove = true;

                    Scatter.Items.Add(svi);

                    pos.X += rand.Next(-POSTIT_VARIATION, POSTIT_VARIATION);
                    pos.Y += rand.Next(-POSTIT_VARIATION, POSTIT_VARIATION);

                    Duration duration = new Duration(TimeSpan.FromSeconds(0.5));
                    PointAnimation an = new PointAnimation();
                    an.Duration = duration;
                    an.FillBehavior = FillBehavior.Stop;
                    an.To = pos;

                    Storyboard sb = new Storyboard();
                    sb.Duration = duration;
                    sb.Children.Add(an);

                    Storyboard.SetTarget(an, svi);
                    Storyboard.SetTargetProperty(an, new PropertyPath(ScatterViewItem.CenterProperty));

                    sb.Completed += new EventHandler((s, e) =>
                    {
                        svi.Center = pos;
                    });

                    sb.Begin(Scatter);
                }
            }));
        }
Exemplo n.º 2
0
 public void MakeAnnotation(Annotation a)
 {
     try
     {
         Tabletop.AddAnnotation(a);
     }
     catch (Exception e)
     {
         throw new FaultException(new FaultReason(e.Message + "\r\n" + e.StackTrace));
     }
 }