Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
32 changes: 16 additions & 16 deletions .ghal.rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
}
},
"contentsource": {
"(?i).*master\/docs\/framework\/wpf.*": {
"labels-add": ":books: Area - Framework,:card_file_box: Technology - WPF"
"(?i).*dotnet-desktop-guide\/framework\/wpf.*": {
"labels-add": ":books: Area - .Framework,:card_file_box: Technology - WPF"
},
"(?i).*master\/docs\/framework\/winforms.*": {
"labels-add": ":books: Area - Framework,:card_file_box: Technology - WinForms"
"(?i).*dotnet-desktop-guide\/framework\/winforms.*": {
"labels-add": ":books: Area - .Framework,:card_file_box: Technology - WinForms"
},
"(?i).*master\/docs\/net\/wpf.*": {
"labels-add": ":books: Area - NET,:card_file_box: Technology - WPF"
"(?i).*dotnet-desktop-guide\/net\/wpf.*": {
"labels-add": ":books: Area - .NET,:card_file_box: Technology - WPF"
},
"(?i).*master\/docs\/net\/winforms.*": {
"labels-add": ":books: Area - NET,:card_file_box: Technology - WinForms"
"(?i).*dotnet-desktop-guide\/net\/winforms.*": {
"labels-add": ":books: Area - .NET,:card_file_box: Technology - WinForms"
}
}
}
Expand All @@ -49,17 +49,17 @@
"processors": {
"processor-files": {
"changedfile": {
"(?i).*docs\/framework\/wpf.*": {
"labels-add": ":books: Area - Framework,:card_file_box: Technology - WPF"
"(?i).*dotnet-desktop-guide\/framework\/wpf.*": {
"labels-add": ":books: Area - .Framework,:card_file_box: Technology - WPF"
},
"(?i).*docs\/framework\/winforms.*": {
"labels-add": ":books: Area - Framework,:card_file_box: Technology - WinForms"
"(?i).*dotnet-desktop-guide\/framework\/winforms.*": {
"labels-add": ":books: Area - .Framework,:card_file_box: Technology - WinForms"
},
"(?i).*docs\/net\/wpf.*": {
"labels-add": ":books: Area - NET,:card_file_box: Technology - WPF"
"(?i).*dotnet-desktop-guide\/net\/wpf.*": {
"labels-add": ":books: Area - .NET,:card_file_box: Technology - WPF"
},
"(?i).*docs\/net\/winforms.*": {
"labels-add": ":books: Area - NET,:card_file_box: Technology - WinForms"
"(?i).*dotnet-desktop-guide\/net\/winforms.*": {
"labels-add": ":books: Area - .NET,:card_file_box: Technology - WinForms"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
run: |
echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json"
npm i -g markdownlint-cli
markdownlint "**/*.md" -i "samples/**/*.md"
markdownlint "**/*.md"
5 changes: 5 additions & 0 deletions dotnet-desktop-guide/TOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ items:
href: https://docs.microsoft.com/dotnet/desktop/winforms/?view=netdesktop-5.0
- name: .NET Framework
href: https://docs.microsoft.com/dotnet/desktop/winforms/?view=netframeworkdesktop-4.8
- name: Windows Presentation Foundation
expanded: true
items:
- name: .NET Framework
href: https://docs.microsoft.com/dotnet/desktop/wpf/?view=netframeworkdesktop-4.8
22 changes: 22 additions & 0 deletions dotnet-desktop-guide/framework/breadcrumb/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,25 @@ items:
- name: Controls
tocHref: /dotnet/desktop/winforms/controls/
topicHref: /dotnet/desktop/winforms/controls/index
- name: Windows Presentation Foundation
tocHref: /dotnet/desktop/wpf/
topicHref: /dotnet/desktop/wpf/index
items:
- name: Advanced
tocHref: /dotnet/desktop/wpf/advanced/
topicHref: /dotnet/desktop/wpf/advanced/index
- name: Application development
tocHref: /dotnet/desktop/wpf/app-development/
topicHref: /dotnet/desktop/wpf/app-development/index
- name: Controls
tocHref: /dotnet/desktop/wpf/controls/
topicHref: /dotnet/desktop/wpf/controls/index
- name: Data
tocHref: /dotnet/desktop/wpf/data/
topicHref: /dotnet/desktop/wpf/data/index
- name: Get started (WPF)
tocHref: /dotnet/desktop/wpf/getting-started/
topicHref: /dotnet/desktop/wpf/getting-started/index
- name: Graphics and multimedia
tocHref: /dotnet/desktop/wpf/graphics-multimedia/
topicHref: /dotnet/desktop/wpf/graphics-multimedia/index
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "Activate Function - WPF unmanaged API reference"
titleSuffix: ""
ms.date: "03/30/2017"
dev_langs:
- "cpp"
api_name:
- "Activate"
api_location:
- "PresentationHost_v0400.dll"
ms.assetid: 1400329c-b598-465f-80f2-e3dabf044811
---

# Activate Function (WPF Unmanaged API Reference)

This API supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

Used by the Windows Presentation Foundation (WPF) infrastructure for windows management.

## Syntax

```cpp
void Activate(
const ActivateParameters* pParameters,
__deref_out_ecount(1) LPUNKNOWN* ppInner,
);
```

## Parameters

`pParameters`\
A pointer to the window's activation parameters.

`ppInner`\
A pointer to the address of a single-element buffer that contains a pointer to an <xref:Microsoft.VisualStudio.OLE.Interop.IOleDocument> object.

## Requirements

**Platforms:** See [.NET Framework System Requirements](/dotnet/framework/get-started/system-requirements).

**DLL:**

In the .NET Framework 3.0 and 3.5: PresentationHostDLL.dll

In the .NET Framework 4 and later: PresentationHost_v0400.dll

**.NET Framework Version:** [!INCLUDE[net_current_v30plus](../../../includes/net-current-v30plus-md.md)]

## See also

- [WPF Unmanaged API Reference](wpf-unmanaged-api-reference.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: "Advanced Ink Handling"
ms.date: "03/30/2017"
f1_keywords:
- "AutoGeneratedOrientationPage"
helpviewer_keywords:
- "System.Windows.Input.StylusPlugIns classes"
- "InkCanvas control [WPF]"
- "ink [WPF], advanced handling"
ms.assetid: abc8481a-f983-416f-b051-9168ac8b2ba3
---
# Advanced Ink Handling
The [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] ships with the <xref:System.Windows.Controls.InkCanvas>, and is an element you can put in your application to immediately start collecting and displaying ink. However, if the <xref:System.Windows.Controls.InkCanvas> control does not provide a fine enough level of control, you can maintain control at a higher level by customizing your own ink collection and ink rendering classes using <xref:System.Windows.Input.StylusPlugIns>.

The <xref:System.Windows.Input.StylusPlugIns> classes provide a mechanism for implementing low-level control over <xref:System.Windows.Input.Stylus> input and dynamically rendering ink. The <xref:System.Windows.Input.StylusPlugIns.StylusPlugIn> class provides a mechanism for you to implement custom behavior and apply it to the stream of data coming from the stylus device for optimal performance. The <xref:System.Windows.Input.StylusPlugIns.DynamicRenderer>, a specialized <xref:System.Windows.Input.StylusPlugIns.StylusPlugIn>, allows you to customize dynamically rendering ink data in real-time which means that the <xref:System.Windows.Input.StylusPlugIns.DynamicRenderer> draws digital ink immediately as <xref:System.Windows.Input.StylusPoint> data is generated, so it appears to "flow" from the stylus device.

## In This Section
[Custom Rendering Ink](custom-rendering-ink.md)
[Intercepting Input from the Stylus](intercepting-input-from-the-stylus.md)
[Creating an Ink Input Control](creating-an-ink-input-control.md)
[The Ink Threading Model](the-ink-threading-model.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: "Advanced Text Formatting"
ms.date: "03/30/2017"
dev_langs:
- "csharp"
- "vb"
helpviewer_keywords:
- "formatting [WPF]"
- "text [WPF]"
- "typography [WPF], text formatting"
ms.assetid: f0a7986e-f5b2-485c-a27d-f8e922022212
---
# Advanced Text Formatting
Windows Presentation Foundation (WPF) provides a robust set of APIs for including text in your application. Layout and [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)] APIs, such as <xref:System.Windows.Controls.TextBlock>, provide the most common and general-use elements for text presentation. Drawing APIs, such as <xref:System.Windows.Media.GlyphRunDrawing> and <xref:System.Windows.Media.FormattedText>, provide a means for including formatted text in drawings. At the most advanced level, WPF provides an extensible text formatting engine to control every aspect of text presentation, such as text store management, text run formatting management, and embedded object management.

This topic provides an introduction to WPF text formatting. It focuses on client implementation and use of the WPF text formatting engine.

> [!NOTE]
> All code examples within this document can be found in the [Advanced Text Formatting Sample](https://github.com/Microsoft/WPF-Samples/tree/master/PerMonitorDPI/TextFormatting).

<a name="prereq"></a>
## Prerequisites
This topic assumes that you are familiar with the higher level APIs used for text presentation. Most user scenarios will not require the advanced text formatting APIs discussed in this topic. For an introduction to the different text APIs, see [Documents in WPF](documents-in-wpf.md).

<a name="section1"></a>
## Advanced Text Formatting
The text layout and [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] controls in WPF provide formatting properties that allow you to easily include formatted text in your application. These controls expose a number of properties to handle the presentation of text, which includes its typeface, size, and color. Under ordinary circumstances, these controls can handle the majority of text presentation in your application. However, some advanced scenarios require the control of text storage as well as text presentation. WPF provides an extensible text formatting engine for this purpose.

The advanced text formatting features found in WPF consist of a text formatting engine, a text store, text runs, and formatting properties. The text formatting engine, <xref:System.Windows.Media.TextFormatting.TextFormatter>, creates lines of text to be used for presentation. This is achieved by initiating the line formatting process and calling the text formatter's <xref:System.Windows.Media.TextFormatting.TextFormatter.FormatLine%2A>. The text formatter retrieves text runs from your text store by calling the store's <xref:System.Windows.Media.TextFormatting.TextSource.GetTextRun%2A> method. The <xref:System.Windows.Media.TextFormatting.TextRun> objects are then formed into <xref:System.Windows.Media.TextFormatting.TextLine> objects by the text formatter and given to your application for inspection or display.

<a name="section2"></a>
## Using the Text Formatter
<xref:System.Windows.Media.TextFormatting.TextFormatter> is the WPF text formatting engine and provides services for formatting and breaking text lines. The text formatter can handle different text character formats and paragraph styles, and includes support for international text layout.

Unlike a traditional text API, the <xref:System.Windows.Media.TextFormatting.TextFormatter> interacts with a text layout client through a set of callback methods. It requires the client to provide these methods in an implementation of the <xref:System.Windows.Media.TextFormatting.TextSource> class. The following diagram illustrates the text layout interaction between the client application and <xref:System.Windows.Media.TextFormatting.TextFormatter>.

![Diagram of text layout client and TextFormatter](./media/advanced-text-formatting/text-layout-textformatter-interaction.png)

The text formatter is used to retrieve formatted text lines from the text store, which is an implementation of <xref:System.Windows.Media.TextFormatting.TextSource>. This is done by first creating an instance of the text formatter by using the <xref:System.Windows.Media.TextFormatting.TextFormatter.Create%2A> method. This method creates an instance of the text formatter and sets the maximum line height and width values. As soon as an instance of the text formatter is created, the line creation process is started by calling the <xref:System.Windows.Media.TextFormatting.TextFormatter.FormatLine%2A> method. <xref:System.Windows.Media.TextFormatting.TextFormatter> calls back to the text source to retrieve the text and formatting parameters for the runs of text that form a line.

In the following example, the process of formatting a text store is shown. The <xref:System.Windows.Media.TextFormatting.TextFormatter> object is used to retrieve text lines from the text store and then format the text line for drawing into the <xref:System.Windows.Media.DrawingContext>.

[!code-csharp[TextFormatterExample#100](~/samples/snippets/csharp/VS_Snippets_Wpf/TextFormatterExample/CSharp/Window1.xaml.cs#100)]
[!code-vb[TextFormatterExample#100](~/samples/snippets/visualbasic/VS_Snippets_Wpf/TextFormatterExample/VisualBasic/Window1.xaml.vb#100)]

<a name="section3"></a>
## Implementing the Client Text Store
When you extend the text formatting engine, you are required to implement and manage all aspects of the text store. This is not a trivial task. The text store is responsible for tracking text run properties, paragraph properties, embedded objects, and other similar content. It also provides the text formatter with individual <xref:System.Windows.Media.TextFormatting.TextRun> objects which the text formatter uses to create <xref:System.Windows.Media.TextFormatting.TextLine> objects.

To handle the virtualization of the text store, the text store must be derived from <xref:System.Windows.Media.TextFormatting.TextSource>. <xref:System.Windows.Media.TextFormatting.TextSource> defines the method the text formatter uses to retrieve text runs from the text store. <xref:System.Windows.Media.TextFormatting.TextSource.GetTextRun%2A> is the method used by the text formatter to retrieve text runs used in line formatting. The call to <xref:System.Windows.Media.TextFormatting.TextSource.GetTextRun%2A> is repeatedly made by the text formatter until one of the following conditions occurs:

- A <xref:System.Windows.Media.TextFormatting.TextEndOfLine> or a subclass is returned.

- The accumulated width of text runs exceeds the maximum line width specified in either the call to create the text formatter or the call to the text formatter's <xref:System.Windows.Media.TextFormatting.TextFormatter.FormatLine%2A> method.

- A Unicode newline sequence, such as "CF", "LF", or "CRLF", is returned.

<a name="section4"></a>
## Providing Text Runs
The core of the text formatting process is the interaction between the text formatter and the text store. Your implementation of <xref:System.Windows.Media.TextFormatting.TextSource> provides the text formatter with the <xref:System.Windows.Media.TextFormatting.TextRun> objects and the properties with which to format the text runs. This interaction is handled by the <xref:System.Windows.Media.TextFormatting.TextSource.GetTextRun%2A> method, which is called by the text formatter.

The following table shows some of the predefined <xref:System.Windows.Media.TextFormatting.TextRun> objects.

|TextRun Type|Usage|
|------------------|-----------|
|<xref:System.Windows.Media.TextFormatting.TextCharacters>|The specialized text run used to pass a representation of character glyphs back to the text formatter.|
|<xref:System.Windows.Media.TextFormatting.TextEmbeddedObject>|The specialized text run used to provide content in which measuring, hit testing, and drawing is done in whole, such as a button or image within the text.|
|<xref:System.Windows.Media.TextFormatting.TextEndOfLine>|The specialized text run used to mark the end of a line.|
|<xref:System.Windows.Media.TextFormatting.TextEndOfParagraph>|The specialized text run used to mark the end of a paragraph.|
|<xref:System.Windows.Media.TextFormatting.TextEndOfSegment>|The specialized text run used to mark the end of a segment, such as to end the scope affected by a previous <xref:System.Windows.Media.TextFormatting.TextModifier> run.|
|<xref:System.Windows.Media.TextFormatting.TextHidden>|The specialized text run used to mark a range of hidden characters.|
|<xref:System.Windows.Media.TextFormatting.TextModifier>|The specialized text run used to modify properties of text runs in its scope. The scope extends to the next matching <xref:System.Windows.Media.TextFormatting.TextEndOfSegment> text run, or the next <xref:System.Windows.Media.TextFormatting.TextEndOfParagraph>.|

Any of the predefined <xref:System.Windows.Media.TextFormatting.TextRun> objects can be subclassed. This allows your text source to provide the text formatter with text runs that include custom data.

The following example demonstrates a <xref:System.Windows.Media.TextFormatting.TextSource.GetTextRun%2A> method. This text store returns <xref:System.Windows.Media.TextFormatting.TextRun> objects to the text formatter for processing.

[!code-csharp[TextFormatterExample#101](~/samples/snippets/csharp/VS_Snippets_Wpf/TextFormatterExample/CSharp/CustomTextSource.cs#101)]
[!code-vb[TextFormatterExample#101](~/samples/snippets/visualbasic/VS_Snippets_Wpf/TextFormatterExample/VisualBasic/CustomTextSource.vb#101)]

> [!NOTE]
> In this example, the text store provides the same text properties to all of the text. Advanced text stores would need to implement their own span management to allow individual characters to have different properties.

<a name="section5"></a>
## Specifying Formatting Properties
<xref:System.Windows.Media.TextFormatting.TextRun> objects are formatted by using properties provided by the text store. These properties come in two types, <xref:System.Windows.Media.TextFormatting.TextParagraphProperties> and <xref:System.Windows.Media.TextFormatting.TextRunProperties>. <xref:System.Windows.Media.TextFormatting.TextParagraphProperties> handle paragraph inclusive properties such as <xref:System.Windows.TextAlignment> and <xref:System.Windows.FlowDirection>. <xref:System.Windows.Media.TextFormatting.TextRunProperties> are properties that can be different for each text run within a paragraph, such as foreground brush, <xref:System.Windows.Media.Typeface>, and font size. To implement custom paragraph and custom text run property types, your application must create classes that derive from <xref:System.Windows.Media.TextFormatting.TextParagraphProperties> and <xref:System.Windows.Media.TextFormatting.TextRunProperties> respectively.

## See also

- [Typography in WPF](typography-in-wpf.md)
- [Documents in WPF](documents-in-wpf.md)
Loading