summaryrefslogtreecommitdiff
path: root/BCT/TranslationPlugins/PhoneControlsPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'BCT/TranslationPlugins/PhoneControlsPlugin.cs')
-rw-r--r--BCT/TranslationPlugins/PhoneControlsPlugin.cs56
1 files changed, 25 insertions, 31 deletions
diff --git a/BCT/TranslationPlugins/PhoneControlsPlugin.cs b/BCT/TranslationPlugins/PhoneControlsPlugin.cs
index e539b1b8..daa7c345 100644
--- a/BCT/TranslationPlugins/PhoneControlsPlugin.cs
+++ b/BCT/TranslationPlugins/PhoneControlsPlugin.cs
@@ -7,7 +7,7 @@ using System.IO;
namespace TranslationPlugins {
public enum Visibility { Visible, Collapsed };
- public enum Event { Click, Checked, Unchecked };
+ public enum Event { Click, Checked, Unchecked, SelectionChanged };
public class HandlerSignature {
public static string[] getParameterTypesForHandler(Event controlEvent) {
@@ -15,6 +15,7 @@ namespace TranslationPlugins {
case Event.Checked:
case Event.Unchecked:
case Event.Click:
+ case Event.SelectionChanged:
return new string[] { "object", "System.WindowsRoutedventArgs" };
default:
throw new NotImplementedException("Handlers for event: " + controlEvent + " not supported yet");
@@ -94,7 +95,7 @@ namespace TranslationPlugins {
public class PhoneControlsPlugin : TranslationPlugin {
// TODO this will probably need a complete rewrite once it is event based, and make it more push than pull
// TODO but it doesn't make sense right now to make it BCT or CCI aware
- private static int CONFIG_LINE_FIELDS= 11;
+ private static int CONFIG_LINE_FIELDS= 12;
private static int PAGE_CLASS_FIELD= 0;
private static int PAGE_XAML_FIELD= 1;
private static int PAGE_BOOGIE_STRING_FIELD = 2;
@@ -105,7 +106,8 @@ namespace TranslationPlugins {
private static int CLICK_HANDLER_FIELD= 7;
private static int CHECKED_HANDLER_FIELD= 8;
private static int UNCHECKED_HANDLER_FIELD = 9;
- private static int BPL_NAME_FIELD = 10;
+ private static int SELECTIONCHANGED_HANDLER_FIELD = 10;
+ private static int BPL_NAME_FIELD = 11;
private IDictionary<string, PageStructure> pageStructureInfo;
@@ -125,28 +127,6 @@ namespace TranslationPlugins {
return mockBaseUri.MakeRelativeUri(mockStrippedUri).ToString();
}
- /// <summary>
- /// uri is a valid URI but possibly partial (incomplete ?arg= values) and overspecified (complete ?arg=values)
- /// This method returns a base URI
- /// </summary>
- /// <param name="uri"></param>
- /// <returns></returns>
- public static string getURIBase(string uri) {
- // I need to build an absolute URI just to call getComponents() ...
- Uri mockBaseUri = new Uri("mock://mock/", UriKind.RelativeOrAbsolute);
- Uri realUri;
- try {
- realUri = new Uri(uri, UriKind.Absolute);
- } catch (UriFormatException) {
- // uri string is relative
- realUri = new Uri(mockBaseUri, uri);
- }
-
- string str = realUri.GetComponents(UriComponents.Path | UriComponents.StrongAuthority | UriComponents.Scheme, UriFormat.UriEscaped);
- Uri mockStrippedUri = new Uri(str);
- return mockBaseUri.MakeRelativeUri(mockStrippedUri).ToString();
- }
-
//public static string getFullyQualifiedControlClass(string controlClass) {
// // TODO do an actual API discovery. The problem will be differencing 7.0 apps from 7.1 apps
// return "System.Windows.Controls." + controlClass;
@@ -190,6 +170,7 @@ namespace TranslationPlugins {
}
private void setPageAsMainPage(string pageXAML) {
+ pageXAML = pageXAML.ToLower();
int lastDirPos= pageXAML.LastIndexOf('/');
if (lastDirPos != -1)
pageXAML = pageXAML.Substring(lastDirPos+1);
@@ -212,14 +193,15 @@ namespace TranslationPlugins {
public void DumpControlStructure(StreamWriter outputStream) {
// maintain same format as input format
- string pageClass, pageXAML, pageBoogieStringName, controlClass, controlName, enabled, visibility, clickHandler, checkedHandler, uncheckedHandler, bplName;
+ string pageClass, pageXAML, pageBoogieStringName, controlClass, controlName, enabled, visibility, clickHandler,
+ checkedHandler, uncheckedHandler, selectionChangedHandler, bplName;
outputStream.WriteLine(getMainPageXAML());
outputStream.WriteLine(getBoogieNavigationVariable());
outputStream.WriteLine(getMainAppTypeName());
foreach (KeyValuePair<string, PageStructure> entry in this.pageStructureInfo) {
pageClass = entry.Key;
- pageXAML = entry.Value.PageXAML;
+ pageXAML = entry.Value.PageXAML.ToLower();
pageBoogieStringName = entry.Value.PageBoogieName;
foreach (ControlInfoStructure controlInfo in entry.Value.getAllControlsInfo()) {
controlClass= controlInfo.ClassName;
@@ -253,8 +235,17 @@ namespace TranslationPlugins {
} else {
uncheckedHandler = "";
}
+
+ handlers = controlInfo.getHandlers(Event.SelectionChanged);
+ if (handlers.Any()) {
+ selectionChangedHandler= handlers.First().Name;
+ } else {
+ selectionChangedHandler = "";
+ }
bplName = controlInfo.BplName;
- outputStream.WriteLine(pageClass + "," + pageXAML + "," + pageBoogieStringName + "," + controlClass + "," + controlName + "," + enabled + "," + visibility + "," + clickHandler + "," + checkedHandler + "," + uncheckedHandler + "," + bplName);
+ outputStream.WriteLine(pageClass + "," + pageXAML.ToLower() + "," + pageBoogieStringName + "," + controlClass + "," + controlName + "," + enabled + "," +
+ visibility + "," + clickHandler + "," + checkedHandler + "," + uncheckedHandler + "," + selectionChangedHandler + "," +
+ bplName);
}
}
}
@@ -276,14 +267,15 @@ namespace TranslationPlugins {
// 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, bplName;
+ 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();
+ string mainPageXAML= configLine.Trim().ToLower();
configLine = configStream.ReadLine();
// second line states boogie current nav variable, possibly dummy value
@@ -305,7 +297,7 @@ namespace TranslationPlugins {
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();
+ 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();
@@ -317,6 +309,7 @@ namespace TranslationPlugins {
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 {
@@ -341,6 +334,7 @@ namespace TranslationPlugins {
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;