Exemple #1
0
        /// <summary>
        /// Choose an IAnnotationComponent for a given IAttachedAnnotation.  Implementation in AnnotationComponentChooser knows
        /// about all out-of-box IAnnotationComponents.  The default mapping will be stated here later.
        /// Subclasses can overwrite this method to return application specific mapping.
        /// Note: In future release this method should be made virtual.
        /// </summary>
        /// <param name="attachedAnnotation">The IAttachedAnnotation that needs an IAnnotationComponent </param>
        /// <returns></returns>
        public IAnnotationComponent ChooseAnnotationComponent(IAttachedAnnotation attachedAnnotation)
        {
            if (attachedAnnotation == null)
            {
                throw new ArgumentNullException("attachedAnnotation");
            }

            IAnnotationComponent ac = null;

            // Text StickyNote
            if (attachedAnnotation.Annotation.AnnotationType == StickyNoteControl.TextSchemaName)
            {
                ac = new StickyNoteControl(StickyNoteType.Text) as IAnnotationComponent;
            }
            // Ink StickyNote
            else if (attachedAnnotation.Annotation.AnnotationType == StickyNoteControl.InkSchemaName)
            {
                ac = new StickyNoteControl(StickyNoteType.Ink) as IAnnotationComponent;
            }
            // Highlight
            else if (attachedAnnotation.Annotation.AnnotationType == HighlightComponent.TypeName)
            {
                ac = new HighlightComponent() as IAnnotationComponent;
            }

            return(ac);
        }
        // Token: 0x06007854 RID: 30804 RVA: 0x002243FC File Offset: 0x002225FC
        public static void UpdateAnnotation(XmlToken token, StickyNoteControl snc, SNCAnnotation sncAnnotation)
        {
            AnnotationService annotationService = null;
            bool autoFlush = false;

            try
            {
                annotationService = AnnotationService.GetService(((IAnnotationComponent)snc).AnnotatedElement);
                if (annotationService != null && annotationService.Store != null)
                {
                    autoFlush = annotationService.Store.AutoFlush;
                    annotationService.Store.AutoFlush = false;
                }
                if ((token & XmlToken.Ink) != (XmlToken)0 && snc.Content.Type == StickyNoteType.Ink)
                {
                    sncAnnotation.UpdateContent(snc, true, XmlToken.Ink);
                }
                if ((token & XmlToken.Text) != (XmlToken)0 && snc.Content.Type == StickyNoteType.Text)
                {
                    sncAnnotation.UpdateContent(snc, true, XmlToken.Text);
                }
                if ((token & (XmlToken.Left | XmlToken.Top | XmlToken.XOffset | XmlToken.YOffset | XmlToken.Width | XmlToken.Height | XmlToken.IsExpanded | XmlToken.Author | XmlToken.ZOrder)) != (XmlToken)0)
                {
                    SNCAnnotation.UpdateMetaData(token, snc, sncAnnotation);
                }
            }
            finally
            {
                if (annotationService != null && annotationService.Store != null)
                {
                    annotationService.Store.AutoFlush = autoFlush;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Invoked when the comment collection in m_stream changes. This method updates the set of
        /// sticky note controls on the drawing canvas that are used to represent comments for
        /// the process unit.
        /// </summary>
        private void Comments_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            // Start by deleting any sticky note controls that represent comments that are no longer
            // in the comment collection. While we do this, build a list of all comments that we
            // have a sticky note control for (used in next step).
            List <StickyNote> existing = new List <StickyNote>();

            for (int i = 0; i < m_stickyNotes.Count; i++)
            {
                if (!m_stream.Comments.Contains(m_stickyNotes[i].StickyNote))
                {
                    // Tell the sticky note to remove itself from the drawing canvas
                    m_stickyNotes[i].RemoveSelfFromCanvas(m_canvas);

                    // Remove it from our collection as well and then back up the index
                    m_stickyNotes.RemoveAt(i);
                    i--;
                }
                else
                {
                    existing.Add(m_stickyNotes[i].StickyNote);
                }
            }

            // Now add new sticky note controls for comments that don't have them
            for (int i = 0; i < m_stream.Comments.Count; i++)
            {
                if (!existing.Contains(m_stream.Comments[i]))
                {
                    m_stickyNotes.Add(StickyNoteControl.CreateOnCanvas(
                                          m_canvas, m_stream.Comments[i], this));
                }
            }
        }
        // Token: 0x06007863 RID: 30819 RVA: 0x00224D80 File Offset: 0x00222F80
        private static void UpdateMetaData(XmlToken token, StickyNoteControl snc, SNCAnnotation sncAnnotation)
        {
            AnnotationResource annotationResource;
            XmlElement         xmlElement;
            bool flag;
            bool flag2;

            SNCAnnotation.GetCargoAndRoot(sncAnnotation, XmlToken.MetaData, out annotationResource, out xmlElement, out flag, out flag2);
            if ((token & XmlToken.IsExpanded) != (XmlToken)0)
            {
                bool isExpanded = snc.IsExpanded;
                sncAnnotation.UpdateAttribute(xmlElement, XmlToken.IsExpanded, isExpanded.ToString(CultureInfo.InvariantCulture));
            }
            if ((token & XmlToken.Height) != (XmlToken)0)
            {
                double num = (double)snc.GetValue(FrameworkElement.HeightProperty);
                sncAnnotation.UpdateAttribute(xmlElement, XmlToken.Height, num.ToString(CultureInfo.InvariantCulture));
            }
            if ((token & XmlToken.Width) != (XmlToken)0)
            {
                double num2 = (double)snc.GetValue(FrameworkElement.WidthProperty);
                sncAnnotation.UpdateAttribute(xmlElement, XmlToken.Width, num2.ToString(CultureInfo.InvariantCulture));
            }
            if ((token & XmlToken.Left) != (XmlToken)0)
            {
                double num3 = snc.PositionTransform.X;
                if (snc.FlipBothOrigins)
                {
                    num3 = -(num3 + snc.Width);
                }
                sncAnnotation.UpdateAttribute(xmlElement, XmlToken.Left, num3.ToString(CultureInfo.InvariantCulture));
            }
            if ((token & XmlToken.Top) != (XmlToken)0)
            {
                sncAnnotation.UpdateAttribute(xmlElement, XmlToken.Top, snc.PositionTransform.Y.ToString(CultureInfo.InvariantCulture));
            }
            if ((token & XmlToken.XOffset) != (XmlToken)0)
            {
                sncAnnotation.UpdateAttribute(xmlElement, XmlToken.XOffset, snc.XOffset.ToString(CultureInfo.InvariantCulture));
            }
            if ((token & XmlToken.YOffset) != (XmlToken)0)
            {
                sncAnnotation.UpdateAttribute(xmlElement, XmlToken.YOffset, snc.YOffset.ToString(CultureInfo.InvariantCulture));
            }
            if ((token & XmlToken.ZOrder) != (XmlToken)0)
            {
                sncAnnotation.UpdateAttribute(xmlElement, XmlToken.ZOrder, ((IAnnotationComponent)snc).ZOrder.ToString(CultureInfo.InvariantCulture));
            }
            if (flag2)
            {
                annotationResource.Contents.Add(xmlElement);
            }
            if (flag)
            {
                sncAnnotation._annotation.Cargos.Add(annotationResource);
            }
        }
Exemple #5
0
        // Token: 0x06006288 RID: 25224 RVA: 0x001BA5F8 File Offset: 0x001B87F8
        public IAnnotationComponent ChooseAnnotationComponent(IAttachedAnnotation attachedAnnotation)
        {
            if (attachedAnnotation == null)
            {
                throw new ArgumentNullException("attachedAnnotation");
            }
            IAnnotationComponent result = null;

            if (attachedAnnotation.Annotation.AnnotationType == StickyNoteControl.TextSchemaName)
            {
                result = new StickyNoteControl(StickyNoteType.Text);
            }
            else if (attachedAnnotation.Annotation.AnnotationType == StickyNoteControl.InkSchemaName)
            {
                result = new StickyNoteControl(StickyNoteType.Ink);
            }
            else if (attachedAnnotation.Annotation.AnnotationType == HighlightComponent.TypeName)
            {
                result = new HighlightComponent();
            }
            return(result);
        }
Exemple #6
0
 public static IObservable <EventPattern <ContextMenuEventArgs> > ContextMenuClosingObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <ContextMenuEventHandler, ContextMenuEventArgs>(h => This.ContextMenuClosing += h, h => This.ContextMenuClosing -= h));
 }
