105040 优化界面样式
This commit is contained in:
parent
2740456d41
commit
698c23fcdb
|
@ -32,7 +32,7 @@
|
|||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="10">
|
||||
<Grid Margin="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="60" />
|
||||
|
@ -55,6 +55,7 @@
|
|||
x:Name="InfoCard"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
hc:BorderElement.CornerRadius="0,0,0,5"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
FontSize="14">
|
||||
<hc:SimpleStackPanel
|
||||
|
@ -206,18 +207,24 @@
|
|||
<hc:Card
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
hc:BorderElement.CornerRadius="0,0,5,0"
|
||||
Effect="{DynamicResource EffectShadow2}">
|
||||
|
||||
<DataGrid
|
||||
x:Name="SelectedLines_Dg"
|
||||
MinHeight="200"
|
||||
hc:BorderElement.CornerRadius="0,0,5,0"
|
||||
AutoGenerateColumns="False"
|
||||
Background="{StaticResource BackgroundBrush}"
|
||||
CanUserAddRows="False"
|
||||
FontSize="14"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding SelectedLines}"
|
||||
RowDetailsVisibilityMode="Visible"
|
||||
RowHeight="NaN"
|
||||
ScrollViewer.CanContentScroll="False">
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
VirtualizingPanel.IsVirtualizing="False"
|
||||
VirtualizingPanel.ScrollUnit="Pixel">
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
|
@ -300,6 +307,7 @@
|
|||
PreviewMouseWheel="ListView_PreviewMouseWheel"
|
||||
ScrollViewer.CanContentScroll="True"
|
||||
SelectionMode="Single"
|
||||
VirtualizingPanel.IsVirtualizing="False"
|
||||
VirtualizingPanel.ScrollUnit="Pixel">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
|
@ -340,7 +348,7 @@
|
|||
Click="SaveBtn_Click"
|
||||
Content="保存"
|
||||
FontSize="14"
|
||||
Style="{StaticResource ButtonPrimary}" />
|
||||
Style="{StaticResource ButtonSuccess}" />
|
||||
<Button
|
||||
Margin="10,0,10,0"
|
||||
hc:IconElement.Geometry="{StaticResource CloseGeometry}"
|
||||
|
|
|
@ -34,13 +34,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
set
|
||||
{
|
||||
_motor = (MotorModel)value;
|
||||
_viewModel.Motor = _motor;
|
||||
ViewModel.Motor = _motor;
|
||||
SetValue(MotorProperty, value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private CableLectotypeViewModel _viewModel;
|
||||
private CableLectotypeViewModel ViewModel = new CableLectotypeViewModel();
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
@ -53,45 +53,39 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
public CableLectotypeWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Initialized += CableLectotypeWindow_Initialized;
|
||||
}
|
||||
|
||||
private void CableLectotypeWindow_Initialized(object sender, EventArgs e)
|
||||
{
|
||||
OnMotorChanged();
|
||||
Debug.WriteLine($"Page_Loaded -> {_motor?.MotorModelStr} => {_motor?.OccPartId}");
|
||||
Debug.WriteLine($"CableLectotypeWindow_Created -> {_motor?.MotorModelStr} => {_motor?.OccPartId}");
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void OnMotorChanged()
|
||||
{
|
||||
_motor = (Motor as MotorModel);
|
||||
if (_motor != null)
|
||||
this.Dispatcher.BeginInvoke(() =>
|
||||
try
|
||||
{
|
||||
try
|
||||
LoadingContentMask.Visibility = Visibility.Visible;
|
||||
var oldViewModel = LectotypeViewModelFactory.CreateOrGetAsync(_motor).Result;
|
||||
if (oldViewModel != null)
|
||||
{
|
||||
LoadingContentMask.Visibility = Visibility.Visible;
|
||||
_viewModel = LectotypeViewModelFactory.CreateOrGetAsync(_motor).Result;
|
||||
//if(_viewModel == null)
|
||||
//{
|
||||
// _viewModel = new
|
||||
//}
|
||||
this.DataContext = _viewModel;
|
||||
ViewModel.Apply(oldViewModel);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
LoadingContentMask.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
});
|
||||
this.DataContext = ViewModel;
|
||||
//SelectedLines_Dg.Dispatcher.
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
LoadingContentMask.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
private void CableratorBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_viewModel.Cablerator();
|
||||
ViewModel.Cablerator();
|
||||
}
|
||||
|
||||
private void ListView_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
|
||||
|
@ -111,8 +105,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
|
||||
private void Page_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
OnMotorChanged();
|
||||
Debug.WriteLine($"Page_IsVisibleChanged -> {(Motor as MotorModel)?.MotorModelStr} => {(Motor as MotorModel)?.OccPartId}");
|
||||
//OnMotorChanged();
|
||||
}
|
||||
|
||||
private void SaveBtn_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -120,7 +114,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
LoadingContentMask.Visibility = Visibility.Visible;
|
||||
try
|
||||
{
|
||||
if (_viewModel.SaveToDb())
|
||||
if (ViewModel.SaveToDb())
|
||||
{
|
||||
Growl.Success("保存成功", "CableLectotypeMessage");
|
||||
}
|
||||
|
|
|
@ -181,17 +181,33 @@
|
|||
<TabItem Header="电机数据">
|
||||
<ListBox
|
||||
x:Name="MotorListView"
|
||||
Padding="0"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
ItemsSource="{Binding Motors}"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
VirtualizingPanel.ScrollUnit="Pixel">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource ListBoxItemBaseStyle}" TargetType="ListBoxItem">
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="Margin" Value="0" />
|
||||
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.Resources>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Style BasedOn="{StaticResource ExpanderBaseStyle}" TargetType="Expander">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="MinHeight" Value="50" />
|
||||
<Setter Property="Margin" Value="2" />
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Trigger Property="IsExpanded" Value="True">
|
||||
<Setter Property="Foreground" Value="{StaticResource LightPrimaryBrush}" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding IsError}" Value="True">
|
||||
<Setter Property="Background" Value="#dc4d41" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ListBox.Resources>
|
||||
|
@ -207,7 +223,7 @@
|
|||
<!-- Expander 的标题部分 -->
|
||||
<Expander.Header>
|
||||
<!-- 使用 Grid 定义列布局 -->
|
||||
<Grid>
|
||||
<Grid MinHeight="50">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="160" MinWidth="160" />
|
||||
<ColumnDefinition Width="160" MinWidth="160" />
|
||||
|
@ -241,7 +257,8 @@
|
|||
Grid.Column="4"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<Button Click="SelectedLectotype_Click" Content="展开线材选型" />
|
||||
<!-- Click="SelectedLectotype_Click" -->
|
||||
<ToggleButton Content="展开线材选型" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=Expander}}" />
|
||||
</StackPanel>
|
||||
<!-- ID -->
|
||||
<TextBlock Grid.Column="5" Text="{Binding OccPartId}" />
|
||||
|
|
|
@ -8,6 +8,7 @@ using System.ComponentModel;
|
|||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Security.RightsManagement;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||
|
@ -205,7 +206,10 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
OnPropertyChanged(nameof(SelectedLines));
|
||||
}
|
||||
}
|
||||
public CableLectotypeViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
public CableLectotypeViewModel(MotorModel motor)
|
||||
{
|
||||
Motor = motor;
|
||||
|
@ -335,16 +339,16 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Motor = viewModel.Motor;
|
||||
CableConnectionType = viewModel.CableConnectionType;
|
||||
AxisNo = viewModel.AxisNo;
|
||||
CableType = viewModel.CableType;
|
||||
EncoderLineParagraph = viewModel.EncoderLineParagraph;
|
||||
PowerLineParagraph = viewModel.PowerLineParagraph;
|
||||
CableModelStr = viewModel.CableModelStr;
|
||||
|
||||
SelectedLines = [];
|
||||
// 深拷贝 SelectedLines
|
||||
SelectedLines = viewModel.SelectedLines.Select(line => new LectotypeLineModel
|
||||
SelectedLines.AddRange(viewModel.SelectedLines.Select(line => new LectotypeLineModel
|
||||
{
|
||||
SeqNo = line.SeqNo,
|
||||
MechanicalNo = line.MechanicalNo,
|
||||
|
@ -367,7 +371,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
CableModel = subLine.CableModel,
|
||||
CableType = subLine.CableType
|
||||
}).ToList()
|
||||
}).ToList();
|
||||
}).ToList());
|
||||
|
||||
OnPropertyChanged(nameof(SelectedLines));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue