Skip to content

Commit 9b03b29

Browse files
author
Marcel Sandermann
committed
Add IEditableObject interface and behavior
1 parent 34cd1b5 commit 9b03b29

File tree

3 files changed

+226
-80
lines changed

3 files changed

+226
-80
lines changed

src/Moryx.Controls.Demo/ViewModels/EntryEditorViewModel.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) 2020, Phoenix Contact GmbH & Co. KG
22
// Licensed under the Apache License, Version 2.0
33

4+
using System;
45
using System.Collections.Generic;
56
using System.Windows;
67
using System.Windows.Input;
@@ -13,12 +14,30 @@ namespace Moryx.Controls.Demo.ViewModels
1314
{
1415
public class EntryEditorViewModel : Screen
1516
{
17+
private bool _isEditMode;
18+
1619
public override string DisplayName => "EntryEditor";
1720

1821
public EntryViewModel EntryViewModels { get; }
1922

2023
public ICommand ShowExceptionCommand { get; }
2124

25+
public ICommand BeginEditCmd { get; }
26+
27+
public ICommand EndEditCmd { get; }
28+
29+
public ICommand CancelEditCmd { get; }
30+
31+
public bool IsEditMode
32+
{
33+
get { return _isEditMode; }
34+
private set
35+
{
36+
_isEditMode = value;
37+
NotifyOfPropertyChange();
38+
}
39+
}
40+
2241
public EntryEditorViewModel()
2342
{
2443
var entryModel = new EntryClass
@@ -62,6 +81,26 @@ public EntryEditorViewModel()
6281
EntryViewModels = new EntryViewModel(entry);
6382

6483
ShowExceptionCommand = new RelayCommand(ShowException);
84+
BeginEditCmd = new RelayCommand(BeginEdit);
85+
EndEditCmd = new RelayCommand(EndEdit);
86+
CancelEditCmd = new RelayCommand(CancelEdit);
87+
}
88+
89+
private void EndEdit(object obj)
90+
{
91+
throw new NotImplementedException();
92+
}
93+
94+
private void CancelEdit(object obj)
95+
{
96+
IsEditMode = false;
97+
EntryViewModels.CancelEdit();
98+
}
99+
100+
private void BeginEdit(object obj)
101+
{
102+
IsEditMode = true;
103+
EntryViewModels.BeginEdit();
65104
}
66105

67106
public void ShowException(object parameter)

src/Moryx.Controls.Demo/Views/EntryEditorView.xaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,22 @@
1111
xmlns:controls="clr-namespace:Moryx.Controls;assembly=Moryx.Controls"
1212
mc:Ignorable="d"
1313
d:DataContext="{d:DesignInstance viewModels:EntryEditorViewModel}">
14-
<controls:EntryEditor Margin="20" RootEntry="{Binding EntryViewModels}" IsEditMode="True" ShowExceptionCommand="{Binding ShowExceptionCommand}" />
14+
<DockPanel LastChildFill="True">
15+
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Margin="0,5,5,5" HorizontalAlignment="Right">
16+
<EddieButton Icon="{CommonShape Pencil}"
17+
Command="{Binding BeginEditCmd}"
18+
Content="Begin Edit"/>
19+
<EddieButton Icon="{CommonShape Cross}"
20+
Margin="5,0,0,0"
21+
Command="{Binding CancelEditCmd}"
22+
Content="Cancel Edit"/>
23+
<EddieButton Icon="{CommonShape CheckMark}"
24+
Margin="5,0,0,0"
25+
Command="{Binding EndEditCmd}"
26+
Content="End Edit"/>
27+
</StackPanel>
28+
29+
<controls:EntryEditor Margin="20" DockPanel.Dock="Top" RootEntry="{Binding EntryViewModels}" IsEditMode="{Binding IsEditMode}"
30+
ShowExceptionCommand="{Binding ShowExceptionCommand}" />
31+
</DockPanel>
1532
</UserControl>

0 commit comments

Comments
 (0)