private void loadButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = Directory.GetCurrentDirectory(); dialog.RestoreDirectory = true; dialog.Filter = "yml files (*.yml)|*.yml|All files (*.*)|*.*"; if (dialog.ShowDialog() == true) { SolutionInput input = SolutionInput.FromFile(dialog.FileName); input.SetInput(parameters); if (input.IsFilterGrid) { Dependencies.RemoveFilter(); // TODO reduce extra code? FilterGrid filter = new FilterGrid(filterPanel); filter.Set(input.FilterGrid); filterBuilder = filter; } else { Dependencies.RemoveFilter(); FilterFormulas filter = new FilterFormulas(filterPanel, Dependencies); filter.Deserialize(input.FilterFormulas); filterBuilder = filter; } } }
public FormulaSlot(FilterFormulas builder, int k, int n, WrapPanel holder) { Builder = builder; Holder = holder; K = k; N = n; Container = new Grid(); Container.ColumnDefinitions.Add(ColumnAuto()); Container.ColumnDefinitions.Add(ColumnAuto()); Container.ColumnDefinitions.Add(ColumnAuto()); Container.RowDefinitions.Add(RowAuto()); Container.RowDefinitions.Add(RowAuto()); holder.Children.Add(Container); Button removeButton = new Button() { Content = "✕", VerticalContentAlignment = VerticalAlignment.Stretch, MinWidth = 20, Height = 20, Margin = new Thickness(0, 0, 5, 0) }; removeButton.Click += (a, b) => RemoveButton_Clicked(); Container.Children.Add(removeButton); TextBlock name = new TextBlock() { Text = "ρ" }; Grid.SetColumn(name, 1); Container.Children.Add(name); name.UpdateLayout(); TextBlock nameIndex = new TextBlock() { Text = k.ToString() + "," + n.ToString() }; nameIndex.FontSize = name.FontSize * 0.8; nameIndex.Margin = new Thickness(name.ActualWidth, name.ActualHeight - nameIndex.FontSize * 0.8, 0, 0); name.Text = "ρ = "; Grid.SetColumn(nameIndex, 1); Container.Children.Add(nameIndex); Input = new TextBox() { Text = "0", MinWidth = 30, Height = name.ActualHeight, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, 0, 15, 0) }; Result = new TextBlock() { Text = "0" }; Grid.SetColumn(Input, 2); Grid.SetColumn(Result, 2); Grid.SetRow(Result, 1); Container.Children.Add(Input); Container.Children.Add(Result); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Logger.Destination = log; RenderOptions.SetBitmapScalingMode(scopeImage, BitmapScalingMode.NearestNeighbor); RadioButton[] filterModeButtons = { matrixRadioButton, formulaRadioButton }; FilterModeGroup = new RadioButtonGroup(filterModeButtons); FilterModeGroup.Changed += FillModeChanged; RadioButton[] solMethodButtons = { explicitRadioButton, implicitRadioButton }; SolutionMethodGroup = new RadioButtonGroup(solMethodButtons); SolutionMethodGroup.Changed += SolutionMethodChanged; Dependencies = new DependencySpace(); AddParam("D", "D"); AddParam("A_0", "A0"); AddParam("K", "K"); AddParam("T", "T"); AddParam("t_count", "time"); AddParam("x_count", "spatial"); AddParam("u_0", "u0(x)"); AddLabel(""); AddParam("v", "v(x, t)"); AddButton("Draw v(x,t)", (a, b) => DrawExpectedSolution()); SolutionInput defaultInput = new SolutionInput(); defaultInput.SetInput(parameters); if (defaultInput.IsFilterGrid) { FilterGrid filterGrid = new FilterGrid(filterPanel); filterGrid.Set(defaultInput.FilterGrid); filterBuilder = filterGrid; } else { FilterFormulas filterFormulas = new FilterFormulas(filterPanel, Dependencies); filterFormulas.Deserialize(defaultInput.FilterFormulas); filterBuilder = filterFormulas; } }