Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/Moryx.Controls.Demo/ViewModels/EntryEditorViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2020, Phoenix Contact GmbH & Co. KG
// Licensed under the Apache License, Version 2.0

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;
Expand All @@ -13,12 +14,30 @@ namespace Moryx.Controls.Demo.ViewModels
{
public class EntryEditorViewModel : Screen
{
private bool _isEditMode;

public override string DisplayName => "EntryEditor";

public EntryViewModel EntryViewModels { get; }

public ICommand ShowExceptionCommand { get; }

public ICommand BeginEditCmd { get; }

public ICommand EndEditCmd { get; }

public ICommand CancelEditCmd { get; }

public bool IsEditMode
{
get { return _isEditMode; }
private set
{
_isEditMode = value;
NotifyOfPropertyChange();
}
}

public EntryEditorViewModel()
{
var entryModel = new EntryClass
Expand Down Expand Up @@ -62,6 +81,26 @@ public EntryEditorViewModel()
EntryViewModels = new EntryViewModel(entry);

ShowExceptionCommand = new RelayCommand(ShowException);
BeginEditCmd = new RelayCommand(BeginEdit);
EndEditCmd = new RelayCommand(EndEdit);
CancelEditCmd = new RelayCommand(CancelEdit);
}

private void EndEdit(object obj)
{
throw new NotImplementedException();
}

private void CancelEdit(object obj)
{
IsEditMode = false;
EntryViewModels.CancelEdit();
}

private void BeginEdit(object obj)
{
IsEditMode = true;
EntryViewModels.BeginEdit();
}

public void ShowException(object parameter)
Expand Down
19 changes: 18 additions & 1 deletion src/Moryx.Controls.Demo/Views/EntryEditorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,22 @@
xmlns:controls="clr-namespace:Moryx.Controls;assembly=Moryx.Controls"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance viewModels:EntryEditorViewModel}">
<controls:EntryEditor Margin="20" RootEntry="{Binding EntryViewModels}" IsEditMode="True" ShowExceptionCommand="{Binding ShowExceptionCommand}" />
<DockPanel LastChildFill="True">
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Margin="0,5,5,5" HorizontalAlignment="Right">
<EddieButton Icon="{CommonShape Pencil}"
Command="{Binding BeginEditCmd}"
Content="Begin Edit"/>
<EddieButton Icon="{CommonShape Cross}"
Margin="5,0,0,0"
Command="{Binding CancelEditCmd}"
Content="Cancel Edit"/>
<EddieButton Icon="{CommonShape CheckMark}"
Margin="5,0,0,0"
Command="{Binding EndEditCmd}"
Content="End Edit"/>
</StackPanel>

<controls:EntryEditor Margin="20" DockPanel.Dock="Top" RootEntry="{Binding EntryViewModels}" IsEditMode="{Binding IsEditMode}"
ShowExceptionCommand="{Binding ShowExceptionCommand}" />
</DockPanel>
</UserControl>
Loading