private IEnumerable<IStatement> getCodeForSettingCheckedState(ControlInfoStructure controlInfo) { // IList<IStatement> code = new List<IStatement>(); // BoundExpression boundControl = makeBoundControlFromControlInfo(controlInfo); // MethodCall setCheckStateCall= new MethodCall() { // IsStaticCall = false, // IsVirtualCall = true, // IsTailCall = false, // Type = ((Microsoft.Cci.Immutable.PlatformType) host.PlatformType).SystemVoid, // MethodToCall = isCheckedSetter, // ThisArgument = boundControl, // }; // setCheckStateCall.Arguments.Add(controlInfo.IsChecked ? trueConstant : falseConstant); // ExpressionStatement callStmt = new ExpressionStatement() { // Expression = setCheckStateCall, // }; // code.Add(callStmt); // return code; return new List<IStatement>(); }
private IEnumerable<IStatement> getCodeForSettingVisibility(ControlInfoStructure controlInfo) { // TODO I do not want to import System.Windows into this project...and using the underlying uint won't work for dependency properties /* IList<IStatement> code = new List<IStatement>(); BoundExpression boundControl = makeBoundControlFromControlInfo(controlInfo); MethodCall setVisibilityCall= new MethodCall() { IsStaticCall = false, IsVirtualCall = true, IsTailCall = false, Type = ((Microsoft.Cci.Immutable.PlatformType) host.PlatformType).SystemVoid, MethodToCall = visibilitySetter, ThisArgument = boundControl, }; ITypeReference visibilityType= ((Microsoft.Cci.Immutable.PlatformType) host.PlatformType).CreateReference(phoneSystemWindowsAssembly, "System", "Windows", "Visibility"); switch (controlInfo.Visible) { case Visibility.Visible: setVisibilityCall.Arguments.Add(new CompileTimeConstant() { Type = visibilityType, Value = 0, } ); // Visible break; case Visibility.Collapsed: setVisibilityCall.Arguments.Add(new CompileTimeConstant() { Type = visibilityType, Value = 1, } ); // Collapsed break; default: throw new ArgumentException("Invalid visibility value for control " + controlInfo.Name + ": " + controlInfo.Visible); } ExpressionStatement callStmt = new ExpressionStatement() { Expression = setVisibilityCall, }; code.Add(callStmt); return code; * */ return new List<IStatement>(); }
private IEnumerable<IStatement> getCodeForSettingEnabledness(ControlInfoStructure controlInfo) { IList<IStatement> code = new List<IStatement>(); BoundExpression boundControl = makeBoundControlFromControlInfo(controlInfo); MethodCall setEnablednessCall = new MethodCall() { IsStaticCall = false, IsVirtualCall = true, IsTailCall = false, Type = ((Microsoft.Cci.Immutable.PlatformType) host.PlatformType).SystemVoid, MethodToCall = isEnabledSetter, ThisArgument = boundControl, }; setEnablednessCall.Arguments.Add(controlInfo.IsEnabled ? trueConstant : falseConstant); ExpressionStatement callStmt = new ExpressionStatement() { Expression = setEnablednessCall, }; code.Add(callStmt); return code; }
private BoundExpression makeBoundControlFromControlInfo(ControlInfoStructure controlInfo) { return new BoundExpression() { Definition = new FieldDefinition() { ContainingTypeDefinition = methodBeingTraversed.Container, Name = host.NameTable.GetNameFor(controlInfo.Name), Type = getTypeForClassname(controlInfo.ClassName), IsStatic = false, }, Instance = new ThisReference() { Type = methodBeingTraversed.Container }, Type=getTypeForClassname(controlInfo.ClassName), }; }
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); }
public void setControlInfo(string controlName, ControlInfoStructure controlInfo) { controlsInfo[controlName] = controlInfo; }
public void setControlInfo(string controlName, ControlInfoStructure controlInfo) { controlsInfo[controlName] = controlInfo; }
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); }