Skip to content

Commit 6faa681

Browse files
committed
加上测试文件
1 parent 80a24e0 commit 6faa681

7 files changed

Lines changed: 86 additions & 4 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
using Microsoft.Maui.Graphics;
8+
9+
namespace MauiPptxViewerCore;
10+
11+
public class PptxViewer
12+
{
13+
public PptxViewer(FileInfo pptxFile, ICanvas canvas)
14+
{
15+
PptxFile = pptxFile;
16+
Canvas = canvas;
17+
}
18+
19+
public FileInfo PptxFile { get; }
20+
public ICanvas Canvas { get; }
21+
22+
public void Open()
23+
{
24+
25+
}
26+
}
27+
28+
//public record PptxViewerBuilder(FileInfo PptxFile, ICanvas Canvas)
29+
//{
30+
//}

demo/DocumentFormat.OpenXml.Flatten.Demo/WPF/OpenXmlFlattenMauiForWpfDemo/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<RowDefinition></RowDefinition>
1313
<RowDefinition Height="Auto"></RowDefinition>
1414
</Grid.RowDefinitions>
15-
<local:PaintBoardUserControl/>
15+
<local:PaintBoardUserControl x:Name="PaintBoardUserControl" Margin="10,10,10,10"/>
1616

1717
<Grid Grid.Row="1" Margin="10,10,10,10">
1818

@@ -24,7 +24,7 @@
2424

2525
<TextBlock Margin="0,0,5,0" VerticalAlignment="Center">Pptx File Path:</TextBlock>
2626
<TextBox x:Name="PptxFilePathTextBox" Grid.Column="1"></TextBox>
27-
<Button x:Name="OpenPptxFileButton" Grid.Column="2" Margin="5,0,0,0">Open</Button>
27+
<Button x:Name="OpenPptxFileButton" Grid.Column="2" Margin="5,0,0,0" Click="OpenPptxFileButton_OnClick">Open</Button>
2828
</Grid>
2929

3030
</Grid>

demo/DocumentFormat.OpenXml.Flatten.Demo/WPF/OpenXmlFlattenMauiForWpfDemo/MainWindow.xaml.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
45
using System.Text;
56
using System.Threading.Tasks;
@@ -23,6 +24,29 @@ public partial class MainWindow : Window
2324
public MainWindow()
2425
{
2526
InitializeComponent();
27+
28+
Loaded += MainWindow_Loaded;
29+
}
30+
31+
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
32+
{
33+
var folder = System.IO.Path.GetDirectoryName(GetType().Assembly.Location)!;
34+
var testFile = System.IO.Path.Combine(folder, @"TestFiles\Shape Triangle.pptx");
35+
36+
if (File.Exists(testFile))
37+
{
38+
PaintBoardUserControl.Open(new FileInfo(testFile));
39+
}
40+
}
41+
42+
private void OpenPptxFileButton_OnClick(object sender, RoutedEventArgs e)
43+
{
44+
var pptxFilePath = PptxFilePathTextBox.Text;
45+
46+
if (!string.IsNullOrEmpty(pptxFilePath) && File.Exists(pptxFilePath))
47+
{
48+
PaintBoardUserControl.Open(new FileInfo(pptxFilePath));
49+
}
2650
}
2751
}
2852

demo/DocumentFormat.OpenXml.Flatten.Demo/WPF/OpenXmlFlattenMauiForWpfDemo/OpenXmlFlattenMauiForWpfDemo.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@
1212
<ProjectReference Include="..\MauiForWpf\MauiForWpf.csproj" />
1313
</ItemGroup>
1414

15+
<ItemGroup>
16+
<None Update="TestFiles\*.pptx">
17+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
18+
</None>
19+
</ItemGroup>
20+
1521
</Project>

demo/DocumentFormat.OpenXml.Flatten.Demo/WPF/OpenXmlFlattenMauiForWpfDemo/PaintBoardUserControl.xaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
xmlns:local="clr-namespace:OpenXmlFlattenMauiForWpfDemo"
77
mc:Ignorable="d"
88
d:DesignHeight="450" d:DesignWidth="800">
9-
<Grid>
10-
9+
<Grid Background="Gray">
10+
<Viewbox Stretch="Uniform">
11+
<Canvas x:Name="MauiCanvas"></Canvas>
12+
</Viewbox>
1113
</Grid>
1214
</UserControl>

demo/DocumentFormat.OpenXml.Flatten.Demo/WPF/OpenXmlFlattenMauiForWpfDemo/PaintBoardUserControl.xaml.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
45
using System.Text;
56
using System.Threading.Tasks;
@@ -12,8 +13,12 @@
1213
using System.Windows.Media.Imaging;
1314
using System.Windows.Navigation;
1415
using System.Windows.Shapes;
16+
using MauiPptxViewerCore;
17+
using Microsoft.Maui.Graphics;
18+
using Microsoft.Maui.Graphics.Xaml;
1519

1620
namespace OpenXmlFlattenMauiForWpfDemo;
21+
1722
/// <summary>
1823
/// PaintBoardUserControl.xaml 的交互逻辑
1924
/// </summary>
@@ -22,5 +27,20 @@ public partial class PaintBoardUserControl : UserControl
2227
public PaintBoardUserControl()
2328
{
2429
InitializeComponent();
30+
31+
var xamlCanvas = new XamlCanvas()
32+
{
33+
Canvas = MauiCanvas,
34+
};
35+
_xamlCanvas = xamlCanvas;
36+
}
37+
38+
public void Open(FileInfo pptxFile)
39+
{
40+
_pptxViewer = new PptxViewer(pptxFile, _xamlCanvas);
41+
_pptxViewer.Open();
2542
}
43+
44+
private PptxViewer? _pptxViewer;
45+
private XamlCanvas _xamlCanvas;
2646
}

0 commit comments

Comments
 (0)