public EntityEditPanel(string modelName, TrackerContext context, MainForm owner = null) { this.ModelName = modelName; this.Model = DonationModels.GetModel(this.ModelName); this.Context = context; this.Owner = owner; }
public EntityAccessContext(string modelName, TrackerContext context) { this.ModelName = modelName; this.Model = DonationModels.GetModel(this.ModelName); this.Context = context; this.Busy = false; }
public DonorTab(MainForm owner, TrackerContext context) : base(owner, context, "donor") { this.DonorPanel = new DonorEditPanel(this.Owner, this.Context); this.SetPanel(this.DonorPanel); this.AddForm(this.DonorPanel.GetDonorFormBinding()); this.AddTable(this.DonorPanel.GetDonationsTableBinding(), this.Model.GetField("donations") as EntitySetModel); this.AddTable(this.DonorPanel.GetPrizeTableBinding(), this.Model.GetField("prizes") as EntitySetModel); }
public EntitySelectionCache(TrackerContext context, string model) { this.ModelName = model; this.Model = DonationModels.GetModel(this.ModelName); this.Context = context; this.AccessControl = new Mutex(); this.LastRefreshTime = DateTime.MinValue; this.PublicCache = new BiMap<int,string>(null, StringComparer.OrdinalIgnoreCase); this.BlockRequests = false; }
public DeleteContext(TrackerContext context, string model, int id) : base(context) { this.Id = id; this.Model = model; this.OnBegin += () => { this.Result = null; }; }
public SaveContext(TrackerContext context, string model, IEnumerable<KeyValuePair<string, string>> createParams) : base(context) { this.Model = model; this.CreateParams = createParams; this.Result = null; this.OnBegin += () => { this.Result = null; }; }
public EntityTab(MainForm owner, TrackerContext context, string rootModel) { InitializeComponent(); this.Owner = owner; this.Access = new EntityAccessContext(rootModel, context); this.Access.RefreshComplete += this.OnRefreshComplete; this.Access.SaveComplete += this.OnSaveComplete; this.Access.DeleteComplete += this.OnDeleteComplete; this.Access.Error += this.OnError; }
public SearchContext(TrackerContext context, string model, IEnumerable<KeyValuePair<string, string>> searchParams, bool singleSearch = false) : base(context) { this.SingleSearch = singleSearch; this.Model = model; this.SearchParams = searchParams; this.Result = null; this.OnBegin += () => { this.Result = null; }; }
public ChoiceEditPanel(MainForm owner, TrackerContext context) : base("choice", context, owner) { this.RootPanel = new TableLayoutPanel() { Dock = DockStyle.Fill, RowCount = 2, ColumnCount = 1, RowStyles = { new RowStyle(SizeType.Percent, 60.0f), new RowStyle(SizeType.Percent, 40.0f), }, ColumnStyles = { new ColumnStyle(SizeType.Percent, 100.0f), }, }; this.ChoiceForm = new EntityFormPanelConstruct("choice", new string[] { "total", "name", "description", "state", "speedrun", }, this.Context, this.Owner ) { Dock = DockStyle.Fill, }; this.OptionsTable = new EntityTablePanelConstruct("choiceoption", this.Owner, this.Context, new string[] { "name", "total", } ) { Dock = DockStyle.Fill, }; this.RootPanel.Controls.Add(this.ChoiceForm, 0, 0); this.RootPanel.Controls.Add(this.OptionsTable, 0, 1); this.Controls.Add(this.RootPanel); }
public RunTab(MainForm owner, TrackerContext context) : base(owner, context, "run") { this.RunPanel = new RunEditPanel(context, owner) { Dock = DockStyle.Fill }; this.SetPanel(this.RunPanel); this.AddForm(this.RunPanel.RunForm.Binding); this.AddTable(this.RunPanel.BidTable.Binding, this.Model.GetField("bids") as EntitySetModel); this.AddTable(this.RunPanel.PrizeTable.Binding, this.Model.GetField("endprizes") as EntitySetModel); }
public ChallengeTab(MainForm owner, TrackerContext context) : base(owner, context, "challenge") { this.Panel = new ChallengeEditPanel(this.Owner, this.Context) { Dock = DockStyle.Fill, }; this.SetPanel(this.Panel); EntityModel donationModel = DonationModels.ChoiceModel; this.AddForm(this.Panel.Forms.First()); }
public PrizeCategoryTab(MainForm owner, TrackerContext context) : base(owner, context, "prizecategory") { this.FormPanel = new EntityFormPanelConstruct("prizecategory", new string[] { "name" }, this.Context, this.Owner) { Dock = DockStyle.Fill, }; this.SetPanel(this.FormPanel); this.AddForm(this.FormPanel.Binding); }
public ChoiceTab(MainForm owner, TrackerContext context) : base(owner, context, "choice") { this.Panel = new ChoiceEditPanel(this.Owner, this.Context) { Dock = DockStyle.Fill, }; this.SetPanel(this.Panel); EntityModel donationModel = DonationModels.ChoiceModel; this.AddForm(this.Panel.Forms.First()); this.AddTable(this.Panel.Tables.First(), donationModel.GetField("options") as EntitySetModel); }
public EditEntityDialog(TrackerContext context, EntityFormPanel editPanel) { this.Context = context; this.EntityForm = editPanel; this.RootPanel = new TableLayoutPanel() { RowCount = 2, ColumnCount = 3, RowStyles = { new RowStyle() { SizeType = SizeType.Percent, Height = 100.0f }, new RowStyle() { SizeType = SizeType.AutoSize }, }, ColumnStyles = { new ColumnStyle() { SizeType = SizeType.Percent, Width = 100.0f }, new ColumnStyle() { SizeType = SizeType.AutoSize }, new ColumnStyle() { SizeType = SizeType.AutoSize }, }, Dock = DockStyle.Fill }; this.EntityForm.Dock = DockStyle.Fill; this.SaveButton = new Button() { Text = "Save", Dock = DockStyle.Fill }; this.SaveButton.Click += this.SaveButton_Click; this.CancelButton = new Button() { Text = "Cancel", Dock = DockStyle.Fill }; this.CancelButton.Click += this.CancelButton_Click; this.RootPanel.Controls.Add(this.EntityForm, 0, 0); this.RootPanel.SetColumnSpan(this.EntityForm, 3); this.RootPanel.Controls.Add(this.SaveButton, 1, 1); this.RootPanel.Controls.Add(this.CancelButton, 2, 1); this.OriginalData = this.EntityForm.Binding.SaveObject(); }
// eventually this should probably be replaced with a dictionary with a delegate function lookup // or something else cleaner public static EntityTab CreateEntityTab(string modelName, MainForm owner, TrackerContext context) { if (modelName.IEquals("donor")) return new DonorTab(owner, context); else if (modelName.IEquals("donation")) return new DonationTab(owner, context); else if (modelName.IEquals("prize")) return new PrizeTab(owner, context); else if (modelName.IEquals("prizecategory")) return new PrizeCategoryTab(owner, context); else if (modelName.IEquals("run")) return new RunTab(owner, context); else if (modelName.IEquals("choice")) return new ChoiceTab(owner, context); else if (modelName.IEquals("challenge")) return new ChallengeTab(owner, context); else throw new Exception("Error, navigation to " + modelName + " not supported"); }
public static FieldBinding CreateBindingField(FieldModel fieldModel, string fieldName = null, TrackerContext context = null, MainForm owner = null) { if (fieldModel is StringFieldModel) { StringFieldModel strModel = fieldModel as StringFieldModel; return new TextBoxBinding(new TextBox(), readOnly: fieldModel.ReadOnly, nullable: fieldModel.Nullable, longText: strModel.LongText); } else if (fieldModel is DateTimeFieldModel) { DateTimePicker picker = new DateTimePicker(); if (fieldName != null && fieldName.Contains("_gte")) picker.Value = picker.MinDate; else picker.Value = DateTime.Now; return new DateTimePickerBinding(picker, readOnly: fieldModel.ReadOnly, nullable: fieldModel.Nullable); } else if (fieldModel is BooleanFieldModel) return new CheckBoxBinding(new CheckBox(), readOnly: fieldModel.ReadOnly); else if (fieldModel is EnumFieldModel) return new ComboBoxBinding(new ComboBox(), fieldModel.FieldType, readOnly: fieldModel.ReadOnly); else if (fieldModel is MoneyFieldModel) return new MoneyFieldBinding(new TextBox(), readOnly: fieldModel.ReadOnly, allowNull: fieldModel.Nullable); else if (fieldModel is EntityFieldModel) { EntityFieldModel entityField = fieldModel as EntityFieldModel; EntitySelector selector = new EntitySelector() { Owner = owner, UseSelectionCache = DonationModels.IsCachingEntity(entityField.ModelName), }; if (context != null) selector.Initialize(context, entityField.ModelName); else throw new Exception("Error, trying to create entity selector without context"); return new EntitySelectorBinding(selector); } else throw new Exception("Unknown model type"); }
public SelectEventDialog(MainForm mainForm, TrackerContext context) { this.InitializeComponent(); this.MainForm = mainForm; this.ListBinding = new ListBinding<JObjectSimpleDisplay>(this.EventsList, x => new JObjectSimpleDisplay(x as JObject, "name"), "Display"); this.ListBinding.AddSelectionControl(this.SelectButton); this.Context = context; this.CurrentSearch = this.Context.DeferredSearch("event", new Dictionary<string, string> { { "q", "" } }); this.CurrentSearch.OnComplete += results => { this.ListBinding.LoadArray(results); this.ListBinding.EnableControls(); }; this.ListBinding.DisableControls(); this.CurrentSearch.Begin(); }
public ChallengeEditPanel(MainForm owner, TrackerContext context) : base("choice", context, owner) { this.ChallengeForm = new EntityFormPanelConstruct("challenge", new string[] { "total", "name", "description", "goal", "state", "speedrun", }, this.Context, this.Owner ) { Dock = DockStyle.Fill, }; this.Controls.Add(this.ChallengeForm); }
public ExternalProcessContext(TrackerContext context) : base(context) { }
public EntityFormPanelConstruct(string modelName, IEnumerable<string> fields, TrackerContext context = null, MainForm owner = null) : base(modelName) { this.Context = context; this.Owner = owner; this.TableLayout = new TableLayoutPanel() { Dock = DockStyle.Fill, AutoSize = true, AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink, }; this.TableLayout.ColumnCount = 2; this.TableLayout.ColumnStyles.Add(new ColumnStyle() { SizeType = SizeType.AutoSize }); this.TableLayout.ColumnStyles.Add(new ColumnStyle() { SizeType = SizeType.Percent, Width = 100.0f }); foreach (var fieldName in fields) { ++this.TableLayout.RowCount; RowStyle currentRowStyle = new RowStyle() { SizeType = SizeType.AutoSize, }; this.TableLayout.RowStyles.Add(currentRowStyle); FieldModel fieldModel = this.Model.GetField(fieldName); Label label = new Label() { Text = Util.SymbolToNatural(fieldName), Dock = DockStyle.Right, }; this.TableLayout.Controls.Add(label, 0, this.TableLayout.RowCount - 1); FieldBinding fieldBinding = FieldBindingHelper.CreateBindingField(fieldModel, fieldName, this.Context, this.Owner); fieldBinding.BoundControl.Dock = DockStyle.Fill; if (IsLargeField(fieldModel)) { ++this.TableLayout.RowCount; RowStyle nextRowStyle = new RowStyle() { SizeType = SizeType.Percent, Height = 100.0f, }; this.TableLayout.RowStyles.Add(nextRowStyle); this.TableLayout.Controls.Add(fieldBinding.BoundControl, 0, this.TableLayout.RowCount - 1); this.TableLayout.SetColumnSpan(fieldBinding.BoundControl, 2); } else { this.TableLayout.Controls.Add(fieldBinding.BoundControl, 1, this.TableLayout.RowCount - 1); } Binding.AddBinding(fieldName, fieldBinding); } ++this.TableLayout.RowCount; this.TableLayout.RowStyles.Add(new RowStyle() { SizeType = System.Windows.Forms.SizeType.Percent, Height = 100.0f }); this.Controls.Add(this.TableLayout); this.AutoSize = true; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; }
public void Initialize(MainForm owner, TrackerContext context) { this.Owner = owner; this.Context = context; this.BidsTable = new EntityTablePanelConstruct("donationbid", this.Owner, this.Context, new string[] { "amount", "target", } ) { Dock = DockStyle.Fill, AddAllowed = true, TabIndex = 11, }; this.BidsTable.Binding.AddModelMapping("choicebid", new Dictionary<string, string>() { { "amount", "amount" }, { "option", "target" }, }); this.BidsTable.Binding.AddModelMapping("challengebid", new Dictionary<string, string>() { { "amount", "amount" }, { "challenge", "target" }, }); this.DonationPanel.Controls.Add(this.BidsTable, 0, 7); this.DonationPanel.SetColumnSpan(this.BidsTable, 2); this.BidsTable.Enabled = false; this.Combiner = new EntityAccessContext("donation", this.Context); this.Combiner.AddForm(this.DonationBinding); this.Combiner.AddTable(this.BidsTable.Binding, DonationModels.DonationModel.GetField("bids") as EntitySetModel); this.Combiner.SaveComplete += this.OnSaveComplete; this.Combiner.Error += this.OnSaveError; }
public EntityTablePanelConstruct(string modelName, MainForm owner, TrackerContext context, params string[] columns) : base(modelName) { this.Owner = owner; this.Table = new DataGridView() { Dock = DockStyle.Fill, SelectionMode = DataGridViewSelectionMode.FullRowSelect, MultiSelect = false, AutoSize = true, AllowUserToAddRows = false, TabIndex = 1, }; this.SetTableBinding(new TableBinding(this.Table, columns) { Context = context }); if (!DonationModels.GetModel(modelName).IsAbstract) this.Binding.AddDefaultModelMapping(modelName); this.TableLabel = new Label() { Text = Util.SymbolToNatural(modelName) + "s" }; this.NavigateToButton = new Button() { Text = "Open", Visible = this.NavigateAllowed, }; this.NavigateToButton.Click += (o, e) => { this.OpenSelectedEntities(); }; this.AddInstanceButton = new Button() { Text = "New", }; this.AddInstanceButton.Click += (o, e) => { this.CreateNewEntity(); }; this.ButtonsPanel = new FlowLayoutPanel() { FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight, Dock = DockStyle.Fill, AutoSize = true, AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink, Controls = { this.TableLabel, this.NavigateToButton, this.AddInstanceButton, }, TabIndex = 0, }; this.RootLayout = new TableLayoutPanel() { Dock = DockStyle.Fill, ColumnCount = 1, RowCount = 2, }; this.RootLayout.RowStyles.Add(new RowStyle() { SizeType = System.Windows.Forms.SizeType.AutoSize, }); this.RootLayout.RowStyles.Add(new RowStyle() { SizeType = System.Windows.Forms.SizeType.Percent, Height = 100.0f, }); this.RootLayout.Controls.Add(this.Table, 0, 1); this.RootLayout.Controls.Add(this.ButtonsPanel, 0, 0); this.Controls.Add(this.RootLayout); this.AutoSize = true; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.Binding.AddAssociatedControl(this.ButtonsPanel); }
public PrizeTab(MainForm owner, TrackerContext context) : base(owner, context, "prize") { this.RootPanel = new TableLayoutPanel() { Dock = DockStyle.Fill, RowCount = 2, ColumnCount = 2, RowStyles = { new RowStyle(SizeType.Percent, 100.0f), new RowStyle(SizeType.AutoSize), }, ColumnStyles = { new ColumnStyle(SizeType.AutoSize), new ColumnStyle(SizeType.Percent, 100.0f), }, }; this.PrizeForm = new EntityFormPanelConstruct(this.ModelName, new string[] { "name", "image", "category", "minimumbid", "maximumbid", "sumdonations", "randomdraw", "provided", "description", "winner", "startrun", "endrun", "starttime", "endtime", "pin", }, this.Context, this.Owner) { Dock = DockStyle.Fill, }; this.DrawPrizeButton = new Button() { Text = "Draw Prize", }; this.DrawPrizeButton.Click += (o, e) => { this.RunPrizeDraw(); }; this.DrawResultsText = new TextBox() { ReadOnly = true, Dock = DockStyle.Fill, }; this.RootPanel.Controls.Add(this.PrizeForm, 0, 0); this.RootPanel.SetColumnSpan(this.PrizeForm, 2); this.RootPanel.Controls.Add(this.DrawPrizeButton, 0, 1); this.RootPanel.Controls.Add(this.DrawResultsText, 1, 1); this.SetPanel(this.RootPanel); this.PrizeForm.Binding.AddAssociatedControl(this.DrawPrizeButton); this.AddForm(this.PrizeForm.Binding); }
public RunEditPanel(TrackerContext context, MainForm owner) : base("run", context, owner) { this.RootPanel = new TableLayoutPanel() { Dock = DockStyle.Fill, }; this.RootPanel.RowCount = 2; this.RootPanel.ColumnCount = 2; this.RootPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50.0f)); this.RootPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50.0f)); this.RootPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 60.0f)); this.RootPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 40.0f)); this.RunForm = new EntityFormPanelConstruct(this.ModelName, new string[] { "name", "runners", "description", "starttime", "endtime" }, this.Context, this.Owner) { Dock = DockStyle.Fill }; this.BidTable = new EntityTablePanelConstruct("bid", this.Owner, this.Context, new string[] { "name", "description", "state", } ) { Dock = DockStyle.Fill, AddAllowed = false, }; this.PrizeTable = new EntityTablePanelConstruct("prize", this.Owner, this.Context, new string[] { "name", } ) { Dock = DockStyle.Fill, AddAllowed = false, }; this.BidTable.Binding.AddDefaultModelMapping("choice"); this.BidTable.Binding.AddDefaultModelMapping("challenge"); this.PrizeTable.Binding.AddDefaultModelMapping("prize"); this.RootPanel.Controls.Add(this.RunForm, 0, 0); this.RootPanel.SetColumnSpan(this.RunForm, 2); this.RootPanel.Controls.Add(this.BidTable, 0, 1); this.RootPanel.Controls.Add(this.PrizeTable, 1, 1); this.Controls.Add(this.RootPanel); }
public void Initialize(TrackerContext context, string modelName) { if (this.Cache != null) { this.Cache.DataRefreshed -= this.RebuildMappingInfo; } this.Cache = context.GetEntitySelectionCache(modelName); this.Cache.DataRefreshed += this.RebuildMappingInfo; this.SelectedId = null; this.NameText.InvokeEx(() => this.NameText.AutoCompleteCustomSource = new AutoCompleteStringCollection()); this.NameText.InvokeEx(() => this.NameText.Text = ""); this.RebuildMappingInfo(this.Cache.GetLatestCache()); if (this.UseSelectionCache) { this.Cache.RequestRefresh(EntitySelectionCacheRefreshType.Strong); } this.SearchButton.Visible = SearchPanelHelpers.HasSearchPanel(this.ModelName); }
public ChipinMergeContext(TrackerContext context) : base(context) { }
private void OnEventChanged(TrackerContext c) { this.InvokeEx(() => { this.Text = RootTitle + " - " + this.Context.EventName; foreach (TabPage control in this.TabControl.TabPages) { this.TabControl.TabPages.Remove(control); control.Dispose(); } this.TabControl.TabPages.Clear(); }); }
public DonationEditPanel(MainForm owner, TrackerContext context) : base("donation", context, owner) { this.RootPanel = new TableLayoutPanel() { Dock = DockStyle.Fill, ColumnCount = 1, RowCount = 2, ColumnStyles = { new ColumnStyle(SizeType.Percent, 100.0f), }, RowStyles = { new RowStyle(SizeType.Percent, 75.0f), new RowStyle(SizeType.Percent, 25.0f), }, }; this.FormPanel = new EntityFormPanelConstruct("donation", new string[] { //"domain", //"domainId", "timereceived", "amount", "donor", "comment", "modcomment", "readstate", "commentstate", "bidstate", }, this.Context, this.Owner ) { Dock = DockStyle.Fill, }; this.BidsPanel = new EntityTablePanelConstruct("donationbid", this.Owner, this.Context, new string[] { "amount", "target", } ) { Dock = DockStyle.Fill, AddAllowed = true, }; this.BidsPanel.Binding.AddModelMapping("choicebid", new Dictionary<string, string>() { { "amount", "amount" }, { "option", "target" }, }); this.BidsPanel.Binding.AddModelMapping("challengebid", new Dictionary<string, string>() { { "amount", "amount" }, { "challenge", "target" }, }); this.RootPanel.Controls.Add(this.FormPanel, 0, 0); this.RootPanel.Controls.Add(this.BidsPanel, 0, 1); this.Controls.Add(this.RootPanel); }
public ScheduleMergeContext(TrackerContext context) : base(context) { }
public PrizeAssignContext(TrackerContext context, int prizeId) : base(context) { this.PrizeId = prizeId; }