Exemple #7
0
 public static IObservable <EventPattern <ToolTipEventArgs> > ToolTipClosingObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <ToolTipEventHandler, ToolTipEventArgs>(h => This.ToolTipClosing += h, h => This.ToolTipClosing -= h));
 }
Exemple #8
0
 public static IObservable <EventPattern <RoutedEventArgs> > UnloadedObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.Unloaded += h, h => This.Unloaded -= h));
 }
Exemple #9
0
 public static IObservable <EventPattern <ManipulationCompletedEventArgs> > ManipulationCompletedObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <EventHandler <ManipulationCompletedEventArgs>, ManipulationCompletedEventArgs>(h => This.ManipulationCompleted += h, h => This.ManipulationCompleted -= h));
 }
Exemple #10
0
 public static IObservable <EventPattern <RequestBringIntoViewEventArgs> > RequestBringIntoViewObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <RequestBringIntoViewEventHandler, RequestBringIntoViewEventArgs>(h => This.RequestBringIntoView += h, h => This.RequestBringIntoView -= h));
 }
        // Token: 0x06007862 RID: 30818 RVA: 0x00224C48 File Offset: 0x00222E48
        private void UpdateContent(StickyNoteControl snc, bool updateAnnotation, XmlToken token)
        {
            Invariant.Assert(snc != null, "Sticky Note Control is null.");
            Invariant.Assert((token & (XmlToken.Text | XmlToken.Ink)) > (XmlToken)0, "No token specified.");
            StickyNoteContentControl content = snc.Content;

            if (content == null)
            {
                return;
            }
            if ((token == XmlToken.Ink && content.Type != StickyNoteType.Ink) || (token == XmlToken.Text && content.Type != StickyNoteType.Text))
            {
                return;
            }
            XmlElement xmlElement = null;

            if (updateAnnotation)
            {
                AnnotationResource annotationResource = null;
                bool flag  = false;
                bool flag2 = false;
                if (!content.IsEmpty)
                {
                    SNCAnnotation.GetCargoAndRoot(this, token, out annotationResource, out xmlElement, out flag2, out flag);
                    content.Save(xmlElement);
                }
                else
                {
                    string cargoName = SNCAnnotation.GetCargoName(token);
                    annotationResource = this.FindCargo(cargoName);
                    if (annotationResource != null)
                    {
                        this._annotation.Cargos.Remove(annotationResource);
                        this._cachedXmlElements.Remove(token);
                    }
                }
                if (flag)
                {
                    Invariant.Assert(xmlElement != null, "XmlElement should have been created.");
                    Invariant.Assert(annotationResource != null, "Cargo should have been retrieved.");
                    annotationResource.Contents.Add(xmlElement);
                }
                if (flag2)
                {
                    Invariant.Assert(annotationResource != null, "Cargo should have been created.");
                    this._annotation.Cargos.Add(annotationResource);
                    return;
                }
            }
            else
            {
                XmlElement xmlElement2 = (XmlElement)this.FindData(token);
                if (xmlElement2 != null)
                {
                    content.Load(xmlElement2);
                    return;
                }
                if (!content.IsEmpty)
                {
                    content.Clear();
                }
            }
        }
