mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
Remove unused code
- ListBoxItem_OnDrop Event Handler - ItemDropEvent Handler - UpdateItemNumber method
This commit is contained in:
@@ -32,25 +32,9 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
//pnlResult.ItemDropEvent += pnlResult_ItemDropEvent;
|
|
||||||
Closing += MainWindow_Closing;
|
Closing += MainWindow_Closing;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void pnlResult_ItemDropEvent(Result result, IDataObject dropDataObject, DragEventArgs args)
|
|
||||||
//{
|
|
||||||
// PluginPair pluginPair = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ID == result.PluginID);
|
|
||||||
// if (ResultItemDropEvent != null && pluginPair != null)
|
|
||||||
// {
|
|
||||||
// foreach (var delegateHandler in ResultItemDropEvent.GetInvocationList())
|
|
||||||
// {
|
|
||||||
// if (delegateHandler.Target == pluginPair.Plugin)
|
|
||||||
// {
|
|
||||||
// delegateHandler.DynamicInvoke(result, dropDataObject, args);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
void MainWindow_Closing(object sender, CancelEventArgs e)
|
void MainWindow_Closing(object sender, CancelEventArgs e)
|
||||||
{
|
{
|
||||||
UserSettingStorage.Instance.WindowLeft = Left;
|
UserSettingStorage.Instance.WindowLeft = Left;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<ListBox x:Name="lbResults" MaxHeight="{Binding MaxHeight}" SelectedItem="{Binding SelectedResult}"
|
<ListBox x:Name="lbResults" MaxHeight="{Binding MaxHeight}" SelectedItem="{Binding SelectedResult}"
|
||||||
HorizontalContentAlignment="Stretch" ItemsSource="{Binding Results}" Margin="{Binding Margin}"
|
HorizontalContentAlignment="Stretch" ItemsSource="{Binding Results}" Margin="{Binding Margin}"
|
||||||
Style="{DynamicResource BaseListboxStyle}" SelectionChanged="lbResults_SelectionChanged" Focusable="False"
|
Style="{DynamicResource BaseListboxStyle}" SelectionChanged="lbResults_SelectionChanged" Focusable="False"
|
||||||
KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" Drop="ListBoxItem_OnDrop"
|
KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single"
|
||||||
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard">
|
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ namespace Wox
|
|||||||
[Synchronization]
|
[Synchronization]
|
||||||
public partial class ResultPanel : UserControl
|
public partial class ResultPanel : UserControl
|
||||||
{
|
{
|
||||||
public event Action<Result, IDataObject, DragEventArgs> ItemDropEvent;
|
|
||||||
|
|
||||||
public void AddResults(List<Result> newResults, string resultId)
|
public void AddResults(List<Result> newResults, string resultId)
|
||||||
{
|
{
|
||||||
var vm = this.DataContext as ResultPanelViewModel;
|
var vm = this.DataContext as ResultPanelViewModel;
|
||||||
@@ -26,27 +24,6 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void UpdateItemNumber()
|
|
||||||
{
|
|
||||||
//VirtualizingStackPanel virtualizingStackPanel = GetInnerStackPanel(lbResults);
|
|
||||||
//int index = 0;
|
|
||||||
//for (int i = (int)virtualizingStackPanel.VerticalOffset; i <= virtualizingStackPanel.VerticalOffset + virtualizingStackPanel.ViewportHeight; i++)
|
|
||||||
//{
|
|
||||||
// index++;
|
|
||||||
// ListBoxItem item = lbResults.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;
|
|
||||||
// if (item != null)
|
|
||||||
// {
|
|
||||||
// ContentPresenter myContentPresenter = FindVisualChild<ContentPresenter>(item);
|
|
||||||
// if (myContentPresenter != null)
|
|
||||||
// {
|
|
||||||
// DataTemplate dataTemplate = myContentPresenter.ContentTemplate;
|
|
||||||
// TextBlock tbItemNumber = (TextBlock)dataTemplate.FindName("tbItemNumber", myContentPresenter);
|
|
||||||
// tbItemNumber.Text = index.ToString();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResultPanel()
|
public ResultPanel()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -57,26 +34,8 @@ namespace Wox
|
|||||||
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
|
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
|
||||||
{
|
{
|
||||||
lbResults.ScrollIntoView(e.AddedItems[0]);
|
lbResults.ScrollIntoView(e.AddedItems[0]);
|
||||||
//Dispatcher.DelayInvoke("UpdateItemNumber", () =>
|
|
||||||
//{
|
|
||||||
//UpdateItemNumber();
|
|
||||||
//}, TimeSpan.FromMilliseconds(3));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListBoxItem_OnDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
var item = ItemsControl.ContainerFromElement(lbResults, e.OriginalSource as DependencyObject) as ListBoxItem;
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
OnItemDropEvent(item.DataContext as ResultItemViewModel, e.Data, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnItemDropEvent(ResultItemViewModel obj, IDataObject data, DragEventArgs e)
|
|
||||||
{
|
|
||||||
var handler = ItemDropEvent;
|
|
||||||
if (handler != null) handler(obj.RawResult, data, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user