private void LoadControlStructure(StreamReader configStream) { // FEEDBACK TODO. Easy check on Feedback issue: Button and HyperLinkButton MUST have a Click handler, if not, it is obvious there is no feedback // TODO it would be nice to have some kind of dynamic definition of config format // TODO for now remember that config format is CSV // TODO each line is <pageClassName>,<pageXAMLPath>,<pageBoogieStringName>,<controlClassName>,<controlName>,<IsEnabledValue>,<VisibilityValue>,<ClickValue>,<CheckedValue>,<UncheckedValue>,<BPL control name> // TODO BPL control name will most probably be empty, but it is useful to be able to dump it // TODO check PhoneControlsExtractor.py and PhoneBoogieCodeCreator.py // TODO the page.xaml value is saved with no directory information: if two pages exist with same name but different directories it will treat them as the same // TODO I'm not handling this for now, and I won't be handling relative/absolute URI either for now string pageClass, pageXAML, pageBoogieStringName, controlClass, controlName, enabled, visibility, clickHandler, checkedHandler, uncheckedHandler, selectionChangedHandler, bplName; string configLine = configStream.ReadLine(); string[] inputLine; PageStructure pageStr; ControlInfoStructure controlInfoStr; // first line just states the main page xaml string mainPageXAML = configLine.Trim().ToLower(); configLine = configStream.ReadLine(); // second line states boogie current nav variable, possibly dummy value setBoogieNavigationVariable(configLine.Trim()); configLine = configStream.ReadLine(); // third line is main phone app type, possibly dummy; setMainAppTypeName(configLine.Trim()); configLine = configStream.ReadLine(); while (configLine != null) { if (configLine.Trim().Equals(string.Empty)) { configLine = configStream.ReadLine(); continue; } inputLine = configLine.Split(','); if (inputLine.Length != CONFIG_LINE_FIELDS) { throw new ArgumentException("Config input line contains wrong number of fields: " + inputLine.Length + ", expected " + CONFIG_LINE_FIELDS); } pageClass = inputLine[PAGE_CLASS_FIELD].Trim(); pageXAML = inputLine[PAGE_XAML_FIELD].Trim().ToLower(); pageBoogieStringName = inputLine[PAGE_BOOGIE_STRING_FIELD].Trim(); controlClass = inputLine[CONTROL_CLASS_FIELD].Trim(); controlName = inputLine[CONTROL_NAME_FIELD].Trim(); if (string.IsNullOrEmpty(controlName)) { controlName = BOOGIE_DUMMY_CONTROL + dummyControlNameIndex++; } enabled = inputLine[ENABLED_FIELD].Trim(); visibility = inputLine[VISIBILITY_FIELD].Trim(); clickHandler = inputLine[CLICK_HANDLER_FIELD].Trim(); checkedHandler = inputLine[CHECKED_HANDLER_FIELD].Trim(); uncheckedHandler = inputLine[UNCHECKED_HANDLER_FIELD].Trim(); selectionChangedHandler = inputLine[SELECTIONCHANGED_HANDLER_FIELD].Trim(); bplName = inputLine[BPL_NAME_FIELD].Trim(); try { pageStr = pageStructureInfo[pageClass]; } catch (KeyNotFoundException) { pageStr = new PageStructure(); pageStr.PageClassName = pageClass; pageStr.PageXAML = pageXAML; pageStr.PageBoogieName = pageBoogieStringName; pageStr.IsMainPage = false; } controlInfoStr = pageStr.getControlInfo(controlName); if (controlInfoStr == null) { controlInfoStr = new ControlInfoStructure(); controlInfoStr.Name = controlName; controlInfoStr.ClassName = controlClass; controlInfoStr.BplName = bplName; } controlInfoStr.IsEnabled = enabled.ToLower() == "false" ? false : true; controlInfoStr.Visible = visibility == "Collapsed" ? Visibility.Collapsed : Visibility.Visible; controlInfoStr.setHandler(Event.Click, clickHandler); controlInfoStr.setHandler(Event.Checked, checkedHandler); controlInfoStr.setHandler(Event.Unchecked, uncheckedHandler); controlInfoStr.setHandler(Event.SelectionChanged, selectionChangedHandler); pageStr.setControlInfo(controlName, controlInfoStr); pageStructureInfo[pageClass] = pageStr; configLine = configStream.ReadLine(); } setPageAsMainPage(mainPageXAML); }
private void LoadControlStructure(StreamReader configStream) { // FEEDBACK TODO. Easy check on Feedback issue: Button and HyperLinkButton MUST have a Click handler, if not, it is obvious there is no feedback // TODO it would be nice to have some kind of dynamic definition of config format // TODO for now remember that config format is CSV // TODO each line is <pageClassName>,<pageXAMLPath>,<pageBoogieStringName>,<controlClassName>,<controlName>,<IsEnabledValue>,<VisibilityValue>,<ClickValue>,<CheckedValue>,<UncheckedValue>,<BPL control name> // TODO BPL control name will most probably be empty, but it is useful to be able to dump it // TODO check PhoneControlsExtractor.py and PhoneBoogieCodeCreator.py // TODO the page.xaml value is saved with no directory information: if two pages exist with same name but different directories it will treat them as the same // TODO I'm not handling this for now, and I won't be handling relative/absolute URI either for now string pageClass, pageXAML, pageBoogieStringName, controlClass, controlName, enabled, visibility, clickHandler, checkedHandler, uncheckedHandler, selectionChangedHandler, bplName; string configLine = configStream.ReadLine(); string[] inputLine; PageStructure pageStr; ControlInfoStructure controlInfoStr; // first line just states the main page xaml string mainPageXAML= configLine.Trim().ToLower(); configLine = configStream.ReadLine(); // second line states boogie current nav variable, possibly dummy value setBoogieNavigationVariable(configLine.Trim()); configLine= configStream.ReadLine(); // third line is main phone app type, possibly dummy; setMainAppTypeName(configLine.Trim()); configLine = configStream.ReadLine(); while (configLine != null) { if (configLine.Trim().Equals(string.Empty)) { configLine = configStream.ReadLine(); continue; } inputLine = configLine.Split(','); if (inputLine.Length != CONFIG_LINE_FIELDS) throw new ArgumentException("Config input line contains wrong number of fields: " + inputLine.Length + ", expected " + CONFIG_LINE_FIELDS); pageClass = inputLine[PAGE_CLASS_FIELD].Trim(); pageXAML = inputLine[PAGE_XAML_FIELD].Trim().ToLower(); pageBoogieStringName = inputLine[PAGE_BOOGIE_STRING_FIELD].Trim(); controlClass = inputLine[CONTROL_CLASS_FIELD].Trim(); controlName = inputLine[CONTROL_NAME_FIELD].Trim(); if (string.IsNullOrEmpty(controlName)) controlName = BOOGIE_DUMMY_CONTROL + dummyControlNameIndex++; enabled = inputLine[ENABLED_FIELD].Trim(); visibility = inputLine[VISIBILITY_FIELD].Trim(); clickHandler = inputLine[CLICK_HANDLER_FIELD].Trim(); checkedHandler = inputLine[CHECKED_HANDLER_FIELD].Trim(); uncheckedHandler = inputLine[UNCHECKED_HANDLER_FIELD].Trim(); selectionChangedHandler = inputLine[SELECTIONCHANGED_HANDLER_FIELD].Trim(); bplName = inputLine[BPL_NAME_FIELD].Trim(); try { pageStr = pageStructureInfo[pageClass]; } catch (KeyNotFoundException) { pageStr = new PageStructure(); pageStr.PageClassName = pageClass; pageStr.PageXAML = pageXAML; pageStr.PageBoogieName = pageBoogieStringName; pageStr.IsMainPage = false; } controlInfoStr= pageStr.getControlInfo(controlName); if (controlInfoStr == null) { controlInfoStr = new ControlInfoStructure(); controlInfoStr.Name = controlName; controlInfoStr.ClassName = controlClass; controlInfoStr.BplName = bplName; } controlInfoStr.IsEnabled = enabled.ToLower() == "false" ? false : true; controlInfoStr.Visible = visibility == "Collapsed" ? Visibility.Collapsed : Visibility.Visible; controlInfoStr.setHandler(Event.Click, clickHandler); controlInfoStr.setHandler(Event.Checked, checkedHandler); controlInfoStr.setHandler(Event.Unchecked, uncheckedHandler); controlInfoStr.setHandler(Event.SelectionChanged, selectionChangedHandler); pageStr.setControlInfo(controlName, controlInfoStr); pageStructureInfo[pageClass] = pageStr; configLine = configStream.ReadLine(); } setPageAsMainPage(mainPageXAML); }