Exemple #12
0
 public static IObservable <EventPattern <EventArgs> > LayoutUpdatedObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <EventHandler, EventArgs>(h => This.LayoutUpdated += h, h => This.LayoutUpdated -= h));
 }
Exemple #13
0
 public static IObservable <EventPattern <RoutedEventArgs> > LostFocusObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.LostFocus += h, h => This.LostFocus -= h));
 }
Exemple #14
0
 public static IObservable <EventPattern <TouchEventArgs> > PreviewTouchUpObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.PreviewTouchUp += h, h => This.PreviewTouchUp -= h));
 }
Exemple #15
0
 public static IObservable <EventPattern <TouchEventArgs> > TouchLeaveObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.TouchLeave += h, h => This.TouchLeave -= h));
 }
Exemple #16
0
 public static IObservable <EventPattern <SizeChangedEventArgs> > SizeChangedObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <SizeChangedEventHandler, SizeChangedEventArgs>(h => This.SizeChanged += h, h => This.SizeChanged -= h));
 }
Exemple #17
0
 public static IObservable <EventPattern <DragEventArgs> > DropObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.Drop += h, h => This.Drop -= h));
 }
Exemple #18
0
 public static IObservable <EventPattern <DragEventArgs> > PreviewDragLeaveObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.PreviewDragLeave += h, h => This.PreviewDragLeave -= h));
 }
