style it good
This commit is contained in:
parent
a39096014c
commit
f002cd8de4
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Configuration;
|
using Qrakhen.Qamp.Editor.ViewModel;
|
||||||
|
using System.Configuration;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
|
|
@ -11,7 +12,7 @@ public partial class App : Application
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
{
|
{
|
||||||
MainWindow window = new MainWindow() {
|
MainWindow window = new MainWindow() {
|
||||||
DataContext = new ViewModel.EditorFrameViewModel()
|
DataContext = new MainViewModel()
|
||||||
};
|
};
|
||||||
|
|
||||||
window.Show();
|
window.Show();
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,10 @@ public partial class EditorFrame : UserControl
|
||||||
if (DataContext is EditorFrameViewModel vm) {
|
if (DataContext is EditorFrameViewModel vm) {
|
||||||
vm.MoveCaretCommand.Execute(
|
vm.MoveCaretCommand.Execute(
|
||||||
new MoveCaretOptions(
|
new MoveCaretOptions(
|
||||||
CalculateCursorPosition(e.GetPosition(this), 0, 0),
|
CalculateCursorPosition(
|
||||||
|
e.GetPosition(LineList),
|
||||||
|
ScrollView.VerticalOffset,
|
||||||
|
ScrollView.HorizontalOffset),
|
||||||
false,
|
false,
|
||||||
false));
|
false));
|
||||||
}
|
}
|
||||||
|
|
@ -95,13 +98,13 @@ public partial class EditorFrame : UserControl
|
||||||
private BufferPosition CalculateCursorPosition(Point point, double scrollY, double scrollX)
|
private BufferPosition CalculateCursorPosition(Point point, double scrollY, double scrollX)
|
||||||
{
|
{
|
||||||
var ft = TextHelper.GetText(new string('_', 1), 14, null, VisualTreeHelper.GetDpi(this).PixelsPerDip);
|
var ft = TextHelper.GetText(new string('_', 1), 14, null, VisualTreeHelper.GetDpi(this).PixelsPerDip);
|
||||||
return new BufferPosition((int)(point.Y / TextHelper.LineHeight), (int)((point.X - 2) / ft.Width));
|
return new BufferPosition((int)(point.Y / TextHelper.LineHeight), (int)((point.X - 5) / ft.Width));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point CalculateCaretPosition(int line, int index, double scrollY, double scrollX)
|
private Point CalculateCaretPosition(int line, int index, double scrollY, double scrollX)
|
||||||
{
|
{
|
||||||
var ft = TextHelper.GetText(new string('_', index), 14, null, VisualTreeHelper.GetDpi(this).PixelsPerDip);
|
var ft = TextHelper.GetText(new string('_', index), 14, null, VisualTreeHelper.GetDpi(this).PixelsPerDip);
|
||||||
return new Point(ft.Width + 2, line * TextHelper.LineHeight);
|
return new Point(ft.Width + 5, line * TextHelper.LineHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveCaret(Point point)
|
private void MoveCaret(Point point)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,10 @@
|
||||||
<RowDefinition Height="18" />
|
<RowDefinition Height="18" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid Grid.Row="0"
|
<Grid Grid.Row="0"
|
||||||
Background="#202122">
|
Background="#141516">
|
||||||
<Menu Background="#202122"
|
<Border BorderBrush="#444648"
|
||||||
|
BorderThickness="0,0,0,1">
|
||||||
|
<Menu Background="#141516"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
VerticalContentAlignment="Center"
|
VerticalContentAlignment="Center"
|
||||||
Height="32">
|
Height="32">
|
||||||
|
|
@ -38,43 +40,66 @@
|
||||||
|
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
<Grid Grid.Row="2"
|
||||||
|
Background="#141516">
|
||||||
|
<Border BorderBrush="#444648"
|
||||||
|
BorderThickness="0,1,0,0">
|
||||||
|
<Label Foreground="#80efefef"
|
||||||
|
FontSize="10"
|
||||||
|
Padding="2">Fun & Status</Label>
|
||||||
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Row="1">
|
<Grid Grid.Row="1">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*"
|
||||||
<ColumnDefinition Width="5*" />
|
MinWidth="8" />
|
||||||
|
<ColumnDefinition Width="5*"
|
||||||
|
MinWidth="8" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid Grid.Column="0" Background="#242526">
|
<Grid Grid.Column="0" Background="#1c1d1e">
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
<GridSplitter Grid.Column="0"
|
<GridSplitter Grid.Column="0"
|
||||||
ResizeDirection="Columns"
|
ResizeDirection="Columns"
|
||||||
Width="1"
|
Width="5"
|
||||||
Background="#40fefefe" />
|
BorderBrush="#444648"
|
||||||
|
BorderThickness="1,0,1,0"
|
||||||
|
Margin="0,-1,0,-1"
|
||||||
|
Background="#141516" />
|
||||||
<Grid Grid.Column="1">
|
<Grid Grid.Column="1">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="5*" />
|
<RowDefinition Height="5*"
|
||||||
<RowDefinition Height="*" />
|
MinHeight="8" />
|
||||||
|
<RowDefinition Height="*"
|
||||||
|
MinHeight="8" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid Grid.Row="0">
|
<Grid Grid.Row="0">
|
||||||
<controls:EditorFrame />
|
<controls:EditorFrame DataContext="{Binding EditorFrame}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<GridSplitter Grid.Row="0"
|
<GridSplitter Grid.Row="0"
|
||||||
ResizeDirection="Rows"
|
ResizeDirection="Rows"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
Height="1"
|
Height="5"
|
||||||
Background="#40fefefe" />
|
Margin="-1,0,0,0"
|
||||||
|
BorderBrush="#444648"
|
||||||
|
BorderThickness="0,1,0,1"
|
||||||
|
Background="#141516" />
|
||||||
<Grid Grid.Row="1" Background="#1e1f20">
|
<Grid Grid.Row="1" Background="#1e1f20">
|
||||||
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
|
<TextBlock Background="#202122"
|
||||||
|
Foreground="#32ef64"
|
||||||
|
Padding="4"
|
||||||
|
FontFamily="Consolas">$ ...</TextBlock>
|
||||||
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Row="2"
|
|
||||||
Background="#141516">
|
|
||||||
<Label Foreground="#80efefef"
|
|
||||||
FontSize="10"
|
|
||||||
Padding="2">Fun & Status</Label>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Window.InputBindings>
|
||||||
|
<KeyBinding Key="F5" Command="{Binding RunCommand}" />
|
||||||
|
<KeyBinding Key="S" Modifiers="Ctrl" Command="{Binding SaveCommand}" />
|
||||||
|
</Window.InputBindings>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,35 @@
|
||||||
using System;
|
using Qrakhen.Qamp.Editor.Commands;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Qrakhen.Qamp.Editor.ViewModel;
|
namespace Qrakhen.Qamp.Editor.ViewModel;
|
||||||
|
|
||||||
public class MainViewModel
|
public class MainViewModel
|
||||||
|
{
|
||||||
|
public EditorFrameViewModel EditorFrame { get; set; }
|
||||||
|
|
||||||
|
public ICommand RunCommand { get; set; }
|
||||||
|
public ICommand SaveCommand { get; set; }
|
||||||
|
public ICommand LoadCommand { get; set; }
|
||||||
|
|
||||||
|
public MainViewModel()
|
||||||
|
{
|
||||||
|
EditorFrame = new EditorFrameViewModel();
|
||||||
|
|
||||||
|
RunCommand = new RelayCommand(ExecuteRun, CanRun);
|
||||||
|
SaveCommand = null;
|
||||||
|
LoadCommand = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteRun()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CanRun()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue