Skip to content

Commit

Permalink
port problems
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishonselaar committed Apr 24, 2013
1 parent 692d04e commit c5e927e
Show file tree
Hide file tree
Showing 27 changed files with 610 additions and 150 deletions.
6 changes: 3 additions & 3 deletions ProtoPad Client/App.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
</configuration>
12 changes: 8 additions & 4 deletions ProtoPad Client/DumpToXhtml.cs
Expand Up @@ -6,26 +6,30 @@

namespace ProtoPad_Client
{
[DataContract]
public class DumpValue
{
public enum DumpTypes { PrimitiveEnumerable, ComplexEnumerable, Group, Primitive, Complex, BeyondMaxLevel, Image }

public string TypeName { get; set; }
public DumpTypes DumpType { get; set; }

public object PrimitiveValue { get; set; } // only value types
public Dictionary<string, DumpValue> ComplexValue { get; set; }

public List<object> PrimitiveEnumerable { get; set; } // only value types
public List<DumpValue> ComplexEnumerable { get; set; }
}

[DataContract]
public class ResultPair
{
public string ResultKey;
public DumpValue ResultValue;
}

[DataContract]
public class ExecuteResponse
{
public string ErrorMessage { get; set; }
public List<Tuple<string, DumpValue>> Results { get; set; }
public List<ResultPair> Results { get; set; }
}

public static class DumpToXhtml
Expand Down
86 changes: 63 additions & 23 deletions ProtoPad Client/EditorHelpers.cs
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -11,27 +12,43 @@ namespace ProtoPad_Client
{
public static class EditorHelpers
{
public static readonly string[] StandardAssemblies_Android = new[]
{
@"c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll",
@"c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v4.0.3\Mono.Android.dll",
@"c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll"
};
public const string SampleCode_Android_Program = @"(5).Dump();";

public static readonly string[] StandardAssemblies_iOS = new[]
{
@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoTouch\v4.0\System.dll",
@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoTouch\v4.0\System.Core.dll",
@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoTouch\v4.0\monotouch.dll"
};
public enum CodeType {Expression, Statements, Program}

public static string GetFrameworkReferenceAssembliesDirectory()
{
var programFilesx86Dir = Environment.GetEnvironmentVariable("programfiles(x86)") ?? @"C:\Program Files (x86)\";
return Path.Combine(programFilesx86Dir, @"Reference Assemblies\Microsoft\Framework");
}

public const string SampleCode_Android_Program = @"";
public static string[] GetXamarinAndroidBaseAssemblies(string mainMonodroidAssemblyName)
{
if (String.IsNullOrWhiteSpace(mainMonodroidAssemblyName)) return new string[]{};
var fileNames = Directory.GetFiles(GetFrameworkReferenceAssembliesDirectory(), "Mono.Android.dll", SearchOption.AllDirectories);
//var mainMonodroidAssemblyPath = fileNames.First(f => Assembly.LoadFrom(f). .FullName == mainMonodroidAssemblyName);
var mainMonodroidAssemblyPath = @"c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v4.0\Mono.Android.dll";
var monoDroidAssembliesParentPath = Directory.GetParent(mainMonodroidAssemblyPath).Parent.FullName;
var androidSystemDllPath = Directory.GetFiles(monoDroidAssembliesParentPath, "System.dll", SearchOption.AllDirectories).First();
//var androidMsCorDllPath = Directory.GetFiles(monoDroidAssembliesParentPath, "mscorlib.dll", SearchOption.AllDirectories).First();
var androidSystemCoreDllPath = Directory.GetFiles(monoDroidAssembliesParentPath, "System.Core.dll", SearchOption.AllDirectories).First();
return new[] { androidSystemDllPath, androidSystemCoreDllPath, /*androidMsCorDllPath, */mainMonodroidAssemblyPath };
}

public enum CodeType {Expression, Statements, Program}
public static string[] GetXamariniOSBaseAssemblies(string mainMonotouchAssemblyName)
{
if (String.IsNullOrWhiteSpace(mainMonotouchAssemblyName)) return new string[] { };
var fileNames = Directory.GetFiles(GetFrameworkReferenceAssembliesDirectory(), "monotouch.dll", SearchOption.AllDirectories);
var mainMonotouchAssemblyPath = fileNames.First(f => Assembly.LoadFrom(f).FullName == mainMonotouchAssemblyName);
var monoTouchAssembliesParentPath = Directory.GetParent(mainMonotouchAssemblyPath).Parent.FullName;
var monoTouchSystemDllPath = Directory.GetFiles(monoTouchAssembliesParentPath, "System.dll", SearchOption.AllDirectories).First();
var monoTouchSystemCoreDllPath = Directory.GetFiles(monoTouchAssembliesParentPath, "System.Core.dll", SearchOption.AllDirectories).First();
return new[] { mainMonotouchAssemblyPath, monoTouchSystemDllPath, monoTouchSystemCoreDllPath };
}

public static string GetDeviceSpecificMainParams(MainWindow.DeviceTypes deviceType)
{
return deviceType == MainWindow.DeviceTypes.Android ? "ViewGroup window" : "UIWindow window";
return deviceType == MainWindow.DeviceTypes.Android ? "Activity activity, Android.Views.Window window" : "UIApplicationDelegate appDelegate, UIWindow window";
}

public static string GetWrapText(CodeType codeType, MainWindow.DeviceTypes deviceType)
Expand Down Expand Up @@ -152,11 +169,17 @@ public static void ____TrackStatementOffset(int offset)
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Runtime.CompilerServices;
public class __MTDynamicCode
{
public static int ___lastExecutedLineNumber = 1;
public static List<Tuple<string, object, int, bool>> ___dumps = new List<Tuple<string, object, int, bool>>();
public static int ___lastExecutedStatementOffset = 0;
public static void ____TrackStatementOffset(int offset)
{
___lastExecutedStatementOffset = offset;
}
public static int ___maxEnumerableItemCount = 1000;
public static List<DumpHelpers.DumpObj> ___dumps = new List<DumpHelpers.DumpObj>();
__STATEMENTSHERE__
}";
Expand All @@ -166,29 +189,46 @@ public class __MTDynamicCode
public static class DumpHelpers
{
public const int DefaultLevel = 3;
public class DumpObj
{
public string Description;
public object Value;
public int Level;
public bool ToDataGrid;
public DumpObj(string description, object value, int level, bool toDataGrid)
{
Description = description;
Value = value;
Level = level;
ToDataGrid = toDataGrid;
}
}
public static void Dump(this object dumpValue)
{
__MTDynamicCode.___dumps.Add(Tuple.Create<string, object, int, bool>("""", dumpValue, DefaultLevel, false));
__MTDynamicCode.___dumps.Add(new DumpObj("""", dumpValue, DefaultLevel, false));
}
public static void Dump(this object dumpValue, string description)
{
__MTDynamicCode.___dumps.Add(Tuple.Create<string, object, int, bool>(description, dumpValue, DefaultLevel, false));
__MTDynamicCode.___dumps.Add(new DumpObj(description, dumpValue, DefaultLevel, false));
}
public static void Dump(this object dumpValue, int depth)
{
__MTDynamicCode.___dumps.Add(Tuple.Create<string, object, int, bool>("""", dumpValue, depth, false));
__MTDynamicCode.___dumps.Add(new DumpObj("""", dumpValue, depth, false));
}
public static void Dump(this object dumpValue, bool toDataGrid)
{
__MTDynamicCode.___dumps.Add(Tuple.Create<string, object, int, bool>("""", dumpValue, DefaultLevel, toDataGrid));
__MTDynamicCode.___dumps.Add(new DumpObj("""", dumpValue, DefaultLevel, toDataGrid));
}
public static void Dump(this object dumpValue, string description, int depth)
{
__MTDynamicCode.___dumps.Add(Tuple.Create<string, object, int, bool>(description, dumpValue, depth, false));
__MTDynamicCode.___dumps.Add(new DumpObj(description, dumpValue, depth, false));
}
public static void Dump(this object dumpValue, string description, bool toDataGrid)
{
__MTDynamicCode.___dumps.Add(Tuple.Create<string, object, int, bool>(description, dumpValue, DefaultLevel, toDataGrid));
__MTDynamicCode.___dumps.Add(new DumpObj(description, dumpValue, DefaultLevel, toDataGrid));
}
}";
}
Expand Down
2 changes: 1 addition & 1 deletion ProtoPad Client/MainWindow.xaml
Expand Up @@ -23,7 +23,7 @@
<sys:String>Statements</sys:String>
<sys:String>Program</sys:String>
</ComboBox>
<Button x:Name="ConnectToAppButton" Content="Find servers" Height="31" VerticalAlignment="Top" Width="89" Click="ConnectToAppButton_Click" ToolTip="Autodiscover (through mDNS) any running ProtoPad-enabled apps, and show them in the adjacent dropdown so you can select and connect to one."/>
<Button x:Name="FindAppsButton" Content="Find servers" Height="31" VerticalAlignment="Top" Width="89" Click="FindAppsButton_Click" ToolTip="Autodiscover (through mDNS) any running ProtoPad-enabled apps, and show them in the adjacent dropdown so you can select and connect to one."/>
<ComboBox SelectedValuePath="DeviceAddress" DisplayMemberPath="DeviceName" IsEnabled="False" x:Name="DevicesComboBox" VerticalAlignment="Top" Width="187" Height="31" SelectionChanged="DevicesComboBox_SelectionChanged" Margin="0" ToolTip="Shows the list of auto-discovered ProtoPad-enabled apps on your local machine or network. If no apps are shown, try using the 'Find servers' button or alternatively use 'Add IP' to connect to an app manually.">
</ComboBox>
<Button x:Name="AddManualIPButton" Content="Add IP" Height="31" VerticalAlignment="Bottom" Width="83" Click="AddManualIPButton_Click" ToolTip="If auto-discovery did not locate your app, use this button to add your app's IP address and port manually. You can find this information on the similarly named properties of the ProtoPadServer object that you created within your app."/>
Expand Down

0 comments on commit c5e927e

Please sign in to comment.