chore: add Shortcut for demo.
This commit is contained in:
1 parent
d787654486
commit
c07ad3f801
3 files changed
+29
-42
No files matched your search
@@ -27,7 +27,9 @@ public partial class MainWindow
|
|||||||
GlobalShortcut.Init(new List<KeyBinding>
|
GlobalShortcut.Init(new List<KeyBinding>
|
||||||
{
|
{
|
||||||
new(ViewModelLocator.Instance.Main.GlobalShortcutInfoCmd, Key.I, ModifierKeys.Control | ModifierKeys.Alt),
|
new(ViewModelLocator.Instance.Main.GlobalShortcutInfoCmd, Key.I, ModifierKeys.Control | ModifierKeys.Alt),
|
||||||
new(ViewModelLocator.Instance.Main.GlobalShortcutWarningCmd, Key.E, ModifierKeys.Control | ModifierKeys.Alt)
|
new(ViewModelLocator.Instance.Main.GlobalShortcutWarningCmd, Key.E, ModifierKeys.Control | ModifierKeys.Alt),
|
||||||
|
new(ViewModelLocator.Instance.Main.OpenDocCmd, Key.F1, ModifierKeys.None),
|
||||||
|
new(ViewModelLocator.Instance.Main.OpenCodeCmd, Key.F12, ModifierKeys.None)
|
||||||
});
|
});
|
||||||
|
|
||||||
Dialog.SetToken(this, MessageToken.MainWindow);
|
Dialog.SetToken(this, MessageToken.MainWindow);
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
<hc:SimplePanel>
|
<hc:SimplePanel>
|
||||||
<hc:Watermark Mark="{Binding ContentTitle}" MarkMargin="3,0" FontSize="20" FontWeight="Bold" MarkBrush="#0F000000"/>
|
<hc:Watermark Mark="{Binding ContentTitle}" MarkMargin="3,0" FontSize="20" FontWeight="Bold" MarkBrush="#0F000000"/>
|
||||||
<TextBlock Style="{StaticResource TextBlockDefault}" Foreground="White" Text="{Binding ContentTitle}"/>
|
<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}"/>
|
<ToggleButton Margin="0,0,6,0" IsChecked="{Binding IsCodeOpening}" Padding="5" Foreground="{DynamicResource TextIconBrush}" Style="{StaticResource ToggleButtonIconTransparent}" HorizontalAlignment="Right" hc:IconElement.Geometry="{StaticResource CodeGeometry}"/>
|
||||||
<Button Command="{Binding OpenDocCmd}" Height="26" Width="30" Margin="6,0,0,0" Padding="5" Foreground="{DynamicResource TextIconBrush}" Style="{StaticResource ButtonIcon}" HorizontalAlignment="Left" hc:IconElement.Geometry="{StaticResource DocumentGeometry}"/>
|
<Button Command="{Binding OpenDocCmd}" Height="26" Width="30" Margin="6,0,0,0" Padding="5" Foreground="{DynamicResource TextIconBrush}" Style="{StaticResource ButtonIcon}" HorizontalAlignment="Left" hc:IconElement.Geometry="{StaticResource DocumentGeometry}"/>
|
||||||
<hc:Drawer Name="DrawerCode" Opened="DrawerCode_OnOpened">
|
<hc:Drawer Name="DrawerCode" Opened="DrawerCode_OnOpened" IsOpen="{Binding IsCodeOpening}">
|
||||||
<Border Style="{StaticResource BorderClip}" Margin="32,32,0,32" CornerRadius="10,0,0,10" Background="{DynamicResource RegionBrush}" Width="800" Name="BorderCode"/>
|
<Border Style="{StaticResource BorderClip}" Margin="32,32,0,32" CornerRadius="10,0,0,10" Background="{DynamicResource RegionBrush}" Width="800" Name="BorderCode"/>
|
||||||
</hc:Drawer>
|
</hc:Drawer>
|
||||||
</hc:SimplePanel>
|
</hc:SimplePanel>
|
||||||
|
|||||||
@@ -18,22 +18,12 @@ namespace HandyControlDemo.ViewModel;
|
|||||||
|
|
||||||
public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
||||||
{
|
{
|
||||||
#region 字段
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 内容标题
|
|
||||||
/// </summary>
|
|
||||||
private object _contentTitle;
|
private object _contentTitle;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 子内容
|
|
||||||
/// </summary>
|
|
||||||
private object _subContent;
|
private object _subContent;
|
||||||
|
private bool _isCodeOpened;
|
||||||
|
|
||||||
private readonly DataService _dataService;
|
private readonly DataService _dataService;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public MainViewModel(DataService dataService)
|
public MainViewModel(DataService dataService)
|
||||||
{
|
{
|
||||||
_dataService = dataService;
|
_dataService = dataService;
|
||||||
@@ -42,18 +32,10 @@ public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
|||||||
UpdateLeftContent();
|
UpdateLeftContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 属性
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 当前选中的demo项
|
|
||||||
/// </summary>
|
|
||||||
public DemoItemModel DemoItemCurrent { get; private set; }
|
public DemoItemModel DemoItemCurrent { get; private set; }
|
||||||
|
|
||||||
public DemoInfoModel DemoInfoCurrent { get; set; }
|
public DemoInfoModel DemoInfoCurrent { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 子内容
|
|
||||||
/// </summary>
|
|
||||||
public object SubContent
|
public object SubContent
|
||||||
{
|
{
|
||||||
get => _subContent;
|
get => _subContent;
|
||||||
@@ -64,9 +46,6 @@ public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 内容标题
|
|
||||||
/// </summary>
|
|
||||||
public object ContentTitle
|
public object ContentTitle
|
||||||
{
|
{
|
||||||
get => _contentTitle;
|
get => _contentTitle;
|
||||||
@@ -77,18 +56,18 @@ public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public bool IsCodeOpened
|
||||||
/// demo信息
|
{
|
||||||
/// </summary>
|
get => _isCodeOpened;
|
||||||
|
#if NET40
|
||||||
|
set => Set(nameof(IsCodeOpened), ref _isCodeOpened, value);
|
||||||
|
#else
|
||||||
|
set => Set(ref _isCodeOpened, value);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
public ObservableCollection<DemoInfoModel> DemoInfoCollection { get; set; }
|
public ObservableCollection<DemoInfoModel> DemoInfoCollection { get; set; }
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 命令
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 切换例子命令
|
|
||||||
/// </summary>
|
|
||||||
public RelayCommand<SelectionChangedEventArgs> SwitchDemoCmd => new(SwitchDemo);
|
public RelayCommand<SelectionChangedEventArgs> SwitchDemoCmd => new(SwitchDemo);
|
||||||
|
|
||||||
public RelayCommand OpenPracticalDemoCmd => new(OpenPracticalDemo);
|
public RelayCommand OpenPracticalDemoCmd => new(OpenPracticalDemo);
|
||||||
@@ -99,12 +78,23 @@ public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
|||||||
|
|
||||||
public RelayCommand OpenDocCmd => new(() =>
|
public RelayCommand OpenDocCmd => new(() =>
|
||||||
{
|
{
|
||||||
|
if (DemoItemCurrent is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ControlCommands.OpenLink.Execute(_dataService.GetDemoUrl(DemoInfoCurrent, DemoItemCurrent));
|
ControlCommands.OpenLink.Execute(_dataService.GetDemoUrl(DemoInfoCurrent, DemoItemCurrent));
|
||||||
});
|
});
|
||||||
|
|
||||||
#endregion
|
public RelayCommand OpenCodeCmd => new(() =>
|
||||||
|
{
|
||||||
|
if (DemoItemCurrent is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#region 方法
|
IsCodeOpened = !IsCodeOpened;
|
||||||
|
});
|
||||||
|
|
||||||
private void UpdateMainContent()
|
private void UpdateMainContent()
|
||||||
{
|
{
|
||||||
@@ -156,9 +146,6 @@ public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 切换例子
|
|
||||||
/// </summary>
|
|
||||||
private void SwitchDemo(SelectionChangedEventArgs e)
|
private void SwitchDemo(SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.AddedItems.Count == 0) return;
|
if (e.AddedItems.Count == 0) return;
|
||||||
@@ -185,6 +172,4 @@ public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
|||||||
Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{MessageToken.PracticalDemo}"), MessageToken.LoadShowContent);
|
Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{MessageToken.PracticalDemo}"), MessageToken.LoadShowContent);
|
||||||
Messenger.Default.Send(true, MessageToken.FullSwitch);
|
Messenger.Default.Send(true, MessageToken.FullSwitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user