public override void Load(Dictionary<string, string> parameters) { // var catList = new CatRepository ().GetCats (); catRepo = new CatRepository (); var catList = catRepo.GetCats (); if (parameters.ContainsKey ("textField1")) { if (catList.Exists (o => o.Name == parameters ["textField1"])) { iApp.Session ["Cat"] = catList.Single (o => o.Name == parameters ["textField1"]); this.CancelLoadAndNavigate ("CatDetail".AppendPath (parameters ["textField1"])); return; } else { this.Title = "<bad cat>"; } } // Title = "Cats"; var menu = new iMenu (); menu.Header = "Items"; foreach (var c in catList) { menu.Items.Add (new iItem () { Text = c.Name, Subtext = c.Breed.ToString(), Link = new Link ("CatDetail".AppendPath(c.Name)) }); } this.Items.Add (menu); var fieldSet = new Fieldset (); fieldSet.Header = "Fields"; // fieldSet.Fields.Add (new TextField ("textField1") { // Label = "TF1", // Text = parameters.ContainsKey("textField1") ? parameters ["textField1"] : string.Empty // }); var textField = (new TextField ("textField1") { Label = "TF1", Text = parameters.ContainsKey("textField1") ? parameters ["textField1"] : string.Empty }); textField.Validate = (value, errorMsg, args) => { if (!catList.Exists (o => o.Name == value)) { errorMsg = "bad cat"; textField.BrokenRules.Add("bad cat"); } }; fieldSet.Fields.Add (textField); this.Items.Add (fieldSet); this.ActionButtons.Add (new SubmitButton ("Save", "CatList")); }
public override void Load(Dictionary<string, string> parameters) { base.Load(parameters); this.Title = parameters.ContainsKey(CAR_NAME) ? parameters[CAR_NAME] : NO_CAR; this.BackButton = new iFactr.Core.Controls.Button(BACK, CAR_LIST); if (iApp.Session.ContainsKey(CAR)) { Car car = iApp.Session[CAR] as Car; iApp.Session.Remove(CAR); var menu = new iMenu(); menu.Add(new iItem { Text = car.Name, Subtext = car.VehicleClass.ToString()}); this.Items.Add(menu); } }
public override void Load(System.Collections.Generic.Dictionary<string, string> parameters) { this.Title = parameters.ContainsKey ("CatName") ? parameters ["CatName"] : "No Cat"; this.BackButton = new iFactr.Core.Controls.Button ("Back", "CatList"); if (iApp.Session.ContainsKey("Cat")) { Cat cat = iApp.Session ["Cat"] as Cat; iApp.Session.Remove ("Cat"); var menu = new iMenu (); menu.Add (new iItem { Text = cat.Name, Subtext = cat.Breed.ToString()}); this.Items.Add (menu); } }
protected void OutputMenu(iMenu menu) { System.Console.WriteLine(); if (!string.IsNullOrEmpty(menu.Header)) { System.Console.WriteLine(menu.Header); } foreach (iItem menuItem in menu.Items) { string output = menuItem.Text; if (menuItem.Subtext != null) { output = output + " - " + menuItem.Subtext; } if (menuItem.Link != null) { output = navigationKeys.Count + ". " + output; } System.Console.WriteLine(output); navigationKeys.Add(navigationKeys.Count, menuItem.Link); } }
public override void Load(Dictionary<string, string> parameters) { base.Load(parameters); Title = "List"; //// add items to an iList //iList list = new iList(); //var menu = new iMenu(); //menu.Header = "Items"; //this.Items.Add(menu); carRepository = new CarRepository(); var carList = carRepository.GetCars(); // test comment if (parameters.ContainsKey(TEXTFIELD1)) { if (carList.Exists(o => o.Name == parameters[TEXTFIELD1])) { iApp.Session[CAR] = carList.Single(o => o.Name == parameters[TEXTFIELD1]); this.CancelLoadAndNavigate(CAR_DETAIL.AppendPath(parameters[TEXTFIELD1])); return; } else this.Title = BAD_CAR; } // Make the menu var menu = new iMenu(); menu.Header = ITEMS; // Add the cars to the list foreach (var car in carList) { menu.Items.Add(new iItem() { Text = car.Name, Subtext = car.VehicleClass.ToString(), Link = new iFactr.Core.Controls.Link(CAR_DETAIL.AppendPath(car.Name)) }); } this.Items.Add(menu); var fieldSet = new Fieldset(); fieldSet.Header = FIELDS; var textField = (new TextField(TEXTFIELD1) { Label = TF1, Text = parameters.ContainsKey(TEXTFIELD1) ? parameters[TEXTFIELD1] : string.Empty }); // Validation textField.Validate = (value, errorMsg, args) => { if (!carList.Exists(o => o.Name == value)) { errorMsg = BAD_CAR; textField.BrokenRules.Add(BAD_CAR); } }; fieldSet.Fields.Add(textField); this.Items.Add(fieldSet); this.ActionButtons.Add(new SubmitButton(SAVE, CAR_LIST)); }