Skip to content

Instantly share code, notes, and snippets.

View dgwaldo's full-sized avatar
🏠
Working from home

Don W. dgwaldo

🏠
Working from home
View GitHub Profile
@dgwaldo
dgwaldo / CustomNotificationPopupView
Last active August 29, 2015 14:08
Prism Custom PopupWindowAction
<UserControl x:Class="KNE.Athena.Infrastructure.UserControls.NotificationPopupView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Width="400"
Height="180"
Name="Root">
@dgwaldo
dgwaldo / ConfigurationManagerWrapper
Last active August 29, 2015 14:08
Changing SQL Connection String
public class ConfigurationManagerWrapper : IConfigurationManager
{
public NameValueCollection AppSettings
{
get
{
return ConfigurationManager.AppSettings;
}
}
@dgwaldo
dgwaldo / ExceptionFilterRegistration
Created October 28, 2014 18:43
Example of WebAPI 2 Exception Filter
public static class WebApiConfig{
public static void Register(HttpConfiguration config)
{
#if DEBUG
config.Filters.Add(new DebugGeneralExceptionAttribute());
#endif
webApiConfig . Filters. Add( new DbEntityValidationExceptionAttribute ());
// Other configuration code...
@dgwaldo
dgwaldo / ListCollectionView Custom Sort
Created October 16, 2014 00:54
ListCollectionView Wireup with CustomSort
//Exmaple wire up of ListCollectionView in constructor
public FluidViewModel()
{
_fluidPoints = new ObservableCollection<FluidPointViewModel>();
FluidPointsSorted = new ListCollectionView(_fluidPoints) { CustomSort = new FluidSortComparer() };
}
@dgwaldo
dgwaldo / Comparer<T> Example
Created October 16, 2014 00:48
Custom Sort For ListCollectionView
public class FluidSortComparer : Comparer<FluidPointViewModel>
{
public override int Compare(FluidPointViewModel x, FluidPointViewModel y)
{
if (x == null | y == null) return 0;
if (x.Temperature > y.Temperature) return 1;
if (x.Temperature < y.Temperature) return -1;
return 0;
}
}
@dgwaldo
dgwaldo / Horizontal & Vertical GridSplitter Example
Last active August 29, 2015 14:07
Horizontal & Vertical GridSplitter Example - with two list boxes above and below the horizontal split.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<h:HelixViewport3D Name="HelixViewport3D"
PanGesture="LeftClick"
DataContext="{Binding PreviewPlot, UpdateSourceTrigger=PropertyChanged}"
DefaultCamera="{Binding PerspectiveCamera, UpdateSourceTrigger=PropertyChanged}"
services:HelixViewport3DZoomExtent.ZoomExtentsOnUpdate="{Binding RelativeSource={RelativeSource AncestorType={x:Type views:WellSurveyPlot3DPreview}},
Path=DataContext.PreviewUpdatedReZoom, UpdateSourceTrigger=PropertyChanged}">
<h:SunLight/>
<h:TubeVisual3D Path="{Binding TubePath}" Diameter="75" ThetaDiv="12" IsPathClosed="False" Fill="DarkSlateGray"/>
public class WellSurveyPlot3DViewModel : BindableBase
{
private readonly List<WellXyzPoint> _calculatedSurveyPoints;
private int _xDir;
private int _yDir;
public WellSurveyPlot3DViewModel(List<WellXyzPoint> calculatedSurveyPoints)
{
_calculatedSurveyPoints = calculatedSurveyPoints;
MajorGridSpacing = 300; //Meters
[TestMethod]
public void LoadData_SendsUpdateStatusEvents()
{
//Arrange
_mockEventAggregator.Setup(x => x.GetEvent<UpdateStatusEvent>().Publish(It.IsAny<string>()));
//Act
_materialMasterVm.LoadData().GetAwaiter();
//Assert
_mockEventAggregator.Verify(x => x.GetEvent<UpdateStatusEvent>().Publish(It.IsAny<string>()), Times.Exactly(2));
}