add resize
This commit is contained in:
@@ -355,11 +355,28 @@
|
||||
|
||||
<Separator Margin="0,10,0,10" />
|
||||
|
||||
<TextBlock Text="Смещение dX" /> <TextBox x:Name="MoveDx" />
|
||||
<TextBlock Text="Смещение dY" /> <TextBox x:Name="MoveDy" />
|
||||
<TextBlock Text="Смещение dX" />
|
||||
<TextBox x:Name="MoveDx" />
|
||||
<TextBlock Text="Смещение dY" />
|
||||
<TextBox x:Name="MoveDy" />
|
||||
|
||||
<Button Content="Переместить" Margin="0,10,0,0" Click="ClickMoveSelected" />
|
||||
<Button Content="Удалить" Margin="0,10,0,0" Click="ClickDeleteSelected" />
|
||||
<Button Content="Переместить" Margin="0,10,0,0" Click="ClickMoveSelected" />
|
||||
<Button Content="Удалить" Margin="0,10,0,0" Click="ClickDeleteSelected" />
|
||||
|
||||
<Separator />
|
||||
|
||||
<TextBlock Text="Новый размер (W/H)" />
|
||||
<TextBox x:Name="ResizeW" />
|
||||
<TextBox x:Name="ResizeH" />
|
||||
|
||||
<TextBlock
|
||||
Text="Для квадрата/круга W должен равняться H. Для многоугольника меняется bounding box."
|
||||
Foreground="{StaticResource TextBrushHint}"
|
||||
TextWrapping="Wrap"
|
||||
Margin="0,6,0,0"
|
||||
/>
|
||||
|
||||
<Button Content="Изменить размер" Margin="0,10,0,0" Click="ClickResizeSelected" />
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
@@ -304,6 +304,38 @@ namespace Main
|
||||
}
|
||||
}
|
||||
|
||||
private void ClickResizeSelected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var fig = GetSelectedFigureOrThrow();
|
||||
|
||||
if (!TryReadInt(ResizeW.Text, "W", 1, CanvasW, out int newW)) return;
|
||||
if (!TryReadInt(ResizeH.Text, "H", 1, CanvasH, out int newH)) return;
|
||||
|
||||
if (fig is SquareFigure || fig is CircleFigure)
|
||||
{
|
||||
if (newW != newH)
|
||||
{
|
||||
MessageBox.Show("Для квадрата/круга W должен быть равен H.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fig.ResizeToChecked(newW, newH))
|
||||
{
|
||||
MessageBox.Show("Фигура не помещается в область рисования.");
|
||||
return;
|
||||
}
|
||||
|
||||
Redraw();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Reference in New Issue
Block a user