using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FCM0000
{
    public partial class fUserGroupPermission : FCOMMON.fBase
    {
        public int permission = 0;
        public fUserGroupPermission(int permission_)
        {
            InitializeComponent();
            Properties.Settings.Default["gwcs"] = FCOMMON.info.CS;
            this.permission = permission_;
        }

        private void fUserGroupPermission_Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
           foreach(var ctl in this.Controls)
           {
               if(ctl.GetType() == typeof(CheckBox))
               {
                   var chk = ctl as CheckBox;
                   if(chk.Tag == null) continue;
                   int idx = int.Parse(chk.Tag.ToString());
                   var bitValue = FCOMMON.Util.getBit( this.permission, idx);
                   chk.Checked = bitValue;
               }
           }
        }
     
        private void button1_Click(object sender, EventArgs e)
        {
           
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            foreach (var ctl in this.Controls)
            {
                if (ctl.GetType() == typeof(CheckBox))
                {
                    var chk = ctl as CheckBox;
                    if (chk.Tag == null) continue;
                    int idx = int.Parse(chk.Tag.ToString());
                    FCOMMON.Util.setBit(ref this.permission, idx, chk.Checked);
                }
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }
    }
}
