Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 8d4decc9 authored by Harald Martini's avatar Harald Martini
Browse files

Added AirdragViewModel v2_8

parent d6db1c88
No related branches found
No related tags found
No related merge requests found
Showing
with 525 additions and 95 deletions
......@@ -30,11 +30,8 @@ namespace VECTO3GUI2020.Helper.Converter
}
return Binding.DoNothing;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
......
......@@ -25,8 +25,8 @@ namespace VECTO3GUI2020.Helper.Converter
}
return Binding.DoNothing;
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
......
using System;
using System.Diagnostics;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using Castle.Core.Resource;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCore.Utils;
using TUGraz.VectoHashing.Impl;
using VECTO3GUI2020.Util.XML;
using VECTO3GUI2020.Util.XML.Interfaces;
......@@ -39,5 +42,59 @@ namespace VECTO3GUI2020.Helper
return signatureElement;
}
}
public static XmlDocument ToXmlDocument(this XDocument xDocument)
{
var xmlDocument = new XmlDocument();
using (var reader = xDocument.CreateReader())
{
xmlDocument.Load(reader);
}
var xDeclaration = xDocument.Declaration;
if (xDeclaration != null)
{
var xmlDeclaration = xmlDocument.CreateXmlDeclaration(
xDeclaration.Version,
xDeclaration.Encoding,
xDeclaration.Standalone);
xmlDocument.InsertBefore(xmlDeclaration, xmlDocument.FirstChild);
}
return xmlDocument;
}
public static XmlNode ToXmlNode(this XElement element)
{
using (XmlReader xmlReader = element.CreateReader())
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(xmlReader);
return xmlDocument;
}
}
public static string GetVersion(this XElement element)
{
return element.ToXmlNode().GetVersion();
}
public static string GetVersion(this XmlNode node)
{
if (node == null)
{
return null;
}
var version = XMLHelper.GetXsdType(node.SchemaInfo.SchemaType);
if (string.IsNullOrWhiteSpace(version))
{
version = XMLHelper.GetVersionFromNamespaceUri((node.SchemaInfo.SchemaType?.Parent as XmlSchemaElement)?.QualifiedName.Namespace);
}
return version;
}
}
}
\ No newline at end of file
using System;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using Castle.Core.Internal;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCore.Utils;
namespace VECTO3GUI2020.Helper
{
......@@ -13,9 +17,8 @@ namespace VECTO3GUI2020.Helper
var xmlDocument = new XmlDocument();
using (var reader = new XmlTextReader(filePath)) {
xmlDocument.Load(reader);
}
xmlDocument.Load(filePath);
return xmlDocument;
}
......@@ -29,22 +32,22 @@ namespace VECTO3GUI2020.Helper
return xmlDocument.SelectNodes($"//*[local-name()='{parentNode}']//*[local-name()='{nodeName}']");
}
//public static bool ValidateXDocument(XDocument xDocument, Action<bool> resultAction = null,
// Action<XmlSeverityType, ValidationEvent> validationErrorAction = null)
//{
// var xmlDocument = xDocument.ToXmlDocument();
// if (xmlDocument == null)
// return false;
// var documentType = XMLHelper.GetDocumentType(xmlDocument.DocumentElement.LocalName);
// if (documentType == null)
// {
// throw new VectoException("unknown xml file! {0}", xmlDocument.DocumentElement.LocalName);
// }
// var validator = new XMLValidator(xmlDocument, resultAction, validationErrorAction);
// return validator.ValidateXML(documentType.Value); ;
//}
public static bool ValidateXDocument(XDocument xDocument, Action<bool> resultAction = null,
Action<XmlSeverityType, ValidationEvent> validationErrorAction = null)
{
var xmlDocument = xDocument.ToXmlDocument();
if (xmlDocument == null)
return false;
var documentType = XMLHelper.GetDocumentType(xmlDocument.DocumentElement.LocalName);
if (documentType == null)
{
throw new VectoException("unknown xml file! {0}", xmlDocument.DocumentElement.LocalName);
}
var validator = new XMLValidator(xmlDocument, resultAction, validationErrorAction);
return validator.ValidateXML(documentType.Value); ;
}
public static string GetXmlAbsoluteFilePath(string baseUri)
{
......
......@@ -35,6 +35,7 @@ namespace VECTO3GUI2020.Ninject.Vehicle
Bind<IComponentViewModel>().To<AirDragViewModel_v1_0>().Named(AirDragViewModel_v1_0.VERSION);
Bind<IComponentViewModel>().To<AirDragViewModel_v2_0>().Named(AirDragViewModel_v2_0.VERSION);
Bind<IComponentViewModel>().To<AirDragViewModel_v2_8>().Named(AirDragViewModel_v2_8.VERSION);
Bind<IComponentViewModel>().To<AxleWheelsViewModel_v1_0>().Named(AxleWheelsViewModel_v1_0.VERSION);
Bind<IComponentViewModel>().To<AxleWheelsViewModel_v2_0>().Named(AxleWheelsViewModel_v2_0.VERSION);
......
......@@ -193,6 +193,11 @@
<componentviews:EngineFuelView/>
</DataTemplate>
<!--#endregion-->
<DataTemplate DataType="{x:Type componentimpl:AirDragViewModel_v2_8}">
<multistageviews:AirDragView_v2_8></multistageviews:AirDragView_v2_8>
</DataTemplate>
<!--#region Multistage -->
<DataTemplate DataType="{x:Type multistageimpl:NewMultiStageJobViewModel}">
<multistageviews:NewMultistageFileView/>
......
......@@ -345,9 +345,15 @@
<Compile Include="Views\MessageView.xaml.cs">
<DependentUpon>MessageView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Multistage\AirDragView_v2_8.xaml.cs">
<DependentUpon>AirDragView_v2_8.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Multistage\CustomControls\FilePicker.xaml.cs">
<DependentUpon>FilePicker.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Multistage\CustomControls\LabledTextBoxMultistage.xaml.cs">
<DependentUpon>LabledTextBoxMultistage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Multistage\CustomControls\MultiStageParameter.xaml.cs">
<DependentUpon>MultiStageParameter.xaml</DependentUpon>
</Compile>
......@@ -536,10 +542,18 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Multistage\AirDragView_v2_8.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Multistage\CustomControls\FilePicker.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Multistage\CustomControls\LabledTextBoxMultistage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Multistage\CustomControls\MultiStageParameter.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
using System;
using System.Diagnostics;
using System.Reflection.Emit;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -31,7 +32,9 @@ namespace VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components
public AirDragViewModel(IXMLAirdragDeclarationInputData inputData, IComponentViewModelFactory vmFactory)
{
{
LabelVisible = true;
IsReadOnly = false;
_inputData = inputData as IAirdragDeclarationInputData;
Debug.Assert(_inputData != null);
_isPresent = (_inputData?.DataSource?.SourceFile != null);
......@@ -49,6 +52,11 @@ namespace VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components
#region Implementation of IAirDragDeclarationInputData
protected SquareMeter _airDragArea;
protected SquareMeter _transferredAirDragArea;
protected SquareMeter _airDragArea_0;
private bool _isReadOnly;
private bool _labelVisible;
public DataSource DataSource
{
get => _commonComponentViewModel.DataSource;
......@@ -100,11 +108,33 @@ namespace VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components
public string AppVersion => _commonComponentViewModel.AppVersion;
public virtual SquareMeter AirDragArea {get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public SquareMeter TransferredAirDragArea { get => throw new NotImplementedException(); }
public SquareMeter AirDragArea_0 { get => throw new NotImplementedException(); }
public virtual SquareMeter AirDragArea
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
public virtual SquareMeter TransferredAirDragArea {
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
public virtual SquareMeter AirDragArea_0 {
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
#endregion
public bool LabelVisible
{
get => _labelVisible;
set => SetProperty(ref _labelVisible, value);
}
public bool IsReadOnly
{
get => _isReadOnly;
set => SetProperty(ref _isReadOnly, value);
}
}
......@@ -142,4 +172,40 @@ namespace VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components
set => SetProperty(ref _airDragArea, value);
}
}
public class AirDragViewModel_v2_8 : AirDragViewModel_v2_0
{
public static new readonly string VERSION = typeof(XMLDeclarationAirdragDataProviderV28).FullName;
public AirDragViewModel_v2_8(IXMLAirdragDeclarationInputData inputData, IComponentViewModelFactory vmFactory) : base(inputData, vmFactory)
{
LabelVisible = false;
IsReadOnly = true;
}
public override void SetProperties()
{
_airDragArea = _inputData.AirDragArea;
_airDragArea_0 = _inputData.AirDragArea_0;
_transferredAirDragArea = _inputData.TransferredAirDragArea;
}
public override SquareMeter AirDragArea
{
get => _airDragArea;
set => SetProperty(ref _airDragArea, value);
}
public override SquareMeter TransferredAirDragArea {
get => _transferredAirDragArea;
set => SetProperty(ref _transferredAirDragArea, value);
}
public override SquareMeter AirDragArea_0
{
get => _airDragArea_0;
set => SetProperty(ref _airDragArea_0, value);
}
}
}
......@@ -4,5 +4,7 @@ namespace VECTO3GUI2020.ViewModel.Interfaces.JobEdit.Vehicle.Components
{
public interface IAirDragViewModel : IAirdragDeclarationInputData, IComponentViewModel
{
bool LabelVisible { get; set; }
bool IsReadOnly { get; set; }
}
}
......@@ -88,7 +88,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
Components.Add(VehicleViewModel.Name, VehicleViewModel as IViewModelBase);
var airDragEditViewModel = viewModelFactory.GetMultistageAirdragViewModel();
var airDragEditViewModel = viewModelFactory.GetMultistageAirdragViewModel(_consolidatedManufacturingStageInputData.Vehicle.Components.AirdragInputData);
Components.Add("Airdrag", airDragEditViewModel as IViewModelBase);
var auxiliariesViewModel =
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.InputData.FileIO.XML;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Factory;
using TUGraz.VectoCore.Utils;
using VECTO3GUI2020.Helper;
using VECTO3GUI2020.Properties;
using VECTO3GUI2020.Util;
......@@ -19,7 +28,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
public class MultistageAirdragViewModel : ViewModelBase, IMultistageAirdragViewModel
{
private IDialogHelper _dialogHelper;
private IXMLInputDataReader _inputDataReader;
private IComponentViewModelFactory _componentViewModelFactory;
private IAirDragViewModel _airdragViewModel;
private bool _airdragModified;
......@@ -31,21 +39,21 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
set => SetProperty(ref _airdragViewModel, value);
}
public IAirdragDeclarationInputData ConsolidatedAirdragData
{
get => _consolidatedAirdragInputData;
set => SetProperty(ref _consolidatedAirdragInputData, value);
}
#region Commands
private ICommand _loadAirdragFileCommand;
private Dictionary<string, string> _validationErrors;
private IAirdragDeclarationInputData _consolidatedAirdragInputData;
private DataSource _dataSource;
private bool _savedInDeclarationMode;
private string _manufacturer;
private string _model;
private DateTime _date;
private string _appVersion;
private CertificationMethod _certificationMethod;
private string _certificationNumber;
private DigestData _digestValue;
private SquareMeter _airDragArea;
private readonly IDeclarationInjectFactory _injectFactory;
public ICommand LoadAirdragFileCommand
{
......@@ -55,67 +63,99 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
public void LoadAirdragFileCommandExecute()
{
var fileName = _dialogHelper.OpenXMLFileDialog(Settings.Default.DefaultFilePath);
var success = true;
var errorStringBuilder = new StringBuilder();
try {
var xDoc = new XmlDocument();
xDoc.Load(fileName);
//_inputDataReader.Create();
//var xmlNodes = GetXmlNodes(filePath);
//if (xmlNodes.IsNullOrEmpty())
// return;
//var compReader = new XmlComponentReaderHelper(xmlNodes[0].ParentNode);
//SetLoadedAirdragData(compReader.GetAirdragComponentData());
var xDoc = XDocument.Load(fileName);
var doc = new XmlDocument();
doc.Load(fileName);
var airdragElements = xDoc.Descendants().Where(e => e.Name.LocalName == XMLNames.Component_AirDrag);
if (airdragElements.Count() == 1) {
//GET FROM FILE
var dataProviderVersion = XMLDeclarationAirdragDataProviderV28.QUALIFIED_XSD_TYPE;
//var dataProviderVersion = XMLDeclarationAirdragDataProviderV28.QUALIFIED_XSD_TYPE;
XElement airdragElement = airdragElements.First();
XmlNode airdragNode = airdragElement.ToXmlNode();
var airDragInputData = _injectFactory.CreateAirdragData(dataProviderVersion, null, airdragNode, fileName);
AirDragViewModel = _componentViewModelFactory.CreateComponentViewModel(airDragInputData) as IAirDragViewModel;
success = false;
} else {
success = false;
}
}
catch (Exception e) {
_dialogHelper.ShowMessageBox(e.Message, "Invalid File", MessageBoxButton.OK,
_dialogHelper.ShowMessageBox(e.Message,
"Invalid File",
MessageBoxButton.OK,
MessageBoxImage.Error);
}
if (!success) {
}
}
private void ValidationErrorAction(XmlSeverityType arg1, ValidationEvent arg2)
{
var xmlException = arg2?.ValidationEventArgs?.Exception as XmlSchemaValidationException;
if (xmlException != null)
{
var message = xmlException.InnerException;
var sourceObject = xmlException.SourceObject as XmlElement;
var localName = sourceObject?.LocalName;
if (sourceObject != null)
_validationErrors.Add(localName, message?.Message);
}
}
#endregion
public MultistageAirdragViewModel(IDialogHelper dialogHelper, IXMLInputDataReader inputDataReader, IComponentViewModelFactory componentViewModelFactory)
public MultistageAirdragViewModel(IDialogHelper dialogHelper, IDeclarationInjectFactory injectFactory, IComponentViewModelFactory componentViewModelFactory)
{
_dialogHelper = dialogHelper;
_inputDataReader = inputDataReader;
_injectFactory = injectFactory;
_componentViewModelFactory = componentViewModelFactory;
}
public MultistageAirdragViewModel(IAirdragDeclarationInputData consolidatedAirdragInputData,
IDialogHelper dialogHelper,
IXMLInputDataReader inputDataReader,
IComponentViewModelFactory componentViewModelFactory) : this(dialogHelper, inputDataReader, componentViewModelFactory)
IDeclarationInjectFactory injectFactory,
IComponentViewModelFactory componentViewModelFactory) : this(dialogHelper, injectFactory, componentViewModelFactory)
{
_consolidatedAirdragInputData = consolidatedAirdragInputData;
ConsolidatedAirdragData = consolidatedAirdragInputData;
}
public DataSource DataSource => _dataSource;
public DataSource DataSource => _airdragViewModel.DataSource;
public bool SavedInDeclarationMode => _airdragViewModel.SavedInDeclarationMode;
public string Manufacturer => _airdragViewModel.Manufacturer;
public bool SavedInDeclarationMode => _savedInDeclarationMode;
public string Model => _airdragViewModel.Model;
public string Manufacturer => _manufacturer;
public DateTime Date => _airdragViewModel.Date;
public string Model => _model;
public string AppVersion => _airdragViewModel.AppVersion;
public DateTime Date => _date;
public CertificationMethod CertificationMethod => _airdragViewModel.CertificationMethod;
public string AppVersion => _appVersion;
public string CertificationNumber => _airdragViewModel.CertificationNumber;
public CertificationMethod CertificationMethod => _certificationMethod;
public DigestData DigestValue => _airdragViewModel.DigestValue;
public string CertificationNumber => _certificationNumber;
public SquareMeter AirDragArea => _airdragViewModel.AirDragArea;
public DigestData DigestValue => _digestValue;
public SquareMeter TransferredAirDragArea => _airdragViewModel.TransferredAirDragArea;
public SquareMeter AirDragArea => _airDragArea;
public SquareMeter TransferredAirDragArea { get; }
public SquareMeter AirDragArea_0 { get; }
public SquareMeter AirDragArea_0 => _airdragViewModel.AirDragArea_0;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using TUGraz.VectoCommon.Utils;
namespace VECTO3GUI2020.Views.CustomControls
{
......@@ -46,5 +48,56 @@ namespace VECTO3GUI2020.Views.CustomControls
var PropertyType = Binding?.ResolvedSource?.GetType().GetProperty(PropertyName).PropertyType;
return PropertyType;
}
public static object CreateDummyContent(this UserControl userControl, DependencyPropertyChangedEventArgs e)
{
var type = userControl.GetPropertyType(e.Property);
if (type == null)
{
return null;
}
try
{
dynamic dynType = type;
var baseType = dynType.BaseType;
//Create SI Dummy
if (baseType.BaseType == typeof(SI))
{
var createMethod = baseType.GetMethod("Create");
var dummyContent = createMethod?.Invoke(null, new object[] { (new double()) });
return dummyContent;
}
else
{
var bindingProperty = userControl.GetBindingExpression(e.Property);
var dataItemType = bindingProperty?.DataItem.GetType();
var sourcePropertyType =
dataItemType?.GetProperty(bindingProperty?.ResolvedSourcePropertyName)?.PropertyType;
var underlyingType = Nullable.GetUnderlyingType(dynType);
Enum dummyEnum;
if (underlyingType != null)
{
dummyEnum = Enum.Parse(underlyingType, underlyingType.GetEnumNames()[0]);
}
else
{
dummyEnum = Enum.Parse(dynType, dynType.GetEnumNames()[0]);
}
return dummyEnum;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
return null;
}
return null;
}
}
}
<UserControl x:Class="VECTO3GUI2020.Views.Multistage.AirDragView_v2_8"
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:VECTO3GUI2020.Views.Multistage"
xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls"
xmlns:implementation="clr-namespace:VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components" d:DataContext="{d:DesignInstance Type=implementation:AirDragViewModel_v2_8}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<StackPanel>
<Label
Visibility="{Binding LabelVisible, Converter={StaticResourceExtension BooleanToVisibilityConverter}}">Airdrag</Label>
<customControls:LabledTextBoxMultistage
Content="{Binding Manufacturer}"
ReadOnly="{Binding IsReadOnly}"/>
<customControls:LabledTextBoxMultistage
Content="{Binding Model}"
ReadOnly="{Binding IsReadOnly}"/>
<customControls:LabledTextBoxMultistage
Content="{Binding CertificationNumber}"
ReadOnly="{Binding IsReadOnly}"/>
<customControls:LabledTextBoxMultistage
Content="{Binding AirDragArea}"
ReadOnly="{Binding IsReadOnly}"/>
<customControls:LabledTextBoxMultistage
Content="{Binding AirDragArea_0}"
ReadOnly="{Binding IsReadOnly}"/>
<customControls:LabledTextBoxMultistage
Content="{Binding TransferredAirDragArea}"
ReadOnly="{Binding IsReadOnly}"/>
</StackPanel>
</Grid>
</UserControl>
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 VECTO3GUI2020.Views.Multistage
{
/// <summary>
/// Interaction logic for AirDragView_v2_8.xaml
/// </summary>
public partial class AirDragView_v2_8 : UserControl
{
public AirDragView_v2_8()
{
InitializeComponent();
}
}
}
......@@ -5,19 +5,20 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls"
mc:Ignorable="d"
d:DesignHeight="30" d:DesignWidth="800" Name="filepickercustomcontrol">
<Grid>
<Grid Margin="4" DockPanel.Dock="Top">
<Grid.ColumnDefinitions>
d:DesignHeight="30" d:DesignWidth="800" Name="filepickercustomcontrol" MinHeight="40" MaxHeight="30">
<Grid Margin="4" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="30px"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBox VerticalContentAlignment="Center" Height="Auto" Padding="4" Margin = "0 0 0 0" IsReadOnly="True"
<TextBox VerticalContentAlignment="Center" Padding="4" Margin = "0 0 0 0" IsReadOnly="True"
Text="{Binding Text, ElementName=filepickercustomcontrol}" HorizontalAlignment="Stretch"/>
<Button Padding="4" Margin="4 0 0 0" Grid.Column="1" Command="{Binding Command, ElementName=filepickercustomcontrol}">
<Image Source="../../../Resources/folderpicker.ico">
</Image>
</Button>
</Grid>
</Grid>
</UserControl>
<UserControl x:Class="VECTO3GUI2020.Views.Multistage.CustomControls.LabledTextBoxMultistage"
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:VECTO3GUI2020.Views.Multistage.CustomControls"
mc:Ignorable="d"
Name="labledTextBoxMultistage"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*" SharedSizeGroup="W"/>
<ColumnDefinition Width="4*" SharedSizeGroup="W"/>
<ColumnDefinition Width="1*" SharedSizeGroup="N"/>
</Grid.ColumnDefinitions>
<Label Content="{Binding LabelText, ElementName=labledTextBoxMultistage}"/>
<TextBox Grid.Column="1" Name ="TextBoxContent" VerticalAlignment="Center" Margin="2 0 2 0"
Text="{Binding ElementName=labledTextBoxMultistage, Path=Content,
Converter={StaticResourceExtension SIValueToStringConverter},
ValidatesOnExceptions=True,
UpdateSourceTrigger=PropertyChanged}"
IsReadOnly="{Binding ElementName=labledTextBoxMultistage, Path=ReadOnly}"/>
<Label Grid.Column="2" x:Name="AutoUnitLabel"
Content="{Binding DummyContent, ElementName=labledTextBoxMultistage, Converter={StaticResource SIToUnitStringConverter}}">
</Label>
</Grid>
</UserControl>
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;
using VECTO3GUI2020.Properties;
using VECTO3GUI2020.Views.CustomControls;
namespace VECTO3GUI2020.Views.Multistage.CustomControls
{
/// <summary>
/// Interaction logic for LabledTextBoxMultistage.xaml
/// </summary>
public partial class LabledTextBoxMultistage : UserControl
{
#region Dependency Properties
public static readonly DependencyProperty ReadOnlyProperty = DependencyProperty.Register(
"ReadOnly", typeof(bool), typeof(LabledTextBoxMultistage), new PropertyMetadata(default(bool)));
public bool ReadOnly
{
get { return (bool)GetValue(ReadOnlyProperty); }
set { SetValue(ReadOnlyProperty, value); }
}
public static readonly DependencyProperty DummyContentProperty = DependencyProperty.Register(
"DummyContent", typeof(object), typeof(LabledTextBoxMultistage), new PropertyMetadata(default(object)));
public object DummyContent
{
get { return (object)GetValue(DummyContentProperty); }
set { SetValue(DummyContentProperty, value); }
}
public new static readonly DependencyProperty ContentProperty =
DependencyProperty.Register("Content",
typeof(object),
typeof(LabledTextBoxMultistage),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(ContentChanged))); //TODO Default value null breaks it for SIs default value "" for strings
public new object Content
{
get { return (object)GetValue(ContentProperty); }
set
{
SetCurrentValue(ContentProperty, value);
}
}
public static readonly DependencyProperty LabelTextProperty = DependencyProperty.Register(
"LabelText", typeof(string), typeof(LabledTextBoxMultistage), new PropertyMetadata(null));
public string LabelText
{
get { return (string)GetValue(LabelTextProperty); }
set { SetValue(LabelTextProperty, value); }
}
#endregion
private static void ContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var labledTextBoxMultistage = (CustomControls.LabledTextBoxMultistage)d;
labledTextBoxMultistage.DummyContent = labledTextBoxMultistage.CreateDummyContent(e);
if (labledTextBoxMultistage.LabelText != null)
{
return;
}
labledTextBoxMultistage.LabelText = labledTextBoxMultistage.GetLabelByPropertyName(
LabledTextBoxMultistage.ContentProperty,
Strings.ResourceManager);
}
public LabledTextBoxMultistage()
{
InitializeComponent();
}
}
}
......@@ -7,7 +7,7 @@
xmlns:implementation="clr-namespace:VECTO3GUI2020.ViewModel.MultiStage.Implementation"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance implementation:ManufacturingStageViewModel_v0_1 }">
<Grid MaxWidth="900">
<Grid>
<DockPanel>
<Grid Margin="4" DockPanel.Dock="Top">
<Grid.ColumnDefinitions>
......
......@@ -4,17 +4,26 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VECTO3GUI2020.Views.Multistage"
xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls"
xmlns:customControls1="clr-namespace:VECTO3GUI2020.Views.CustomControls"
xmlns:customControlsMultistage="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls"
xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.CustomControls"
xmlns:impl="clr-namespace:VECTO3GUI2020.ViewModel.MultiStage.Implementation"
xmlns:properties="clr-namespace:VECTO3GUI2020.Properties"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" BorderBrush="Aquamarine" BorderThickness="2" Margin="4"
d:DataContext="{d:DesignInstance impl:MultistageAirdragViewModel}">
<Grid>
<StackPanel>
<Label Content="AIRDRAG" HorizontalAlignment="Stretch" Background="Aquamarine"/>
<customControls1:LabledCheckBoxAutomatic Content="{Binding AirdragModified}"></customControls1:LabledCheckBoxAutomatic>
<customControls:FilePicker Height="30px" VerticalAlignment="Top" Text="Test" Command="{Binding LoadAirdragFileCommand}"></customControls:FilePicker>
<customControlsMultistage:FilePicker Text="Test" Command="{Binding LoadAirdragFileCommand}"/>
<StackPanel HorizontalAlignment="Stretch" Margin="4">
<Label>Consolidated Airdrag Data</Label>
<customControlsMultistage:LabledTextBoxMultistage Content="{Binding ConsolidatedAirdragData.Manufacturer, Mode=OneWay}" ReadOnly="True"/>
<customControlsMultistage:LabledTextBoxMultistage Content="{Binding ConsolidatedAirdragData.Model, Mode=OneWay}" ReadOnly="True"/>
<customControlsMultistage:LabledTextBoxMultistage Content="{Binding ConsolidatedAirdragData.AirDragArea, Mode=OneWay}" ReadOnly="True"/>
<Separator/>
<Label>Data from File</Label>
<ContentControl Margin="0" Padding="0" Content="{Binding AirDragViewModel}"/>
</StackPanel>
</StackPanel>
</Grid>
......
......@@ -5,22 +5,14 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VECTO3GUI2020.Views.Multistage"
xmlns:implementation="clr-namespace:VECTO3GUI2020.ViewModel.MultiStage.Implementation"
xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance implementation:NewMultiStageJobViewModel }">
<Grid>
<Grid MaxWidth="900">
<DockPanel>
<Grid Margin="4" DockPanel.Dock="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="30px"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBox VerticalContentAlignment="Center" Height="Auto" Padding="4" Margin = "0 0 0 0" IsReadOnly="True"
Text="{Binding VifPath}" HorizontalAlignment="Stretch"/>
<Button Padding="4" Margin="4 0 0 0" Grid.Column="1" Command="{Binding AddVifFile}">
<Image Source="../../Resources/folderpicker.ico">
</Image>
</Button>
<Grid DockPanel.Dock="Top">
<customControls:FilePicker Grid.Row="0" Text="{Binding VifPath}" HorizontalAlignment="Stretch" Command="{Binding AddVifFile}"/>
</Grid>
<ContentControl Grid.Row="2" Content="{Binding MultiStageJobViewModel}"/>
</DockPanel>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment