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 / FindContentItems.cs
Created January 22, 2014 14:25
Finds contentitems for an IEntityProperty
public static List<IContentItem> FindContentItems(this IScreenObject screen, IEntityProperty viewModel)
{
IPresentationScreenView screenView = VsExportProviderService
.GetServiceFromCache<IServiceProxy>().ScreenViewService.GetScreenView(screen) as IPresentationScreenView;
if (screenView == null)
{
throw new InvalidOperationException();
}
IContentItem currentView = screenView.ContentItemTree;
@janvanderhaegen
janvanderhaegen / ColorBackground
Created January 22, 2014 14:29
Colors the background of a control.
public static IEnumerable<IContentItemPresenter> GetAssociatedPresenters(this IContentItem contentItem)
{
var internale = contentItem as IContentItemInternal;
if (internale == null)
return new List<IContentItemPresenter>();
return internale.AssociatedPresenters;
}
public static void SetBackground(this IContentItemPresenter presenter, Color color)
var userViewer = $('<a id="userviewer" href="#" target="_self" >' + user.Name + '</a>');
userViewer.appendTo($(".msls-screen-buttons"));
//interaction 1
userViewer.on('click', function () {
myapp.showEditMyProfile(user);
});
contentItem.dataBind("value.Name", function () {
//interaction 2
$("#userviewer").text(contentItem.value.Name);
@janvanderhaegen
janvanderhaegen / ExpressionCombiner
Created September 5, 2014 19:59
C# code to combine two lambda expressions
//Shoutout to MBoros on stackoverflow
public static class ExpressionCombiner {
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> exp, Expression<Func<T, bool>> newExp)
{
// get the visitor
var visitor = new ParameterUpdateVisitor(newExp.Parameters.First(), exp.Parameters.First());
// replace the parameter in the expression just created
newExp = visitor.Visit(newExp) as Expression<Func<T, bool>>;
// now you can and together the two expressions
@janvanderhaegen
janvanderhaegen / myscreen.lsml.js
Created October 7, 2014 00:57
SP Overlay: CSS
myapp.menuHome.buttonResources_postRender = function (element, contentItem) {
$(element).spOverlay(contentItem, 'Content/Images/TouchIcons/ResourcesLarge.png', { height:170, width:170});
};
myapp.menuHome.buttonDesigns_postRender = function (element, contentItem) {
$(element).spOverlay(contentItem, 'Content/Images/TouchIcons/DesignsLarge.png');
};
myapp.menuHome.buttonProjects_postRender = function (element, contentItem) {
$(element).spOverlay(contentItem, 'Content/Images/TouchIcons/ProjectsLarge.png');
@janvanderhaegen
janvanderhaegen / LoadOnDemandExtensions.cs
Last active January 19, 2020 05:42
Loading of collections in the desktop client on a 'need to see' basis.
using Microsoft.LightSwitch.Client;
using Microsoft.LightSwitch.Details.Client;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using Microsoft.LightSwitch.Presentation.Internal;
using Microsoft.LightSwitch.Sdk.Proxy;
using Microsoft.VisualStudio.ExtensibilityHosting;
using System;
using System.Collections.Generic;