Exemplo n.º 1
0
        //This method is called when the 'Add Highlight' context menu is
        //clicked by the user on either of the two document viewer controls.
        private void DocumentViewer_AddHighlight(object sender,
                                                 RoutedEventArgs e)
        {
            //Work out which document viewer we are dealing with
            //and get the appropriate store.
            string tag = ((MenuItem)sender).Tag.ToString();

            AnnotationService annotationService =
                tag == "fixed"
                ? fixedAnnotationService
                : flowAnnotationService;

            //Get the current user's name as the author
            string userName = System.Environment.UserName;

            try
            {
                //Creates a yellow highlight
                AnnotationHelper.CreateHighlightForSelection(
                    annotationService, userName, Brushes.Yellow);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Please select some text to highlight.");
            }
        }
Exemplo n.º 2
0
        internal static void HighlightText(this FlowDocumentScrollViewer viewer, AnnotationService service, int offset, int length)
        {
            var brush    = new SolidColorBrush(Color.FromArgb(127, (byte)random.Next(200), (byte)random.Next(200), (byte)random.Next(200)));
            var startPos = viewer.Document.ContentStart.GetOffsetTextPointer(offset);
            var endPos   = startPos.GetOffsetTextPointer(length);

            viewer.Selection.Select(startPos, endPos);

            AnnotationHelper.CreateHighlightForSelection(service, String.Empty, brush);
            //textRange.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
        }
Exemplo n.º 3
0
		// Function to create highlighting
		private void CreateHighlight(object sender, RoutedEventArgs e)
		{
			try
			{
				AnnotationHelper.CreateHighlightForSelection(currentAnnotService,
				  "Vista user", Brushes.Yellow);
			}
			catch (InvalidOperationException)
			{
				// If someone tries to highlight without actually selecting text, do nothing.
			}
		}
Exemplo n.º 4
0
 // ------------------------ OnAddBookmark() ---------------------------
 void OnAddBookmark(object sender, RoutedEventArgs args)
 {
     try
     {
         System.Windows.Media.Color col     = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#A6FFFF00");
         System.Windows.Media.Brush myBrush = new SolidColorBrush(col);
         string userName = System.Windows.Forms.SystemInformation.UserName;
         AnnotationHelper.CreateHighlightForSelection(
             _annServ, userName, myBrush);
     }
     catch (InvalidOperationException)
     {
         return;
     }
     //AddBookmarkOrComment(BookmarkList);
 }