mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Edit mode works in Groups and Entries
This commit is contained in:
@@ -40,6 +40,13 @@
|
|||||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||||
<Setter Property="Margin" Value="20" />
|
<Setter Property="Margin" Value="20" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style x:Key="HeaderTextBoxStyle" TargetType="TextBox">
|
||||||
|
<Setter Property="FontSize" Value="56"/>
|
||||||
|
<Setter Property="FontWeight" Value="Light"/>
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<!--<Setter Property="LineHeight" Value="40"/>-->
|
||||||
|
</Style>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|
||||||
</Application>
|
</Application>
|
||||||
|
@@ -56,10 +56,16 @@
|
|||||||
AutomationProperties.Name="Back"
|
AutomationProperties.Name="Back"
|
||||||
AutomationProperties.AutomationId="BackButton"
|
AutomationProperties.AutomationId="BackButton"
|
||||||
AutomationProperties.ItemType="Navigation Button"/>
|
AutomationProperties.ItemType="Navigation Button"/>
|
||||||
<TextBlock Text="{Binding Title}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1"
|
<TextBox
|
||||||
IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
|
Grid.Column="1"
|
||||||
|
Text="{Binding Title, Mode=TwoWay}"
|
||||||
|
Style="{StaticResource HeaderTextBoxStyle}"
|
||||||
|
IsHitTestVisible="{Binding IsEditMode}"
|
||||||
|
TextWrapping="NoWrap"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="0,0,30,0"/>
|
||||||
<CommandBar Grid.Column="2" Margin="0,40,0,0" Background="Transparent" IsOpen="True">
|
<CommandBar Grid.Column="2" Margin="0,40,0,0" Background="Transparent" IsOpen="True">
|
||||||
<AppBarButton Icon="Edit" Label="Edit" />
|
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}" />
|
||||||
<AppBarButton Icon="Delete" Label="Delete" Click="AppBarButton_Click" />
|
<AppBarButton Icon="Delete" Label="Delete" Click="AppBarButton_Click" />
|
||||||
</CommandBar>
|
</CommandBar>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@@ -187,24 +187,21 @@
|
|||||||
AutomationProperties.Name="Back"
|
AutomationProperties.Name="Back"
|
||||||
AutomationProperties.AutomationId="BackButton"
|
AutomationProperties.AutomationId="BackButton"
|
||||||
AutomationProperties.ItemType="Navigation Button"/>
|
AutomationProperties.ItemType="Navigation Button"/>
|
||||||
<TextBlock
|
<TextBox
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Text="{Binding Name}"
|
Text="{Binding Name, Mode=TwoWay}"
|
||||||
Style="{StaticResource HeaderTextBlockStyle}"
|
Style="{StaticResource HeaderTextBoxStyle}"
|
||||||
IsHitTestVisible="false"
|
IsHitTestVisible="{Binding IsEditMode}"
|
||||||
TextWrapping="NoWrap"
|
TextWrapping="NoWrap"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Center"
|
||||||
Margin="0,0,30,40"/>
|
Margin="0,0,30,0"/>
|
||||||
<CommandBar
|
<CommandBar
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Margin="0,40,0,0"
|
Margin="0,40,0,0"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
IsOpen="True">
|
IsOpen="True">
|
||||||
<CommandBar.SecondaryCommands>
|
<AppBarToggleButton Icon="Edit" Label="Edit" IsChecked="{Binding IsEditMode, Mode=TwoWay}" />
|
||||||
<AppBarButton Icon="Edit" Label="Edit" />
|
<AppBarButton Icon="Delete" Label="Delete" IsEnabled="{Binding IsNotRoot}" Click="AppBarButton_Click" />
|
||||||
<AppBarButton Icon="Delete" Label="Delete" IsEnabled="{Binding IsNotRoot}" Click="AppBarButton_Click" />
|
|
||||||
</CommandBar.SecondaryCommands>
|
|
||||||
<AppBarButton Icon="Save" Label="Save" />
|
|
||||||
</CommandBar>
|
</CommandBar>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@@ -1,17 +1,19 @@
|
|||||||
using Windows.UI.Text;
|
using Windows.UI.Text;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using ModernKeePass.Common;
|
||||||
using ModernKeePass.Mappings;
|
using ModernKeePass.Mappings;
|
||||||
using ModernKeePassLib;
|
using ModernKeePassLib;
|
||||||
using ModernKeePassLib.Security;
|
using ModernKeePassLib.Security;
|
||||||
|
|
||||||
namespace ModernKeePass.ViewModels
|
namespace ModernKeePass.ViewModels
|
||||||
{
|
{
|
||||||
public class EntryVm
|
public class EntryVm: NotifyPropertyChangedBase
|
||||||
{
|
{
|
||||||
public GroupVm ParentGroup { get; }
|
public GroupVm ParentGroup { get; }
|
||||||
public PwEntry Entry => _pwEntry;
|
public PwEntry Entry { get; }
|
||||||
public System.Drawing.Color? BackgroundColor => _pwEntry?.BackgroundColor;
|
|
||||||
public System.Drawing.Color? ForegroundColor => _pwEntry?.ForegroundColor;
|
public System.Drawing.Color? BackgroundColor => Entry?.BackgroundColor;
|
||||||
|
public System.Drawing.Color? ForegroundColor => Entry?.ForegroundColor;
|
||||||
|
|
||||||
public string Title
|
public string Title
|
||||||
{
|
{
|
||||||
@@ -47,18 +49,24 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_pwEntry == null) return Symbol.Add;
|
if (Entry == null) return Symbol.Add;
|
||||||
var result = PwIconToSegoeMapping.GetSymbolFromIcon(_pwEntry.IconId);
|
var result = PwIconToSegoeMapping.GetSymbolFromIcon(Entry.IconId);
|
||||||
return result == Symbol.More ? Symbol.Permissions : result;
|
return result == Symbol.More ? Symbol.Permissions : result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly PwEntry _pwEntry;
|
public bool IsEditMode
|
||||||
|
{
|
||||||
|
get { return _isEditMode; }
|
||||||
|
set { SetProperty(ref _isEditMode, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _isEditMode;
|
||||||
|
|
||||||
public EntryVm() { }
|
public EntryVm() { }
|
||||||
public EntryVm(PwEntry entry, GroupVm parent)
|
public EntryVm(PwEntry entry, GroupVm parent)
|
||||||
{
|
{
|
||||||
_pwEntry = entry;
|
Entry = entry;
|
||||||
ParentGroup = parent;
|
ParentGroup = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,12 +77,12 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
private string GetEntryValue(string key)
|
private string GetEntryValue(string key)
|
||||||
{
|
{
|
||||||
return _pwEntry?.Strings.GetSafe(key).ReadString();
|
return Entry?.Strings.GetSafe(key).ReadString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetEntryValue(string key, string newValue)
|
private void SetEntryValue(string key, string newValue)
|
||||||
{
|
{
|
||||||
_pwEntry?.Strings.Set(key, new ProtectedString(true, newValue));
|
Entry?.Strings.Set(key, new ProtectedString(true, newValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,12 +13,17 @@ namespace ModernKeePass.ViewModels
|
|||||||
public GroupVm ParentGroup { get; }
|
public GroupVm ParentGroup { get; }
|
||||||
public ObservableCollection<EntryVm> Entries { get; set; } = new ObservableCollection<EntryVm>();
|
public ObservableCollection<EntryVm> Entries { get; set; } = new ObservableCollection<EntryVm>();
|
||||||
public ObservableCollection<GroupVm> Groups { get; set; } = new ObservableCollection<GroupVm>();
|
public ObservableCollection<GroupVm> Groups { get; set; } = new ObservableCollection<GroupVm>();
|
||||||
public string Name => _pwGroup == null ? "New group" : _pwGroup.Name;
|
|
||||||
public int EntryCount => Entries.Count - 1;
|
public int EntryCount => Entries.Count - 1;
|
||||||
public int GroupCount => Groups.Count - 1;
|
public int GroupCount => Groups.Count - 1;
|
||||||
public bool IsNotRoot => ParentGroup != null;
|
public bool IsNotRoot => ParentGroup != null;
|
||||||
public FontWeight FontWeight => _pwGroup == null ? FontWeights.Bold : FontWeights.Normal;
|
public FontWeight FontWeight => _pwGroup == null ? FontWeights.Bold : FontWeights.Normal;
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return _pwGroup == null ? "New group" : _pwGroup.Name; }
|
||||||
|
set { _pwGroup.Name = value; }
|
||||||
|
}
|
||||||
public Symbol IconSymbol
|
public Symbol IconSymbol
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -35,8 +40,15 @@ namespace ModernKeePass.ViewModels
|
|||||||
set { SetProperty(ref _isLeftPaneOpen, value); }
|
set { SetProperty(ref _isLeftPaneOpen, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsEditMode
|
||||||
|
{
|
||||||
|
get { return _isEditMode; }
|
||||||
|
set { SetProperty(ref _isEditMode, value); }
|
||||||
|
}
|
||||||
|
|
||||||
private readonly PwGroup _pwGroup;
|
private readonly PwGroup _pwGroup;
|
||||||
private bool _isLeftPaneOpen;
|
private bool _isLeftPaneOpen;
|
||||||
|
private bool _isEditMode;
|
||||||
|
|
||||||
public GroupVm() {}
|
public GroupVm() {}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user