added a new tab dialog window
This commit is contained in:
parent
a6904ecb34
commit
0d129c574a
Binary file not shown.
Binary file not shown.
|
@ -7,6 +7,9 @@
|
|||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Views\Dialogs\NewTabDialogView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Views\LightingModes\AnimationView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
@ -21,6 +24,9 @@
|
|||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Views\Dialogs\NewTabDialogView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Views\LightingModes\AnimationView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using RGBController2.Commands;
|
||||
using RGBController2.Views.Dialogs;
|
||||
|
||||
namespace RGBController2.ViewModels.Dialogs
|
||||
{
|
||||
class NewTabDialogViewModel : BaseViewModel
|
||||
{
|
||||
private NewTabDialogView DialogWindow;
|
||||
|
||||
public ICommand AddTabCommand { get; }
|
||||
|
||||
private string _deviceName;
|
||||
public string DeviceName
|
||||
{
|
||||
get { return _deviceName; }
|
||||
set { _deviceName = value; }
|
||||
}
|
||||
|
||||
private int _selectedDeviceType;
|
||||
|
||||
public int SelectedDeviceType
|
||||
{
|
||||
get { return _selectedDeviceType; }
|
||||
set { _selectedDeviceType = value; }
|
||||
}
|
||||
|
||||
private bool _success;
|
||||
public bool Success
|
||||
{
|
||||
get { return _success; }
|
||||
}
|
||||
public NewTabDialogViewModel()
|
||||
{
|
||||
AddTabCommand = new ActionCommand(p => AddTab());
|
||||
_success = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates window instance for this dialog viewmodel and displays it, getting the dialog result.
|
||||
/// </summary>
|
||||
public void ShowDialogWindow()
|
||||
{
|
||||
// This is a property of the DialogViewModelBase class - thus, each DialogViewModel holds a reference to its own DialogWindow:
|
||||
this.DialogWindow = new NewTabDialogView();
|
||||
// Tell the DialogWindow to display this ViewModel:
|
||||
this.DialogWindow.DataContext = this;
|
||||
// Launch the Window, using a method of the Window baseclass, that only returns when the window is closed:
|
||||
this.DialogWindow.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the call back function used for the add button.
|
||||
/// </summary>
|
||||
public void AddTab()
|
||||
{
|
||||
// Do some validation here
|
||||
string errorMessage = "";
|
||||
|
||||
if (DeviceName == "" || DeviceName == null)
|
||||
errorMessage += " - Device Name cannot be left empty\n";
|
||||
|
||||
// Close the dialog window if validdation passes
|
||||
if (errorMessage == "")
|
||||
{
|
||||
_success = true;
|
||||
DialogWindow.Close();
|
||||
}
|
||||
else
|
||||
MessageBox.Show("Validation error\n" + errorMessage);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ using System.Text;
|
|||
using System.Windows.Input;
|
||||
using RGBController2.Commands;
|
||||
using RGBController2.ViewModels.Tabs;
|
||||
using RGBController2.ViewModels.Dialogs;
|
||||
|
||||
namespace RGBController2.ViewModels
|
||||
{
|
||||
|
@ -50,7 +51,16 @@ namespace RGBController2.ViewModels
|
|||
|
||||
private void NewTab()
|
||||
{
|
||||
Tabs.Add(new ArduinoTab(DateTime.UtcNow.ToString()));
|
||||
// Open the add tab dialog
|
||||
var dialog = new NewTabDialogViewModel();
|
||||
dialog.ShowDialogWindow();
|
||||
|
||||
// Use the results from the dialog when creating the new tab
|
||||
if (dialog.Success)
|
||||
{
|
||||
Tabs.Add(new ArduinoTab(dialog.DeviceName));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<Window x:Class="RGBController2.Views.Dialogs.NewTabDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:RGBController2.Views.Dialogs"
|
||||
mc:Ignorable="d"
|
||||
Title="NewTabDialogView" Height="150" Width="300">
|
||||
<Grid>
|
||||
<Label Content="Device Type" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5,5,0,0"/>
|
||||
<ComboBox VerticalAlignment="Top" HorizontalAlignment="Left" Margin="90,5,0,0" Width="150" SelectedIndex="{Binding SelectedDeviceType}">
|
||||
<ComboBoxItem>Arduino</ComboBoxItem>
|
||||
<ComboBoxItem>Corsair Keyboard</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<Label Content="Device Name" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5,30,0,0"/>
|
||||
<TextBox VerticalAlignment="Top" HorizontalAlignment="Left" Margin="90,35,0,0" Width="150" Text="{Binding DeviceName}"/>
|
||||
<Button VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,80,0,0" Content="Add Device" Command="{Binding AddTabCommand}"/>
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Shapes;
|
||||
|
||||
namespace RGBController2.Views.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for NewTabDialogView.xaml
|
||||
/// </summary>
|
||||
public partial class NewTabDialogView : Window
|
||||
{
|
||||
public NewTabDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -52,3 +52,5 @@ C:\Users\Conor\Desktop\RGB Contorller Tabs Test\RGBController\RGBController2\bin
|
|||
C:\Users\Conor\Desktop\RGB Contorller Tabs Test\RGBController\RGBController2\bin\Debug\netcoreapp3.1\zh-Hans\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\Users\Conor\Desktop\RGB Contorller Tabs Test\RGBController\RGBController2\obj\Debug\netcoreapp3.1\Views\LightingModes\InformationView.g.cs
|
||||
C:\Users\Conor\Desktop\RGB Contorller Tabs Test\RGBController\RGBController2\obj\Debug\netcoreapp3.1\Views\LightingModes\InformationView.baml
|
||||
C:\Users\Conor\Desktop\RGB Contorller Tabs Test\RGBController\RGBController2\obj\Debug\netcoreapp3.1\Views\Dialogs\NewTabDialogView.g.cs
|
||||
C:\Users\Conor\Desktop\RGB Contorller Tabs Test\RGBController\RGBController2\obj\Debug\netcoreapp3.1\Views\Dialogs\NewTabDialogView.baml
|
||||
|
|
Binary file not shown.
|
@ -10,11 +10,11 @@ none
|
|||
false
|
||||
TRACE;DEBUG;NETCOREAPP;NETCOREAPP3_1
|
||||
C:\Users\Conor\Desktop\RGB Contorller Tabs Test\RGBController\RGBController2\App.xaml
|
||||
51005650093
|
||||
6528146077
|
||||
|
||||
211693773004
|
||||
23-1728879787
|
||||
198942953170
|
||||
Views\LightingModes\AnimationView.xaml;Views\LightingModes\InformationView.xaml;Views\LightingModes\StaticView.xaml;Views\MainWindow.xaml;Views\Tabs\ArduinoTabView.xaml;
|
||||
Views\Dialogs\NewTabDialogView.xaml;Views\LightingModes\AnimationView.xaml;Views\LightingModes\InformationView.xaml;Views\LightingModes\StaticView.xaml;Views\MainWindow.xaml;Views\Tabs\ArduinoTabView.xaml;
|
||||
|
||||
False
|
||||
|
||||
|
|
Loading…
Reference in New Issue