using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using C1.Silverlight;
using C1.Silverlight.RichTextBox.Documents;

namespace Annotations
{
    /// <summary>
    /// A sticky note used by the AnnotationService
    /// </summary>
    public partial class StickyNote : UserControl
    {
        public StickyNote()
        {
            InitializeComponent();

            new C1DragHelper(drag, captureElementOnPointerPressed: true).DragDelta += (s, e) =>
            {
                var transform = Normal.RenderTransform as TranslateTransform;
                if (transform == null)
                    transform = new TranslateTransform();
                transform.X = transform.X + e.DeltaTranslation.X;
                transform.Y = transform.Y + e.DeltaTranslation.Y;
                Normal.RenderTransform = transform;
                line.X2 = -transform.X;
                line.Y2 = -transform.Y;
            };
        }

        public C1TextRange Range { get; set; }

        public string Text
        {
            get { return textBox.Text; }
            set { textBox.Text = value; }
        }

        private void Minimize(object sender, RoutedEventArgs e)
        {
            Normal.Visibility = Visibility.Collapsed;
            Minimized.Visibility = Visibility.Visible;
        }

        private void Restore(object sender, RoutedEventArgs e)
        {
            Minimized.Visibility = Visibility.Collapsed;
            Normal.Visibility = Visibility.Visible;
        }
    }
}
