添加项目
This commit is contained in:
@@ -28,6 +28,25 @@ public static class OptionsBarAssist
|
||||
}
|
||||
}
|
||||
|
||||
public static TViewModel SetupOptionsBar<TPanel, TViewModel>()
|
||||
where TViewModel : ObservableObject, new() where TPanel : Panel, new()
|
||||
{
|
||||
CloseOptionsBar();
|
||||
var options = new TViewModel();
|
||||
var view = new TPanel();
|
||||
view.DataContext = options;
|
||||
ShowOptionsBar(view);
|
||||
return options;
|
||||
}
|
||||
public static void ShowInternalToolPanel()
|
||||
{
|
||||
if (InternalToolPanel is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
InternalToolPanel.Visibility = Visibility.Visible;
|
||||
InternalToolPanel.Height = 26;
|
||||
}
|
||||
public static void ShowOptionsBar(FrameworkElement content)
|
||||
{
|
||||
if (_panelPresenter is not null)
|
||||
@@ -41,19 +60,21 @@ public static class OptionsBarAssist
|
||||
// actuallWidth += child.ActualWidth;
|
||||
//}
|
||||
_panelPresenter.Content = content;
|
||||
_panelPresenter.Visibility = System.Windows.Visibility.Visible;
|
||||
_panelPresenter.Visibility = Visibility.Visible;
|
||||
//设为0,隐藏内部的Panel
|
||||
//InternalToolPanel.Height = 0;
|
||||
InternalToolPanel.Height = 0;
|
||||
return;
|
||||
}
|
||||
//第一次执行时,会创建
|
||||
_panelPresenter = CreateOptionsBar();
|
||||
_panelPresenter.Content = content;
|
||||
|
||||
//InternalToolPanel.Height = 0;
|
||||
InternalToolPanel.Height = 0;
|
||||
}
|
||||
|
||||
public static void HideOptionsBar()
|
||||
/// <summary>
|
||||
/// 关闭、释放
|
||||
/// </summary>
|
||||
public static void CloseOptionsBar()
|
||||
{
|
||||
if (_panelPresenter is null)
|
||||
{
|
||||
@@ -61,15 +82,51 @@ public static class OptionsBarAssist
|
||||
}
|
||||
|
||||
_panelPresenter.Content = null;
|
||||
_panelPresenter.Visibility = System.Windows.Visibility.Collapsed;
|
||||
_panelPresenter.Visibility = Visibility.Collapsed;
|
||||
|
||||
InternalToolPanel.Height = 26;
|
||||
}
|
||||
/// <summary>
|
||||
/// 隐藏
|
||||
/// </summary>
|
||||
public static void HideOptionsBar()
|
||||
{
|
||||
if (_panelPresenter is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public static async void HideOptionsBar(TimeSpan delay)
|
||||
//_panelPresenter.Content = null;
|
||||
_panelPresenter.Visibility = Visibility.Collapsed;
|
||||
|
||||
InternalToolPanel.Height = 26;
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示
|
||||
/// </summary>
|
||||
public static void ShowOptionsBar()
|
||||
{
|
||||
if (_panelPresenter is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//_panelPresenter.Content = null;
|
||||
_panelPresenter.Visibility = Visibility.Visible;
|
||||
|
||||
InternalToolPanel.Height = 0;
|
||||
}
|
||||
public static async void CloseOptionsBarAsync(TimeSpan delay)
|
||||
{
|
||||
await Task.Delay(delay);
|
||||
HideOptionsBar();
|
||||
try
|
||||
{
|
||||
CloseOptionsBar();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static ContentPresenter CreateOptionsBar()
|
||||
@@ -117,9 +174,9 @@ public static class OptionsBarAssist
|
||||
action(view, viewModel);
|
||||
ShowOptionsBar(view);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user