/// <summary> /// The btn check fare flex_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void btnCheckFareFlex_Click(object sender, EventArgs e) { var senderBtn = sender as Button; senderBtn.Enabled = false; var param = this.GetExecutionParam(false, false, false, OperationMode.Unspecified); var newForm = new CheckFareForm(param); newForm.Attach(new CheckFareController()); newForm.Show(); senderBtn.Enabled = true; }
/// <summary> /// The run. /// </summary> /// <param name="args"> /// The args. /// </param> internal void Run(string[] args) { ExecutionParam executionParam; if (!ExecutionParam.Parse(args, AppUtil.GetLocalDataPath(this.GUI_INI_FILENAME), this.Logger, out executionParam)) { ExecutionParam.ShowHelp(); return; } this.Logger.InfoFormat("Application {0} {1} was started!", AppUtil.ProductName, AppUtil.ProductVersion); this.MuteApplicationVolume(); if (args.Length < 1 && !SingleInstance.Start()) { // Show up other instance if no parameter was specified if (MessageBox.Show( "Another instance was already running. Do you want to start a new instance ?", AppUtil.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { SingleInstance.ShowFirstInstance(); return; } } string historyFile = AppUtil.GetLocalDataPath(this.HISTORY_FILENAME); bool firstStart = !File.Exists(historyFile); if (firstStart) { Directory.CreateDirectory(AppUtil.LocalProductDataPath); File.Create(historyFile); using (var introForm = new IntroForm()) introForm.ShowDialog(); } var globalContext = WinFormGlobalContext.GetInstance(this.Logger); globalContext.SetFirstStart(firstStart); AppContext.Initialize(globalContext); MonitorEnvironment env = this.GetEnvironment(executionParam, globalContext); if (env == null) { Environment.Exit(1); } env.Logger = this.Logger; globalContext.SetEnvironment(env); var mainForm = new FlightStatisticForm(null, executionParam, true); CheckFareForm checkFareForm = null; if (executionParam != null && executionParam.OperationMode != OperationMode.Unspecified) { mainForm.Hide(); mainForm.WindowState = FormWindowState.Minimized; var controller = new CheckFareController(executionParam); checkFareForm = new CheckFareForm(executionParam); checkFareForm.Attach(controller); if (executionParam.IsMinimized) { checkFareForm.WindowState = FormWindowState.Minimized; checkFareForm.ShowInTaskbar = false; } checkFareForm.Show(); } Application.Run(mainForm); SingleInstance.Stop(); this.Logger.Info("Application stopped"); }
/// <summary> /// The mnu check this date_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void mnuCheckThisDate_Click(object sender, EventArgs e) { var lv = ((ToolStripItem)sender).Tag as FlightDataListView; if (lv == null) { return; } var selFlight = lv.SelectedFlight; if (selFlight != null) { if (selFlight.OutboundLeg.Departure < DateTime.Now) { return; } var param = this.GetExecutionParam(false, false, false, OperationMode.ShowFare); param.DepartureDate = selFlight.OutboundLeg.Departure; param.ReturnDate = selFlight.InboundLeg.Departure; param.DepartureDateRange = param.ReturnDateRange = DateRangeDiff.Empty; param.MinStayDuration = param.MaxStayDuration = (int)(param.ReturnDate - param.DepartureDate).TotalDays; var checkFareForm = new CheckFareForm(param); checkFareForm.Attach(new CheckFareController()); checkFareForm.Show(); } }