Exemple #19
0
 public static IObservable <EventPattern <MouseButtonEventArgs> > PreviewMouseDownObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.PreviewMouseDown += h, h => This.PreviewMouseDown -= h));
 }
 // Token: 0x06007855 RID: 30805 RVA: 0x002244C0 File Offset: 0x002226C0
 public static void UpdateStickyNoteControl(XmlToken token, StickyNoteControl snc, SNCAnnotation sncAnnotation)
 {
     Invariant.Assert((token & (XmlToken.Left | XmlToken.Top | XmlToken.XOffset | XmlToken.YOffset | XmlToken.Width | XmlToken.Height | XmlToken.IsExpanded | XmlToken.Author | XmlToken.Text | XmlToken.Ink | XmlToken.ZOrder)) > (XmlToken)0, "No token specified.");
     Invariant.Assert(snc != null, "Sticky Note Control is null.");
     Invariant.Assert(sncAnnotation != null, "Annotation is null.");
     if ((token & XmlToken.Ink) != (XmlToken)0 && sncAnnotation.HasInkData)
     {
         sncAnnotation.UpdateContent(snc, false, XmlToken.Ink);
     }
     if ((token & XmlToken.Text) != (XmlToken)0 && sncAnnotation.HasTextData)
     {
         sncAnnotation.UpdateContent(snc, false, XmlToken.Text);
     }
     if ((token & XmlToken.Author) != (XmlToken)0)
     {
         int    count         = sncAnnotation._annotation.Authors.Count;
         string listSeparator = snc.Language.GetSpecificCulture().TextInfo.ListSeparator;
         string text          = string.Empty;
         for (int i = 0; i < count; i++)
         {
             if (i != 0)
             {
                 text = text + listSeparator + sncAnnotation._annotation.Authors[i];
             }
             else
             {
                 text += sncAnnotation._annotation.Authors[i];
             }
         }
         snc.SetValue(StickyNoteControl.AuthorPropertyKey, text);
     }
     if ((token & XmlToken.Height) != (XmlToken)0)
     {
         XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.Height);
         if (xmlAttribute != null)
         {
             double num = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture);
             snc.SetValue(FrameworkElement.HeightProperty, num);
         }
         else
         {
             snc.ClearValue(FrameworkElement.HeightProperty);
         }
     }
     if ((token & XmlToken.Width) != (XmlToken)0)
     {
         XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.Width);
         if (xmlAttribute != null)
         {
             double num2 = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture);
             snc.SetValue(FrameworkElement.WidthProperty, num2);
         }
         else
         {
             snc.ClearValue(FrameworkElement.WidthProperty);
         }
     }
     if ((token & XmlToken.IsExpanded) != (XmlToken)0)
     {
         XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.IsExpanded);
         if (xmlAttribute != null)
         {
             bool isExpanded = Convert.ToBoolean(xmlAttribute.Value, CultureInfo.InvariantCulture);
             snc.IsExpanded = isExpanded;
         }
         else
         {
             snc.ClearValue(StickyNoteControl.IsExpandedProperty);
         }
     }
     if ((token & XmlToken.ZOrder) != (XmlToken)0)
     {
         XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.ZOrder);
         if (xmlAttribute != null)
         {
             ((IAnnotationComponent)snc).ZOrder = Convert.ToInt32(xmlAttribute.Value, CultureInfo.InvariantCulture);
         }
     }
     if ((token & (XmlToken.Left | XmlToken.Top | XmlToken.XOffset | XmlToken.YOffset)) != (XmlToken)0)
     {
         TranslateTransform translateTransform = new TranslateTransform();
         if ((token & XmlToken.Left) != (XmlToken)0)
         {
             XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.Left);
             if (xmlAttribute != null)
             {
                 double num3 = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture);
                 if (snc.FlipBothOrigins)
                 {
                     num3 = -(num3 + snc.Width);
                 }
                 translateTransform.X = num3;
             }
         }
         if ((token & XmlToken.Top) != (XmlToken)0)
         {
             XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.Top);
             if (xmlAttribute != null)
             {
                 double y = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture);
                 translateTransform.Y = y;
             }
         }
         if ((token & XmlToken.XOffset) != (XmlToken)0)
         {
             XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.XOffset);
             if (xmlAttribute != null)
             {
                 snc.XOffset = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture);
             }
         }
         if ((token & XmlToken.YOffset) != (XmlToken)0)
         {
             XmlAttribute xmlAttribute = (XmlAttribute)sncAnnotation.FindData(XmlToken.YOffset);
             if (xmlAttribute != null)
             {
                 snc.YOffset = Convert.ToDouble(xmlAttribute.Value, CultureInfo.InvariantCulture);
             }
         }
         snc.PositionTransform = translateTransform;
     }
 }
