fixed #192
This commit is contained in:
1 parent
d9b94f83fe
commit
7f0330856d
20 files changed
+1159
-52
No files matched your search
@@ -5,6 +5,7 @@ using System.Windows.Controls.Primitives;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools.Extension;
|
||||
using HandyControlDemo.Data;
|
||||
using HandyControlDemo.ViewModel;
|
||||
|
||||
|
||||
namespace HandyControlDemo.UserControl
|
||||
@@ -24,6 +25,7 @@ namespace HandyControlDemo.UserControl
|
||||
if (e.AddedItems.Count == 0) return;
|
||||
if (e.AddedItems[0] is DemoInfoModel demoInfo)
|
||||
{
|
||||
ViewModelLocator.Instance.Main.DemoInfoCurrent = demoInfo;
|
||||
var selectedIndex = demoInfo.SelectedIndex;
|
||||
demoInfo.SelectedIndex = -1;
|
||||
demoInfo.SelectedIndex = selectedIndex;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<Border xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
|
||||
x:Class="HandyControlDemo.UserControl.MainContent"
|
||||
Background="{DynamicResource MainContentBackgroundBrush}">
|
||||
<Border Background="{DynamicResource MainContentForegroundDrawingBrush}">
|
||||
@@ -10,7 +12,25 @@
|
||||
</Grid.RowDefinitions>
|
||||
<Border Name="BorderEffect" Grid.RowSpan="2" Background="{DynamicResource RegionBrush}" CornerRadius="10" Effect="{StaticResource EffectShadow4}"/>
|
||||
<Border Height="32" Name="BorderTitle" Grid.Row="0" CornerRadius="10,10,0,0" Background="{DynamicResource TitleBrush}">
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Foreground="White" Text="{Binding ContentTitle}"/>
|
||||
<hc:SimplePanel>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Foreground="White" Text="{Binding ContentTitle}"/>
|
||||
<ToggleButton Margin="0,0,6,0" IsChecked="{Binding IsOpen,ElementName=DrawerCode}" Padding="5" Foreground="{DynamicResource TextIconBrush}" Style="{StaticResource ToggleButtonIconTransparent}" HorizontalAlignment="Right" hc:IconElement.Geometry="{StaticResource CodeGeometry}"/>
|
||||
<hc:Drawer Name="DrawerCode" Opened="DrawerCode_OnOpened">
|
||||
<Border Style="{StaticResource BorderClip}" Margin="32,32,0,32" CornerRadius="10,0,0,10" Background="{DynamicResource RegionBrush}" Width="800">
|
||||
<TabControl Grid.Row="1" Style="{StaticResource TabControlInLine}">
|
||||
<TabItem Header="XAML">
|
||||
<avalonedit:TextEditor IsReadOnly="True" FontFamily="Consolas" Background="{DynamicResource RegionBrush}" SyntaxHighlighting="XML" Name="EditorXaml" Margin="4" ShowLineNumbers="True"/>
|
||||
</TabItem>
|
||||
<TabItem Header="C#">
|
||||
<avalonedit:TextEditor IsReadOnly="True" FontFamily="Consolas" Background="{DynamicResource RegionBrush}" SyntaxHighlighting="C#" Name="EditorCs" Margin="4" ShowLineNumbers="True"/>
|
||||
</TabItem>
|
||||
<TabItem Header="VM">
|
||||
<avalonedit:TextEditor IsReadOnly="True" FontFamily="Consolas" Background="{DynamicResource RegionBrush}" SyntaxHighlighting="C#" Name="EditorVm" Margin="4" ShowLineNumbers="True"/>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Border>
|
||||
</hc:Drawer>
|
||||
</hc:SimplePanel>
|
||||
</Border>
|
||||
<Border Grid.Row="1" ClipToBounds="True">
|
||||
<ContentPresenter Name="PresenterMain" Margin="0,0,0,10" Content="{Binding SubContent}"/>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using HandyControl.Tools.Extension;
|
||||
using HandyControlDemo.Data;
|
||||
using HandyControlDemo.ViewModel;
|
||||
|
||||
|
||||
namespace HandyControlDemo.UserControl
|
||||
@@ -13,6 +14,8 @@ namespace HandyControlDemo.UserControl
|
||||
{
|
||||
private bool _isFull;
|
||||
|
||||
private string _currentDemoKey;
|
||||
|
||||
public MainContent()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -43,5 +46,25 @@ namespace HandyControlDemo.UserControl
|
||||
PresenterMain.Margin = new Thickness(0, 0, 0, 10);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawerCode_OnOpened(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var typeKey = ViewModelLocator.Instance.Main.DemoInfoCurrent.Key;
|
||||
var demoKey = ViewModelLocator.Instance.Main.DemoItemCurrent.TargetCtlName;
|
||||
if (Equals(_currentDemoKey, demoKey)) return;
|
||||
_currentDemoKey = demoKey;
|
||||
|
||||
if (ViewModelLocator.Instance.Main.SubContent is FrameworkElement demoCtl)
|
||||
{
|
||||
var xamlPath = $"UserControl/{typeKey}/{demoCtl.GetType().Name}.xaml";
|
||||
var dc = demoCtl.DataContext;
|
||||
var dcTypeName = dc.GetType().Name;
|
||||
var vmPath = $"ViewModel/{dcTypeName}";
|
||||
|
||||
EditorXaml.Text = DemoHelper.GetCode(xamlPath);
|
||||
EditorCs.Text = DemoHelper.GetCode($"{xamlPath}.cs");
|
||||
EditorVm.Text = DemoHelper.GetCode($"{vmPath}.cs");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user