添加任务窗格和窗口支持

在 `AddinEntry.cs` 中添加了 `FeaturesUserControl` 任务窗格,设置了标题和工具提示。更新了 `SWDocReader.cs`,移除调试输出并添加条件判断。修改 `Laservall.Solidworks.csproj` 以支持 WPF 项目类型,添加了新的编译项和 XAML 页面。在 `FeaturesUserControl.xaml` 和 `FeaturesUserControl.xaml.cs` 中创建了用户控件和按钮事件处理。在 `ItemsPropWindow.xaml` 和 `ItemsPropWindow.xaml.cs` 中创建了新窗口和数据模板。
This commit is contained in:
Ling 2025-10-24 10:30:51 +08:00
parent 2e7995590b
commit 1699b69ebc
7 changed files with 160 additions and 3 deletions

View File

@ -48,6 +48,12 @@ namespace Laservall.Solidworks
{ {
SubscribeToSelectionEvents(this.Application.Documents.Active); SubscribeToSelectionEvents(this.Application.Documents.Active);
} }
this.CreateTaskPane<FeaturesUserControl>(new TaskPaneSpec
{
Title = "Laservall Features",
Tooltip = "Laservall Features"
});
} }
private void OnDocumentActivated(IXDocument doc) private void OnDocumentActivated(IXDocument doc)
{ {

View File

@ -94,9 +94,7 @@ namespace Laservall.Solidworks.Extension
swCustProp = swModelDocExt.get_CustomPropertyManager(""); swCustProp = swModelDocExt.get_CustomPropertyManager("");
//status = swCustProp.Get4(propertyName, false, out val, out valout); //status = swCustProp.Get4(propertyName, false, out val, out valout);
status = swCustProp.Get6(propertyName, false, out val,out valout,out bool wasResolved,out bool _); status = swCustProp.Get6(propertyName, false, out val,out valout,out bool wasResolved,out bool _);
Debug.Print("Value: " + val);
Debug.Print("Evaluated value: " + valout);
//Debug.Print("Up-to-date data: " + status);
if (wasResolved) if (wasResolved)
{ {
return valout; return valout;

View File

@ -5,6 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A8B83CC2-1DC4-478D-8956-B5357CDC336A}</ProjectGuid> <ProjectGuid>{A8B83CC2-1DC4-478D-8956-B5357CDC336A}</ProjectGuid>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Laservall.Solidworks</RootNamespace> <RootNamespace>Laservall.Solidworks</RootNamespace>
@ -80,6 +81,9 @@
<Compile Include="Extension\SWDocReader.cs" /> <Compile Include="Extension\SWDocReader.cs" />
<Compile Include="Extension\WPFApplicationExt.cs" /> <Compile Include="Extension\WPFApplicationExt.cs" />
<Compile Include="Model\PartPropModel.cs" /> <Compile Include="Model\PartPropModel.cs" />
<Compile Include="Pane\FeaturesUserControl.xaml.cs">
<DependentUpon>FeaturesUserControl.xaml</DependentUpon>
</Compile>
<Compile Include="Pane\PartPropPaneUserControl.xaml.cs"> <Compile Include="Pane\PartPropPaneUserControl.xaml.cs">
<DependentUpon>PartPropPaneUserControl.xaml</DependentUpon> <DependentUpon>PartPropPaneUserControl.xaml</DependentUpon>
</Compile> </Compile>
@ -87,11 +91,18 @@
<DependentUpon>TestUserControl.xaml</DependentUpon> <DependentUpon>TestUserControl.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Windows\ItemsPropWindow.xaml.cs">
<DependentUpon>ItemsPropWindow.xaml</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="Pane\FeaturesUserControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pane\PartPropPaneUserControl.xaml"> <Page Include="Pane\PartPropPaneUserControl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -103,7 +114,12 @@
<Page Include="Themes\Theme.xaml"> <Page Include="Themes\Theme.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Windows\ItemsPropWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\Xarial.XCad.SolidWorks.0.8.2\build\Xarial.XCad.SolidWorks.targets" Condition="Exists('packages\Xarial.XCad.SolidWorks.0.8.2\build\Xarial.XCad.SolidWorks.targets')" /> <Import Project="packages\Xarial.XCad.SolidWorks.0.8.2\build\Xarial.XCad.SolidWorks.targets" Condition="Exists('packages\Xarial.XCad.SolidWorks.0.8.2\build\Xarial.XCad.SolidWorks.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View File

@ -0,0 +1,15 @@
<UserControl x:Class="Laservall.Solidworks.Pane.FeaturesUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Laservall.Solidworks.Pane"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<ScrollViewer>
<WrapPanel>
<Button Content="查看所有机加件属性" Width="150" Height="50" Margin="5" Click="Button_Click"/>
</WrapPanel>
</ScrollViewer>
</UserControl>

View File

@ -0,0 +1,34 @@
using Laservall.Solidworks.Windows;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Laservall.Solidworks.Pane
{
/// <summary>
/// FeaturesUserControl.xaml 的交互逻辑
/// </summary>
public partial class FeaturesUserControl : UserControl
{
public FeaturesUserControl()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
new JJJPropWindow().ShowDialog();
}
}
}

View File

@ -0,0 +1,47 @@
<Window x:Class="Laservall.Solidworks.Windows.ItemsPropWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Laservall.Solidworks.Windows"
mc:Ignorable="d"
Loaded="Window_Loaded"
Title="机加件列表" Height="450" Width="800">
<Window.Resources>
<DataTemplate x:Key="LoadingMask">
<Grid Background="#66424242">
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Vertical">
<TextBlock
HorizontalAlignment="Center"
FontSize="16"
Text="加载中..." />
<ProgressBar
Width="200"
Height="10"
IsIndeterminate="True" />
</StackPanel>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ContentPresenter
x:Name="LoadingMask"
Grid.Row="0"
Grid.RowSpan="2"
Panel.ZIndex="99"
Content="{Binding}"
ContentTemplate="{StaticResource LoadingMask}" />
<StackPanel Orientation="Horizontal" Grid.Row="0">
<Button Content="搜索" Margin="10"/>
<TextBox Text="" Margin="10" MinWidth="200"/>
</StackPanel>
<DataGrid x:Name="propDataGrid" Grid.Row="1" Margin="10" />
</Grid>
</Window>

View File

@ -0,0 +1,41 @@
using Laservall.Solidworks.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Laservall.Solidworks.Windows
{
/// <summary>
/// JJJPropWindow.xaml 的交互逻辑
/// </summary>
public partial class ItemsPropWindow : Window
{
public ItemsPropWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//propDataGrid.ItemsSource = new List<PartPropModel>()
//{
// new PartPropModel
// {
// PartName = "测试零件",
// DrawNo = "JJJ123111",
// }
//};
}
}
}