DialogResult EditEntry(FilterEntry entry, bool newentry, bool allowdel) { ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); DateTime starttime = EDDConfig.Instance.ConvertTimeToSelectedFromUTC(entry.StartTimeUTC); DateTime endtime = EDDConfig.Instance.ConvertTimeToSelectedFromUTC(entry.EndTimeUTC); int width = 430; f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Name:".T(EDTx.UserControlCombatPanel_Name), new Point(10, 40), new Size(80, 24), "")); f.Add(new ExtendedControls.ConfigurableForm.Entry("Name", typeof(ExtendedControls.ExtTextBox), entry.Name, new Point(100, 40), new Size(width - 100 - 20, 24), "Give name to campaign".T(EDTx.UserControlCombatPanel_C1)) { clearonfirstchar = newentry }); f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Faction:".T(EDTx.UserControlCombatPanel_Faction), new Point(10, 70), new Size(80, 24), "")); f.Add(new ExtendedControls.ConfigurableForm.Entry("Faction", typeof(ExtendedControls.ExtTextBox), entry.TargetFaction, new Point(100, 70), new Size(width - 100 - 20, 24), "Optional faction to target".T(EDTx.UserControlCombatPanel_C2))); f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Start:".T(EDTx.UserControlCombatPanel_Start), new Point(10, 100), new Size(80, 24), "")); f.Add(new ExtendedControls.ConfigurableForm.Entry("DTS", typeof(ExtendedControls.ExtDateTimePicker), starttime.ToStringZulu(), new Point(100, 100), new Size(width - 100 - 20, 24), "Select Start time".T(EDTx.UserControlCombatPanel_C3)) { customdateformat = "yyyy-MM-dd HH:mm:ss" }); f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "End:".T(EDTx.UserControlCombatPanel_End), new Point(10, 130), new Size(80, 24), "")); f.Add(new ExtendedControls.ConfigurableForm.Entry("DTE", typeof(ExtendedControls.ExtDateTimePicker), endtime.ToStringZulu(), new Point(100, 130), new Size(width - 100 - 20, 24), "Select Start time".T(EDTx.UserControlCombatPanel_C4)) { customdateformat = "yyyy-MM-dd HH:mm:ss" }); f.AddOK(new Point(width - 100, 180), "Press to Accept".T(EDTx.UserControlCombatPanel_C5)); f.AddCancel(new Point(width - 200, 180), "Press to Cancel".T(EDTx.UserControlCombatPanel_C6)); if (allowdel) { f.Add(new ExtendedControls.ConfigurableForm.Entry("Delete", typeof(ExtendedControls.ExtButton), "Delete".T(EDTx.Delete), new Point(10, 180), new Size(80, 24), "Press to Delete".T(EDTx.UserControlCombatPanel_C7))); } f.Trigger += (dialogname, controlname, tag) => { if (controlname == "OK") { FilterEntry fe = displayedfilterentries.Find(x => x.UniqueID.Equals(f.Get("Name"))); if (fe != null && fe != entry) { ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "Name of campaign already in use, cannot overwrite".T(EDTx.UserControlCombatPanel_NoOverwrite), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { f.ReturnResult(DialogResult.OK); } } else if (controlname == "Delete") { if (f.Get("Name").Equals(entry.Name)) { if (ExtendedControls.MessageBoxTheme.Show(this.FindForm(), string.Format("Confirm deletion of {0}".T(EDTx.UserControlCombatPanel_Condel), entry.Name), "Warning".T(EDTx.Warning), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { f.ReturnResult(DialogResult.Abort); } } else { ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "Name changed - can't delete".T(EDTx.UserControlCombatPanel_NC), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (controlname == "Cancel" || controlname == "Close") { f.ReturnResult(DialogResult.Cancel); } }; DialogResult res = f.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Campaign".T(EDTx.Campaign), closeicon: true); if (res == DialogResult.OK) { entry.Reset(f.Get("Name"), f.Get("Faction"), EDDConfig.Instance.ConvertTimeToUTCFromSelected(f.GetDateTime("DTS").Value), EDDConfig.Instance.ConvertTimeToUTCFromSelected(f.GetDateTime("DTE").Value)); } return(res); }
public void EDSMSend() { var helist = EDSMJournalSync.GetListToSend(history.EntryOrder()); // find out what to send.. if (helist.Count >= 500) { ExtendedControls.ConfigurableForm cf = new ExtendedControls.ConfigurableForm(); int width = 400; DateTime lasthe = helist.Last().EventTimeUTC; cf.Add(new ExtendedControls.ConfigurableForm.Entry("UC", typeof(Label), string.Format("There are {0} EDSM reports to send, this will take time and bandwidth, choose from the following what to do. Entries before this will be marked as sent.".T(EDTx.EDDiscoveryForm_SendEDSMCaption), helist.Count), new Point(5, 30), new Size(width - 5 - 20, 100), null) { textboxmultiline = true }); cf.Add(new ExtendedControls.ConfigurableForm.Entry("All", typeof(ExtendedControls.ExtButton), "Send All to EDSM".T(EDTx.EDDiscoveryForm_SendEDSMAll), new Point(5, 130), new Size(width - 5 - 20, 24), null)); cf.Add(new ExtendedControls.ConfigurableForm.Entry("Today", typeof(ExtendedControls.ExtButton), "Send Last 24 Hours of entries to EDSM".T(EDTx.EDDiscoveryForm_SendEDSM24), new Point(5, 180), new Size(width - 5 - 20, 24), null)); cf.Add(new ExtendedControls.ConfigurableForm.Entry("Custom", typeof(ExtendedControls.ExtButton), "Send From".T(EDTx.EDDiscoveryForm_SendEDSMFrom), new Point(5, 230), new Size(80, 24), null)); cf.Add(new ExtendedControls.ConfigurableForm.Entry("Date", typeof(ExtendedControls.ExtDateTimePicker), lasthe.AddDays(-28).ToStringZulu(), new Point(100, 230), new Size(width - 100 - 20, 24), null)); cf.Add(new ExtendedControls.ConfigurableForm.Entry("None", typeof(ExtendedControls.ExtButton), "EDSM is up to date - send Nothing more".T(EDTx.EDDiscoveryForm_SendEDSMNone), new Point(5, 280), new Size(width - 5 - 20, 24), null)); cf.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ExtButton), "I'll decide later, do nothing".T(EDTx.EDDiscoveryForm_SendEDSMCancel), new Point(5, 330), new Size(width - 5 - 20, 24), null)); DateTime date = DateTime.UtcNow; cf.Trigger += (dialogname, controlname, tag) => { if (controlname.Contains("All")) { date = new DateTime(1900, 1, 1); cf.ReturnResult(DialogResult.OK); } else if (controlname.Contains("Today")) { date = lasthe.AddDays(-1); cf.ReturnResult(DialogResult.OK); } else if (controlname.Contains("Custom")) { date = cf.GetDateTime("Date").Value.ToUniversalTime(); cf.ReturnResult(DialogResult.OK); } else if (controlname.Contains("None")) { cf.ReturnResult(DialogResult.OK); } else if (controlname.Contains("Cancel")) { cf.ReturnResult(DialogResult.Cancel); } }; if (cf.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Sending a large number of EDSM Entries".T(EDTx.EDDiscoveryForm_SendEDSMTitle)) == DialogResult.Cancel) { return; } var jes = helist.Where(x => x.EventTimeUTC < date).Select(x => x.journalEntry).ToList(); JournalEntry.SetEdsmSyncList(jes); helist = EDSMJournalSync.GetListToSend(history.EntryOrder()); // find out what to send.. } if (helist.Count > 0) { EDSMJournalSync.SendEDSMEvents(l => LogLine(l), helist); } }