Exemple #1
0
        /// <summary>
        /// 初始化种子搜索站点
        /// </summary>
        private void InitTorrentSite(object sender, OnUserChangeEventArgs e)
        {
            panelSite.Controls.Clear();
            if (Global.Users != null && Global.Users.Count > 0)
            {
                for (int i = 0; i < Global.Users.Count; i++)
                {
                    var      user = Global.Users[i];
                    CheckBox cb   = new CheckBox();
                    cb.AutoSize = true;
                    cb.Size     = new Size(100, 25);
                    cb.Location = new Point(20, i * cb.Size.Height + 10);
                    cb.Name     = cb + user.Site.Name;
                    cb.TabIndex = i;
                    cb.Text     = user.Site.Name;
                    cb.UseVisualStyleBackColor = true;
                    cb.Tag             = user.Site.Id;
                    cb.CheckedChanged += Cb_CheckedChanged;
                    panelSite.Controls.Add(cb);
                }

                //追加全选按钮
                if (panelSite.Controls.Count > 0)
                {
                    CheckBox cb = new CheckBox();
                    cb.AutoSize = true;
                    cb.Size     = new Size(100, 25);
                    cb.Location = new Point(20, panelSite.Controls.Count * cb.Size.Height + 10);
                    cb.Name     = cb + "Select";
                    cb.TabIndex = panelSite.Controls.Count;
                    cb.Text     = "全选";
                    cb.Tag      = false;
                    cb.UseVisualStyleBackColor = true;
                    cb.CheckedChanged         += CbSelect_CheckedChanged;
                    panelSite.Controls.Add(cb);
                }

                JObject o = new JObject();
                string  selectSiteJson = ConfigUtil.GetConfigValue(YUConst.CONFIG_SEARCHSITEHISTORY);
                if (!selectSiteJson.IsNullOrEmptyOrWhiteSpace())
                {
                    o = JsonConvert.DeserializeObject <JObject>(selectSiteJson);
                    foreach (var item in panelSite.Controls)
                    {
                        if (item is CheckBox)
                        {
                            var cb = item as CheckBox;
                            if (o.ContainsKey(cb.Name))
                            {
                                cb.Checked = o[cb.Name].TryPareValue(false);
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
 private void OnUserChanged(OnUserChangeEventArgs e)
 {
     if (e.User != null)
     {
         if (UserChanged != null)
         {
             UserChanged.Invoke(this, e);
         }
     }
 }
Exemple #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            UserFrm frm = new UserFrm(null);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                OnUserChangeEventArgs el = new OnUserChangeEventArgs();
                el.User = frm.User;
                OnUserChanged(el);
            }
        }
Exemple #4
0
 private void OnUserChanged(OnUserChangeEventArgs e)
 {
     if (e.User != null)
     {
         Global.Users = AppService.GetAllUsers(Global.Sites);
         InitUser();
         if (UserChanged != null)
         {
             UserChanged.Invoke(this, e);
         }
     }
 }
Exemple #5
0
        private void BtnEdit_Click(object sender, EventArgs e)
        {
            PTUser user = ((sender as Control).Tag as PTUser);

            if (user == null)
            {
                throw new Exception("获取用户数据失败。");
            }
            else
            {
                UserFrm frm = new UserFrm(user);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    OnUserChangeEventArgs el = new OnUserChangeEventArgs();
                    el.User = user;
                    OnUserChanged(el);
                }
            }
        }
Exemple #6
0
        private void BtnDel_Click(object sender, EventArgs e)
        {
            PTUser user = ((sender as Control).Tag as PTUser);

            if (user == null)
            {
                throw new Exception("获取用户数据失败。");
            }
            else
            {
                if (AppService.DeleteUser(user.Site.Id) > 0)
                {
                    var pt = PTFactory.GetPT(user.Site.Id, user) as AbstractPT;
                    pt.DelLocalCookie();
                    OnUserChangeEventArgs el = new OnUserChangeEventArgs();
                    el.User = user;
                    OnUserChanged(el);
                }
            }
        }
Exemple #7
0
 private void OnUserChanged(OnUserChangeEventArgs e)
 {
     if (e.User != null)
     {
         try
         {
             var pt = PTFactory.GetPT(e.User.Site.Id, e.User);
             (pt as AbstractPT).DelLocalCookie();
         }
         catch (Exception ex)
         {
             Logger.Error(string.Format("{0} 用户名:{1} 删除Cookie出错。", e.User.Site.Id, e.User.UserName), ex);
         }
         Global.InitUser();
         InitUser();
         if (UserChanged != null)
         {
             UserChanged.Invoke(this, e);
         }
     }
 }
Exemple #8
0
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     //存在Cookie时则不要求输入任何信息
     if (Validation(rtbInput.Text.IsNullOrEmptyOrWhiteSpace()))
     {
         var result = Save();
         if (result)
         {
             if (cbIsContinue.Checked)
             {
                 FormUtils.ShowInfoMessage("保存成功,你可以选择其他站点继续添加。");
             }
             else
             {
                 this.DialogResult = DialogResult.OK;
             }
             OnUserChangeEventArgs el = new OnUserChangeEventArgs();
             el.User = User;
             OnUserChanged(el);
         }
     }
 }
Exemple #9
0
        private void BtnDel_Click(object sender, EventArgs e)
        {
            PTUser user = ((sender as Control).Tag as PTUser);

            if (user == null)
            {
                throw new Exception("获取用户数据失败。");
            }
            else
            {
                YUEnums.PTEnum  siteId = user.Site.Id;
                string          delSql = "DELETE FROM USER WHERE PTSITEID = @PTSITEID";
                SQLiteParameter parm   = new SQLiteParameter("@PTSITEID", DbType.Int32);
                parm.Value = (int)siteId;
                if (DBUtils.ExecuteNonQuery(delSql, parm) > 0)
                {
                    OnUserChangeEventArgs el = new OnUserChangeEventArgs();
                    el.User = user;
                    OnUserChanged(el);
                }
            }
        }
Exemple #10
0
 private void Frm_UserChanged(object sender, OnUserChangeEventArgs e)
 {
     OnUserChanged(e);
 }