How can I clone a printer ?

In the example below, a second print queue is cloned from an existing print queue. The second differs from the first only in its name, location, port, and shared status. The major steps for doing this are as follows. [C#] LocalPrintServer myLocalPrintServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer); PrintQueue sourcePrintQueue = myLocalPrintServer.DefaultPrintQueue; PrintPropertyDictionary myPrintProperties = sourcePrintQueue.PropertiesCollection; // Share the new printer using Remove/Add methods PrintBooleanProperty shared = new PrintBooleanProperty(‘IsShared’, true); myPrintProperties.Remove(‘IsShared’); myPrintProperties.Add(‘IsShared’, shared); // Give the new printer its share name using SetProperty method PrintStringProperty theShareName = new PrintStringProperty(‘ShareName’, ‘\’Son of ‘ + sourcePrintQueue.Name +’\”); myPrintProperties.SetProperty(‘ShareName’, theShareName); // Specify the physical location of the new printer using Remove/Add methods PrintStringProperty theLocation = new PrintStringProperty(‘Location’, ‘the supply room’); myPrintProperties.Remove(‘Location’); myPrintProperties.Add(‘Location’, theLocation); // Specify the port for the new printer String[] port = new String[] { ‘COM1:’ }; // Install the new printer on the local print server PrintQueue clonedPrinter = myLocalPrintServer.InstallPrintQueue(‘My clone of ‘ + sourcePrintQueue.Name, ‘Xerox WCP 35 PS’, port, ‘WinPrint’, myPrintProperties); myLocalPrintServer.Commit(); // Report outcome Console.WriteLine(‘{0} in {1} has been installed and shared as {2}’, clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName); Console.WriteLine(‘Press Return to continue …’); Console.ReadLine();

Can I embed a figure into a paragraph of text ?

Figure and Floater are used to embed content in Flow Documents with placement properties that can be customized independent of the primary content flow. Figure or Floater elements are often used to highlight or accentuate portions of content to host supporting images or other content within the main content flow or to inject loosely related content such as advertisements. The following example shows how to embed a Figure into a paragraph of text. [XAML] <FlowDocument xmlns=’http://schemas.microsoft.com/winfx/2006/xaml/presentation’ xmlns:x=’http://schemas.microsoft.com/winfx/2006/xaml’> <Paragraph> <Figure Width=’300′ Height=’100′ Background=’GhostWhite’ HorizontalAnchor=’PageLeft’ > <Paragraph FontStyle=’Italic’ Background=’Beige’ Foreground=’DarkGreen’ > A Figure embeds content into flow content with placement properties that can be customized independently from the primary content flow </Paragraph> </Figure> </Paragraph> </FlowDocument>

How can I define three paragraphs under one section ?

We can define three paragraphs under one section as follows. In the following example, the section has a “Background” property value of Red, therefore the background color of the paragraphs is also red. [XAML] <FlowDocument xmlns=’http://schemas.microsoft.com/winfx/2006/xaml/presentation’ xmlns:x=’http://schemas.microsoft.com/winfx/2006/xaml’> <!– By default, Section applies no formatting to elements contained within it. However, in this example, the section has a Background property value of ‘Red’, therefore, the three paragraphs (the block) inside the section also have a red background. –> <Section Background=’Red’> <Paragraph> Paragraph 1 </Paragraph> <Paragraph> Paragraph 2 </Paragraph> <Paragraph> Paragraph 3 </Paragraph> </Section> </FlowDocument>

How can I create an application that is used to declare a Context Menu with routed commands that the users can access to create and manage annotations ?

Users typically create annotations by first selecting some text or an item of interest and then right-clicking to display a context menu of annotation options. The following example shows the XAML you can use to declare a Context Menu with routed commands that users can access to create and manage annotations. [XAML] <DocumentViewer.ContextMenu> <ContextMenu> <MenuItem Command=’ApplicationCommands.Copy’ /> <Separator /> <!– Add a Highlight annotation to a user selection. –> <MenuItem Command=’ann:AnnotationService.CreateHighlightCommand’ Header=’Add Highlight’ /> <!– Add a Text Note annotation to a user selection. –> <MenuItem Command=’ann:AnnotationService.CreateTextStickyNoteCommand’ Header=’Add Text Note’ /> <!– Add an Ink Note annotation to a user selection. –> <MenuItem Command=’ann:AnnotationService.CreateInkStickyNoteCommand’ Header=’Add Ink Note’ /> <Separator /> <!– Remove Highlights from a user selection. –> <MenuItem Command=’ann:AnnotationService.ClearHighlightsCommand’ Header=’Remove Highlights’ /> <!– Remove Text Notes and Ink Notes from a user selection. –> <MenuItem Command=’ann:AnnotationService.DeleteStickyNotesCommand’ Header=’Remove Notes’ /> <!– Remove Highlights, Text Notes, Ink Notes from a selection. –> <MenuItem Command=’ann:AnnotationService.DeleteAnnotationsCommand’ Header=’Remove Highlights & Notes’ /> </ContextMenu> </DocumentViewer.ContextMenu>

How can I Match Annotations with Annotated Objects ?

You can match annotations with the corresponding annotated objects. For example, consider a simple document reader application that has a comments pane. The comments pane might be a listbox that displays the text from a list of annotations that are anchored to a document. If the user selects an item in the listbox, then the application brings into view the paragraph in the document that the corresponding annotation object is anchored to. The following piece of C # code demonstrates how to implement the event handler of such a listbox that serves as the comments pane. [C#] void annotationsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { Annotation comment = (sender as ListBox).SelectedItem as Annotation; if (comment != null) { // IAnchorInfo info; // service is an AnnotationService object // comment is an Annotation object info = AnnotationHelper.GetAnchorInfo(this.service, comment); TextAnchor resolvedAnchor = info.ResolvedAnchor as TextAnchor; TextPointer textPointer = (TextPointer)resolvedAnchor.BoundingStart; textPointer.Paragraph.BringIntoView(); } }