<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace easyIcon
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
        }

        private void Register_Load(object sender, EventArgs e)
        {
            label_MachineSerial.Text = MachineInfo.MachineSerial(); // 显示机器码
            setPicePicture(Price());    // 设置注册价格
        }

        // 设置注册价格
        private void setPicePicture(int price)
        {
            if (price == 1) pictureBox1.Image = Properties.Resources.price_1;
            else if (price == 2) pictureBox1.Image = Properties.Resources.price_2;
            else if (price == 3) pictureBox1.Image = Properties.Resources.price_3;
            else if (price == 10) pictureBox1.Image = Properties.Resources.price_10;
            else if (price == 20) pictureBox1.Image = Properties.Resources.price_20;
        }

        // 软件注册，记录注册码到注册表中
        private void button1_Click(object sender, EventArgs e)
        {
            string serial = textBox_SerialNum.Text.Trim();
            serial = MachineInfo.format(serial);
            if(serial.Equals(MachineInfo.RegSerial()))
            {
                mainForm.F.RegistrySave(@"Scimence\easyIcon\Set", "Serial", serial);
                this.Close();   
                MessageBox.Show("恭喜，您已成功注册！");
            }
            else MessageBox.Show("抱歉，注册码无效！");
        }


        // 判断用户是否已经注册
        public static bool IsRegUser()
        {
            // 联网控制开关状态为，不需要进行注册
            bool containsSerial = mainForm.F.RegistryCotains(@"Scimence\easyIcon\Set", "Serial");
            //mainForm.F.RegistryRemove(@"Scimence\easyIcon\Set", "Serial");
            if (!containsSerial && !needRegister()) return true;   

            // 优先判断本地注册表数据
            string serial = mainForm.F.RegistryStrValue(@"Scimence\easyIcon\Set", "Serial");
            if (!serial.Equals("") && serial.Equals(MachineInfo.RegSerial())) return true;

            // 判断联网数据中，是否有本机的注册码
            loadOnlineSerial();
            if(!OnlineSerial.Equals("") && OnlineSerial.Equals(MachineInfo.RegSerial()))
            {
                mainForm.F.RegistrySave(@"Scimence\easyIcon\Set", "Serial", OnlineSerial);
                MessageBox.Show("恭喜，软件作者已通过联网方式，成功为您注册！");
                return true;
            }
            else return false;
        }


        # region 获取在线设置数据

        private static string SettingData;      // 在线设置信息
        public static void loadSettingData()
        {
            // 获取设置数据
            if (SettingData == null)
            {
                string url = "https://git.oschina.net/scimence/UpdateFiles/raw/master/files/settingPage.txt";
                SettingData = mainForm.F.getWebData(url);
                if (!SettingData.Equals("")) SettingData = getNodeData(SettingData, "scimence", false);
            }
        }

        private static string OnlineSerial;     // 在线注册码
        public static void loadOnlineSerial()
        {
            // 联网获取本机的注册码
            if (OnlineSerial == null)
            {
                string url = "https://git.oschina.net/scimence/UpdateFiles/raw/master/files/onlineSerial.txt";
                OnlineSerial = mainForm.F.getWebData(url);
                if (!OnlineSerial.Equals("")) OnlineSerial = getNodeData(OnlineSerial, "scimence", false);
                if (!OnlineSerial.Equals("")) OnlineSerial = getNodeData(OnlineSerial, MachineInfo.MachineSerial(), true);
            }
        }

        // 根据网页控制开关，判定是否需要注册
        public static bool needRegister()
        {
            loadSettingData();  // 载入设置数据
            string NeedToRegister = getNodeData(SettingData, "NeedToRegister", true);
            return !NeedToRegister.Equals("false");

            //string RegisterPrice = getNodeData(SettingData, "RegisterPrice", false);
        }

        // 根据网页控制开关，判定判定注册价格
        public static int Price()
        {
            loadSettingData();  // 载入设置数据
            try
            {
                string RegisterPrice = getNodeData(SettingData, "RegisterPrice", true);
                return Int32.Parse(RegisterPrice);
            }
            catch (Exception) { return 5; }
        }

        // 根据网页设置，获取当前推荐显示的url<commit_msg>Update Register.cs<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace easyIcon
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
        }

        private void Register_Load(object sender, EventArgs e)
        {
            label_MachineSerial.Text = MachineInfo.MachineSerial(); // 显示机器码
            setPicePicture(Price());    // 设置注册价格
        }

        // 设置注册价格
        private void setPicePicture(int price)
        {
            if (price == 1) pictureBox1.Image = Properties.Resources.price_1;
            else if (price == 2) pictureBox1.Image = Properties.Resources.price_2;
            else if (price == 3) pictureBox1.Image = Properties.Resources.price_3;
            else if (price == 10) pictureBox1.Image = Properties.Resources.price_10;
            else if (price == 20) pictureBox1.Image = Properties.Resources.price_20;
        }

        // 软件注册，记录注册码到注册表中
        private void button1_Click(object sender, EventArgs e)
        {
            string serial = textBox_SerialNum.Text.Trim();
            serial = MachineInfo.format(serial);
            if(serial.Equals(MachineInfo.RegSerial()))
            {
                mainForm.F.RegistrySave(@"Scimence\easyIcon\Set", "Serial", serial);
                this.Close();   
                MessageBox.Show("恭喜，您已成功注册！");
            }
            else MessageBox.Show("抱歉，注册码无效！");
        }


        // 判断用户是否已经注册
        public static bool IsRegUser()
        {
            // 联网控制开关状态为，不需要进行注册
            bool containsSerial = mainForm.F.RegistryCotains(@"Scimence\easyIcon\Set", "Serial");
            //mainForm.F.RegistryRemove(@"Scimence\easyIcon\Set", "Serial");
            if (!containsSerial && !needRegister()) return true;   

            // 优先判断本地注册表数据
            string serial = mainForm.F.RegistryStrValue(@"Scimence\easyIcon\Set", "Serial");
            if (!serial.Equals("") && serial.Equals(MachineInfo.RegSerial())) return true;

            // 判断联网数据中，是否有本机的注册码
            loadOnlineSerial();
            if(!OnlineSerial.Equals("") && OnlineSerial.Equals(MachineInfo.RegSerial()))
            {
                mainForm.F.RegistrySave(@"Scimence\easyIcon\Set", "Serial", OnlineSerial);
                MessageBox.Show("恭喜，软件作者已通过联网方式，成功为您注册！");
                return true;
            }
            else return false;
        }


        # region 获取在线设置数据

        private static string SettingData;      // 在线设置信息
        public static void loadSettingData()
        {
            // 获取设置数据
            if (SettingData == null)
            {
                string url = "https://git.oschina.net/scimence/easyIcon/raw/master/files/settingPage.txt";
                SettingData = mainForm.F.getWebData(url);
                if (!SettingData.Equals("")) SettingData = getNodeData(SettingData, "scimence", false);
            }
        }

        private static string OnlineSerial;     // 在线注册码
        public static void loadOnlineSerial()
        {
            // 联网获取本机的注册码
            if (OnlineSerial == null)
            {
                string url = "https://git.oschina.net/scimence/easyIcon/raw/master/files/onlineSerial.txt";
                OnlineSerial = mainForm.F.getWebData(url);
                if (!OnlineSerial.Equals("")) OnlineSerial = getNodeData(OnlineSerial, "scimence", false);
                if (!OnlineSerial.Equals("")) OnlineSerial = getNodeData(OnlineSerial, MachineInfo.MachineSerial(), true);
            }
        }

        // 根据网页控制开关，判定是否需要注册
        public static bool needRegister()
        {
            loadSettingData();  // 载入设置数据
            string NeedToRegister = getNodeData(SettingData, "NeedToRegister", true);
            return !NeedToRegister.Equals("false");

            //string RegisterPrice = getNodeData(SettingData, "RegisterPrice", false);
        }

        // 根据网页控制开关，判定判定注册价格
        public static int Price()
        {
            loadSettingData();  // 载入设置数据
            try
            {
                string RegisterPrice = getNodeData(SettingData, "RegisterPrice", true);
                return Int32.Parse(RegisterPrice);
            }
            catch (Exception) { return 5; }
        }

        // 根据网页设置，获取当前推荐显示的url
{'fraction_non_alphanumeric': 0.11063686397843424, 'fraction_numerical': 0.005166797708637538, 'mean_word_length': 1.8862236628849272, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7222382', 'n_tokens_mistral': 2712, 'n_tokens_neox': 2751, 'n_words': 456}