|
@@ -44,7 +44,7 @@ namespace PDF_Master.Views.BOTA
|
|
|
/// </summary>
|
|
|
public partial class AnnotationContent : UserControl
|
|
|
{
|
|
|
- private AnnotationContentViewModel viewModel;
|
|
|
+ public AnnotationContentViewModel viewModel;
|
|
|
|
|
|
private string unicode;
|
|
|
|
|
@@ -62,105 +62,138 @@ namespace PDF_Master.Views.BOTA
|
|
|
eventAggregator.GetEvent<RefreshAnnotationEvent>().Subscribe(ExpandGroupHeader, e => e.Unicode == unicode);
|
|
|
}
|
|
|
|
|
|
- private async void ExpandGroupHeader(RefreshAnnotationArgs obj)
|
|
|
+ public async void ExpandGroupHeader(RefreshAnnotationArgs obj)
|
|
|
{
|
|
|
if (obj.IsAll)
|
|
|
{
|
|
|
- try
|
|
|
+ ExpandAllGroupHeader(obj);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //需要时间加载完 listbox所有的控件模板
|
|
|
+ await Task.Delay(500);
|
|
|
+ ExpandOneGroupHeader(obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private async void ExpandAllGroupHeader(RefreshAnnotationArgs obj)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ foreach (var item in AnnotationList.Items)
|
|
|
{
|
|
|
- foreach (var item in AnnotationList.Items)
|
|
|
+ var groups = AnnotationList.Items.Groups;
|
|
|
+
|
|
|
+ for (int i = 0; i < groups.Count; i++)
|
|
|
{
|
|
|
- var groups = AnnotationList.Items.Groups;
|
|
|
- for (int i = 0; i < groups.Count; i++)
|
|
|
+ if (groups[i] is CollectionViewGroup group)
|
|
|
{
|
|
|
- var group = groups[i] as CollectionViewGroup;
|
|
|
if (group.Items.Contains(item))
|
|
|
{
|
|
|
- await Task.Delay(2);
|
|
|
+ await Task.Delay(5);
|
|
|
var scroller = GetScrollHost(AnnotationList);
|
|
|
var stackpanel = CommonHelper.FindVisualChild<StackPanel>(scroller);
|
|
|
- var groupItem = VisualTreeHelper.GetChild(stackpanel, i) as GroupItem;
|
|
|
- var g = CommonHelper.FindVisualChild<Expander>(groupItem);
|
|
|
- if (g != null)
|
|
|
- {
|
|
|
- g.IsExpanded = true;
|
|
|
- }
|
|
|
- else
|
|
|
+ if (stackpanel != null)
|
|
|
{
|
|
|
- await Task.Delay(5);
|
|
|
- g = CommonHelper.FindVisualChild<Expander>(groupItem);
|
|
|
- if (g != null)
|
|
|
- {
|
|
|
- g.IsExpanded = true;
|
|
|
- }
|
|
|
+ GroupItemExpanded(stackpanel, i);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- catch { }
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception ex) { }
|
|
|
+ }
|
|
|
+
|
|
|
+ public async void ExpandOneGroupHeader(RefreshAnnotationArgs obj)
|
|
|
+ {
|
|
|
+ if (obj.annotHandlerArgs == null)
|
|
|
{
|
|
|
- if (obj.annotHandlerArgs != null)
|
|
|
+ if (obj.Pageindex != -1 && obj.AnnotIndex != -1)
|
|
|
{
|
|
|
- try
|
|
|
+ List<AnnotationHandlerEventArgs> annotations = AnnotationList.Items.Cast<AnnotationHandlerEventArgs>().ToList();
|
|
|
+ obj.annotHandlerArgs = annotations.FirstOrDefault(x => x.PageIndex == obj.Pageindex && x.AnnotIndex == obj.AnnotIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.annotHandlerArgs != null)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var groups = AnnotationList.Items.Groups;
|
|
|
+ if (groups != null && groups.Count > 0)
|
|
|
{
|
|
|
- var groups = AnnotationList.Items.Groups;
|
|
|
- if (groups != null && groups.Count > 0)
|
|
|
+ for (int i = 0; i < groups.Count; i++)
|
|
|
{
|
|
|
- for (int i = 0; i < groups.Count; i++)
|
|
|
+ if (groups[i] is CollectionViewGroup group)
|
|
|
{
|
|
|
- var l = groups[i] as CollectionViewGroup;
|
|
|
- if (l.Items.Contains(obj.annotHandlerArgs))
|
|
|
+ if (group.Items.Contains(obj.annotHandlerArgs))
|
|
|
{
|
|
|
- await Task.Delay(5);
|
|
|
var scroller = GetScrollHost(AnnotationList);
|
|
|
var stackpanel = CommonHelper.FindVisualChild<StackPanel>(scroller);
|
|
|
- var groupItem = VisualTreeHelper.GetChild(stackpanel, i) as GroupItem;
|
|
|
- if (groupItem != null)
|
|
|
+ if (stackpanel != null)
|
|
|
{
|
|
|
- var g = CommonHelper.FindVisualChild<Expander>(groupItem);
|
|
|
- if (g != null)
|
|
|
- {
|
|
|
- g.IsExpanded = true;
|
|
|
- }
|
|
|
- else
|
|
|
+ GroupItemExpanded(stackpanel, i);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ItemsPresenter itemsPresenter = CommonHelper.FindVisualChild<ItemsPresenter>(scroller);
|
|
|
+ if (itemsPresenter != null)
|
|
|
{
|
|
|
- await Task.Delay(5);
|
|
|
- g = CommonHelper.FindVisualChild<Expander>(groupItem);
|
|
|
- if (g != null)
|
|
|
- {
|
|
|
- g.IsExpanded = true;
|
|
|
- }
|
|
|
+ var tt = VisualTreeHelper.GetChild(itemsPresenter, i);
|
|
|
+ int count = VisualTreeHelper.GetChildrenCount(tt);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (obj.IsSelect && obj.annotHandlerArgs != null)
|
|
|
- {
|
|
|
- if (viewModel.ViewContentViewModel.IsMultiSelected == false)
|
|
|
- {
|
|
|
- if (AnnotationList.SelectedItems.IndexOf(obj.annotHandlerArgs) == -1)
|
|
|
- {
|
|
|
- viewModel.IsModified = false;
|
|
|
- AnnotationList.SelectedItem = obj.annotHandlerArgs;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (obj.IsDel)
|
|
|
+ if (obj.IsDel)
|
|
|
+ {
|
|
|
+ viewModel.IsModified = true;
|
|
|
+ }
|
|
|
+ await Task.Delay(10);//不加延时 会有不滚动的现象
|
|
|
+ SelectedItems(obj);
|
|
|
+ }
|
|
|
+ catch (Exception ex) { }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void GroupItemExpanded(StackPanel stackpanel, int i)
|
|
|
+ {
|
|
|
+ int count = VisualTreeHelper.GetChildrenCount(stackpanel);
|
|
|
+ if (count > 0)
|
|
|
+ {
|
|
|
+ if (VisualTreeHelper.GetChild(stackpanel, i) is GroupItem groupItem)
|
|
|
+ {
|
|
|
+ var expander = CommonHelper.FindVisualChild<Expander>(groupItem);
|
|
|
+ if (expander != null)
|
|
|
+ {
|
|
|
+ if (expander.IsExpanded == false)
|
|
|
{
|
|
|
- viewModel.IsModified = true;
|
|
|
+ expander.IsExpanded = true;
|
|
|
}
|
|
|
- await Task.Delay(2);//不加延时 会有不滚动的现象
|
|
|
- AnnotationList.ScrollIntoView(obj.annotHandlerArgs);
|
|
|
}
|
|
|
- catch { }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private async void SelectedItems(RefreshAnnotationArgs obj)
|
|
|
+ {
|
|
|
+ if (obj.IsSelect && obj.annotHandlerArgs != null)
|
|
|
+ {
|
|
|
+ if (viewModel.ViewContentViewModel.IsMultiSelected == false)
|
|
|
+ {
|
|
|
+ if (AnnotationList.SelectedItems.IndexOf(obj.annotHandlerArgs) == -1)
|
|
|
+ {
|
|
|
+ viewModel.IsModified = false;
|
|
|
+ AnnotationList.SelectedItem = obj.annotHandlerArgs;
|
|
|
+ AnnotationList.SelectedIndex = AnnotationList.Items.IndexOf(obj.annotHandlerArgs);
|
|
|
+
|
|
|
+ await Task.Delay(10);//不加延时 会有不滚动的现象
|
|
|
+ AnnotationList.ScrollIntoView(AnnotationList.SelectedItem);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -466,28 +499,22 @@ namespace PDF_Master.Views.BOTA
|
|
|
|
|
|
private void AnnotationList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
- //var a = AnnotationList.SelectedItems.Count;
|
|
|
- var a1 = (sender as ListBox).SelectedItems.Count;
|
|
|
- //var a2 = (e.OriginalSource as ListBox).SelectedItems.Count;
|
|
|
- //var a3 = (e.Source as ListBox).SelectedItems.Count;
|
|
|
- //Trace.WriteLine("a:" + a + " a1:" + a1 + " a2:" + a2 + " a3:" + a3);
|
|
|
- //AnnotationList.ScrollIntoView(AnnotationList.Items[0]);
|
|
|
- if (a1 == 1)
|
|
|
+ var selectedItems = (sender as ListBox).SelectedItems.Cast<AnnotationHandlerEventArgs>().ToList();
|
|
|
+ if (selectedItems.Count == 1)
|
|
|
{
|
|
|
- //if(viewModel.ViewContentViewModel.IsPropertyOpen==false)
|
|
|
if (viewModel.IsModified)
|
|
|
{
|
|
|
- viewModel.ListBoxItemPreviewMouseLeftButtonDown.Execute((sender as ListBox).SelectedItems[0]);
|
|
|
+ viewModel.ListBoxItemPreviewMouseLeftButtonDown.Execute(selectedItems[0]);
|
|
|
}
|
|
|
viewModel.IsModified = true;
|
|
|
}
|
|
|
- else if (a1 > 1)
|
|
|
+ else if (selectedItems.Count > 1)
|
|
|
{
|
|
|
#region 阅读视图 多选
|
|
|
|
|
|
Dictionary<int, List<int>> selectedItemDics = new Dictionary<int, List<int>>();
|
|
|
List<AnnotationHandlerEventArgs> eventArgs = new List<AnnotationHandlerEventArgs>();
|
|
|
- foreach (var item in (sender as ListBox).SelectedItems)
|
|
|
+ foreach (var item in selectedItems)
|
|
|
{
|
|
|
if (item is AnnotationHandlerEventArgs annotation)
|
|
|
{
|
|
@@ -521,7 +548,8 @@ namespace PDF_Master.Views.BOTA
|
|
|
}
|
|
|
if (e.Key == Key.Escape)
|
|
|
{
|
|
|
- AnnotationList.SelectedItems.Clear();
|
|
|
+ //Windows:BOTA列表,移除Esc取消选中逻辑
|
|
|
+ //AnnotationList.SelectedItems.Clear();
|
|
|
}
|
|
|
}
|
|
|
|