-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1049 from osdanova/master
ObjectEditor - UI module
- Loading branch information
Showing
6 changed files
with
175 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<UserControl x:Class="OpenKh.Tools.Kh2ObjectEditor.Modules.UI.M_UI_Control" | ||
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:OpenKh.Tools.Kh2ObjectEditor.Modules.UI" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="5" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Grid Grid.Column="0"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="30" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<Label Grid.Row="0" Background="SlateGray" HorizontalContentAlignment="Center" FontWeight="Bold">FACE</Label> | ||
<Canvas Grid.Row="1"> | ||
<Canvas.ContextMenu> | ||
<ContextMenu> | ||
<MenuItem Header="Export as PNG" Click="Face_Export"/> | ||
<MenuItem Header="Replace texture" Click="Face_Replace"/> | ||
</ContextMenu> | ||
</Canvas.ContextMenu> | ||
<Canvas.Background> | ||
<DrawingBrush TileMode="Tile" Viewport="0,0,32,32" ViewportUnits="Absolute"> | ||
<DrawingBrush.Drawing> | ||
<GeometryDrawing Geometry="M0,0 H16 V16 H32 V32 H16 V16 H0Z" Brush="#80000000"/> | ||
</DrawingBrush.Drawing> | ||
</DrawingBrush> | ||
</Canvas.Background> | ||
<Image Name="FaceFrame" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Top" | ||
Stretch="Uniform"/> | ||
</Canvas> | ||
</Grid> | ||
|
||
|
||
<GridSplitter Grid.Column="1" Background="LightGray" HorizontalAlignment="Center" VerticalAlignment="Stretch" ShowsPreview="True" Width="5"/> | ||
|
||
<Grid Grid.Column="2"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="30" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<Label Grid.Row="0" Background="SlateGray" HorizontalContentAlignment="Center" FontWeight="Bold">COMMAND</Label> | ||
<Canvas Grid.Row="1"> | ||
<Canvas.ContextMenu> | ||
<ContextMenu> | ||
<MenuItem Header="Export as PNG" Click="Command_Export"/> | ||
<MenuItem Header="Replace texture" Click="Command_Replace"/> | ||
</ContextMenu> | ||
</Canvas.ContextMenu> | ||
<Canvas.Background> | ||
<DrawingBrush TileMode="Tile" Viewport="0,0,32,32" ViewportUnits="Absolute"> | ||
<DrawingBrush.Drawing> | ||
<GeometryDrawing Geometry="M0,0 H16 V16 H32 V32 H16 V16 H0Z" Brush="#80000000"/> | ||
</DrawingBrush.Drawing> | ||
</DrawingBrush> | ||
</Canvas.Background> | ||
<Image Name="CommandFrame" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Top" | ||
Stretch="Uniform"/> | ||
</Canvas> | ||
</Grid> | ||
</Grid> | ||
</UserControl> |
72 changes: 72 additions & 0 deletions
72
OpenKh.Tools.Kh2ObjectEditor/Modules/UI/M_UI_Control.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using OpenKh.AssimpUtils; | ||
using OpenKh.Kh2; | ||
using OpenKh.Tools.Common.Wpf; | ||
using OpenKh.Tools.Kh2ObjectEditor.Services; | ||
using OpenKh.Tools.Kh2ObjectEditor.Utils; | ||
using System.IO; | ||
using System.Windows.Controls; | ||
using System.Windows.Media.Imaging; | ||
|
||
namespace OpenKh.Tools.Kh2ObjectEditor.Modules.UI | ||
{ | ||
public partial class M_UI_Control : UserControl | ||
{ | ||
public M_UI_Control() | ||
{ | ||
InitializeComponent(); | ||
loadImages(); | ||
} | ||
|
||
private void loadImages() | ||
{ | ||
if(ApdxService.Instance.ImgdFace != null) | ||
{ | ||
BitmapSource faceBitmap = ApdxService.Instance.ImgdFace.GetBimapSource(); | ||
FaceFrame.Source = faceBitmap; | ||
} | ||
if (ApdxService.Instance.ImgdCommand != null) | ||
{ | ||
BitmapSource commandBitmap = ApdxService.Instance.ImgdCommand.GetBimapSource(); | ||
CommandFrame.Source = commandBitmap; | ||
} | ||
} | ||
|
||
private void Face_Export(object sender, System.Windows.RoutedEventArgs e) | ||
{ | ||
exportImage(ApdxService.Instance.ImgdFace, "Face"); | ||
} | ||
private void Face_Replace(object sender, System.Windows.RoutedEventArgs e) | ||
{ | ||
Imgd loadedImgd = ImageUtils.loadPngFileAsImgd(); | ||
ApdxService.Instance.ImgdFace = loadedImgd; | ||
loadImages(); | ||
} | ||
|
||
private void Command_Export(object sender, System.Windows.RoutedEventArgs e) | ||
{ | ||
exportImage(ApdxService.Instance.ImgdCommand, "Command"); | ||
} | ||
private void Command_Replace(object sender, System.Windows.RoutedEventArgs e) | ||
{ | ||
Imgd loadedImgd = ImageUtils.loadPngFileAsImgd(); | ||
ApdxService.Instance.ImgdCommand = loadedImgd; | ||
loadImages(); | ||
} | ||
|
||
private void exportImage(Imgd image, string imageName) | ||
{ | ||
BitmapSource bitmapImage = image.GetBimapSource(); | ||
|
||
System.Windows.Forms.SaveFileDialog sfd; | ||
sfd = new System.Windows.Forms.SaveFileDialog(); | ||
sfd.Title = "Export image as PNG"; | ||
sfd.FileName = imageName + ".png"; | ||
sfd.ShowDialog(); | ||
if (sfd.FileName != "") | ||
{ | ||
MemoryStream memStream = new MemoryStream(); | ||
AssimpGeneric.ExportBitmapSourceAsPng(bitmapImage, sfd.FileName); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters