Commit 1fd7b2b3 authored by Rabbit's avatar Rabbit
Browse files

分享功能完成

parent 9b9a0cdc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ using System.Windows;
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("1.0.0.*")]
[assembly: AssemblyVersion("1.1.2.*")]

/// <summary>
/// 使用此类前需要把[assembly: ComVisible(false)]改为true
+51 −0
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;

namespace CountDownList.Class
{
    public class ShardImageProcess:IDisposable
    {
        private ListLabel label;
        public event EventHandler<ImageProcessEventArgs> Processing;
        public event EventHandler<ImageProcessEventArgs> Processed;

        public ShardImageProcess(ListLabel SharedLabel)
        {
            label = SharedLabel;
            
        }

        /// <summary>
        /// 创建图片
        /// </summary>
        /// <param name="w">宽度</param>
        /// <param name="h">高度</param>
        public void CreateNewImage(int w, int h)
        {

        }

        public void Dispose()
        {

        }
    }

    /// <summary>
    /// 图像处理事件参数
    /// </summary>
    public class ImageProcessEventArgs : EventArgs
    {
        public int CurrnetStep { get;set;  }
        public int MaxStep { get;set; }
        public ImageProcessEventArgs(int currnetStep, int maxStep)
        {
            CurrnetStep = currnetStep;
            maxStep = MaxStep;
        }
    }
}
+26 −4
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@ namespace CountDownList.Class
            RefreshNumber();
        }

        /// <summary>
        /// 刷新计数
        /// </summary>
        private async void RefreshNumber()
        {
            while (true)
@@ -162,6 +165,11 @@ namespace CountDownList.Class
            }
        }

        /// <summary>
        /// 创建Label
        /// </summary>
        /// <param name="label">ListLabel</param>
        /// <param name="InsertIndex">插入的位置</param>
        public async void AddCountDownLabelRaw(ListLabel label, int? InsertIndex = null)
        {
            //自动释放资源
@@ -274,7 +282,7 @@ namespace CountDownList.Class
                }
                else
                {
                    HandyControl.Controls.MessageBox.Show("删除失败,此标签禁止删除", $"删除 {((Controls.ListLabel)sender).Title}", MessageBoxButton.OK, MessageBoxImage.Error);
                    HandyControl.Controls.MessageBox.Show("删除失败,此标签禁止删除\n须将该标签的xml属性IsReadOnly设为false", $"删除 {((Controls.ListLabel)sender).Title}", button: MessageBoxButton.OK, icon: MessageBoxImage.Error);
                }
            }
        }
@@ -294,7 +302,7 @@ namespace CountDownList.Class
                }
                else
                {
                    HandyControl.Controls.MessageBox.Show("删除失败,此标签禁止删除", $"删除 {((Controls.ListLabel)sender).Title}", MessageBoxButton.OK, MessageBoxImage.Error);
                    HandyControl.Controls.MessageBox.Show("编辑失败,此标签禁止编辑\n须将该标签的xml属性IsReadOnly设为false", $"编辑 {((Controls.ListLabel)sender).Title}", button: MessageBoxButton.OK, icon: MessageBoxImage.Error);
                }
            }
        }
@@ -486,6 +494,7 @@ namespace CountDownList.Class
        {
            List<ListP> l = new();

            //扫描进行中
            foreach (Controls.ListLabel item in DoingPanel.Children)
            {
                string t, st, et, bg, d;
@@ -525,6 +534,7 @@ namespace CountDownList.Class
                });
            }

            //扫描正计时
            foreach (Controls.ListLabel item in WcPanel.Children)
            {
                string t, st, et, bg, d;
@@ -564,6 +574,7 @@ namespace CountDownList.Class
                });
            }

            //扫描已完成
            foreach (Controls.ListLabel item in CountPanel.Children)
            {
                string t, st, et, bg, d;
@@ -620,6 +631,11 @@ namespace CountDownList.Class
            home.ShowDialog();
        }

        /// <summary>
        /// 主页分享事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Home_OnShare(object? sender, EventArgs e)
        {
            ListLabel? shareElement;
@@ -662,7 +678,7 @@ namespace CountDownList.Class
                    }
                    else
                    {
                        HandyControl.Controls.MessageBox.Show("删除失败,此标签禁止删除", $"删除 {delElememt.Title}", MessageBoxButton.OK, MessageBoxImage.Error);
                        HandyControl.Controls.MessageBox.Show("删除失败,此标签禁止删除\n须将该标签的xml属性IsReadOnly设为false", $"删除 {delElememt.Title}", button: MessageBoxButton.OK, icon: MessageBoxImage.Error);
                    }
                }
            }
@@ -694,7 +710,7 @@ namespace CountDownList.Class
                    }
                    else
                    {
                        HandyControl.Controls.MessageBox.Show("编辑失败,此标签禁止删除", $"删除 {editElement.Title}", MessageBoxButton.OK, MessageBoxImage.Error);
                        HandyControl.Controls.MessageBox.Show("编辑失败,此标签禁止编辑\n须将该标签的xml属性IsReadOnly设为false", $"编辑 {editElement.Title}", button: MessageBoxButton.OK, icon: MessageBoxImage.Error);
                    }
                }
            }
@@ -817,6 +833,12 @@ namespace CountDownList.Class
            }
        }

        /// <summary>
        /// 控件是否在窗口上显示,代码来自 https://cloud.tencent.com/developer/ask/sof/116724
        /// </summary>
        /// <param name="element">要判定的元素</param>
        /// <param name="container">父元素</param>
        /// <returns>如果控件被父元素遮住,返回false</returns>
        private bool IsUserVisible(FrameworkElement element, FrameworkElement container)
        {
            if (!element.IsVisible)
+57 −0
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ 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;

#pragma warning disable
namespace CountDownList.Class
@@ -21,11 +23,18 @@ namespace CountDownList.Class
        public XmlDocument xmlDoc = new();
        public XElement root;
        public XElement main;
        Init init = new();

        public event EventHandler<LoadingEventArgs> ReadLabelsEvent;
        public CountCownListXml() 
        {
            xmlDoc.Load($"{AppDomain.CurrentDomain.BaseDirectory}\\Data\\CountDownList.xml");
        }

        /// <summary>
        /// 保存ListLabel到xml
        /// </summary>
        /// <param name="labels">包含多个ListLabels的列表</param>
        public void WriteListLabels(List<Controls.ListLabel> labels)
        {
            XmlNode rootNode = xmlDoc.SelectSingleNode("shRabbit").SelectSingleNode("CountDownList");
@@ -67,14 +76,28 @@ namespace CountDownList.Class
            xmlDoc.Save($"{AppDomain.CurrentDomain.BaseDirectory}\\Data\\CountDownList.xml");
        }

        /// <summary>
        /// 从xml获取ListLabel
        /// </summary>
        /// <returns>包含多个ListLabels的列表</returns>
        public List<Controls.ListLabel> GetListLabels()
        {
            List<Controls.ListLabel> result = new();

            XmlNode rootNode = xmlDoc.SelectSingleNode("shRabbit").SelectSingleNode("CountDownList");

            int labelsCount = 0;

            DateTime time = DateTime.Now;

            bool initShowed = false;

            foreach (XmlNode item in rootNode.ChildNodes)
            {
                if ((DateTime.Now - time).TotalSeconds >= 3 && initShowed == false)
                {
                    initShowed = true;
                }
                string title = "";
                DateTime startTime = DateTime.Now, endTime = DateTime.Now;
                bool isDarkText = false, isReadOnly = false, isCount = false;
@@ -165,11 +188,45 @@ namespace CountDownList.Class
                catch (Exception)
                {
                }
                finally
                {
                    if (ReadLabelsEvent != null)
                    {
                        labelsCount += 1;
                        LoadingProgress.Value = labelsCount;
                        LoadingProgress.Total = rootNode.ChildNodes.Count;
                    }
                }
            }
            return result;
        }
    }

    public static class LoadingProgress
    {
        public static int Value = 0;
        public static int Total = 0;
    }

    public class LoadingEventArgs(int value, int total) : EventArgs
    {
        public int Value
        {
            get
            {
                return value;
            }
        }

        public int Total
        {
            get
            {
                return total;
            }
        }
    }

    /// <summary>
    /// JSON(反)序列化内容
    /// </summary>
+9 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
    <None Remove="Data\Image\3.png" />
    <None Remove="Data\Image\4.jpg" />
    <None Remove="handle64.exe" />
    <None Remove="UI\CountDownListLogo.png" />
    <None Remove="UI\Icon\0-more.png" />
    <None Remove="UI\Icon\1-Del.png" />
    <None Remove="UI\Icon\2-Hid.png" />
@@ -37,6 +38,7 @@
    <None Remove="UI\Icon\Home.png" />
    <None Remove="UI\Icon\share.png" />
    <None Remove="UI\Misc\00.bmp" />
    <None Remove="UI\shRabbitLight%404x.png" />
    <None Remove="UI\test.png" />
  </ItemGroup>

@@ -105,13 +107,20 @@
    <PackageReference Include="HandyControl" Version="3.5.1" />
    <PackageReference Include="NAudio" Version="2.2.1" />
    <PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" />
    <PackageReference Include="SixLabors.Fonts" Version="2.0.7" />
    <PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />
    <PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.4" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Data\Sounds\UI\" />
  </ItemGroup>

  <ItemGroup>
    <Resource Include="UI\CountDownListLogo.png" />
    <Resource Include="UI\[email protected]" />
  </ItemGroup>

  <ItemGroup>
    <Compile Update="MiscSetting.Designer.cs">
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
Loading