Commit 766db99a authored by Rabbit's avatar Rabbit
Browse files

除保存配置和分享图片外,其余功能已完成

parent c27e49e0
Loading
Loading
Loading
Loading
+94 −7
Original line number Diff line number Diff line
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Text;
@@ -85,9 +87,16 @@ namespace CountDownList.Class
                lb.OnShare += CountDown_OnShare;

                if (InsertIndex != null)
                {
                    try
                    {
                        DoingPanel.Children.Insert((int)InsertIndex, lb);
                    }
                    catch (System.ArgumentOutOfRangeException)
                    {
                        DoingPanel.Children.Add(lb);
                    }
                }
                else
                {
                    DoingPanel.Children.Add(lb);
@@ -209,9 +218,16 @@ namespace CountDownList.Class
                lb.OnShare += CountDown_OnShare;

                if (InsertIndex != null)
                {
                    try
                    {
                        CountPanel.Children.Insert((int)InsertIndex, lb);
                    }
                    catch (System.ArgumentOutOfRangeException)
                    {
                        CountPanel.Children.Add(lb);
                    }
                }
                else
                {
                    CountPanel.Children.Add(lb);
@@ -288,9 +304,10 @@ namespace CountDownList.Class
        }

        /// <summary>
        /// 打开主界面并扫描列表
        /// 将ListLabels转成列表
        /// </summary>
        public void OpenMainWindow()
        /// <returns></returns>
        public List<ListP> ScanList()
        {
            List<ListP> l = new();

@@ -410,12 +427,69 @@ namespace CountDownList.Class
                    Own = item
                });
            }
            return l;
        }


            Home home = new(l);
        /// <summary>
        /// 打开主界面并扫描列表
        /// </summary>
        public void OpenMainWindow()
        {
            Home home = new(ScanList());
            home.OnAdd += Home_OnAdd;
            home.OnEdit += Home_OnEdit;
            home.OnDelete += Home_OnDelete;
            home.OnShare += Home_OnShare;

            home.ShowDialog();
        }

        private void Home_OnShare(object? sender, EventArgs e)
        {
            throw new NotImplementedException();
        }

        private void Home_OnDelete(object? sender, EventArgs e)
        {
            ListLabel? delElememt;
            try
            {
                if ((ListP)((Home)sender).listView.SelectedItem != null)
                {
                    delElememt = ((ListP)((Home)sender).listView.SelectedItem).Own;
                    DeleteForElement(delElememt);
                    if (sender != null)
                    {
                        ((Home)sender).RefreshList(ScanList());
                    }
                }
            }
            catch
            {
            }
        }

        private void Home_OnEdit(object? sender, EventArgs e)
        {
            ListLabel? editElement;
            try
            {
                if ((ListP)((Home)sender).listView.SelectedItem != null)
                {
                    editElement = ((ListP)((Home)sender).listView.SelectedItem).Own;
                    EditAndChange(editElement);
                    if (sender != null)
                    {
                        ((Home)sender).RefreshList(ScanList());
                    }
                }
            }
            catch
            {
            }
        }

        /// <summary>
        /// 主页面点击添加标签,事件回调
        /// </summary>
@@ -423,13 +497,20 @@ namespace CountDownList.Class
        /// <param name="e"></param>
        private void Home_OnAdd(object? sender, EventArgs e)
        {
            OpenNewEditWindow();
            if (OpenNewEditWindow())
            {
                if (sender != null)
                {
                    ((Home)sender).RefreshList(ScanList());
                }
            }
        }

        /// <summary>
        /// 使用编辑窗口新建标签
        /// </summary>
        public void OpenNewEditWindow()
        /// <returns>最终同意了更改,返回True,否则返回False</returns>
        public Boolean OpenNewEditWindow()
        {
            ImageBrush background = new ();
            background.Stretch = Stretch.UniformToFill;
@@ -451,6 +532,11 @@ namespace CountDownList.Class
                {
                    AddCountDownLabel(window.EditResult.Title, window.EditResult.StartTime, window.EditResult.EndTime, window.EditResult.TimeFormat, window.EditResult.DarkText, window.EditResult.LabelBackground);
                }
                return true;
            }
            else
            {
                return false;
            }
        }

