Skip to content

Instantly share code, notes, and snippets.

View janvanderhaegen's full-sized avatar

Jan Van der Haegen janvanderhaegen

View GitHub Profile
@janvanderhaegen
janvanderhaegen / GetScreensFromModelService
Created September 20, 2013 23:40
Get an overview of all screens from the model service.
private static IEnumerable<string> _allScreens;
static BuildingBlockProvider()
{
List<string> screens = new List<string>();
foreach (var screenModel in ServiceProxy.Instance.ModelService.Items.OfType<IScreenDefinition>())
{
if (screenModel.Members.Any(m => m.Attributes.OfType<IIsParameterAttribute>().Any(att => !(att.Parent as IScreenPropertyDefinition).PropertyType.Name.EndsWith("?")))) {
continue;
}
@janvanderhaegen
janvanderhaegen / lightswitch.bing-maps.js
Created August 22, 2013 18:08
JQuery UI Widget for LightSwitch's Bing Map control
/// <reference path="JQuery/jquery-1.6.1.js" />
/// <reference path="JQueryMobile/jquery.mobile-1.0.js" />
/// <reference path="../Libraries/MsLs/msls-1.0.0.js" />
/// <reference path="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0" />
/*
Usage example
myapp.AddEditCustomer.HowDoIGetThere_execute = function (screen) {
$("#addressMap").lightswitchBingMapsControl("getLocationOfUser", $("#directions"));
};
@janvanderhaegen
janvanderhaegen / default.html extract
Created July 18, 2013 21:45
Adds a check to see if JQuery mobile is supported, to the LightSwitch loading screen (default.html). This will catch most of the browsers that are unable to run LightSwich HTML apps (see note on http://janvanderhaegen.wordpress.com/2013/07/19/detect-if-the-browser-will-run-your-lightswitch-html-app/)
<script type="text/javascript">
$(document).ready(function () {
var supported = $.mobile.gradeA();
if (!supported) {
$(".ui-icon-loading").hide();
$(".ui-bottom-load").append('<div class="msls-header">This browser is not supported. Please upgrade to a more recent, <a href="http://jquerymobile.com/gbs/">supported</a> version.</div>');
} else {
msls._run()
.then(null, function failure(error) {
alert(error);
@janvanderhaegen
janvanderhaegen / LSHackingChallenge.cs
Last active December 17, 2015 13:48
LS Hacking challenge
namespace LightSwitchApplication
{
public partial class SchedulingViewDiagram
{
partial void SchedulingViewDiagram_Created()
{
this.FindControl("ReallyCoolImageButton").ControlAvailable += SchedulingViewDiagram_ControlAvailable;
}
void SchedulingViewDiagram_ControlAvailable(object sender, ControlAvailableEventArgs e)
@janvanderhaegen
janvanderhaegen / EntityPropertiesForColor.xml
Last active December 16, 2015 14:40
Poor man's solution when you need to restrict a LightSwitch entity to colors (and you need a lot of colors)... (Modify Service.lsml)
<EntityProperty
Name="Color"
PropertyType=":String">
<EntityProperty.Attributes>
<Required />
<MaxLength
Value="255" />
<SupportedValue
DisplayName="Aero"
Value="#7CB9E8" />
@janvanderhaegen
janvanderhaegen / switchtory.lightswitchsearchbox
Created March 22, 2013 15:27
JavaScript snippet to turn a "custom control" into a JQuery search box (and move it to the command bar)
(function ($) {
$.widget("switchtory.lightswitchsearchbox", {
_create: function () {
},
_init: function () {
@janvanderhaegen
janvanderhaegen / switchtory.lightswitchslider.js
Created March 6, 2013 13:58
JavaScript snippet to turn a LightSwitch List into a Slider.
/// <reference path="jquery-1.7.1.js" />
/// <reference path="jquery.mobile-1.1.1.js" />
/// <reference path="msls-1.0.0.js" />
(function ($) {
$.widget("switchtory.lightswitchSlider", {
options: {
timerInterval: 4000
},