Commit c27e49e0 authored by Rabbit's avatar Rabbit
Browse files

主界面目前可以新增标签了

parent b1106cb5
Loading
Loading
Loading
Loading
+70 −4
Original line number Diff line number Diff line
@@ -8,8 +8,10 @@ using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using CountDownList.Controls;
using CountDownList.UI.Window;
using HandyControl.Controls;

namespace CountDownList.Class
{
@@ -149,11 +151,22 @@ namespace CountDownList.Class
            }
        }

        /// <summary>
        /// 标签分享事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void CountDown_OnShare(object? sender, EventArgs e)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 标签删除事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CountDown_OnDelete(object? sender, EventArgs e)
        {
            if (sender != null)
@@ -162,6 +175,11 @@ namespace CountDownList.Class
            }
        }

        /// <summary>
        /// 标签编辑事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CountDown_OnEdit(object? sender, EventArgs e)
        {
            if (sender != null)
@@ -185,6 +203,11 @@ namespace CountDownList.Class
                //动态添加控件
                lb.Uid = t;

                //事件绑定
                lb.OnEdit += CountDown_OnEdit;
                lb.OnDelete += CountDown_OnDelete;
                lb.OnShare += CountDown_OnShare;

                if (InsertIndex != null)
                {
                    CountPanel.Children.Insert((int)InsertIndex, lb);
@@ -258,6 +281,7 @@ namespace CountDownList.Class
        /// <param name="element">要删除标签的元素</param>
        public void DeleteForElement(ListLabel element)
        {
            element.IsDelete = true;
            DoingPanel.Children.Remove(element);
            WcPanel.Children.Remove(element);
            CountPanel.Children.Remove(element);
@@ -304,7 +328,8 @@ namespace CountDownList.Class
                    StartTime = st,
                    EndTime = et,
                    BackGroung = bg,
                    DarkText = d
                    DarkText = d,
                    Own = item
                });
            }

@@ -342,7 +367,8 @@ namespace CountDownList.Class
                    StartTime = st,
                    EndTime = et,
                    BackGroung = bg,
                    DarkText = d
                    DarkText = d,
                    Own = item
                });
            }

@@ -380,12 +406,52 @@ namespace CountDownList.Class
                    StartTime = st,
                    EndTime = et,
                    BackGroung = bg,
                    DarkText = d
                    DarkText = d,
                    Own = item
                });
            }

            Home home = new(l);
            home.Show();
            home.OnAdd += Home_OnAdd;
            home.ShowDialog();
        }

        /// <summary>
        /// 主页面点击添加标签,事件回调
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Home_OnAdd(object? sender, EventArgs e)
        {
            OpenNewEditWindow();
        }

        /// <summary>
        /// 使用编辑窗口新建标签
        /// </summary>
        public void OpenNewEditWindow()
        {
            ImageBrush background = new ();
            background.Stretch = Stretch.UniformToFill;

            background.ImageSource = new BitmapImage(new Uri(@"UI\test.png", UriKind.Relative));

            ListLabel labelElement = new ListLabel("无标题", DateTime.Now, DateTime.Now.AddDays(1), "dd\\天hh\\:mm\\:ss", false, background, false);

            var window = new EditWindow(labelElement);

            window.ShowDialog();
            if (window.EditResult != null)
            {
                if (window.EditResult.IsCountMode)
                {
                    AddCountLabel(window.EditResult.Title, window.EditResult.StartTime, window.EditResult.TimeFormat, window.EditResult.DarkText, window.EditResult.LabelBackground);
                }
                else
                {
                    AddCountDownLabel(window.EditResult.Title, window.EditResult.StartTime, window.EditResult.EndTime, window.EditResult.TimeFormat, window.EditResult.DarkText, window.EditResult.LabelBackground);
                }
            }
        }

        /// <summary>
