Exemple #1
0
 private void D_Load(object sender, EventArgs e)
 {
     Atiran.UI.WindowsForms.UIElements.Form frm = new Atiran.UI.WindowsForms.UIElements.Form
     {
         KeyPreview    = true,
         StartPosition = FormStartPosition.CenterScreen,
         Width         = usercontrol_.Width,
         Height        = usercontrol_.Height
     };
     if (ChangeSizeFormBySizeOfTheUserControl)
     {
         frm.MaximumSize = new Size(usercontrol_.Width, usercontrol_.Height);
     }
     usercontrol_.Dock = DockStyle.Fill;
     frm.WindowState   = FormWindowState.Normal;
     frm.Controls.Add(usercontrol_);
     frm.ShowDialog();
     D.Close();
 }
Exemple #2
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
            case (Keys.Menu | Keys.Alt):
            {
                List <HubButton> buttons = hubItem.Controls.OfType <HubButton>().ToList();

                buttons.ForEach(i =>
                    {
                        if (i.SubSystemID == 8 | i.SubSystemID == 12)
                        {
                            i.Title.Select(1, 1);
                        }
                        else
                        {
                            i.Title.Select(0, 1);
                        }

                        i.Title.SelectionColor = Color.Crimson;
                    });
                timer.Start();
                return(true);
            }

            case (Keys.Alt | Keys.H):
            {
                HubButton button = new HubButton(Definitions.EnvironmentNames.BasicInformation, this);
                button.RunModule(Definitions.EnvironmentNames.BasicInformation);
                button.Dispose();
                return(true);
            }

            case (Keys.Alt | Keys.J):
            {
                HubButton button = new HubButton(Definitions.EnvironmentNames.Settings, this);
                button.RunModule(Definitions.EnvironmentNames.Settings);
                button.Dispose();
                return(true);
            }

            case (Keys.Alt | Keys.A):
            {
                HubButton button = new HubButton(Definitions.EnvironmentNames.BackupAndRestore, this);
                button.RunModule(Definitions.EnvironmentNames.BackupAndRestore);
                button.Dispose();
                return(true);
            }

            case ((Keys)Atiran.Connections.Enums.ShortcutKeyEnum.HelpKey):
            {
                Help H = new Help();
                UserControlLoader u = new UserControlLoader(H, true, false, true, false);
                return(true);
            }

            case (Keys.Alt | Keys.F4):
            {
                UI.WindowsForms.MessageBoxes.MessageBoxWarning.state = 0;
                DialogResult close =
                    Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيام سيستم",
                                                                                                "آيا مي خواهيد از سيستم خارج شويد؟", "w");
                UI.WindowsForms.MessageBoxes.MessageBoxWarning.state = 1;
                if (close == DialogResult.Yes)
                {
                    if (Connections.Operaions.UserFormPermissionOp.FormPermission.CheckBackupPermission())
                    {
                        DialogResult res =
                            Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show(
                                "پيام سيستم", "آيا مي خواهيد از اطلاعات پشتيبان بگيريد؟", "w");
                        if (res == DialogResult.Yes)
                        {
                            // backup
                            UI.WindowsForms.Controls.FastBackup c = new UI.WindowsForms.Controls.FastBackup();
                            UserControlLoader(c);
                        }
                    }

                    Application.Exit();
                }

                return(true);
            }

            case (Keys)Atiran.Connections.Enums.ShortcutKeyEnum.SearchFormsKey:
            {
                try
                {
                    List <Atiran.Connections.AtiranAccModel.Menu> menu = new List <Connections.AtiranAccModel.Menu>();
                    AtiranSpotlight spotlight = new AtiranSpotlight(menu);
                    new UserControlLoader(spotlight, true, false, true);
                    if (menu.Count > 0)
                    {
                        if (FormPermission.AccessUserForm((int?)menu[0].FormID ?? 0))
                        {
                            RunnerFromHub((Definitions.EnvironmentNames)menu[0].SubSystemID - 1, menu[0], true);
                        }
                        else
                        {
                            UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيام", "شما به اين فرم دسترسي نداريد", "i");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                return(true);
            }

            //case (Keys.Alt | Keys.F7):
            //    {
            //        try
            //        {
            //            List<Atiran.Connections.AtiranAccModel.Menu> menu = new List<Connections.AtiranAccModel.Menu>();
            //            UI.WindowsForms.Shortcuts.AtiranShortcuts ShortCutHere = new UI.WindowsForms.Shortcuts.AtiranShortcuts(menu);
            //            ShortCutHere.pnlLeft.Visible = false;
            //            ShortCutHere.Width = 470;
            //            Atiran.UI.WindowsForms.UIElements.Form frm = new Atiran.UI.WindowsForms.UIElements.Form
            //            {
            //                KeyPreview = true,
            //                StartPosition = System.Windows.Forms.FormStartPosition.Manual,
            //                Width = ShortCutHere.Width,
            //                Height = ShortCutHere.Height,
            //                MaximumSize = new Size(ShortCutHere.Width, ShortCutHere.Height)
            //            };
            //            ShortCutHere.Dock = System.Windows.Forms.DockStyle.Fill;
            //            frm.WindowState = System.Windows.Forms.FormWindowState.Normal;
            //            frm.Controls.Add(ShortCutHere);
            //            frm.Deactivate += (sender, e) => { ShortCutHere.ParentForm.Close(); };
            //            frm.Location = new Point(750, 39);
            //            frm.ShowDialog();
            //            if (menu.Count > 0)
            //            {
            //                if (Connections.Operaions.UserFormPermissionOp.FormPermission.AccessUserForm((int?)menu[0].FormID ?? 0))
            //                {
            //                    RunnerFromHub((Definitions.EnvironmentNames)menu[0].SubSystemID - 1, menu[0], true);
            //                }
            //                else
            //                {
            //                    UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيام", "شما به اين فرم دسترسي نداريد", "i");
            //                }
            //            }
            //        }
            //        catch (Exception ex)
            //        {
            //            MessageBox.Show(ex.ToString());
            //            throw;
            //        }
            //        return true;
            //    }
            case (Keys)Atiran.Connections.Enums.ShortcutKeyEnum.ActivatedFormKey:
            {
                try
                {
                    if (Atiran.UI.WindowsForms.UIElements.TabBar.StaticTabs == null || Atiran.UI.WindowsForms.UIElements.TabBar.StaticTabs.Count == 0)
                    {
                        Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيغام", "هيچ فرمي باز نشده است");
                        return(true);
                    }
                    List <Guid>          menu       = new List <Guid>();
                    AtiranActivatedForms ActiveHere = new AtiranActivatedForms(menu)
                    {
                        Width = 470
                    };
                    Atiran.UI.WindowsForms.UIElements.Form frm = new Atiran.UI.WindowsForms.UIElements.Form
                    {
                        KeyPreview    = true,
                        StartPosition = System.Windows.Forms.FormStartPosition.Manual,
                        Width         = ActiveHere.Width,
                        Height        = ActiveHere.Height,
                        MaximumSize   = new Size(ActiveHere.Width, ActiveHere.Height)
                    };
                    ActiveHere.Dock = System.Windows.Forms.DockStyle.Fill;
                    frm.WindowState = System.Windows.Forms.FormWindowState.Normal;
                    frm.Controls.Add(ActiveHere);
                    frm.Deactivate += (sender, e) => { ActiveHere.ParentForm.Close(); };
                    //  frm.Location = new Point(MousePosition.X - 190, MousePosition.Y + 15);
                    frm.Location = new Point(800, 39);
                    // System.Windows.Forms.MessageBox.Show("X = " + MousePosition.X.ToString() + " Y = " + MousePosition.Y.ToString());
                    frm.ShowDialog();
                    if (menu.Count > 0)
                    {
                        foreach (Tab item in Atiran.UI.WindowsForms.UIElements.TabBar.StaticTabs)
                        {
                            if (item.control.UcGuid == menu.FirstOrDefault())
                            {
                                if (item.control.ProjectName == "Atiran.Accounting")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Accounting, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Accounting, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.BasicInformation")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.BasicInformation, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.BasicInformation, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.KalaGostaran")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.KalaGostaran, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.KalaGostaran, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Management")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.SalesManagement, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.SalesManagement, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Rahyab")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Rahyab, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Rahyab, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Reporting")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Reporting, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Reporting, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Sale")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Sales, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Sales, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Settings")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Settings, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Settings, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.SMS")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.SMS, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.SMS, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.TaskManager")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.EMS, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.EMS, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.Treasury")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.Treasury, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.Treasury, TabGUID: item.control.UcGuid);
                                }
                                else if (item.control.ProjectName == "Atiran.BackupAndRestore")
                                {
                                    HubButton basicInformation = new HubButton(Definitions.EnvironmentNames.BackupAndRestore, this);
                                    basicInformation.RunModule(Definitions.EnvironmentNames.BackupAndRestore, TabGUID: item.control.UcGuid);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                return(true);
            }
            }

            if (keyData == Keys.Escape)
            {
                // new by sharafzade
                UI.WindowsForms.MessageBoxes.MessageBoxWarning.state = 0;
                DialogResult res = Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيام سيستم", "آيا مي خواهيد آتيران را ترك كنيد؟", "w");
                UI.WindowsForms.MessageBoxes.MessageBoxWarning.state = 1;
                if (res == DialogResult.Yes)
                {
                    if (Connections.Operaions.UserFormPermissionOp.FormPermission.CheckBackupPermission())
                    {
                        DialogResult res1 = Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيام سيستم", "آيا مي خواهيد از اطلاعات پشتيبان بگيريد؟", "w");
                        if (res1 == DialogResult.Yes)
                        {
                            // backup
                            UI.WindowsForms.Controls.FastBackup c = new UI.WindowsForms.Controls.FastBackup();
                            UserControlLoader(c);
                        }
                    }

                    Application.Exit();
                }
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }