Browse Source

Fixed importer wrong size

flabbet 5 years ago
parent
commit
81bd1ba686

BIN
PixiEditor/Images/PixiEditorLogo.png


+ 2 - 2
PixiEditor/ViewModels/ImportFilePopupViewModel.cs

@@ -108,8 +108,8 @@ namespace PixiEditor.ViewModels
                 PathIsCorrect = true;
                 _filePath = path;
                 BitmapImage bitmap = new BitmapImage(new Uri(path));
-                ImportHeight = (int)bitmap.Height;
-                ImportWidth = (int)bitmap.Width;
+                ImportHeight = bitmap.PixelHeight;
+                ImportWidth = bitmap.PixelWidth;
             }
         }
 

+ 8 - 8
PixiEditor/ViewModels/ViewModelMain.cs

@@ -112,9 +112,9 @@ namespace PixiEditor.ViewModels
 
         private ToolType _selectedTool;
 
-        public ToolType SelectedTool
+        public ToolType SelectedTool
         {
-            get { return _selectedTool; }
+            get => _selectedTool;
             set
             {
                 if (_selectedTool != value)
@@ -132,7 +132,7 @@ namespace PixiEditor.ViewModels
 
         public LayerChange[] UndoChanges
         {
-            get { return _undoChanges; }
+            get => _undoChanges;
             set
             {
                 _undoChanges = value;
@@ -148,7 +148,7 @@ namespace PixiEditor.ViewModels
 
         public Cursor ToolCursor
         {
-            get { return _toolCursor; }
+            get => _toolCursor;
             set
             {
                 _toolCursor = value;
@@ -260,7 +260,7 @@ namespace PixiEditor.ViewModels
         {
             if (!(property is CancelEventArgs)) throw new ArgumentException();
 
-            (property as CancelEventArgs).Cancel = true;
+            ((CancelEventArgs) property).Cancel = true;
 
             ConfirmationType result = ConfirmationType.No;
             if (_unsavedDocumentModified)
@@ -273,7 +273,7 @@ namespace PixiEditor.ViewModels
             }
             if (result != ConfirmationType.Canceled)
             {
-                (property as CancelEventArgs).Cancel = false;
+                ((CancelEventArgs) property).Cancel = false;
             }
 
         }
@@ -714,8 +714,8 @@ namespace PixiEditor.ViewModels
         {
             ImportFileDialog dialog = new ImportFileDialog();
 
-            if (path != null && File.Exists(path.ToString()))
-                dialog.FilePath = path.ToString();
+            if (path != null && File.Exists(path))
+                dialog.FilePath = path;
 
             if (dialog.ShowDialog())
             {

+ 1 - 1
PixiEditor/Views/ImportFilePopup.xaml

@@ -33,7 +33,7 @@
             <Label Height="40" Width="120" VerticalAlignment="Top" Content="Open" Foreground="Snow" HorizontalContentAlignment="Center" FontSize="24" Margin="0,10,0,0"/>
                 <Button Grid.Row="1" BorderThickness="1" Foreground="Snow" Height="40" Width="160" Margin="0,30,0,0" Content="File Path" Background="#303030" BorderBrush="{Binding PathButtonBorder}" Command="{Binding ChoosePathCommand}"/>
                 <StackPanel Background="{StaticResource MainColor}" Height="120" Width="225" Margin="0,30,0,0">
-                    <local:SizePicker EditingEnabled="{Binding PathIsCorrect}" ChoosenWidth="{Binding ImportWidth, Mode=TwoWay}" ChoosenHeight="{Binding ImportHeight,Mode=TwoWay}"/>
+                    <local:SizePicker EditingEnabled="{Binding PathIsCorrect}" ChosenWidth="{Binding ImportWidth, Mode=TwoWay}" ChoosenHeight="{Binding ImportHeight,Mode=TwoWay}"/>
                 </StackPanel>
         </StackPanel>
         <Button Grid.Row="1" Height="30" Width="60" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="10" Style="{StaticResource DarkRoundButton}" Content="OK" Command="{Binding OkCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>

+ 1 - 1
PixiEditor/Views/NewFilePopup.xaml

@@ -32,7 +32,7 @@
             <Label Content="New File" Grid.Row="1" Margin="0,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="White" FontSize="24"/>
             <StackPanel HorizontalAlignment="Center" Margin="0,60,0,0" Background="{StaticResource MainColor}" VerticalAlignment="Top" Grid.Row="1" Width="350" Height="150">
                 <local:SizePicker Margin="0,20" HorizontalAlignment="Center" Height="110" ChoosenHeight="{Binding FileHeight,Mode=TwoWay, ElementName=newFilePopup}"
-                                  ChoosenWidth="{Binding FileWidth,Mode=TwoWay, ElementName=newFilePopup}"/>
+                                  ChosenWidth="{Binding FileWidth,Mode=TwoWay, ElementName=newFilePopup}"/>
             </StackPanel>
             <Button VerticalAlignment="Bottom" HorizontalAlignment="Right" FontSize="20" Height="30" Width="60" 
                     Style="{StaticResource DarkRoundButton}" Content="OK" Margin="0,0,10,10" Grid.Row="1" 

+ 1 - 1
PixiEditor/Views/ResizeCanvasPopup.xaml

@@ -34,7 +34,7 @@
         </DockPanel>
         <Label Grid.Row="1" VerticalAlignment="Top" Foreground="White" FontSize="24" HorizontalAlignment="Center" Content="Resize Canvas"/>
         <StackPanel HorizontalAlignment="Center" Margin="0,50,0,0" Background="{StaticResource MainColor}" VerticalAlignment="Top" Grid.Row="1" Width="300" Height="250">
-            <local:SizePicker Margin="0,10,0,0" Width="300" Height="110" ChoosenHeight="{Binding NewHeight, Mode=TwoWay, ElementName=window}" ChoosenWidth="{Binding NewWidth, Mode=TwoWay, ElementName=window}"/>
+            <local:SizePicker Margin="0,10,0,0" Width="300" Height="110" ChoosenHeight="{Binding NewHeight, Mode=TwoWay, ElementName=window}" ChosenWidth="{Binding NewWidth, Mode=TwoWay, ElementName=window}"/>
             <Separator Margin="10,20,10,0" Background="{StaticResource AccentColor}" Height="1"/>
             <Label Content="Anchor point:" Foreground="White" Margin="10,5,0,0" HorizontalAlignment="Left" FontSize="16"/>
             <local:AnchorPointPicker AnchorPoint="{Binding Path=SelectedAnchorPoint, Mode=TwoWay, ElementName=window}" Width="78" Margin="45,-25,0,0" Height="78"/>

+ 1 - 1
PixiEditor/Views/ResizeDocumentPopup.xaml

@@ -33,7 +33,7 @@
         <Label Grid.Row="1" VerticalAlignment="Top" Foreground="White" FontSize="24" HorizontalAlignment="Center" Content="Resize document"/>
         <StackPanel HorizontalAlignment="Center" Margin="0,50,0,0" Background="{StaticResource MainColor}" VerticalAlignment="Top" Grid.Row="1" Width="350" Height="150">
             <local:SizePicker Margin="0,20" ChoosenHeight="{Binding Path=NewHeight, Mode=TwoWay, ElementName=window}"
-                              ChoosenWidth="{Binding Path=NewWidth, Mode=TwoWay, ElementName=window}"/>
+                              ChosenWidth="{Binding Path=NewWidth, Mode=TwoWay, ElementName=window}"/>
         </StackPanel>
         <Button Grid.Row="1" Height="30" Width="60" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="10" Style="{StaticResource DarkRoundButton}" Content="OK" Click="Button_Click"/>
     </Grid>

+ 3 - 6
PixiEditor/Views/SaveFilePopup.xaml

@@ -15,7 +15,7 @@
     <Border BorderBrush="Black" BorderThickness="1">
         <Grid Background="{StaticResource AccentColor}">
         <Grid.RowDefinitions>
-            <RowDefinition Height="20*"/>
+            <RowDefinition Height="32"/>
             <RowDefinition Height="229*"/>
         </Grid.RowDefinitions>
         <Grid Grid.Row="0" Background="{StaticResource MainColor}">
@@ -24,17 +24,14 @@
                     <i:InvokeCommandAction Command="{Binding DragMoveCommand}"/>
                 </i:EventTrigger>
             </i:Interaction.Triggers>
-            <Button Width="20" Height="20" Style="{StaticResource ImageButtonStyle}" Cursor="Hand" VerticalAlignment="Top" HorizontalAlignment="Right" BorderThickness="0" 
+            <Button Style="{StaticResource CloseButtonStyle}" VerticalAlignment="Top" HorizontalAlignment="Right" BorderThickness="0" 
                     Command="{Binding CloseButtonCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
-                <Button.Background>
-                    <ImageBrush ImageSource="/Images/Cross.png" Stretch="Uniform"/>
-                </Button.Background>
             </Button>
         </Grid>
         <TextBlock Grid.Row="1"  Foreground="Snow" VerticalAlignment="Top" HorizontalAlignment="Center" Text="File settings" TextAlignment="Center" Margin="0,10,0,0" FontSize="24"/>
             <StackPanel Orientation="Vertical" Grid.Row="1" Margin="0,50,0,0">
             <local:SizePicker  Width="250" Height="120" ChoosenHeight="{Binding Path=SaveHeight, Mode=TwoWay, ElementName=saveFilePopup}"
-                               ChoosenWidth="{Binding Path=SaveWidth, Mode=TwoWay, ElementName=saveFilePopup}"/>
+                               ChosenWidth="{Binding Path=SaveWidth, Mode=TwoWay, ElementName=saveFilePopup}"/>
             <Button Foreground="Snow" Height="40" Width="160" Margin="0,10,0,0" Content="Path" Background="{StaticResource MainColor}" BorderBrush="{Binding PathButtonBorder}" Command="{Binding ChoosePathCommand}"/>
             </StackPanel>
             <Button Grid.Row="1" Height="30" Width="60" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="10" Style="{StaticResource DarkRoundButton}" Content="OK" Command="{Binding OkCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>

+ 6 - 6
PixiEditor/Views/SizeInput.xaml.cs

@@ -31,8 +31,8 @@ namespace PixiEditor.Views
 
         public int Size
         {
-            get { return (int)GetValue(SizeProperty); }
-            set { SetValue(SizeProperty, value); }
+            get => (int)GetValue(SizeProperty);
+            set => SetValue(SizeProperty, value);
         }
 
         // Using a DependencyProperty as the backing store for Size.  This enables animation, styling, binding, etc...
@@ -41,8 +41,8 @@ namespace PixiEditor.Views
 
         public bool PreserveAspectRatio
         {
-            get { return (bool)GetValue(PreserveAspectRatioProperty); }
-            set { SetValue(PreserveAspectRatioProperty, value); }
+            get => (bool)GetValue(PreserveAspectRatioProperty);
+            set => SetValue(PreserveAspectRatioProperty, value);
         }
 
         // Using a DependencyProperty as the backing store for PreserveAspectRatio.  This enables animation, styling, binding, etc...
@@ -52,8 +52,8 @@ namespace PixiEditor.Views
 
         public int AspectRatioValue
         {
-            get { return (int)GetValue(AspectRatioValueProperty); }
-            set { SetValue(AspectRatioValueProperty, value); }
+            get => (int)GetValue(AspectRatioValueProperty);
+            set => SetValue(AspectRatioValueProperty, value);
         }
 
         // Using a DependencyProperty as the backing store for AspectRatioValue.  This enables animation, styling, binding, etc...

+ 2 - 2
PixiEditor/Views/SizePicker.xaml

@@ -9,14 +9,14 @@
     <StackPanel Background="{StaticResource MainColor}">
         <DockPanel Margin="5,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
             <TextBlock Height="30" Foreground="Snow" Text="Height:" TextAlignment="Center" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-            <local:SizeInput IsEnabled="{Binding EditingEnabled, ElementName=uc}" Margin="5,0,0,0" PreserveAspectRatio="{Binding Path=IsChecked, ElementName=aspectRatio}" AspectRatioValue="{Binding Path=ChoosenWidth, ElementName=uc}" 
+            <local:SizeInput IsEnabled="{Binding EditingEnabled, ElementName=uc}" Margin="5,0,0,0" PreserveAspectRatio="{Binding Path=IsChecked, ElementName=aspectRatio}" AspectRatioValue="{Binding Path=ChosenWidth, ElementName=uc}" 
                              HorizontalAlignment="Left" Width="150" Height="30" 
                              Size="{Binding ChoosenHeight, ElementName=uc, Mode=TwoWay}"/>
         </DockPanel>
         <DockPanel Margin="5,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
             <TextBlock Height="30" Foreground="Snow" Text="Width:" TextAlignment="Center" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
             <local:SizeInput IsEnabled="{Binding EditingEnabled, ElementName=uc}" Width="150" Height="30" PreserveAspectRatio="{Binding Path=IsChecked, ElementName=aspectRatio}" AspectRatioValue="{Binding Path=ChoosenHeight, ElementName=uc}"
-                                 HorizontalAlignment="Left" Margin="10,0,0,0" Size="{Binding Path=ChoosenWidth, ElementName=uc, Mode=TwoWay}"/>
+                                 HorizontalAlignment="Left" Margin="10,0,0,0" Size="{Binding Path=ChosenWidth, ElementName=uc, Mode=TwoWay}"/>
         </DockPanel>
         <CheckBox Name="aspectRatio" Content="Preserve aspect ratio" Foreground="White" HorizontalAlignment="Left" IsChecked="True" Margin="50,10,0,0"/>
     </StackPanel>

+ 10 - 10
PixiEditor/Views/SizePicker.xaml.cs

@@ -26,8 +26,8 @@ namespace PixiEditor.Views
 
         public bool EditingEnabled
         {
-            get { return (bool)GetValue(EditingEnabledProperty); }
-            set { SetValue(EditingEnabledProperty, value); }
+            get => (bool)GetValue(EditingEnabledProperty);
+            set => SetValue(EditingEnabledProperty, value);
         }
 
         // Using a DependencyProperty as the backing store for EditingEnabled.  This enables animation, styling, binding, etc...
@@ -36,22 +36,22 @@ namespace PixiEditor.Views
 
 
 
-        public int ChoosenWidth
+        public int ChosenWidth
         {
-            get { return (int)GetValue(ChoosenWidthProperty); }
-            set { SetValue(ChoosenWidthProperty, value); }
+            get => (int)GetValue(ChosenWidthProperty);
+            set => SetValue(ChosenWidthProperty, value);
         }
 
-        // Using a DependencyProperty as the backing store for ChoosenWidth.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty ChoosenWidthProperty =
-            DependencyProperty.Register("ChoosenWidth", typeof(int), typeof(SizePicker), new PropertyMetadata(1));
+        // Using a DependencyProperty as the backing store for ChosenWidth.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty ChosenWidthProperty =
+            DependencyProperty.Register("ChosenWidth", typeof(int), typeof(SizePicker), new PropertyMetadata(1));
 
 
 
         public int ChoosenHeight
         {
-            get { return (int)GetValue(ChoosenHeightProperty); }
-            set { SetValue(ChoosenHeightProperty, value); }
+            get => (int)GetValue(ChoosenHeightProperty);
+            set => SetValue(ChoosenHeightProperty, value);
         }
 
         // Using a DependencyProperty as the backing store for ChoosenHeight.  This enables animation, styling, binding, etc...