@@ -514,6 +600,7 @@ namespace CountDownList.Class
                {
                    AddCountDownLabel(window.EditResult.Title, window.EditResult.StartTime, window.EditResult.EndTime, window.EditResult.TimeFormat, window.EditResult.DarkText, window.EditResult.LabelBackground,Index);
                }

            }
        }

+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@
        </Grid.RowDefinitions>
        <Border x:Name="border1" Grid.RowSpan="1" Background="#7F585858" CornerRadius="8,8,0,0" MouseLeftButtonDown="Border_MouseLeftButtonDown">
            <Grid>
                <Button Click="Button_Click_2">AddOne</Button>
                <Button Click="Button_Click_2" Visibility="Collapsed">AddOne</Button>
                <TextBlock Foreground="#FFF7F7F7" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0,0,0">
                    倒计时列表
                </TextBlock>
+255 B (2.49 KiB)
Loading image diff...
+5 −5
Original line number Diff line number Diff line
@@ -30,13 +30,13 @@
        </ListView>

        <StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Right" Margin="0,-10,10,0">
            <Button Width="40" Height="40" Padding="0,0,0,0" Margin="8,0,0,0" ToolTip="编辑">
                <Image RenderOptions.BitmapScalingMode="Fant" Source="/UI/Icon/3-Edit.png" Width="18"/>
            <Button Width="40" Height="40" Padding="0,0,0,0" Margin="8,0,0,0" ToolTip="编辑" Click="Button_Click_1">
                <Image RenderOptions.BitmapScalingMode="Fant" Source="/UI/Icon/3-Edit.png" Width="24"/>
            </Button>
            <Button Width="40" Height="40" Padding="0,0,0,0" Margin="8,0,0,0" ToolTip="删除选定">
            <Button Width="40" Height="40" Padding="0,0,0,0" Margin="8,0,0,0" ToolTip="删除选定" Click="Button_Click_2">
                <Image RenderOptions.BitmapScalingMode="Fant" Source="/UI/Icon/1-Del.png" Width="26"/>
            </Button>
            <Button Width="40" Height="40" Padding="0,0,0,0" Margin="8,0,0,0" ToolTip="分享为图片">
            <Button Width="40" Height="40" Padding="0,0,0,0" Margin="8,0,0,0" ToolTip="分享为图片" Click="Button_Click_3">
                <Image RenderOptions.BitmapScalingMode="Fant" Source="/UI/Icon/share.png" Width="26"/>
            </Button>
        </StackPanel>
@@ -45,7 +45,7 @@
            <Image RenderOptions.BitmapScalingMode="Fant" Source="/UI/Icon/Help.png" Width="26"/>
        </Button>

        <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,-10,0,0">
        <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,-10,0,0" HorizontalAlignment="Left">
            <Button Width="40" Height="40" Padding="0,0,0,0" Margin="10,0,8,0" HorizontalAlignment="Left" Grid.Row="2" Click="Button_Click" ToolTip="新建标签">
                <Image RenderOptions.BitmapScalingMode="Fant" Source="/UI/Icon/Add.png" Width="20"/>
            </Button>
+42 −1
Original line number Diff line number Diff line
@@ -13,6 +13,10 @@ namespace CountDownList.UI.Window

        public List<ListP> Items;
        public event EventHandler<EventArgs> OnAdd;
        public event EventHandler<EventArgs> OnEdit;
        public event EventHandler<EventArgs> OnDelete;
        public event EventHandler<EventArgs> OnShare;


        public Home(List<ListP> items)
        {
@@ -21,6 +25,23 @@ namespace CountDownList.UI.Window
            Items = items;
        }

        public void RefreshList(List<ListP> items, ListLabel? ChangedElement = null)
        {
            //清空
            if (items.Count <= 0)
            {
                Items.RemoveRange(0, Items.Count - 1);
            }

            //重新添加
            listView.ItemsSource = items;
            Items = items;
            if (ChangedElement != null)
            {
                listView.SelectedItem = ChangedElement;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
@@ -28,7 +49,27 @@ namespace CountDownList.UI.Window
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OnAdd(sender, new());
            OnAdd(this, new());
        }

        /// <summary>
        /// 编辑所选项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            OnEdit(this, new());
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            OnDelete(this, new());
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            OnShare(this, new());
        }
    }