Beispiel #1
0
 /// <summary>
 /// 保存用户自动登录的信息
 /// </summary>
 /// <param name="user"></param>
 public void SaveAutoLoginInfo(AutoLoginUser user)
 {
     using (Stream fStream = new FileStream(ConfigName, FileMode.Create, FileAccess.ReadWrite))
     {
         try
         {
             BinaryFormatter binFormat = new BinaryFormatter();//创建二进制序列化器
             binFormat.Serialize(fStream, user);
         }
         catch (System.Exception ex)
         {
             throw ex;
         }
     }
 }
Beispiel #2
0
 public Login(AutoLoginUser loginUser)
 {
     InitializeComponent();
     InitUIProperty();
     LoginUser = loginUser;
 }
Beispiel #3
0
        public MainForm(AutoLoginUser loginUser)
        {
            InitializeComponent();

            //自定义滚动栏的样式
            var mCommonSkins = CommonSkins.GetSkin(UserLookAndFeel.Default.ActiveLookAndFeel);
            SkinElement skinScrollButton = mCommonSkins[CommonSkins.SkinScrollButton];
            skinScrollButton.Color.BackColor = Color.FromArgb(0, 126, 206);
            skinScrollButton.Image.ImageCount = 0;
            skinScrollButton.Glyph.ImageCount = 0;
            //skinScrollButton.Image.SetImage(Properties.Resources.scrollbutton_glyph, Color.Transparent);
            //skinScrollButton.Glyph.SetImage(Properties.Resources.scrollbutton_glyph, Color.Transparent);
            SkinElement skinScrollButtonThumb = mCommonSkins[CommonSkins.SkinScrollButtonThumb];
            skinScrollButtonThumb.Color.BackColor = Color.Transparent;
            skinScrollButtonThumb.Image.ImageCount = 0;
            skinScrollButtonThumb.Glyph.ImageCount = 0;
            //skinScrollButtonThumb.Image.SetImage(Properties.Resources.scrollthumbbutton, Color.Transparent);
            //skinScrollButtonThumb.Glyph.SetImage(Properties.Resources.scrollthumbbutton, Color.Transparent);
            SkinElement skinSkinScrollShaft = mCommonSkins[CommonSkins.SkinScrollShaft];
            skinSkinScrollShaft.Color.BackColor = Color.Transparent;
            skinSkinScrollShaft.Image.ImageCount = 0;
            LookAndFeelHelper.ForceDefaultLookAndFeelChanged();

            mainWindowsUIView.Appearance.BackColor = Color.FromArgb(0, 126, 206);
            //mainWindowsUIView.AppearanceActionsBar.BackColor = Color.FromArgb(0, 169, 254);
            mainWindowsUIView.AppearanceActionsBar.BackColor = Color.FromArgb(0, 90, 144);

            mSrceenWidth = Screen.PrimaryScreen.Bounds.Width;
            mainWindowsUIView.TileContainerProperties.ItemSize = 180 + (int)((mSrceenWidth - 1500) * 0.05);

            DelegateAction mExitAction = new DelegateAction(canExecuteExitFunction, exitActionFunction);
            mExitAction.Caption = "Exit";
            mExitAction.Type = ActionType.Navigation;
            mExitAction.Edge = ActionEdge.Right;
            mExitAction.Behavior = ActionBehavior.HideBarOnClick;
            mExitAction.Image = Properties.Resources.icon_close32;
            mainWindowsUIView.ContentContainerActions.Add(mExitAction);

            DelegateAction mDesktopAction = new DelegateAction(canExecuteDesktopFunction, desktopActionFunction);
            mDesktopAction.Caption = "Desktop";
            mDesktopAction.Type = ActionType.Navigation;
            mDesktopAction.Edge = ActionEdge.Right;
            mDesktopAction.Behavior = ActionBehavior.HideBarOnClick;
            mDesktopAction.Image = Properties.Resources.icon_desktop32;
            mainWindowsUIView.ContentContainerActions.Add(mDesktopAction);

            DelegateAction mAboutAction = new DelegateAction(canExecuteAboutFunction, aboutActionFunction);
            mAboutAction.Caption = "About";
            mAboutAction.Type = ActionType.Navigation;
            mAboutAction.Edge = ActionEdge.Right;
            mAboutAction.Behavior = ActionBehavior.HideBarOnClick;
            mAboutAction.Image = Properties.Resources.icon_about32;
            mainWindowsUIView.ContentContainerActions.Add(mAboutAction);

            mThemeAction = new DelegateAction(canExecuteThemeFunction, themeActionFunction);
            mThemeAction.Caption = "Picture Theme";
            mThemeAction.Type = ActionType.Context;
            mThemeAction.Edge = ActionEdge.Left;
            mThemeAction.Behavior = ActionBehavior.HideBarOnClick;
            mThemeAction.Image = Properties.Resources.icon_pic32;
            mainWindowsUIView.ContentContainerActions.Add(mThemeAction);

            mainWindowsUIView.AddDocument(mPopupTjControl);
            mainWindowsUIView.AddDocument(mPopupYHEditControl);

            mQxDic.Add("SW", 95);
            mQxDic.Add("WD", 30);
            tileQX.Elements[1].Text = string.Format("水位:{0}m  温度:{1}°C", mQxDic["SW"], mQxDic["WD"]);

            if (loginUser!=null)
            {
                this.tileYHGL.Elements[2].Text = String.Format("登录名:{0}", loginUser.UserName);
            }

            loadData();
        }
Beispiel #4
0
        private void UserLogin(object sender, EventArgs e)
        {
            Action Login = () =>
            {
                if (string.IsNullOrEmpty(txtUserName.Text.Trim()))
                {
                    Error("用户名不能为空");
                    return;
                }
                else if (string.IsNullOrEmpty(txtPassword.Text.Trim()))
                {
                    Error("密码不能为空");
                    return;
                }
                btnLogin.Text = "正在登录...";
                btnLogin.Enabled = false;

                IList<USER> users = USERDao.QueryForList(null).Where(
                    p => p.NAME == txtUserName.Text.Trim() && p.PASSWORD == txtPassword.Text.Trim()).ToList();

                if (users != null && users.Count > 0)
                {
                    this.DialogResult = DialogResult.OK;
                    IList<USERROLE> userRoles = USERROLEDao.QueryForListByUserId(users[0].ID);
                    IList<ROLERIGHT> roleRights = ROLERIGHTDao.QueryForList(null).Where(p => p.ROLE_ID == userRoles[0].ROLE_ID).ToList();
                    IList<RIGHT> rights = new List<RIGHT>();
                    foreach (var roleRight in roleRights)
                    {
                        foreach (var right in RIGHTDao.QueryForList(null).Where(p => p.ID == roleRight.RIGHT_ID))
                        {
                            rights.Add(right);
                        }
                    }

                    AutoLoginUtil autoLogin = new AutoLoginUtil();
                    AutoLoginUser loginUser = new AutoLoginUser();
                    loginUser.UserName = UserName;
                    loginUser.PassWord = PassWord;
                    loginUser.rights = rights;
                    if (ckRemeberPwd.Checked)
                    {
                        loginUser.RememberPwd = true;
                        autoLogin.SaveAutoLoginInfo(loginUser);
                    }
                    else
                    {
                        autoLogin.SaveAutoLoginInfo(new AutoLoginUser());
                    }
                    LoginUser = loginUser;
                }
                else
                {
                    btnLogin.Text = "登录";
                    btnLogin.Enabled = true;
                    string errorMessage = "用户名或密码错误";
                    Error(errorMessage);
                }
            };
            this.BeginInvoke(Login);
        }