-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvements of XamlImageConverter.Web:
- Compiler class - Map class
- Loading branch information
simonegli
committed
May 4, 2013
1 parent
65091c8
commit ffcfc4d
Showing
73 changed files
with
158 additions
and
21,433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Web.Hosting; | ||
|
||
namespace XamlImageConverter.Web.UI { | ||
|
||
public class Compiler { | ||
|
||
public static void Compile(string xic) { | ||
var checker = new XamlBuildCheck(); | ||
object compiler = null; | ||
if (checker.NeedsBuilding(xic)) { | ||
#if Silversite | ||
var handlerInfo = Services.Lazy.Types.Info("XamlImageConverter.Compiler"); | ||
handlerInfo.Load(); | ||
compiler = handlerInfo.New(); | ||
#else | ||
var assemblyfile = HostingEnvironment.MapPath("~/Bin.Lazy/XamlImageConverter.dll"); | ||
if (!System.IO.File.Exists(assemblyfile)) assemblyfile = HostingEnvironment.MapPath("~/Silversite/BinLazy/XamlImageConverter.dll"); | ||
if (!System.IO.File.Exists(assemblyfile)) assemblyfile = HostingEnvironment.MapPath("~/Bin/Lazy/XamlImageConverter.dll"); | ||
var aname = new System.Reflection.AssemblyName("XamlImageConverter"); | ||
aname.CodeBase = new Uri(assemblyfile).ToString(); | ||
var a = System.Reflection.Assembly.Load(aname); | ||
var type = a.GetType("XamlImageConverter.Compiler"); | ||
compiler = Activator.CreateInstance(type); | ||
#endif | ||
|
||
var ct = compiler.GetType(); | ||
var projectPath = ct.GetProperty("ProjectPath"); | ||
var libraryPath = ct.GetProperty("LibraryPath"); | ||
var sourceFiles = ct.GetProperty("SourceFiles"); | ||
projectPath.SetValue(compiler, HostingEnvironment.MapPath("~")); | ||
libraryPath.SetValue(compiler, HostingEnvironment.MapPath("~/bin")); | ||
var sources = new List<string>() { xic }; | ||
sourceFiles.SetValue(compiler, sources); | ||
var compile = ct.GetMethod("Compile"); | ||
compile.Invoke(compiler, new object[0]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.UI; | ||
using System.Web.UI.WebControls; | ||
using Silversite; | ||
using Silversite.Web.UI; | ||
using XamlImageConverter.Web.UI; | ||
|
||
namespace XamlImageConverter.Web.UI { | ||
|
||
public class Map: UserControl { | ||
|
||
public enum Modes { Click, Select }; | ||
public string Source { get; set; } | ||
public string IDs { get; set; } | ||
public string Regions { get; set; } | ||
public Modes Mode { get; set; } | ||
public bool Legend { get; set; } | ||
public string SubmitText { get; set; } | ||
public string Selected { get; set; } | ||
public double Scale { get; set; } | ||
public int LegendTop { get; set; } | ||
public int LegendLeft {get; set; } | ||
public string CssClass { get; set; } | ||
public event EventHandler Submit; | ||
|
||
static int no = 0; | ||
|
||
public Map() { | ||
Mode = Modes.Click; | ||
Source = null; | ||
Regions = "*"; | ||
Legend = false; | ||
Selected = ""; | ||
Scale = 1; | ||
} | ||
|
||
protected override void CreateChildControls() { | ||
base.CreateChildControls(); | ||
var xaml = new XamlImage(); | ||
|
||
if (Mode == Modes.Select) { | ||
var boxlist = new CheckBoxList(); | ||
int n = 0; | ||
if (string.IsNullOrEmpty(IDs)) IDs = Regions; | ||
|
||
var ids = IDs.Tokens(); | ||
foreach (var region in Regions.Tokens()) { | ||
var listItem = new ListItem(); | ||
listItem.Attributes["id"] = "checkbox_" + IDs; | ||
boxlist.Items.Add(new ListItem(region, n.ToString())); | ||
} | ||
|
||
var script = new Script(); | ||
script.Text = "var selected function(id) { var box = $('#checkbox_' + id); box.prop(\"checked\", !box.attr(\"checked\")); };"; | ||
var src = "<xic:XamlImageProvider xmlns=\"https://schemas.johnshope.com/XamlImageConverter/2012\"><xic:Scene Source=\"" + Source + "\"><xic:Snapshot Type=\"png\" >" + | ||
"<xic:Map File=\"" + Source + ".ascx\" Scale=\"" + Scale + "\"><xic:Areas Elements=\"" + IDs + "\" onclick=\"selected(%ID%);\" href=\"#\" /></xic:Map>"; | ||
Compiler.Compile(src); | ||
|
||
var div = new Panel(); | ||
div.Style[HtmlTextWriterStyle.Position] = "absolute"; | ||
var div2 = new Panel(); | ||
div2.Style[HtmlTextWriterStyle.Position] = "relative; top=" + LegendTop.ToString() + "left=" + LegendLeft.ToString(); | ||
|
||
div.Controls.Add(div2); | ||
div2.Controls.Add(boxlist); | ||
|
||
var img = new Image(); | ||
img.ImageUrl = Source + ".png"; | ||
var submit = new Button(); | ||
submit.Text = SubmitText; | ||
submit.Click += (sender, args) => { if (Submit != null) Submit(sender, args); }; | ||
div2.Controls.Add(submit); | ||
|
||
var map = LoadControl(Source + ".ascx"); | ||
var box = new Panel(); | ||
box.Controls.Add(img); | ||
box.Controls.Add(div); | ||
box.Controls.Add(map); | ||
|
||
Controls.Add(box); | ||
} else { | ||
var box = new Panel(); | ||
|
||
if (string.IsNullOrEmpty(ID)) ID = "map." + (no++).ToString(); | ||
var src = "<xic:XamlImageProvider xmlns=\"https://schemas.johnshope.com/XamlImageConverter/2012\"><xic:Scene Source=\"" + Source + "\"><xic:Snapshot Type=\"png\" >" + | ||
"<xic:Map File=\"" + Source + ".ascx\" Scale=\"" + Scale + "\" ><xic:Areas Elements=\"" + IDs + "\" onclick=\"_doPostBack('" + box.ClientID + "','%ID%');\" /></xic:Map>"; | ||
Compiler.Compile(src); | ||
|
||
var img = new Image(); | ||
img.ImageUrl = Source + ".png"; | ||
var map = LoadControl(Source + ".ascx"); | ||
|
||
box.Controls.Add(img); | ||
box.Controls.Add(map); | ||
|
||
Controls.Add(box); | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
lib/SystemThemeChange-master/SystemThemeChange-master/.gitignore
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
lib/SystemThemeChange-master/SystemThemeChange-master/App.xaml
This file was deleted.
Oops, something went wrong.
54 changes: 0 additions & 54 deletions
54
lib/SystemThemeChange-master/SystemThemeChange-master/App.xaml.cs
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
lib/SystemThemeChange-master/SystemThemeChange-master/MainWindow.xaml
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
lib/SystemThemeChange-master/SystemThemeChange-master/MainWindow.xaml.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.