Skip to content

Commit

Permalink
small changes and also binding of elevation property
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Kaiser committed Mar 29, 2023
1 parent 207be0f commit f2c8c7f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 12 deletions.
18 changes: 9 additions & 9 deletions IFCGeoRefCheckerGUI/UpdateGeoRefWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:IFCGeoRefCheckerGUI"
xmlns:vm="clr-namespace:IFCGeoRefCheckerGUI.ViewModels"
xmlns:vc="clr-namespace:IFCGeoRefCheckerGUI.ValueConverters"
mc:Ignorable="d" Icon="/IFCGeorefCheckerGUI;component/images/DD-BIM-ICON.ico"
mc:Ignorable="d"
Title="UpdateGeoRefWindow" Height="600" Width="800"
SizeToContent="Height">
<Window.DataContext>
Expand Down Expand Up @@ -57,8 +57,8 @@
</TextBox.Text>
</TextBox>
<Label Content="Address Lines:" Grid.Row="1" Grid.Column="0"/>
<TextBox Text="{Binding AddressLine1}" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Center"/>
<TextBox Text="{Binding AddressLine2}" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Center"/>
<TextBox Text="{Binding AddressLine1}" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" VerticalAlignment="Center"/>
<TextBox Text="{Binding AddressLine2}" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" VerticalAlignment="Center"/>
<Label Content="Postal Code:" Grid.Row="3" Grid.Column="0"/>
<TextBox Text="{Binding PostalCode}" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"/>
<Label Content="Town:" Grid.Row="3" Grid.Column="2"/>
Expand All @@ -74,7 +74,7 @@
</GroupBox>

<GroupBox Header="Geographic Location of Site" Grid.Row="1" Margin="0,5,0,5">
<TabControl ItemsSource="{Binding Level20s}">
<TabControl ItemsSource="{Binding Level20s}" Margin="0,4,0,4">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="IfcSite"/>
Expand Down Expand Up @@ -114,7 +114,7 @@
<StackPanel Grid.Row="2" Grid.Column="0" Margin="0,5,0,5">
<DockPanel >
<Label Content="RefElevation"/>
<TextBox VerticalAlignment="Center"/>
<TextBox Text="{Binding Elevation}" VerticalAlignment="Center"/>
</DockPanel>
</StackPanel>
</Grid>
Expand Down Expand Up @@ -203,12 +203,12 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Content="Output Path:" Grid.Column="0"/>
<TextBox Grid.Column="1"></TextBox>
<Button Content="Set Path" Grid.Column="2" Margin="5,0,5,0" Padding="5,1,5,1"/>
<Button Content="Start Export" Grid.Column="3" Margin="5,0,5,0" Padding="5,1,5,1"/>
<TextBox Text="{Binding OutIfcPath}" Grid.Column="1" VerticalAlignment="Center" Padding="0,3,0,3"></TextBox>
<Button Content="Set Path" x:Name="setOutBtn" Grid.Column="2" Margin="5,0,5,0" Padding="5,1,5,1" Click="setOutBtn_Click"/>
<Button Content="Start Export" x:Name="exportBtn" Grid.Column="3" Margin="5,0,5,0" Padding="5,1,5,1" Click="exportBtn_Click"/>
</Grid>
</GroupBox>

<Button Content="MyButton" Grid.Row="4" Click="Button_Click" Margin="0,5,0,5"></Button>

</Grid>
</Window>
49 changes: 46 additions & 3 deletions IFCGeoRefCheckerGUI/UpdateGeoRefWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
using IFCGeoRefCheckerGUI.ValueConverters;
using IFCGeoRefCheckerGUI.ViewModels;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -24,10 +27,50 @@ public UpdateGeoRefWindow()
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
private void setOutBtn_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine("hier");
var vm = (UpdateViewModel)DataContext;

var outFileName = System.IO.Path.GetFileName(vm.OutIfcPath);
var defaultDirectory = System.IO.Path.GetDirectoryName(vm.OutIfcPath);

var dialog = new SaveFileDialog
{
Title = "Select location for exported Ifc file",
FileName = outFileName,
InitialDirectory = defaultDirectory,
Filter = "IFC files (*.ifc)|*.ifc|All files (*.*)|*.*"
};

var result = dialog.ShowDialog();

if (result == true)
{
vm.OutIfcPath = dialog.FileName;
}
}

private void exportBtn_Click(object sender, RoutedEventArgs e)
{
var vm = (UpdateViewModel)DataContext;

var selectedPath = vm.OutIfcPath;

if (System.IO.File.Exists(selectedPath))
{
var mbr = MessageBox.Show("File already exists!\nDo you want to overwrite it?", "File already exists!", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (mbr == MessageBoxResult.OK)
{
var inputIsValid = InputValidator.IsValid(this);
if (!inputIsValid)
{
MessageBox.Show("One or more input fields are invalid. Please correct them!", "Validation errors", MessageBoxButton.OK, MessageBoxImage.Exclamation);
return;
}
vm.StartExport!.Execute(null);
this.Close();
}
}
}
}
}

0 comments on commit f2c8c7f

Please sign in to comment.