Exemple #21
0
 public static IObservable <EventPattern <MouseButtonEventArgs> > MouseUpObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.MouseUp += h, h => This.MouseUp -= h));
 }
Exemple #22
0
 public static IObservable <EventPattern <QueryContinueDragEventArgs> > QueryContinueDragObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <QueryContinueDragEventHandler, QueryContinueDragEventArgs>(h => This.QueryContinueDrag += h, h => This.QueryContinueDrag -= h));
 }
Exemple #23
0
 public static IObservable <EventPattern <TextCompositionEventArgs> > TextInputObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <TextCompositionEventHandler, TextCompositionEventArgs>(h => This.TextInput += h, h => This.TextInput -= h));
 }
Exemple #24
0
 public static IObservable <EventPattern <KeyboardFocusChangedEventArgs> > PreviewLostKeyboardFocusObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <KeyboardFocusChangedEventHandler, KeyboardFocusChangedEventArgs>(h => This.PreviewLostKeyboardFocus += h, h => This.PreviewLostKeyboardFocus -= h));
 }
Exemple #25
0
 public static IObservable <EventPattern <DependencyPropertyChangedEventArgs> > FocusableChangedObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <DependencyPropertyChangedEventHandler, DependencyPropertyChangedEventArgs>(h => This.FocusableChanged += h, h => This.FocusableChanged -= h));
 }
Exemple #26
0
 public static IObservable <EventPattern <GiveFeedbackEventArgs> > GiveFeedbackObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <GiveFeedbackEventHandler, GiveFeedbackEventArgs>(h => This.GiveFeedback += h, h => This.GiveFeedback -= h));
 }
        public void MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // If the placement icon is null then we don't do anything
            if (null == m_placementIcon)
            {
                return;
            }

            // Remove the placement icon from the canvas
            m_canvas.RemoveChild(m_placementIcon);
            m_placementIcon = null;

            // Make sure we don't leave anything highlighted
            UnhighlightHover();

            Point mousePt = e.GetPosition(m_canvas);

            // Get a reference to the workspace
            Workspace ws = m_canvas.GetWorkspace();

            // There are two possibilities for a mouse-down. The first is that the mouse isn't over
            // any object that can have comments created for it, in which case we create a free-
            // floating comment. The second is that there is and we need to create an anchored comment.
            UIElement uie = m_canvas.GetChildAtIncludeStreams(mousePt);

            if (uie is ProcessUnitControl || uie is PFD.Streams.StreamControl)
            {
                // All we need to do is add a comment to the appropriate collection in the workspace,
                // but we need to compute a smart location for it. There's a static method in the
                // sticky note control that does this for is.
                MathCore.Vector pos = StickyNoteControl.ComputeNewCommentNoteLocation(
                    m_canvas, uie, 100.0, 100.0);

                // Create the new sticky note and add it to the workspace. Event handlers will update
                // the UI appropriately.
                StickyNote sn = new StickyNote()
                {
                    Width     = 100.0,
                    Height    = 100.0,
                    LocationX = pos.X,
                    LocationY = pos.Y
                };
                if (uie is ProcessUnitControl)
                {
                    (uie as ProcessUnitControl).ProcessUnit.Comments.Add(sn);
                }
                else
                {
                    (uie as PFD.Streams.StreamControl).Stream.Comments.Add(sn);
                }

                // Create an undo
                m_canvas.GetWorkspace().AddUndo(new UndoRedoCollection(
                                                    "Undo creation of anchored comment", new Logic.Undos.RemoveStickyNote(sn)));

                // Tell the control palette to switch back to select mode. It will also set the drawing
                // canvas's state to null
                m_creator.SwitchToSelect();
            }
            else
            {
                // This means we need to create a free-floating sticky note.
                StickyNote note = new StickyNote();
                note.Height    = note.Width = 100.0;
                note.LocationX = mousePt.X;
                note.LocationY = mousePt.Y;

                // Add it to the workspace. Event subscribers will update the UI automatically.
                m_canvas.GetWorkspace().StickyNotes.Add(note);

                // Add an undo that will remove the sticky note
                m_canvas.GetWorkspace().AddUndo(new UndoRedoCollection(
                                                    "Undo creation of free-floating comment",
                                                    new Logic.Undos.RemoveStickyNote(note)));

                // Tell the control palette to switch back to select mode. It will also set the drawing
                // canvas's state to null
                m_creator.SwitchToSelect();
            }
        }
Exemple #28
0
 public static IObservable <EventPattern <ManipulationInertiaStartingEventArgs> > ManipulationInertiaStartingObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <EventHandler <ManipulationInertiaStartingEventArgs>, ManipulationInertiaStartingEventArgs>(h => This.ManipulationInertiaStarting += h, h => This.ManipulationInertiaStarting -= h));
 }
