Ejemplo n.º 1
0
        private void GetUserAdmin()
        {
            menuStrip1.Invoke(new Action(() => menuStrip1.Enabled           = false));
            buttonSignIn.Invoke(new Action(() => buttonSignIn.Enabled       = false));
            textBoxLogin.Invoke(new Action(() => textBoxLogin.Enabled       = false));
            textBoxPassword.Invoke(new Action(() => textBoxPassword.Enabled = false));
            IEnumerable <DALServerDB.Infrastructure.User> user1 = repUs.FindAll(p => p.Login == textBoxLogin.Text && p.IsAdmin == true);

            if (user1 != null)
            {
                User = user1.FirstOrDefault(x => DALServerDB.Models.Crypter.GetCrypt(x.Password) == textBoxPassword.Text);
            }
            if (User == null)
            {
                MessageBox.Show(Environment.NewLine + "user not found!!!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                menuStrip1.Invoke(new Action(() => menuStrip1.Enabled           = true));
                buttonSignIn.Invoke(new Action(() => buttonSignIn.Enabled       = true));
                textBoxLogin.Invoke(new Action(() => textBoxLogin.Enabled       = true));
                textBoxPassword.Invoke(new Action(() => textBoxPassword.Enabled = true));
                return;
            }
            if (User.IsAdmin)
            {
                this.Invoke(new Action(() =>
                {
                    FormMain form = new FormMain(User, Connection);
                    form.Owner    = this;
                    this.Hide();
                    form.ShowDialog();
                }));
            }
        }
Ejemplo n.º 2
0
 private void SetMenu(MenuStrip Info)
 {
     if (Info.InvokeRequired)
     {
         menuDelegate DDD = new menuDelegate(SetMenu);
         Info.Invoke(DDD, new object[] { Info });
     }
     else
     {
         экспортToolStripMenuItem.Enabled = true;
         вTxtToolStripMenuItem.Enabled = true;
         вXSLToolStripMenuItem.Enabled = true;
     }
 }
Ejemplo n.º 3
0
        public override void LoadEditorForm(TabControl ScriptsTab, MenuStrip mainMenu)
        {
            ScriptsTab.TabPages.Add(AddEditorTab());
            this.editorText.KeyPress += new KeyPressEventHandler(editorText_KeyPress);

            mainMenu.Invoke((MethodInvoker)delegate()
            {
                scriptMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
                    loadScript, unloadScript, newScript, saveScript});

                int i = 1;

                foreach (String file in icechatVBScripts.listScripts)
                {
                    if (File.Exists(this.CurrentFolder + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + file))
                    {
                        System.Diagnostics.Debug.WriteLine("loading script file into editor and add to menu: " + file);

                        ToolStripMenuItem s = new ToolStripMenuItem(file);
                        s.Name = file;
                        s.Click += new EventHandler(loadedScript_Click);
                        s.Tag = "saved";

                        //load the first one in the editor
                        if (i == 1)
                        {
                            s.Checked = true;

                            StreamReader sr = new StreamReader(this.CurrentFolder + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + file);
                            editorText.Text = sr.ReadToEnd();
                            sr.Close();
                        }

                        loadedScripts.DropDownItems.AddRange(new ToolStripItem[] {
                            s
                        });

                        i++;
                    }
                }

                mainMenu.Items.Add(scriptMenu);
                mainMenu.Items.Add(loadedScripts);

                //System.Diagnostics.Debug.WriteLine("script items:" + loadedScripts.DropDownItems.Count);

            });
        }