+12 −0
Original line number Diff line number Diff line
@@ -17,8 +17,11 @@
    <None Remove="UI\Icon\1-Del.png" />
    <None Remove="UI\Icon\2-Hid.png" />
    <None Remove="UI\Icon\3-Edit.png" />
    <None Remove="UI\Icon\Add.png" />
    <None Remove="UI\Icon\Close.png" />
    <None Remove="UI\Icon\collapse.png" />
    <None Remove="UI\Icon\Down.png" />
    <None Remove="UI\Icon\Help.png" />
    <None Remove="UI\Icon\Home.png" />
    <None Remove="UI\Icon\share.png" />
    <None Remove="UI\Misc\00.bmp" />
@@ -50,12 +53,21 @@
    <Content Include="UI\Icon\3-Edit.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="UI\Icon\Add.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="UI\Icon\Close.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="UI\Icon\collapse.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="UI\Icon\Down.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="UI\Icon\Help.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="UI\Icon\Home.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
+0 −80
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ namespace CountDownList
            Core.AddCountLabel("去年生日", new(2024, 8, 7), "dd\\天hh\\:mm\\:ss", true, BirthImageTest);
            Core.AddCountLabel("中考", new(2024, 6, 24), "dd\\天hh\\:mm\\:ss", true, zkImageTest);
            Core.AddCountDownLabel("明年生日", new(2024, 8, 7), new(2025, 8, 7), "dd\\天hh\\:mm\\:ss", true, BirthImageTest);

        }

        ImageBrush NewYearImageTest = new();
@@ -96,62 +95,6 @@ namespace CountDownList
            Application.Current.Shutdown();
        }

        async void AddTest(string t, DateTime st, DateTime et, string f, bool dark, Brush brush)
        {
            bool Move = false;

            //动态添加控件
            Controls.ListLabel lb;
            lb = new(t,st,et,f,dark,brush,false);
            lb.Uid = t;

            lb.OnDelete += Lb_OnDelete;
            lb.OnEdit += Lb_OnEdit;

            doingList.Children.Add(lb);

            while (true)
            {
                if (DateTime.Now <= et)
                {
                    //当不是正计时时执行
                    //当展开框展开时才刷新控件,以优化性能

                    if (DoingE.IsExpanded && IsOpen)
                    {
                        lb.SyncProgress();
                        lb.SyncTime();
                        lb.SyncTitle();
                    }
                }
                else
                {
                    //当不是正计时并且已完成
                    //完成时移入“已完成”
                    if (!Move)
                    {
                        Move = true;//运行一次

                        doingList.Children.Remove(lb);//从进行中移除控件
                        wancheng.Children.Add(lb);//添加到已完成
                    }

                    DoingE.Header = $"进行中({doingList.Children.Count})";
                    wcE.Header = $"已完成({wancheng.Children.Count})";
                    countE.Header = $"正计时({count.Children.Count})";

                    if (wcE.IsExpanded && IsOpen)
                    {
                        //当展开框展开时才刷新控件,以优化性能
                        lb.SyncProgress();
                        lb.SyncTime();
                        lb.SyncTitle();
                    }
                }
                await Task.Delay(20);
            }
        }

        private void Lb_OnEdit(object? sender, EventArgs e)
        {
            if (sender != null)
@@ -178,29 +121,6 @@ namespace CountDownList

#pragma warning disable CS8600

        async void AddCount(string t, DateTime st, string f, bool dark, Brush brush)
        {
            //动态添加控件
            Controls.ListLabel lb;
            lb = new(t, st, new(), f, dark, brush, true);
            lb.Uid = t;
            count.Children.Add(lb);

            while (true)
            {
                //当不是正计时时执行
                //当展开框展开时才刷新控件,以优化性能
                if (countE.IsExpanded && IsOpen)
                {
                    lb.SyncProgress();
                    lb.SyncTime();
                    lb.SyncTitle();
                }
                countE.Header = $"正计时({count.Children.Count})";
                await Task.Delay(20);
            }
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Brush brush = new SolidColorBrush
+1.42 KiB
Loading image diff...
+2.23 KiB
Loading image diff...
Loading