Пример #1
0
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.EnableVisualStyles();

            Application.SetCompatibleTextRenderingDefault(false);

            RegisterFrm   registerFrm = null;
            SimpleLoading loadingfrm  = new SimpleLoading(registerFrm);
            //将Loaing窗口,注入到 SplashScreenManager 来管理
            SplashScreenManager loading = new SplashScreenManager(loadingfrm);

            //判断是否已经有实例在运行
            Process instance = RunningInstance();

            if (instance == null) //没有实例在运行
            {
                loading.ShowLoading();
                //try catch 包起来,防止出错
                try
                {
                    CheckoutModel checkoutModel = new CheckoutModel();
                    string        a = string.Empty, b = string.Empty;
                    checkoutModel.res = RegeditTime.InitRegedit(ref a, ref b, checkoutModel.path, checkoutModel.registerCodeName);

                    checkoutModel.sericalNumber = a;
                    checkoutModel.registerCode  = b;

                    LogHelper.WriteLine("程序主入口: 注册结果:" + checkoutModel.res + ",激活码:" + checkoutModel.sericalNumber + ",注册码:" +
                                        "" + checkoutModel.registerCode + "");

                    loading.CloseWaitForm();

                    registerFrm = new RegisterFrm(checkoutModel);
                    registerFrm.ShowDialog();//显示注册激活窗体

                    if (registerFrm.DialogResult == DialogResult.OK)
                    {
                        Application.Run(new HomeForm(checkoutModel, registerFrm.json));
                    }
                }
                catch (Exception e)
                {
                    loading.CloseWaitForm();
                    /*可选处理异常*/
                    LogHelper.WriteLine("程序主入口:" + e.Message.ToString());
                }
            }
            else //已经有一个实例在运行
            {
                //显示窗口
                ShowWindowAsync(instance.MainWindowHandle, 1);
                //窗口显示在最前端
                SetForegroundWindow(instance.MainWindowHandle);
            }
        }
Пример #2
0
        private void registerBtn_Click(object sender, EventArgs e)
        {
            if (!Program.ChatServer.Connected())
            {
                if (!Connect())
                {
                    MessageBox.Show(Program.LanguageManager.Translation.pMsbErrorToServer);
                    return;
                }
            }

            var form = new RegisterFrm();

            form.ShowDialog();
        }
Пример #3
0
        /// <summary>
        /// 获取注册码
        /// </summary>
        public void GetRegisterCode()
        {
            string path = "Software\\IDCardRegisterCode";
            int    res  = RegeditTime.InitRegedit(ref sericalNumber, ref cdKey, path, "registerCode");
            MyRefeshRegisterEventArgs myRefeshRegisterEventArgs = new MyRefeshRegisterEventArgs();

            myRefeshRegisterEventArgs.RegisterCode = sericalNumber;
            myRefeshRegisterEventArgs.Res          = res;
            MyRefreshOwnerRegisterEvent           += this.userLogin1.RefreshRegisterCode;
            //校验通过
            if (res == 0)
            {
                OnMyRefreshOwnerRegisterEvent(myRefeshRegisterEventArgs);
            }
            else if (res == 1)//软件尚未注册
            {
                RegisterFrm registerFrm = new RegisterFrm();
                registerFrm.Owner = this;
                registerFrm.ShowDialog();
            }
            else if (res == 2)//注册机器与本机不一致
            {
                OnMyRefreshOwnerRegisterEvent(myRefeshRegisterEventArgs);
            }
            else if (res == 3)//软件试用已到期
            {
                OnMyRefreshOwnerRegisterEvent(myRefeshRegisterEventArgs);
            }
            else if (res == 4)//激活码与注册码不匹配
            {
                OnMyRefreshOwnerRegisterEvent(myRefeshRegisterEventArgs);
            }
            else//软件运行已到期
            {
                OnMyRefreshOwnerRegisterEvent(myRefeshRegisterEventArgs);
            }
        }
Пример #4
0
        private void registerBtn_Click(object sender, EventArgs e)
        {
            var form = new RegisterFrm();

            form.ShowDialog();
        }