105040 优化电机线材选型页面
This commit is contained in:
parent
4ffa6d478a
commit
870faf37a9
|
@ -0,0 +1,16 @@
|
|||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Common
|
||||
{
|
||||
public class CommonMessage : ValueChangedMessage<int>
|
||||
{
|
||||
public CommonMessage(int value) : base(value)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
using EPLAN.Harness.Core.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
public class ScanCableModel : CheckedModel
|
||||
{
|
||||
private int _index;
|
||||
public int Index
|
||||
{
|
||||
get => _index; set
|
||||
{
|
||||
_index = value;
|
||||
OnPropertyChanged(nameof(Index));
|
||||
}
|
||||
}
|
||||
|
||||
private string _name;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name; set
|
||||
{
|
||||
_name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
|
||||
private string _code;
|
||||
public string Code
|
||||
{
|
||||
get => _code;
|
||||
set
|
||||
{
|
||||
_code = value;
|
||||
OnPropertyChanged(nameof(Code));
|
||||
}
|
||||
}
|
||||
private string _imprint;
|
||||
public string Imprint
|
||||
{
|
||||
get => _imprint;
|
||||
set
|
||||
{
|
||||
_imprint = value;
|
||||
OnPropertyChanged(nameof(Imprint));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -135,6 +135,7 @@
|
|||
<Reference Include="WindowsFormsIntegration" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Common\CommonMessage.cs" />
|
||||
<Compile Include="Models\CheckedModel.cs" />
|
||||
<Compile Include="Models\ConfigItemModel.cs" />
|
||||
<Compile Include="Models\ExcelModel.cs" />
|
||||
|
@ -146,6 +147,7 @@
|
|||
<Compile Include="Models\LineBomModel.cs" />
|
||||
<Compile Include="Models\MotorModel.cs" />
|
||||
<Compile Include="Models\ReportModel.cs" />
|
||||
<Compile Include="Models\ScanCableModel.cs" />
|
||||
<Compile Include="Models\StuffedDataModel.cs" />
|
||||
<Compile Include="Models\TerminalModel.cs" />
|
||||
<Compile Include="TestWindow.xaml.cs">
|
||||
|
@ -164,6 +166,8 @@
|
|||
<Compile Include="Utils\FlagEnumConverter.cs" />
|
||||
<Compile Include="Utils\LambdaComparer.cs" />
|
||||
<Compile Include="Utils\LectotypeLengthDataTemplateSelector.cs" />
|
||||
<Compile Include="Utils\LectotypeManager.cs" />
|
||||
<Compile Include="Utils\MessageSend.cs" />
|
||||
<Compile Include="Utils\MotorExcelHelper.cs" />
|
||||
<Compile Include="Utils\NameTypeConverter.cs" />
|
||||
<Compile Include="Utils\PropertyListExt.cs" />
|
||||
|
@ -172,6 +176,7 @@
|
|||
<Compile Include="ViewModel\LectotypeViewModel.cs" />
|
||||
<Compile Include="ViewModel\MainViewModel.Check.cs" />
|
||||
<Compile Include="ViewModel\MainViewModel.cs" />
|
||||
<Compile Include="ViewModel\ScannerViewModel.cs" />
|
||||
<Compile Include="View\CableLectotypeWindow.xaml.cs">
|
||||
<DependentUpon>CableLectotypeWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -181,6 +186,9 @@
|
|||
<Compile Include="View\MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\ScannerWindow.xaml.cs">
|
||||
<DependentUpon>ScannerWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Page Include="TestWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -201,6 +209,10 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="View\ScannerWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
|
@ -235,6 +247,9 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm">
|
||||
<Version>8.4.0-preview3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="HandyControl">
|
||||
<Version>3.5.1</Version>
|
||||
</PackageReference>
|
||||
|
@ -252,7 +267,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Commands\" />
|
||||
<Folder Include="Common\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -40,13 +40,16 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
[STAThread]
|
||||
public static void Main()
|
||||
{
|
||||
var window = new CableLectotypeWindow(new Models.MotorModel
|
||||
{
|
||||
AxisNo = "MRJ001",
|
||||
MotorPower = "1000W(220V)",
|
||||
MotorModelStr = "HK-KT103WJK",
|
||||
MotorSerie = "HK-KT"
|
||||
});
|
||||
//var window = new CableLectotypeWindow(new Models.MotorModel
|
||||
//{
|
||||
// AxisNo = "MRJ001",
|
||||
// MotorPower = "1000W(220V)",
|
||||
// MotorModelStr = "HK-KT103WJK",
|
||||
// MotorSerie = "HK-KT"
|
||||
//});
|
||||
//window.ShowDialog();
|
||||
|
||||
var window = new ScannerWindow();
|
||||
window.ShowDialog();
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||
{
|
||||
public static class LectotypeManager
|
||||
{
|
||||
public static MotorModel Motor;
|
||||
|
||||
|
||||
public class LectotypeViewModelFactory
|
||||
{
|
||||
private static readonly IDictionary<string, CableLectotypeViewModel> _motorViewModel = new Dictionary<string, CableLectotypeViewModel>();
|
||||
|
||||
public static CableLectotypeViewModel CreateOrGet(MotorModel motor)
|
||||
{
|
||||
if (motor == null || string.IsNullOrEmpty(motor.OccPartId))
|
||||
{
|
||||
Debug.WriteLine($"CreateOrGet Create for null-> {motor?.MotorModelStr} => {motor?.OccPartId}");
|
||||
|
||||
return new CableLectotypeViewModel(new MotorModel());
|
||||
}
|
||||
if (_motorViewModel.ContainsKey(motor.OccPartId))
|
||||
{
|
||||
Debug.WriteLine($"CreateOrGet Get -> {motor.MotorModelStr} => {motor.OccPartId}");
|
||||
return _motorViewModel[motor.OccPartId];
|
||||
}
|
||||
else
|
||||
{
|
||||
var viewModel = new CableLectotypeViewModel(motor);
|
||||
_motorViewModel.Add(motor.OccPartId, viewModel);
|
||||
Debug.WriteLine($"CreateOrGet Create -> {motor.MotorModelStr} => {motor.OccPartId}");
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Register(MotorModel motor, CableLectotypeViewModel viewModel)
|
||||
{
|
||||
if (!_motorViewModel.ContainsKey(motor.OccPartId))
|
||||
{
|
||||
_motorViewModel.Add(motor.OccPartId, viewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// 消息发送与接收
|
||||
/// </summary>
|
||||
public class MessageSend
|
||||
{
|
||||
private static readonly Dictionary<string, List<Action<object>>> _subscribers = new();
|
||||
|
||||
public static void Subscribe(string message, Action<object> callback)
|
||||
{
|
||||
if (!_subscribers.ContainsKey(message))
|
||||
{
|
||||
_subscribers[message] = new List<Action<object>>();
|
||||
}
|
||||
_subscribers[message].Add(callback);
|
||||
}
|
||||
|
||||
public static void Unsubscribe(string message, Action<object> callback)
|
||||
{
|
||||
if (_subscribers.ContainsKey(message))
|
||||
{
|
||||
_subscribers[message].Remove(callback);
|
||||
if (_subscribers[message].Count == 0)
|
||||
{
|
||||
_subscribers.Remove(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Publish(string message, object parameter = null)
|
||||
{
|
||||
if (_subscribers.ContainsKey(message))
|
||||
{
|
||||
foreach (var callback in _subscribers[message])
|
||||
{
|
||||
callback(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<Window
|
||||
<Page
|
||||
x:Class="Sinvo.EplanHpD.Plugin.WPFUI.View.CableLectotypeWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
|
@ -9,18 +9,30 @@
|
|||
xmlns:util="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.Utils"
|
||||
xmlns:viewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel"
|
||||
Title="CableLectotypeWindow"
|
||||
Width="1200"
|
||||
Height="800"
|
||||
Height="750"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:CableLectotypeViewModel}"
|
||||
IsVisibleChanged="Page_IsVisibleChanged"
|
||||
Loaded="Page_Loaded"
|
||||
SnapsToDevicePixels="True"
|
||||
mc:Ignorable="d">
|
||||
<Window.Resources>
|
||||
<Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/Themes/Theme.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<util:ConnectionTypeConverter x:Key="ConnectionTypeConverter" />
|
||||
<DataTemplate x:Key="LoadingMask">
|
||||
<Grid Background="#ccd7d7d7">
|
||||
<!--<hc:WaveProgressBar HorizontalAlignment="Center" VerticalAlignment="Center" />-->
|
||||
<hc:CircleProgressBar
|
||||
Width="150"
|
||||
Height="150"
|
||||
Margin="16,0,0,0"
|
||||
IsIndeterminate="True" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
</Page.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
|
@ -44,7 +56,16 @@
|
|||
VerticalAlignment="Top"
|
||||
Panel.ZIndex="99" />
|
||||
</ScrollViewer>
|
||||
<ContentPresenter
|
||||
x:Name="LoadingContentMask"
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Panel.ZIndex="99"
|
||||
ContentTemplate="{StaticResource LoadingMask}" />
|
||||
<hc:Card
|
||||
x:Name="InfoCard"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
|
@ -53,22 +74,28 @@
|
|||
Margin="10"
|
||||
HorizontalAlignment="Left"
|
||||
Orientation="Vertical">
|
||||
<hc:SimpleStackPanel Margin="0,10,0,0" Orientation="Horizontal">
|
||||
<hc:SimpleStackPanel
|
||||
Margin="0,10,0,0"
|
||||
DataContext="{Binding Motor}"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="电机ID:" />
|
||||
<hc:TextBox
|
||||
VerticalAlignment="Center"
|
||||
IsReadOnly="True"
|
||||
Style="{StaticResource TextBoxPlusBaseStyle}"
|
||||
Text="{Binding Motor.OccPartId}" />
|
||||
Text="{Binding OccPartId}" />
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel Margin="0,10,0,0" Orientation="Horizontal">
|
||||
<hc:SimpleStackPanel
|
||||
Margin="0,10,0,0"
|
||||
DataContext="{Binding Motor}"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="电机型号:" />
|
||||
<hc:TextBox
|
||||
Width="100"
|
||||
VerticalAlignment="Center"
|
||||
IsReadOnly="True"
|
||||
Style="{StaticResource TextBoxPlusBaseStyle}"
|
||||
Text="{Binding Motor.MotorModelStr}" />
|
||||
Text="{Binding MotorModelStr}" />
|
||||
<TextBlock VerticalAlignment="Center" Text="电机功率:" />
|
||||
<hc:TextBox
|
||||
Width="118"
|
||||
|
@ -76,7 +103,7 @@
|
|||
VerticalAlignment="Center"
|
||||
IsReadOnly="True"
|
||||
Style="{StaticResource TextBoxPlusBaseStyle}"
|
||||
Text="{Binding Motor.MotorPower}" />
|
||||
Text="{Binding MotorPower}" />
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel
|
||||
Margin="0,10,0,0"
|
||||
|
@ -169,7 +196,7 @@
|
|||
<Button hc:IconElement.Geometry="{StaticResource WindowRestoreGeometry}" />
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel>
|
||||
<hc:ButtonGroup>
|
||||
<!--<hc:ButtonGroup>
|
||||
<Button
|
||||
Background="{StaticResource LightPrimaryBrush}"
|
||||
Content="查看图纸"
|
||||
|
@ -180,14 +207,12 @@
|
|||
Content="查看BOM"
|
||||
Foreground="{StaticResource PrimaryTextBrush}"
|
||||
Style="{StaticResource ButtonGroupItemBaseStyle}" />
|
||||
<Button
|
||||
x:Name="CableratorBtn"
|
||||
Background="{StaticResource LightPrimaryBrush}"
|
||||
Click="CableratorBtn_Click"
|
||||
Content="生成线材列表"
|
||||
Foreground="{StaticResource PrimaryTextBrush}"
|
||||
Style="{StaticResource ButtonGroupItemBaseStyle}" />
|
||||
</hc:ButtonGroup>
|
||||
</hc:ButtonGroup>-->
|
||||
<Button
|
||||
x:Name="CableratorBtn"
|
||||
Click="CableratorBtn_Click"
|
||||
Content="生成线材推荐列表"
|
||||
Style="{StaticResource ButtonPrimary}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</hc:SimpleStackPanel>
|
||||
</hc:Card>
|
||||
|
@ -205,8 +230,7 @@
|
|||
ItemsSource="{Binding SelectedLines}"
|
||||
RowDetailsVisibilityMode="Visible"
|
||||
RowHeight="NaN"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
VirtualizingPanel.ScrollUnit="Pixel">
|
||||
ScrollViewer.CanContentScroll="False">
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
|
@ -256,9 +280,8 @@
|
|||
<DataGridTemplateColumn Width="300" Header="操作">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel MinWidth="300" Orientation="Horizontal">
|
||||
<StackPanel MinWidth="90" Orientation="Horizontal">
|
||||
<Button Content="查看图纸" />
|
||||
<Button Margin="10,0,0,0" Content="查看BOM" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
|
@ -332,6 +355,7 @@
|
|||
<Button
|
||||
Margin="10,0,0,0"
|
||||
hc:IconElement.Geometry="{StaticResource SaveGeometry}"
|
||||
Click="SaveBtn_Click"
|
||||
Content="保存"
|
||||
FontSize="14"
|
||||
Style="{StaticResource ButtonPrimary}" />
|
||||
|
@ -343,4 +367,4 @@
|
|||
Style="{StaticResource ButtonDanger}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
</Page>
|
||||
|
|
|
@ -1,27 +1,48 @@
|
|||
using HandyControl.Controls;
|
||||
using EPLAN.Harness.Core.Tasks;
|
||||
using HandyControl.Controls;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using static Sinvo.EplanHpD.Plugin.WPFUI.Utils.LectotypeManager;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
||||
{
|
||||
/// <summary>
|
||||
/// CableLectotypeWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CableLectotypeWindow : System.Windows.Window
|
||||
public partial class CableLectotypeWindow : Page
|
||||
{
|
||||
private MotorModel _motor;
|
||||
private CableLectotypeViewModel ViewModel;
|
||||
public CableLectotypeWindow(MotorModel motor)
|
||||
public CableLectotypeWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
_motor = motor;
|
||||
this.DataContext = ViewModel = new CableLectotypeViewModel(motor);
|
||||
Growl.Register("CableLectotypeMessage", GrowlParent);
|
||||
MessageSend.Subscribe("MotorChanged", (x) => OnMotorChanged());
|
||||
}
|
||||
private void OnMotorChanged()
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
_motor = LectotypeManager.Motor;
|
||||
if (ViewModel == null)
|
||||
{
|
||||
|
||||
this.DataContext = ViewModel = LectotypeViewModelFactory.CreateOrGet(_motor);
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewModel.Motor = _motor;
|
||||
}
|
||||
Debug.WriteLine($"OnMotorChanged - ViewModel -> {ViewModel.Motor.MotorModelStr} => {ViewModel.Motor.OccPartId}");
|
||||
Debug.WriteLine($"OnMotorChanged -> {LectotypeManager.Motor.MotorModelStr} => {LectotypeManager.Motor.OccPartId}");
|
||||
|
||||
});
|
||||
}
|
||||
private void CableratorBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.Cablerator();
|
||||
|
@ -29,10 +50,30 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
|
||||
private void ListView_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
|
||||
{
|
||||
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
|
||||
eventArg.RoutedEvent = UIElement.MouseWheelEvent;
|
||||
eventArg.Source = sender;
|
||||
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
|
||||
{
|
||||
RoutedEvent = UIElement.MouseWheelEvent,
|
||||
Source = sender
|
||||
};
|
||||
(sender as ListView).RaiseEvent(eventArg);
|
||||
}
|
||||
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Page_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
//_motor = LectotypeManager.Motor;
|
||||
//this.DataContext = ViewModel = LectotypeViewModelFactory.CreateOrGet(_motor);
|
||||
Debug.WriteLine($"Page_IsVisibleChanged -> {LectotypeManager.Motor?.MotorModelStr} => {LectotypeManager.Motor?.OccPartId}");
|
||||
MessageSend.Publish("MotorChanged", null);
|
||||
}
|
||||
|
||||
private void SaveBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LoadingContentMask.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,6 +160,82 @@
|
|||
</hc:SimpleStackPanel>
|
||||
</hc:Card>
|
||||
<TabControl Grid.Row="1" FontSize="14">
|
||||
<TabItem Header="电机数据">
|
||||
<DataGrid
|
||||
x:Name="MotorDataGrid"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding Motors}"
|
||||
MouseDoubleClick="MotorDataGrid_MouseDoubleClick"
|
||||
RowDetailsVisibilityMode="{Binding RowDetailsVisibility}"
|
||||
RowHeight="NaN"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
SelectionChanged="MotorDataGrid_SelectionChanged">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Click="MotorDataGridToMotorSourceMenuItem_Click" Header="在3D中查看(转至电机)" />
|
||||
<MenuItem Click="MotorDataGridToCableLectotype_Click" Header="根据此电机开始选择线材" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Resources>
|
||||
<Style BasedOn="{StaticResource DataGridCellStyle}" TargetType="DataGridCell">
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="MaxHeight" Value="9999" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.Resources>
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsError}" Value="True">
|
||||
<Setter Property="Background" Value="#dc4d41" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</DataTrigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Setter Property="Background" Value="#326cf3" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding MotorModelStr}"
|
||||
Header="电机型号" />
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding MotorPower}"
|
||||
Header="电机功率" />
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding AxisNo}"
|
||||
Header="轴号" />
|
||||
<DataGridTextColumn Binding="{Binding CheckedMsg}" Header="异常信息" />
|
||||
<DataGridTemplateColumn Width="300" Header="操作">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel MinWidth="90" Orientation="Horizontal">
|
||||
<Button Click="SelectedLectotype_Click" Content="展开线材选型" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
<DataGrid.RowDetailsTemplate>
|
||||
<DataTemplate>
|
||||
<hc:TransitioningContentControl TransitionMode="Top2BottomWithFade">
|
||||
<Frame SnapsToDevicePixels="True" Source="pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/View/CableLectotypeWindow.xaml" />
|
||||
</hc:TransitioningContentControl>
|
||||
</DataTemplate>
|
||||
</DataGrid.RowDetailsTemplate>
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
<TabItem Header="整理后的数据">
|
||||
<!--
|
||||
-->
|
||||
|
@ -342,7 +418,7 @@
|
|||
Checked="CheckBox_Checked"
|
||||
Click="CheckBox_Click"
|
||||
IsChecked="{Binding IsFlexibility, UpdateSourceTrigger=PropertyChanged}"
|
||||
IsEnabled="True"
|
||||
IsEnabled="False"
|
||||
Unchecked="CheckBox_Unchecked" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
|
@ -406,62 +482,7 @@
|
|||
</DataGrid.RowDetailsTemplate>
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
<TabItem Header="电机数据">
|
||||
<DataGrid
|
||||
x:Name="MotorDataGrid"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="False"
|
||||
ItemsSource="{Binding Motors}"
|
||||
RowHeight="NaN">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Click="MotorDataGridToMotorSourceMenuItem_Click" Header="在3D中查看(转至电机)" />
|
||||
<MenuItem Click="MotorDataGridToCableLectotype_Click" Header="根据此电机开始选择线材" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Resources>
|
||||
<Style BasedOn="{StaticResource DataGridCellStyle}" TargetType="DataGridCell">
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="MaxHeight" Value="9999" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.Resources>
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsError}" Value="True">
|
||||
<Setter Property="Background" Value="#dc4d41" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</DataTrigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Setter Property="Background" Value="#326cf3" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding MotorModelStr}"
|
||||
Header="电机型号" />
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding MotorPower}"
|
||||
Header="电机功率" />
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding AxisNo}"
|
||||
Header="轴号" />
|
||||
<DataGridTextColumn Binding="{Binding CheckedMsg}" Header="异常信息" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
|
||||
</TabControl>
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
|
|
|
@ -15,6 +15,7 @@ using System.Windows;
|
|||
using System.Windows.Controls;
|
||||
using System.Windows.Forms.Integration;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI
|
||||
{
|
||||
|
@ -30,6 +31,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
//_docId = docId;
|
||||
this.DataContext = ViewModel = new LectotypeViewModel(docId);
|
||||
Application.Current.SetMainWindow(this);
|
||||
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
|
@ -359,13 +361,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
|
||||
private void MotorDataGridToCableLectotype_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (MotorDataGrid.SelectedItem != null)
|
||||
{
|
||||
var window = new CableLectotypeWindow(MotorDataGrid.SelectedItem as MotorModel);
|
||||
ElementHost.EnableModelessKeyboardInterop(window);
|
||||
window.Show();
|
||||
//if (MotorDataGrid.SelectedItem != null)
|
||||
//{
|
||||
// var window = new CableLectotypeWindow(MotorDataGrid.SelectedItem as MotorModel);
|
||||
// ElementHost.EnableModelessKeyboardInterop(window);
|
||||
// window.Show();
|
||||
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
private void ListView_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
|
||||
|
@ -375,5 +377,46 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
eventArg.Source = sender;
|
||||
(sender as ListView).RaiseEvent(eventArg);
|
||||
}
|
||||
private void MotorDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (LectotypeManager.Motor?.OccPartId != (MotorDataGrid.SelectedItem as MotorModel)?.OccPartId)
|
||||
{
|
||||
//ViewModel.RowDetailsVisibility = DataGridRowDetailsVisibilityMode.Collapsed;
|
||||
LectotypeManager.Motor = MotorDataGrid.SelectedItem as MotorModel;
|
||||
Debug.WriteLine($"{LectotypeManager.Motor.MotorModelStr} => {LectotypeManager.Motor.OccPartId}");
|
||||
//ViewModel.RowDetailsVisibility = DataGridRowDetailsVisibilityMode.VisibleWhenSelected;
|
||||
MessageSend.Publish("MotorChanged", null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void MotorDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
private bool showRowDetails = false;
|
||||
private void SelectedLectotype_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var curSelItem = MotorDataGrid.SelectedItem as MotorModel;
|
||||
if (LectotypeManager.Motor == null || LectotypeManager.Motor.OccPartId == curSelItem.OccPartId)
|
||||
{
|
||||
if (showRowDetails)
|
||||
{
|
||||
ViewModel.RowDetailsVisibility = DataGridRowDetailsVisibilityMode.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewModel.RowDetailsVisibility = DataGridRowDetailsVisibilityMode.VisibleWhenSelected;
|
||||
}
|
||||
//LectotypeManager.Motor = new MotorModel();
|
||||
showRowDetails = !showRowDetails;
|
||||
}
|
||||
else
|
||||
{
|
||||
LectotypeManager.Motor = curSelItem;
|
||||
ViewModel.RowDetailsVisibility = DataGridRowDetailsVisibilityMode.VisibleWhenSelected;
|
||||
}
|
||||
MessageSend.Publish("MotorChanged", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using EPLAN.Harness.Common.Extensions;
|
||||
using EPLAN.Harness.AppCore;
|
||||
using EPLAN.Harness.Common.Extensions;
|
||||
using EPLAN.Harness.Core.Controls;
|
||||
using EPLAN.Harness.Core.Utils;
|
||||
using EPLAN.Harness.ProjectCore;
|
||||
|
@ -14,12 +15,24 @@ using System.Diagnostics;
|
|||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||
|
||||
public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
private DataGridRowDetailsVisibilityMode _rowDetailsVisibility;//= DataGridRowDetailsVisibilityMode.Visible;
|
||||
public DataGridRowDetailsVisibilityMode RowDetailsVisibility
|
||||
{
|
||||
get => _rowDetailsVisibility;
|
||||
set
|
||||
{
|
||||
_rowDetailsVisibility = value;
|
||||
OnPropertyChanged(nameof(RowDetailsVisibility));
|
||||
}
|
||||
}
|
||||
private List<LectotypeLineModel> _wires;
|
||||
public List<LectotypeLineModel> Wires
|
||||
{
|
||||
|
@ -408,15 +421,24 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
{
|
||||
if (imprint != null && imprint.Contains("-"))
|
||||
{
|
||||
var vals = imprint.Split('-');
|
||||
if (int.TryParse(vals[2], out int line))
|
||||
try
|
||||
{
|
||||
return line;
|
||||
var vals = imprint.Split('-');
|
||||
if (int.TryParse(vals[2], out int line))
|
||||
{
|
||||
return line;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToStringEx());
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue