Esempio n. 1
0
        private void OnItemClick(object sender, EventArgs e)
        {
            //Event handler for menu/toolbar item clicked
            ISchedule schedule = null;

            try {
                ToolStripItem item = (ToolStripItem)sender;
                switch (item.Name)
                {
                case "msFileNew":
                case "tsNew":
                case "csNew":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.New();
                    break;

                case "msFileOpen":
                case "tsOpen":
                case "csOpen":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.Open();
                    break;

                case "msFileClone":
                case "tsClone":
                case "csClone":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.Clone();
                    break;

                case "msFileCancel":
                case "tsCancel":
                case "csCancel":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.Cancel();
                    break;

                case "msFileSaveAs":
                    SaveFileDialog dlgSave = new SaveFileDialog();
                    dlgSave.AddExtension     = true;
                    dlgSave.Filter           = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
                    dlgSave.FilterIndex      = 0;
                    dlgSave.Title            = "Export Schedule...";
                    dlgSave.FileName         = this.mActiveForm.Text;
                    dlgSave.CheckFileExists  = false;
                    dlgSave.OverwritePrompt  = true;
                    dlgSave.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
                    if (dlgSave.ShowDialog(this) == DialogResult.OK)
                    {
                        schedule = (ISchedule)this.mActiveForm;
                        schedule.Save(dlgSave.FileName);
                    }
                    break;

                case "msFileExport":
                case "csExport":
                    SaveFileDialog dlgExport = new SaveFileDialog();
                    dlgExport.AddExtension     = true;
                    dlgExport.Filter           = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
                    dlgExport.FilterIndex      = 0;
                    dlgExport.Title            = "Export Pickup Orders...";
                    dlgExport.FileName         = "DailyPickups";
                    dlgExport.CheckFileExists  = false;
                    dlgExport.OverwritePrompt  = false;
                    dlgExport.InitialDirectory = ConfigurationManager.AppSettings["ExportPath" + Program.TerminalCode];
                    if (dlgExport.ShowDialog(this) == DialogResult.OK)
                    {
                        schedule = (ISchedule)this.mActiveForm;
                        schedule.Export(dlgExport.FileName);
                    }
                    break;

                case "tsExport":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.Export();
                    break;

                case "msFilePageSetup":
                    UltraGridPrinter.PageSettings();
                    break;

                case "msFilePrint":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.Print(true);
                    break;

                case "msFilePrintPreview":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.PrintPreview();
                    break;

                case "msFileExit":
                    this.Close();
                    break;

                case "msViewRefresh":
                case "tsRefresh":
                    this.mActiveForm.Refresh();
                    break;

                case "msViewFont":
                    FontDialog fd = new FontDialog();
                    fd.FontMustExist = true;
                    fd.Font          = this.Font;
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        this.Font = this.msMain.Font = this.tsMain.Font = this.tsNav.Font = this.ssMain.Font = fd.Font;
                    }
                    break;

                case "msViewFullScreen":
                case "tsFullScreen":
                    this.tsNav.Visible = !(this.msViewFullScreen.Checked = (!this.msViewFullScreen.Checked));
                    break;

                case "msViewTemplates":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.TemplatesVisible = (this.msViewTemplates.Checked = (!this.msViewTemplates.Checked));
                    break;

                case "msViewToolbar":   this.tsMain.Visible = (this.msViewToolbar.Checked = (!this.msViewToolbar.Checked)); break;

                case "msViewStatusBar": this.ssMain.Visible = (this.msViewStatusBar.Checked = (!this.msViewStatusBar.Checked)); break;

                case "msToolsConfig":   App.ShowConfig(); break;

                case "msWinCascade": this.LayoutMdi(MdiLayout.Cascade); break;

                case "msWinTileH":      this.LayoutMdi(MdiLayout.TileHorizontal); break;

                case "msWinTileV":      this.LayoutMdi(MdiLayout.TileVertical); break;

                case "msHelpAbout":     new dlgAbout(App.Product + " Application", App.Version, App.Copyright, App.Configuration).ShowDialog(this); break;

                case "tsTempNew":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.NewTemplate();
                    break;

                case "tsTempOpen":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.OpenTemplate();
                    break;

                case "tsTempCancel":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.CancelTemplate();
                    break;

                case "tsTempLoad":
                    schedule = (ISchedule)this.mActiveForm;
                    schedule.LoadTemplates();
                    break;
                }
            }
            catch (Exception ex) { App.ReportError(ex); }
            finally { setUserServices(); this.Cursor = Cursors.Default; }
        }