Commit a4b82da0 authored by Rabbit's avatar Rabbit
Browse files

错误修复,新增提醒功能(还没做)

parent 505d2632
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
using Accessibility;
using CountDownList.Controls;
using SixLabors.Fonts;
using SixLabors.ImageSharp;
using System.Drawing;
using System.Windows.Media;

+14 −3
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ namespace CountDownList.Class
        public Expander DoingE, WcE, CountE;
        public FrameworkElement RootWindow;

        NotifyCore notifyCore = new();

        public bool IsOpen = true;
        public ListCore
        (
@@ -821,15 +823,24 @@ namespace CountDownList.Class
            {
                labelElement.IsDelete = true;
                DeleteForElement(labelElement);

                ListLabel label;
                if (window.EditResult.IsCountMode)
                {
                    AddCountLabel(window.EditResult.Title, window.EditResult.StartTime, window.EditResult.TimeFormat, window.EditResult.DarkText, window.EditResult.LabelBackground,Index);
                    label = new(window.EditResult.Title, window.EditResult.StartTime, new DateTime(), "dd\\天hh\\:mm\\:ss", window.EditResult.DarkText, window.EditResult.LabelBackground, true, window.EditResult.IsSound, window.EditResult.IsNotify);

                    label.IsSound = window.EditResult.IsSound;
                    label.IsNotify = window.EditResult.IsNotify;
                    AddCountLabelRaw(label);
                }
                else
                {
                    AddCountDownLabel(window.EditResult.Title, window.EditResult.StartTime, window.EditResult.EndTime, window.EditResult.TimeFormat, window.EditResult.DarkText, window.EditResult.LabelBackground,Index);
                }
                    label = new(window.EditResult.Title, window.EditResult.StartTime, window.EditResult.EndTime, "dd\\天hh\\:mm\\:ss", window.EditResult.DarkText, window.EditResult.LabelBackground, false, window.EditResult.IsSound, window.EditResult.IsNotify);

                    label.IsSound = window.EditResult.IsSound;
                    label.IsNotify = window.EditResult.IsNotify;
                    AddCountDownLabelRaw(label);
                }
            }
        }

+34 −0
Original line number Diff line number Diff line
using CountDownList.Controls;
using NAudio.Wave;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CountDownList.UI.WindowFrame;

namespace CountDownList.Class
{
    public class NotifyCore()
    {
        NotifyWindow window = new NotifyWindow();
        public void SendNotify(ListLabel label)
        {
            using (var audioFile = new AudioFileReader($"{AppDomain.CurrentDomain.BaseDirectory}Data\\Sounds\\NotifySound.mp3"))
            using (var outputDevice = new WaveOutEvent())
            {
                outputDevice.Init(audioFile);
                outputDevice.Play(); // 异步执行

                if (label.IsNotify)
                {
                    window.Show();
                }
                if (label.IsSound)
                {
                    window.NewNotify(label);
                }
            }
        }
    }
}
+13 −2
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml;
using System.Xml.Linq;
using static OpenCvSharp.ML.DTrees;
using CountDownList.UI.WindowFrame;
using HandyControl.Tools.Extension;

@@ -54,6 +53,8 @@ namespace CountDownList.Class
                newElement.SetAttribute("StartTime", label.StartTime.Ticks.ToString());
                newElement.SetAttribute("EndTime", label.EndTime.Ticks.ToString());
                newElement.SetAttribute("DarkText", Convert.ToString(label.DarkText));
                newElement.SetAttribute("IsSound", Convert.ToString(label.IsSound));
                newElement.SetAttribute("IsNotify", Convert.ToString(label.IsNotify));

                if (label.LabelBackground.GetType() == new SolidColorBrush().GetType())
                {
@@ -100,7 +101,7 @@ namespace CountDownList.Class
                }
                string title = "";
                DateTime startTime = DateTime.Now, endTime = DateTime.Now;
                bool isDarkText = false, isReadOnly = false, isCount = false;
                bool isDarkText = false, isReadOnly = false, isCount = false, IsSound = false, IsNotify = false;
                Brush brush = new SolidColorBrush();

                string backgroundRaw = "";
@@ -138,6 +139,14 @@ namespace CountDownList.Class
                            isReadOnly = Convert.ToBoolean(attri.Value);
                            break;

                        case "IsNotify":
                            isReadOnly = Convert.ToBoolean(attri.Value);
                            break;

                        case "IsSound":
                            isReadOnly = Convert.ToBoolean(attri.Value);
                            break;

                        case "BackgroundType":
                            switch (attri.Value)
                            {
@@ -183,6 +192,8 @@ namespace CountDownList.Class

                    Controls.ListLabel lb = new Controls.ListLabel(title, startTime, endTime, "dd\\天hh\\:mm\\:ss", isDarkText, brush, isCount);
                    lb.IsReadOnly = isReadOnly;
                    lb.IsNotify = IsNotify;
                    lb.IsSound = IsSound;
                    result.Add(lb);
                }
                catch (Exception)
+17 −1
Original line number Diff line number Diff line
@@ -33,11 +33,15 @@ namespace CountDownList.Controls
        public bool IsCountMode { get; set; }
        public Brush LabelBackground { get; set; }
        public bool DarkText { get; set; }
        public bool IsNotify { get; set; }
        public bool IsSound { get; set; }
        public bool IsReadOnly { get; set; }

        public event EventHandler<EventArgs>? OnEdit;
        public event EventHandler<EventArgs>? OnDelete;
        public event EventHandler<EventArgs>? OnShare;
        public event EventHandler<EventArgs>? OnNotify;


        public string? TimeFormat;
        public bool IsDelete = false;
@@ -53,7 +57,7 @@ namespace CountDownList.Controls
        /// <param name="endTime">结束时间</param>
        /// <param name="format">时间转换格式</param>
        /// <param name="isCountMode">是否为正计时模式,为true将忽略结束时间</param>
        public ListLabel(string title,DateTime startTime, DateTime endTime, string format, bool darkText, Brush background,bool isCountMode = false)
        public ListLabel(string title, DateTime startTime, DateTime endTime, string format, bool darkText, Brush background, bool isCountMode = false, bool isSound = false, bool isNotify = false)
        {
            InitializeComponent();
            Title = title;
@@ -70,6 +74,8 @@ namespace CountDownList.Controls
            SyncTextColor();
            SyncBackground();

            IsNotify = isNotify;
            IsSound = isSound;
        }

        private bool IsStop;
@@ -143,6 +149,16 @@ namespace CountDownList.Controls
            }
        }

        bool isN = false;
        public void SyncNotify()
        {
            if ((DateTime.Now - EndTime).TotalSeconds <= 1 && IsNotify)
            {
                OnNotify(this, new());
                isN = true;
            }
        }

        public void SyncTime() 
        {
            if (!IsStop)
Loading