diff --git a/FileManager_UWP/Controls/LabelListControl.cs b/FileManager_UWP/Controls/LabelListControl.cs
index 618c4f5..853a160 100644
--- a/FileManager_UWP/Controls/LabelListControl.cs
+++ b/FileManager_UWP/Controls/LabelListControl.cs
@@ -47,6 +47,26 @@ namespace FileManager_UWP.Controls {
update();
}
+ private void SetElasticAnimate(Button b, int expanded_position) {
+ DoubleAnimation expand_animate = new DoubleAnimation();
+ expand_animate.From = null; // labelListCanvas.Children.Count * 22;
+ expand_animate.To = expanded_position;
+ expand_animate.Duration = _animate_during;
+ //expand_animate.Completed += Animate_Completed;
+ _expand_story_board.Children.Add(expand_animate);
+ Storyboard.SetTarget(expand_animate, b);
+ Storyboard.SetTargetProperty(expand_animate, "(Canvas.Left)");
+
+ DoubleAnimation collpse_animate = new DoubleAnimation();
+ collpse_animate.From = null; // expanded_position;
+ collpse_animate.To = labelListCanvas.Children.Count * 20;
+ collpse_animate.Duration = _animate_during;
+ //collpse_animate.Completed += Animate_Completed;
+ _collpse_story_board.Children.Add(collpse_animate);
+ Storyboard.SetTarget(collpse_animate, b);
+ Storyboard.SetTargetProperty(collpse_animate, "(Canvas.Left)");
+ }
+
///
/// 当ItemsSource改变时,绘制标签,注册动画
///
@@ -66,28 +86,38 @@ namespace FileManager_UWP.Controls {
b.SetValue(Canvas.LeftProperty, expanded_position);
b.Style = (Style)genericResourceDictionary["LabelButtonStyle"];
b.Click += B_Click;
-
- DoubleAnimation expand_animate = new DoubleAnimation();
- expand_animate.From = null; // labelListCanvas.Children.Count * 22;
- expand_animate.To = expanded_position;
- expand_animate.Duration = _animate_during;
- expand_animate.Completed += Animate_Completed;
- _expand_story_board.Children.Add(expand_animate);
- Storyboard.SetTarget(expand_animate, b);
- Storyboard.SetTargetProperty(expand_animate, "(Canvas.Left)");
-
- DoubleAnimation collpse_animate = new DoubleAnimation();
- collpse_animate.From = null; // expanded_position;
- collpse_animate.To = labelListCanvas.Children.Count * 20;
- collpse_animate.Duration = _animate_during;
- collpse_animate.Completed += Animate_Completed;
- _collpse_story_board.Children.Add(collpse_animate);
- Storyboard.SetTarget(collpse_animate, b);
- Storyboard.SetTargetProperty(collpse_animate, "(Canvas.Left)");
-
+ SetElasticAnimate(b, expanded_position);
expanded_position += label.tag.Count() * 14 + 15;
labelListCanvas.Children.Add(b);
}
+ Button add_button = new Button();
+ SetElasticAnimate(add_button, expanded_position);
+ add_button.Content = "+";
+ add_button.SetValue(Canvas.LeftProperty, expanded_position);
+ add_button.Style = (Style)genericResourceDictionary["LabelButtonStyle"];
+ add_button.Click += Add_Click;
+ DoubleAnimation appear_animate = new DoubleAnimation {
+ To = 100,
+ Duration = _animate_during
+ };
+ appear_animate.Completed += Animate_Completed;
+ _expand_story_board.Children.Add(appear_animate);
+ Storyboard.SetTarget(appear_animate, add_button);
+ Storyboard.SetTargetProperty(appear_animate, "Opacity");
+ DoubleAnimation disappear_animate = new DoubleAnimation {
+ Duration = _animate_during
+ };
+ // 如果没有标签,则+不自动隐藏
+ if (itemsSource.Count > 0)
+ disappear_animate.To = 0;
+ else
+ disappear_animate.To = 100;
+ disappear_animate.Completed += Animate_Completed;
+ _collpse_story_board.Children.Add(disappear_animate);
+ Storyboard.SetTarget(disappear_animate, add_button);
+ Storyboard.SetTargetProperty(disappear_animate, "Opacity");
+
+ labelListCanvas.Children.Add(add_button);
measure();
LabelListCanvas_PointerExited(null, null);
}
@@ -101,6 +131,15 @@ namespace FileManager_UWP.Controls {
Debug.WriteLine(b.Content);
}
///
+ /// 点击新建标签
+ ///
+ ///
+ ///
+ private void Add_Click(object sender, RoutedEventArgs e) {
+ Button b = sender as Button;
+ Debug.WriteLine(b.Content);
+ }
+ ///
/// 动画完成
///
///
@@ -124,7 +163,7 @@ namespace FileManager_UWP.Controls {
///
private void LabelListCanvas_PointerExited(object sender, PointerRoutedEventArgs e) {
_collpse_story_board.Begin();
- for (int i = 0; i < labelListCanvas.Children.Count - 1; i++) {
+ for (int i = 0; i < labelListCanvas.Children.Count - 2; i++) {
Button b = labelListCanvas.Children[i] as Button;
b.Content = String.Format("{0}...", (b.Content as string)[0]);
}
@@ -137,7 +176,7 @@ namespace FileManager_UWP.Controls {
private void LabelListCanvas_PointerEntered(object sender, PointerRoutedEventArgs e) {
_expand_story_board.Begin();
var labels = ItemsSource as ObservableCollection;
- for (int i = 0; i < labels.Count; i++) {
+ for (int i = 0; i < labels.Count - 1; i++) {
Button b = labelListCanvas.Children[i] as Button;
b.Content = labels[i].tag;
}
diff --git a/FileManager_UWP/View/TestLabelView.xaml b/FileManager_UWP/View/TestLabelView.xaml
index efb1542..cae7822 100644
--- a/FileManager_UWP/View/TestLabelView.xaml
+++ b/FileManager_UWP/View/TestLabelView.xaml
@@ -22,7 +22,9 @@
-->
-
-
+
+
+
+
diff --git a/FileManager_UWP/View/TestLabelView.xaml.cs b/FileManager_UWP/View/TestLabelView.xaml.cs
index f6f4af3..c3ed396 100644
--- a/FileManager_UWP/View/TestLabelView.xaml.cs
+++ b/FileManager_UWP/View/TestLabelView.xaml.cs
@@ -32,6 +32,7 @@ namespace FileManager_UWP.View {
new LabelItem("才明洋与吴岳江进行土耳其摔跤"),
new LabelItem("真正的瑜伽大师")
};
+ public ObservableCollection empty = new ObservableCollection();
public TestLabelView() {
this.InitializeComponent();
@@ -58,5 +59,9 @@ namespace FileManager_UWP.View {
}
Debug.WriteLine(Labels.Count.ToString());
}
+
+ private void LabelListControl_Tapped(object sender, TappedRoutedEventArgs e) {
+ Debug.WriteLine(sender);
+ }
}
}