Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 80d1498cc7 | |||
| de2f453553 | |||
| 7e168c4d0f | |||
| 9becedbd97 | |||
| 16982c3d95 | |||
| 93771dd110 | |||
| 3e14731429 |
+5
-1
@@ -327,8 +327,12 @@
|
|||||||
<Grid ColumnDefinitions="300,*">
|
<Grid ColumnDefinitions="300,*">
|
||||||
<Border Grid.Column="0" Background="#FFF" BorderBrush="#DDD" BorderThickness="0,0,1,0">
|
<Border Grid.Column="0" Background="#FFF" BorderBrush="#DDD" BorderThickness="0,0,1,0">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<Button Content="+ Hinzufügen" Margin="10" x:Name="BtnWikiAddFile"
|
<StackPanel Spacing="10" Orientation="Horizontal" Margin="10">
|
||||||
|
<Button Content="+ Datei" x:Name="BtnWikiAddFile"
|
||||||
Click="BtnWikiAddFile_OnClick" />
|
Click="BtnWikiAddFile_OnClick" />
|
||||||
|
<Button Content="+ Ordner" x:Name="BtnWikiAddFolder"
|
||||||
|
Click="BtnWikiAddFolder_OnClick" />
|
||||||
|
</StackPanel>
|
||||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
|
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
|
||||||
<TreeView Name="NavTree" Margin="10" />
|
<TreeView Name="NavTree" Margin="10" />
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|||||||
+103
-4
@@ -260,12 +260,20 @@ public partial class MainWindow : Window
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PopulateNavTree()
|
public void PopulateNavTree(string? expandToPath = null, string? selectPath = null)
|
||||||
{
|
{
|
||||||
var roots = _wikiService.GetRootItems();
|
var roots = _wikiService.GetRootItems();
|
||||||
var nodes = new List<TreeViewItem>();
|
var nodes = new List<TreeViewItem>();
|
||||||
foreach (var r in roots) nodes.Add(BuildNode(r));
|
foreach (var r in roots) nodes.Add(BuildNode(r));
|
||||||
NavTree.ItemsSource = nodes;
|
NavTree.ItemsSource = nodes;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(expandToPath))
|
||||||
|
ExpandAndFindNode(nodes, expandToPath, out _);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(selectPath) &&
|
||||||
|
ExpandAndFindNode(nodes, selectPath, out var selectedNode) &&
|
||||||
|
selectedNode != null)
|
||||||
|
NavTree.SelectedItem = selectedNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TreeViewItem BuildNode(WikiItem item)
|
private TreeViewItem BuildNode(WikiItem item)
|
||||||
@@ -278,6 +286,63 @@ public partial class MainWindow : Window
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetSelectedWikiTargetDirectory()
|
||||||
|
{
|
||||||
|
var wikiRoot = Global._instance.wiki_storage_path;
|
||||||
|
if (NavTree.SelectedItem is TreeViewItem treeItem && treeItem.Tag is WikiItem selectedItem)
|
||||||
|
{
|
||||||
|
if (selectedItem.IsFolder) return selectedItem.Path;
|
||||||
|
|
||||||
|
var parentDir = Path.GetDirectoryName(selectedItem.Path);
|
||||||
|
if (!string.IsNullOrWhiteSpace(parentDir)) return parentDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wikiRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool PathsEqual(string left, string right)
|
||||||
|
{
|
||||||
|
var normalizedLeft = Path.GetFullPath(left)
|
||||||
|
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||||
|
var normalizedRight = Path.GetFullPath(right)
|
||||||
|
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||||
|
|
||||||
|
var comparison = OperatingSystem.IsWindows()
|
||||||
|
? StringComparison.OrdinalIgnoreCase
|
||||||
|
: StringComparison.Ordinal;
|
||||||
|
return string.Equals(normalizedLeft, normalizedRight, comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ExpandAndFindNode(IEnumerable<TreeViewItem> nodes, string targetPath, out TreeViewItem? foundNode)
|
||||||
|
{
|
||||||
|
foreach (var node in nodes)
|
||||||
|
if (TryExpandToPath(node, targetPath, out foundNode))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
foundNode = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryExpandToPath(TreeViewItem node, string targetPath, out TreeViewItem? foundNode)
|
||||||
|
{
|
||||||
|
if (node.Tag is WikiItem item && PathsEqual(item.Path, targetPath))
|
||||||
|
{
|
||||||
|
foundNode = node;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var childRaw in node.Items)
|
||||||
|
if (childRaw is TreeViewItem childNode &&
|
||||||
|
TryExpandToPath(childNode, targetPath, out foundNode))
|
||||||
|
{
|
||||||
|
node.IsExpanded = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foundNode = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void OpenFolderButton_Click(object? sender, RoutedEventArgs e)
|
private void OpenFolderButton_Click(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var path = Global._instance.wiki_storage_path;
|
var path = Global._instance.wiki_storage_path;
|
||||||
@@ -991,11 +1056,21 @@ public partial class MainWindow : Window
|
|||||||
private async void BtnWikiAddFile_OnClick(object? sender, RoutedEventArgs e)
|
private async void BtnWikiAddFile_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var result = await NamingWindow.Show(this);
|
var result = await NamingWindow.Show(this);
|
||||||
if (result != null)
|
if (string.IsNullOrWhiteSpace(result)) return;
|
||||||
|
|
||||||
|
result = result.Trim();
|
||||||
|
if (!result.EndsWith(".md", StringComparison.OrdinalIgnoreCase)) result += ".md";
|
||||||
|
|
||||||
|
if (!Directory.Exists(Global._instance.wiki_storage_path))
|
||||||
|
Directory.CreateDirectory(Global._instance.wiki_storage_path);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.WriteAllText(Path.Combine(Global._instance.wiki_storage_path, result), "");
|
var targetDirectory = GetSelectedWikiTargetDirectory();
|
||||||
PopulateNavTree();
|
Directory.CreateDirectory(targetDirectory);
|
||||||
|
var newFilePath = Path.Combine(targetDirectory, result);
|
||||||
|
File.WriteAllText(newFilePath, "");
|
||||||
|
PopulateNavTree(targetDirectory, newFilePath);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1003,6 +1078,30 @@ public partial class MainWindow : Window
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void BtnWikiAddFolder_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var result = await NamingWindow.Show(this);
|
||||||
|
if (string.IsNullOrWhiteSpace(result)) return;
|
||||||
|
|
||||||
|
result = result.Trim();
|
||||||
|
|
||||||
|
if (!Directory.Exists(Global._instance.wiki_storage_path))
|
||||||
|
Directory.CreateDirectory(Global._instance.wiki_storage_path);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var targetDirectory = GetSelectedWikiTargetDirectory();
|
||||||
|
var newFolderPath = Path.Combine(targetDirectory, result);
|
||||||
|
Directory.CreateDirectory(newFolderPath);
|
||||||
|
PopulateNavTree(targetDirectory, newFolderPath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(this, ex.StackTrace, "Fehler");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private async void MnIAdSetRename_OnClick(object? sender, RoutedEventArgs e)
|
private async void MnIAdSetRename_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (LstCustomerAdressSets.SelectedItems.Count > 0)
|
if (LstCustomerAdressSets.SelectedItems.Count > 0)
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ public class CombineAddresses
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool CompareAddresses(KasPerson first, KasPerson second, bool only_refsid = false)
|
public bool CompareAddresses(KasPerson first, KasPerson second, bool only_refsid = false)
|
||||||
{
|
{
|
||||||
if (first.refsid == second.refsid) return true;
|
// A refsid of 0 means "missing", so it must not collapse unrelated entries.
|
||||||
|
if (first.refsid != 0 && second.refsid != 0 && first.refsid == second.refsid) return true;
|
||||||
if (!only_refsid)
|
if (!only_refsid)
|
||||||
if (first.name == second.name &&
|
if (first.name == second.name &&
|
||||||
first.anrede == second.anrede &&
|
first.anrede == second.anrede &&
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
x:Class="Logof_Client.Wiki.EditorWindow"
|
x:Class="Logof_Client.Wiki.EditorWindow"
|
||||||
Title="Wiki Editor" MinWidth="600" MinHeight="350" WindowState="Maximized">
|
Title="Wiki Editor" MinWidth="600" MinHeight="350" WindowState="Maximized">
|
||||||
<Grid>
|
<Grid Margin="10,0,10,10">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="50" />
|
<RowDefinition Height="50" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
<StackPanel Grid.Row="0" Spacing="10" Orientation="Horizontal">
|
||||||
<Button x:Name="BtnSave" Content="Speichern" Click="BtnSave_OnClick" />
|
<Button x:Name="BtnSave" Content="Speichern" Click="BtnSave_OnClick" />
|
||||||
<Button x:Name="BtnSaveAs" Content="Speichern unter..." Click="BtnSaveAs_OnClick" />
|
<Button x:Name="BtnSaveAs" Content="Speichern unter..." Click="BtnSaveAs_OnClick" />
|
||||||
<Button x:Name="BtnDelete" Content="Löschen" Click="BtnDelete_OnClick" />
|
<Button x:Name="BtnDelete" Content="Löschen" Click="BtnDelete_OnClick" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBox Grid.Row="1" x:Name="TbContent" />
|
<TextBox AcceptsTab="True" AcceptsReturn="True" Grid.Row="1" x:Name="TbContent" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -52,7 +52,11 @@ public partial class EditorWindow : Window
|
|||||||
{
|
{
|
||||||
var result = await MessageBox.Show(null, "Sicher?", "Sicher?", MessageBoxButton.YesNo);
|
var result = await MessageBox.Show(null, "Sicher?", "Sicher?", MessageBoxButton.YesNo);
|
||||||
if (result == MessageBoxResult.No) return;
|
if (result == MessageBoxResult.No) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
|
} catch {}
|
||||||
|
|
||||||
MainWindow._instance.PopulateNavTree();
|
MainWindow._instance.PopulateNavTree();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user