Exemple #29
0
        private void AddCommentCollectionMenuOptions(ContextMenu newContextMenu, string title)
        {
            // Make the header in the menu for the comment-specific options
            MenuItem menuItem = new MenuItem();

            menuItem.Header = title;
            newContextMenu.Items.Add(menuItem);
            // We're using this item as a label, so don't let the user click it
            menuItem.IsHitTestVisible = false;
            // Change the colors to signal to the user that it's a label
            menuItem.Background = new SolidColorBrush(Colors.LightGray);
            menuItem.Foreground = new SolidColorBrush(Color.FromArgb(255, 100, 100, 100));
            menuItem.FontWeight = FontWeights.Bold;

            menuItem        = new MenuItem();
            menuItem.Header = "Add new comment";
            menuItem.Tag    = m_canvas.SelectedElement;
            newContextMenu.Items.Add(menuItem);

            // Use an anonymous delegate to handle the click event
            menuItem.Click += delegate(object sender, RoutedEventArgs e)
            {
                MenuItem tempMI = sender as MenuItem;
                PFD.Streams.StreamControl stream = tempMI.Tag as PFD.Streams.StreamControl;
                ProcessUnitControl        unit   = tempMI.Tag as ProcessUnitControl;

                // Get a reference to the comment collection
                IList <StickyNote> comments;
                if (null != stream)
                {
                    comments = stream.Stream.Comments;
                }
                else
                {
                    comments = unit.ProcessUnit.Comments;
                }

                // Compute the location for the new comment
                MathCore.Vector location = StickyNoteControl.ComputeNewCommentNoteLocation(
                    m_canvas, tempMI.Tag, 100.0, 100.0);

                // Create the new sticky note and add it to the workspace. Event handlers will update
                // the UI appropriately
                StickyNote sn = new StickyNote()
                {
                    Width     = 100.0,
                    Height    = 100.0,
                    LocationX = location.X,
                    LocationY = location.Y
                };
                comments.Add(sn);

                // Add an undo that will remove the comment
                m_workspace.AddUndo(new UndoRedoCollection("Undo creation of comment",
                                                           new RemoveComment(comments, comments.IndexOf(sn))));

                // Make sure to remove the popup menu from the canvas
                m_canvas.Children.Remove(m_contextMenu);
                m_contextMenu = null;

                // Flip back to the default state for the canvas (null)
                m_canvas.CurrentState = null;
            };

            string objName = "selected object";

            if (m_canvas.SelectedElement is ProcessUnitControl)
            {
                objName = (m_canvas.SelectedElement as ProcessUnitControl).ProcessUnit.Label;
            }
            else if (m_canvas.SelectedElement is ChemProV.PFD.Streams.StreamControl)
            {
                objName = "selected stream";
            }

            // Add a new menu item to hide all comments
            menuItem        = new MenuItem();
            menuItem.Header = "Hide all comments for " + objName;
            menuItem.Tag    = m_canvas.SelectedElement;
            newContextMenu.Items.Add(menuItem);
            menuItem.Click += delegate(object sender, RoutedEventArgs e)
            {
                MenuItem tempMI = sender as MenuItem;
                (tempMI.Tag as UI.ICommentControlManager).HideAllComments();

                // Make sure to remove the popup menu from the canvas
                m_canvas.Children.Remove(m_contextMenu);
                m_contextMenu = null;

                // Flip back to the default state for the canvas (null)
                m_canvas.CurrentState = null;
            };

            // Add one to show all comments too
            menuItem        = new MenuItem();
            menuItem.Header = "Show all comments for " + objName;
            menuItem.Tag    = m_canvas.SelectedElement;
            newContextMenu.Items.Add(menuItem);
            menuItem.Click += delegate(object sender, RoutedEventArgs e)
            {
                MenuItem tempMI = sender as MenuItem;
                (tempMI.Tag as UI.ICommentControlManager).ShowAllComments();

                // Make sure to remove the popup menu from the canvas
                m_canvas.Children.Remove(m_contextMenu);
                m_contextMenu = null;

                // Flip back to the default state for the canvas (null)
                m_canvas.CurrentState = null;
            };
        }
Exemple #30
0
 public static IObservable <EventPattern <ManipulationBoundaryFeedbackEventArgs> > ManipulationBoundaryFeedbackObserver(this StickyNoteControl This)
 {
     return(Observable.FromEventPattern <EventHandler <ManipulationBoundaryFeedbackEventArgs>, ManipulationBoundaryFeedbackEventArgs>(h => This.ManipulationBoundaryFeedback += h, h => This.ManipulationBoundaryFeedback -= h));
 }