MainWindow geändert, dynamische Menu erzeugt
This commit is contained in:
76
KanSan/UI/UCSewerMainMenu.xaml.cs
Normal file
76
KanSan/UI/UCSewerMainMenu.xaml.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using KanSan.Base.Models;
|
||||
using KanSan.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace KanSan.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für UCSewerMainMenu.xaml
|
||||
/// </summary>
|
||||
public partial class UCSewerMainMenu : UserControl
|
||||
{
|
||||
public event EventHandler<SewerMainMenuItemSelectedEventArgs> SewerMainMenuSelected;
|
||||
|
||||
protected virtual void OnSewerMenuSelected(SewerMainMenuItemSelectedEventArgs e)
|
||||
{
|
||||
EventHandler<SewerMainMenuItemSelectedEventArgs> handler = SewerMainMenuSelected;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
|
||||
public UCSewerMainMenu(Sewer objekt)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new SewerMainMenuViewModel(objekt);
|
||||
Style style = this.FindResource("ToggelButtonList") as Style;
|
||||
|
||||
RadioButton radioButton = new RadioButton();
|
||||
radioButton.Name = "Schlauch122123";
|
||||
radioButton.Content = "Schlauchliner";
|
||||
radioButton.Style = style;
|
||||
radioButton.Checked += rbSewerMenuItem_Checked;
|
||||
|
||||
MenuItems.Children.Add(radioButton);
|
||||
}
|
||||
|
||||
private void rbSewerMenuItem_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
RadioButton radioButton = (RadioButton)sender;
|
||||
if (radioButton == null) return;
|
||||
//Debugger.Break();
|
||||
ESewerMainMenuCommand command = ESewerMainMenuCommand.NONE;
|
||||
if (radioButton.Name.Equals("rbStammdaten")) command = ESewerMainMenuCommand.STAMMDATEN;
|
||||
else if (radioButton.Name.Equals("rbSchaeden")) command = ESewerMainMenuCommand.SCHAEDEN;
|
||||
|
||||
OnSewerMenuSelected(new SewerMainMenuItemSelectedEventArgs()
|
||||
{
|
||||
Command = command
|
||||
}) ;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ESewerMainMenuCommand
|
||||
{
|
||||
NONE,
|
||||
STAMMDATEN,
|
||||
SCHAEDEN,
|
||||
SANIERUNG
|
||||
}
|
||||
public class SewerMainMenuItemSelectedEventArgs : EventArgs
|
||||
{
|
||||
public ESewerMainMenuCommand Command { get; set; }
|
||||
public int Parameter { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user