void UpdateParameterUI() { ParameterGrid.Children.Clear(); ParameterGrid.RowDefinitions.Clear(); int useRow = 0; foreach (var parameter in ShaderParser.ParameterList) { //Boolean if (parameter.Type == typeof(bool)) { var rd = new RowDefinition(); rd.Height = new GridLength(50); ParameterGrid.RowDefinitions.Add(rd); var boolView = new BoolView(); var boolDc = new BoolViewModel(); boolDc.ShaderName = parameter.ShaderName; if (parameter.DefaultValue != string.Empty) { boolDc.ContentValue = bool.Parse(parameter.DefaultValue); } boolView.DataContext = boolDc; boolView.SetValue(Grid.RowProperty, useRow); ParameterGrid.Children.Add(boolView); ++useRow; } //Int else if (parameter.Type == typeof(int)) { var rd = new RowDefinition(); rd.Height = new GridLength(50); ParameterGrid.RowDefinitions.Add(rd); var intView = new IntView(); var intDc = new IntViewModel(); intDc.ShaderName = parameter.ShaderName; if (parameter.DefaultValue != string.Empty) { intDc.ContentValue = int.Parse(parameter.DefaultValue); } intView.DataContext = intDc; intView.SetValue(Grid.RowProperty, useRow); ParameterGrid.Children.Add(intView); ++useRow; } //Float if (parameter.Type == typeof(float)) { var rd = new RowDefinition(); rd.Height = new GridLength(50); ParameterGrid.RowDefinitions.Add(rd); var floatView = new FloatView(); var floatViewDc = new FloatViewModel(); floatViewDc.ShaderName = parameter.ShaderName; if (parameter.DefaultValue != string.Empty) { floatViewDc.ContentValue = float.Parse(parameter.DefaultValue, CultureInfo.InvariantCulture); } floatView.DataContext = floatViewDc; floatView.SetValue(Grid.RowProperty, useRow); ParameterGrid.Children.Add(floatView); ++useRow; } //Float2 else if (parameter.Type == typeof(Float2)) { var rd = new RowDefinition(); rd.Height = new GridLength(75); ParameterGrid.RowDefinitions.Add(rd); var float2View = new Float2View(); var float2Dc = new Float2ViewModel(); float2Dc.ShaderName = parameter.ShaderName; if (parameter.DefaultValue != string.Empty) { float2Dc.ContentValue = new Float2(parameter.DefaultValue); } float2View.DataContext = float2Dc; float2View.SetValue(Grid.RowProperty, useRow); ParameterGrid.Children.Add(float2View); ++useRow; } //Float3 else if (parameter.Type == typeof(Float3)) { var rd = new RowDefinition(); rd.Height = new GridLength(75); ParameterGrid.RowDefinitions.Add(rd); var float3View = new Float3View(); var float3Dc = new Float3ViewModel(); float3Dc.ShaderName = parameter.ShaderName; if (parameter.DefaultValue != string.Empty) { float3Dc.ContentValue = new Float3(parameter.DefaultValue); } float3View.DataContext = float3Dc; float3View.SetValue(Grid.RowProperty, useRow); ParameterGrid.Children.Add(float3View); ++useRow; } //Float4 else if (parameter.Type == typeof(Float4)) { var rd = new RowDefinition(); rd.Height = new GridLength(75); ParameterGrid.RowDefinitions.Add(rd); var float4View = new Float4View(); var float4Dc = new Float4ViewModel(); float4Dc.ShaderName = parameter.ShaderName; if (parameter.DefaultValue != string.Empty) { float4Dc.ContentValue = new Float4(parameter.DefaultValue); } float4View.DataContext = float4Dc; float4View.SetValue(Grid.RowProperty, useRow); ParameterGrid.Children.Add(float4View); ++useRow; } //Texture2D else if (parameter.Type == typeof(Texture2D)) { var rd = new RowDefinition(); rd.Height = new GridLength(75); ParameterGrid.RowDefinitions.Add(rd); var textureView = new Texture2DView(); var textureDc = new Texture2DViewModel(); textureDc.ShaderName = parameter.ShaderName; if (parameter.DefaultValue == String.Empty) { textureDc.ContentValue = Resource.FromFile <Texture2D>(ViewPort.GetDevice(), @"./Textures/TestTexture.png"); textureDc.FileName = @"./Textures/TestTexture.png"; } else { textureDc.ContentValue = Resource.FromFile <Texture2D>(ViewPort.GetDevice(), parameter.DefaultValue); textureDc.FileName = parameter.DefaultValue; } textureDc.SetDevice(ViewPort.GetDevice()); textureView.DataContext = textureDc; textureView.SetValue(Grid.RowProperty, useRow); ParameterGrid.Children.Add(textureView); ++useRow; } } UndoRedoStack.Reset(); }