Skip to content

Commit 8ec187d

Browse files
committed
Merge branch 'main' into aashcraft/main-cloud-files-add-copilot-plus-note
2 parents bedc0c4 + 775dace commit 8ec187d

46 files changed

Lines changed: 714 additions & 532 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

windows.applicationmodel.core/coreapplicationview_ishosted.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,47 @@ public bool IsHosted { get; }
1010
# Windows.ApplicationModel.Core.CoreApplicationView.IsHosted
1111

1212
## -description
13-
Gets the value that indicates whether this app view is hosted or not.
13+
14+
Gets the value that indicates whether this app view is hosted.
1415

1516
## -property-value
16-
If **true**, this app view is hosted; if **false**, it is not.
17+
18+
If **true**, this app view is hosted; if **false**, it isn't.
1719

1820
## -remarks
19-
An app view is considered hosted when the process that launched it controls its lifetime. For example, the window that opens when a [FileOpenPicker](../windows.storage.pickers/fileopenpicker.md) is launched is considered hosted.
21+
22+
An app view is hosted when the process that launches it controls its lifetime. For example, the window that opens when a [FileOpenPicker](../windows.storage.pickers/fileopenpicker.md) is launched is hosted.
2023

2124
## -examples
2225

26+
Here's a simple example that demonstrates how to use the `IsHosted` property:
27+
28+
```csharp
29+
using Windows.ApplicationModel.Core;
30+
using Windows.UI.Xaml;
31+
32+
namespace ExampleApp
33+
{
34+
public sealed partial class MainPage : Page
35+
{
36+
public MainPage()
37+
{
38+
this.InitializeComponent();
39+
40+
// Check if the current app view is hosted
41+
bool isHosted = CoreApplication.GetCurrentView().IsHosted;
42+
43+
// Display the result
44+
if (isHosted)
45+
{
46+
System.Diagnostics.Debug.WriteLine("The app view is hosted.");
47+
}
48+
else
49+
{
50+
System.Diagnostics.Debug.WriteLine("The app view is not hosted.");
51+
}
52+
}
53+
}
54+
}
55+
2356
## -see-also

windows.applicationmodel.datatransfer.dragdrop.core/coredragdropmanager.md

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,67 @@ public class CoreDragDropManager : Windows.ApplicationModel.DataTransfer.DragDro
1111
# Windows.ApplicationModel.DataTransfer.DragDrop.Core.CoreDragDropManager
1212

1313
## -description
14+
1415
Manages access for drag and drop within and between apps.
1516

1617
## -remarks
1718

1819
## -examples
20+
21+
The following example demonstrates how to use the `CoreDragDropManager` to set up a drag-and-drop target that filters incoming data and delegates handling to a specified control.
22+
1923
```csharp
24+
using System;
25+
using Windows.ApplicationModel.DataTransfer;
26+
using Windows.ApplicationModel.DataTransfer.DragDrop.Core;
27+
using Windows.UI.Xaml.Controls;
28+
2029
public sealed partial class MainPage : Page
2130
{
22-
private void DropOperationTargetRequested(CoreDragDropManager sender,
23-
CoreDropOperationTargetRequestedEventArgs evtArgs)
24-
{
25-
// Create a target (see above for more implementation details)
26-
var target = new DropTarget ();
27-
evtArgs.SetTarget(target);
28-
}
29-
30-
public MainPage()
31-
{
32-
InitializeComponents();
33-
var dragDropManager = DragDropManager.GetForCurrentView();
34-
dragDropManager.DropOperationTargetRequested += DropOperationTargetRequested;
35-
}
36-
}
31+
private void DropOperationTargetRequested(CoreDragDropManager sender, CoreDropOperationTargetRequestedEventArgs evtArgs)
32+
{
33+
// Create a target (see above for more implementation details)
34+
var target = new DropTarget();
3735

38-
```
36+
// Example filter: Only allow storage files
37+
target.DragOver += (s, e) =>
38+
{
39+
if (e.DataView.Contains(StandardDataFormats.StorageItems))
40+
{
41+
e.AcceptedOperation = DataPackageOperation.Copy;
42+
}
43+
else
44+
{
45+
e.AcceptedOperation = DataPackageOperation.None;
46+
}
47+
};
3948

49+
// Delegate handling to a specified control
50+
target.Drop += (s, e) =>
51+
{
52+
// Assuming 'specifiedControl' is a UI element in your app
53+
specifiedControl.HandleDrop(e);
54+
};
4055

56+
evtArgs.SetTarget(target);
57+
}
58+
59+
public MainPage()
60+
{
61+
InitializeComponent();
62+
var dragDropManager = CoreDragDropManager.GetForCurrentView();
63+
dragDropManager.TargetRequested += DropOperationTargetRequested;
64+
}
65+
}
66+
67+
// Example of a specified control handling the drop
68+
public class SpecifiedControl : UserControl
69+
{
70+
public void HandleDrop(CoreDragInfo dragInfo)
71+
{
72+
// Handle the drop operation here
73+
}
74+
}
75+
```
4176

4277
## -see-also

windows.applicationmodel.datatransfer/datapackage_setdata_2074524277.md

Lines changed: 150 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,168 @@ public void SetData(System.String formatId, System.Object value)
1010
# Windows.ApplicationModel.DataTransfer.DataPackage.SetData
1111

1212
## -description
13+
1314
Sets the data contained in the [DataPackage](datapackage.md) in a [RandomAccessStream](../windows.storage.streams/randomaccessstream.md) format.
1415

1516
## -parameters
17+
1618
### -param formatId
17-
Specifies the format of the data. We recommend that you set this value by using the [StandardDataFormats](standarddataformats.md) class.
19+
20+
Specifies the format of the data. Set this value by using the [StandardDataFormats](standarddataformats.md) class.
1821

1922
### -param value
23+
2024
Specifies the content that the [DataPackage](datapackage.md) contains.
2125

2226
## -remarks
23-
To add data using this method, your app must convert the data into an object. You must also specify a *formatId* that target apps can use to request the data. Note that the target app can request this data only if it knows the *formatId*.
2427

25-
This method is often used when you use a delegate function to share data. For more information, see [How to support pull operations](/previous-versions/windows/apps/hh770848(v=win.10)).
28+
To add data with this method, your app must convert the data into an object. You must also specify a *formatId* that target apps can use to request the data. The target app can request this data only if it knows the *formatId*.
29+
30+
Use this method when you use a delegate function to share data. For more information, see [How to support pull operations](/previous-versions/windows/apps/hh770848(v=win.10)).
2631

2732
## -examples
2833

34+
The following example demonstrates how to use the **SetData** method to serialize a custom C# object into a **RandomAccessStream** and pass it to the **DataPackage**. It also shows how to deserialize the data back to the original object type by using [GetDataAsync](datapackageview_getdataasync_225712847.md).
35+
36+
```csharp
37+
using System;
38+
using System.IO;
39+
using System.Runtime.Serialization;
40+
using Windows.ApplicationModel.DataTransfer;
41+
using Windows.Storage.Streams;
42+
43+
// Define a custom class to serialize
44+
[DataContract]
45+
public class PersonData
46+
{
47+
[DataMember]
48+
public string Name { get; set; }
49+
50+
[DataMember]
51+
public int Age { get; set; }
52+
53+
[DataMember]
54+
public string Email { get; set; }
55+
}
56+
57+
// Method to serialize object and set data in DataPackage
58+
private async Task<DataPackage> CreateDataPackageWithSerializedObject()
59+
{
60+
// Create sample data
61+
var person = new PersonData
62+
{
63+
Name = "John Doe",
64+
Age = 30,
65+
Email = "john.doe@example.com"
66+
};
67+
68+
// Serialize the object to a RandomAccessStream
69+
var stream = await SerializeObjectToStreamAsync(person);
70+
71+
// Create DataPackage and set the serialized data
72+
var dataPackage = new DataPackage();
73+
dataPackage.SetData("application/x-custom-person", stream);
74+
75+
return dataPackage;
76+
}
77+
78+
// Helper method to serialize an object to InMemoryRandomAccessStream
79+
private async Task<InMemoryRandomAccessStream> SerializeObjectToStreamAsync<T>(T obj)
80+
{
81+
// Create a DataContractSerializer for the object type
82+
var serializer = new DataContractSerializer(typeof(T));
83+
84+
// Create a memory stream to hold the serialized data
85+
using (var memoryStream = new MemoryStream())
86+
{
87+
// Serialize the object to the memory stream
88+
serializer.WriteObject(memoryStream, obj);
89+
90+
// Create an InMemoryRandomAccessStream and copy the data
91+
var randomAccessStream = new InMemoryRandomAccessStream();
92+
var outputStream = randomAccessStream.GetOutputStreamAt(0);
93+
var dataWriter = new DataWriter(outputStream);
94+
95+
// Write the serialized bytes to the random access stream
96+
dataWriter.WriteBytes(memoryStream.ToArray());
97+
await dataWriter.StoreAsync();
98+
await dataWriter.FlushAsync();
99+
100+
// Reset position to beginning for reading
101+
randomAccessStream.Seek(0);
102+
103+
dataWriter.Dispose();
104+
outputStream.Dispose();
105+
106+
return randomAccessStream;
107+
}
108+
}
109+
110+
// Method to deserialize data from DataPackageView back to original object
111+
private async Task<T> DeserializeObjectFromDataAsync<T>(DataPackageView dataPackageView, string formatId)
112+
{
113+
try
114+
{
115+
// Get the stream data from the DataPackageView
116+
var streamData = await dataPackageView.GetDataAsync(formatId);
117+
var randomAccessStream = streamData as IRandomAccessStream;
118+
119+
if (randomAccessStream == null)
120+
throw new InvalidOperationException("Data is not in the expected stream format");
121+
122+
// Create a DataContractSerializer for the target type
123+
var serializer = new DataContractSerializer(typeof(T));
124+
125+
// Convert RandomAccessStream to a regular .NET Stream for deserialization
126+
var inputStream = randomAccessStream.GetInputStreamAt(0);
127+
var dataReader = new DataReader(inputStream);
128+
129+
// Read all bytes from the stream
130+
var bytesLoaded = await dataReader.LoadAsync((uint)randomAccessStream.Size);
131+
var bytes = new byte[bytesLoaded];
132+
dataReader.ReadBytes(bytes);
133+
134+
// Deserialize from memory stream
135+
using (var memoryStream = new MemoryStream(bytes))
136+
{
137+
var deserializedObject = (T)serializer.ReadObject(memoryStream);
138+
return deserializedObject;
139+
}
140+
}
141+
catch (Exception ex)
142+
{
143+
throw new InvalidOperationException($"Failed to deserialize object: {ex.Message}", ex);
144+
}
145+
}
146+
147+
// Example usage demonstrating the complete round-trip
148+
private async Task ExampleUsageAsync()
149+
{
150+
// Create DataPackage with serialized object
151+
var dataPackage = await CreateDataPackageWithSerializedObject();
152+
153+
// Simulate getting the data back (e.g., from clipboard or sharing operation)
154+
var dataPackageView = dataPackage.GetView();
155+
156+
// Deserialize the object back to its original type
157+
var retrievedPerson = await DeserializeObjectFromDataAsync<PersonData>(
158+
dataPackageView, "application/x-custom-person");
159+
160+
// Use the deserialized object
161+
Console.WriteLine($"Name: {retrievedPerson.Name}, Age: {retrievedPerson.Age}, Email: {retrievedPerson.Email}");
162+
}
163+
```
164+
165+
This example shows how to:
166+
167+
1. **Serialization**: Use **DataContractSerializer** to serialize a custom object and convert it to an **InMemoryRandomAccessStream** suitable for **SetData**.
168+
1. **Setting Data**: Call **SetData** with a custom format identifier and the serialized stream.
169+
1. **Deserialization**: Retrieve the data by using **GetDataAsync** and deserialize it back to the original object type.
170+
1. **Error Handling**: Implement basic error handling for serialization and deserialization operations.
171+
172+
> [!NOTE]
173+
> This example uses **DataContractSerializer**, which is safer and more modern than the deprecated **BinaryFormatter**. To ensure proper serialization support, add the `[DataContract]` and `[DataMember]` attributes to your custom classes.
29174
30175
## -see-also
176+
177+
[GetDataAsync](datapackageview_getdataasync_225712847.md)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
-api-id: P:Windows.Media.Core.CodecSubtypes.VideoFormatAv1
3+
-api-type: winrt property
4+
---
5+
6+
# Windows.Media.Core.CodecSubtypes.VideoFormatAv1
7+
8+
<!--
9+
public static string VideoFormatAv1 { get; }
10+
-->
11+
12+
13+
## -description
14+
15+
Gets the string representation of the [GUID](/windows/win32/api/guiddef/ns-guiddef-guid) for the AV1 video subtype.
16+
17+
## -property-value
18+
19+
The string representation of the AV1 video subtype.
20+
21+
## -remarks
22+
23+
This GUID matches the value of the Media Foundation subtype [MFVideoFormat_AV1](/windows/win32/medfound/video-subtype-guids), defined using the FOURCC 'AV01'.
24+
25+
## -see-also
26+
27+
## -examples
28+
29+

windows.media.core/codecsubtypes_videoformatdv25.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ public string VideoFormatDV25 { get; }
1010
# Windows.Media.Core.CodecSubtypes.VideoFormatDV25
1111

1212
## -description
13+
1314
Gets the string representation of the [GUID](/windows/win32/api/guiddef/ns-guiddef-guid) for the DVCPRO 25 (525-60 or 625-50) video subtype.
1415

1516
## -property-value
17+
1618
The string representation of the GUID for the DVCPRO 25 (525-60 or 625-50) video subtype.
1719

1820
## -remarks

windows.security.credentials/keycredentialmanager.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,33 @@ Contains methods for basic management of key credentials.
1616

1717
## -remarks
1818

19+
The `KeyCredentialManager` class provides methods to manage key credentials, which are RSA 2048-bit keys. These keys are used for secure authentication and cryptographic operations.
20+
21+
#### Key Information
22+
23+
- **Key Type**: RSA 2048-bit
24+
- **Signature Format**: PKCS #1 RSA PSS with SHA256
25+
- **Attestation Data**: The attestation data is a binary blob that includes metadata about the key, such as its origin and security properties.
26+
27+
#### Attestation Data Format
28+
29+
The attestation data is encoded in a binary format. It includes:
30+
31+
1. **Key Metadata**: Information about the key's origin and properties.
32+
1. **Certificate Chain**: A chain of certificates that can be used to verify the authenticity of the attestation.
33+
34+
#### Verifying Attestation Data
35+
36+
To verify the attestation data:
37+
38+
1. Parse the binary blob to extract the metadata and certificate chain.
39+
1. Use the certificate chain to validate the authenticity of the attestation.
40+
1. Ensure the metadata matches the expected properties of the key.
41+
42+
For more details, refer to the [KeyCredentialManager sample](https://github.com/Microsoft/Windows-universal-samples/tree/main/Samples/KeyCredentialManager).
43+
1944
## -examples
2045

2146
## -see-also
2247

23-
[KeyCredentialManager sample](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/KeyCredentialManager)
48+
[KeyCredentialManager sample](https://github.com/Microsoft/Windows-universal-samples/tree/main/Samples/KeyCredentialManager)

0 commit comments

Comments
 (0)