Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
* load repositories resident
Browse files Browse the repository at this point in the history
  to find CDs for SAMM/ SMT
  • Loading branch information
festo-i40 committed Nov 19, 2023
1 parent 93b7737 commit 6644b67
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 42 deletions.
12 changes: 6 additions & 6 deletions src/AasxIntegrationBaseWpf/DynamicContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ namespace AasxIntegrationBaseWpf
/// Display data for WPF context menu items.
/// Holds the WPF control.
/// </summary>
public class DynamicContextMenuDispalyDataWpf : AasxMenuDisplayDataBase
public class DynamicContextMenuDisplayDataWpf : AasxMenuDisplayDataBase
{
/// <summary>
/// A WPF control for the context menu item.
/// </summary>
public Control Control;

public DynamicContextMenuDispalyDataWpf() { }
public DynamicContextMenuDisplayDataWpf() { }

public DynamicContextMenuDispalyDataWpf(Control control)
public DynamicContextMenuDisplayDataWpf(Control control)
{
Control = control;
}
Expand Down Expand Up @@ -68,7 +68,7 @@ protected Control RenderMenuItem(AasxMenu root, AasxMenuItemBase item)
var ctl = new Separator();

// result
sep.DisplayData = new DynamicContextMenuDispalyDataWpf(ctl);
sep.DisplayData = new DynamicContextMenuDisplayDataWpf(ctl);
return ctl;
}

Expand Down Expand Up @@ -103,7 +103,7 @@ protected Control RenderMenuItem(AasxMenu root, AasxMenuItemBase item)
ctl.Tag = mitb;

// result
mitb.DisplayData = new DynamicContextMenuDispalyDataWpf(ctl);
mitb.DisplayData = new DynamicContextMenuDisplayDataWpf(ctl);
return ctl;
}

Expand All @@ -117,7 +117,7 @@ protected Control RenderMenuItem(AasxMenu root, AasxMenuItemBase item)
ctl.IsChecked = mi.IsChecked;

// result
mi.DisplayData = new DynamicContextMenuDispalyDataWpf(ctl);
mi.DisplayData = new DynamicContextMenuDisplayDataWpf(ctl);
return ctl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Name="MenuItemUnload" Header="Un-load" Click="MenuItem_Click">
<MenuItem Name="MenuItemLoad" Header="Load if resident" Click="MenuItem_Click">
<MenuItem.Icon>
<TextBlock Text="&#x2b8e;"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Name="MenuItemUnload" Header="Un-Load" Click="MenuItem_Click">
<MenuItem.Icon>
<TextBlock Text="&#x1f5d1;"/>
</MenuItem.Icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,19 @@ private async void MenuItem_Click(object sender, RoutedEventArgs e)
this.FileRepository?.MoveDown(fi);
}

if (mi?.Name == "MenuItemUnload" && fi != null)
if (mi?.Name == "MenuItemLoad" && fi != null)
{
await fi.LoadResidentIfPossible(this.FileRepository?.GetFullItemLocation(fi.Location));
Log.Singleton.Info($"Repository item {fi.Location} loaded.");
}

if (mi?.Name == "MenuItemUnload" && fi != null)
{
fi.Close();
}
Log.Singleton.Info($"Repository item {fi.Location} unloaded.");
}

if (mi?.Name == "MenuItemRecalc" && fi != null)
if (mi?.Name == "MenuItemRecalc" && fi != null)
{
await fi.LoadResidentIfPossible(theFileRepository?.GetFullItemLocation(fi.Location));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,17 @@ public async Task CommandBinding_FileRepoAll(Control senderList, PackageContaine
}
}

if (cmd == "filerepomakerelative")
if (fr is PackageContainerListLocalBase frlb
&& !(fr is PackageContainerListLastRecentlyUsed))
{
foreach (var fi in frlb.EnumerateItems())
{
await fi.LoadResidentIfPossible(frlb.GetFullItemLocation(fi.Location));
Log.Singleton.Info($"Repository item {fi.Location} loaded.");
}
}

if (cmd == "filerepomakerelative")
if (fr is PackageContainerListLocal frl)
{
Expand Down Expand Up @@ -302,25 +313,6 @@ public async Task CommandBinding_FileRepoAll(Control senderList, PackageContaine
if (!(await _flyout?.GetDisplayContext()?.StartFlyoverModalAsync(uc))
|| !uc.Result)
return;
// dead-csharp off
//var inputDialog = new Microsoft.Win32.OpenFileDialog();
//inputDialog.Title = "AASX Package File to be uploaded in the file repository";
//inputDialog.Filter = "AASX package files (*.aasx)|*.aasx|AAS XML file (*.xml)|*.xml|All files (*.*)|*.*";
//_flyout.StartFlyover(new EmptyFlyout());
//var okClicked = inputDialog.ShowDialog();
//_flyout.CloseFlyover();

//if (okClicked != true)
//{
// return;
//}

//if (inputDialog.FileName.Length < 1 || inputDialog.FileNames.Length > 1)
//{
// return;
//}
// dead-csharp on
//Add file to package explorer's unnamed repo

var fileName = uc.OriginalFileName;
if (fr is PackageContainerAasxFileRepository fileRepo)
Expand Down Expand Up @@ -434,30 +426,35 @@ private async Task PackageContainerListControl_ButtonClick(
if (btn == PackageContainerListControl.CustomButton.Context)
{
var menu = new AasxMenu()
.AddAction("FileRepoClose", "Close", "\u274c")
.AddAction("FileRepoEditName", "Edit name", "\u270e");
.AddAction("FileRepoClose", "Close", icon: "\u274c")
.AddAction("FileRepoEditName", "Edit name", icon: "\u270e");

if (!(fr is PackageContainerListLastRecentlyUsed))
{
menu.AddAction("item-up", "Move Up", "\u25b2")
.AddAction("item-down", "Move Down", "\u25bc");
menu.AddAction("item-up", "Move Up", icon: "\u25b2")
.AddAction("item-down", "Move Down", icon: "\u25bc");
}

menu.AddSeparator()
.AddAction("FileRepoSaveAs", "Save as ..", "\U0001f4be")
.AddAction("FileRepoSaveAs", "Save as ..", icon: "\U0001f4be")
.AddSeparator();

if (!(fr is PackageContainerListLastRecentlyUsed))
{
if (fr is PackageContainerListLocal)
menu.AddAction(
"FileRepoMakeRelative", "Make AASX filenames relative ..", "\u2699");
menu.AddAction(
"FileRepoLoadAllResident", "Load all resident files ..", icon: "\U0001f503");

menu.AddAction("FileRepoAddCurrent", "Add current AAS", "\u2699")
.AddAction("FileRepoAddToServer", "Add AASX File to File Repository", "\u2699")
.AddAction("FileRepoMultiAdd", "Add multiple AASX files ..", "\u2699")
.AddAction("FileRepoAddFromServer", "Add from REST server ..", "\u2699")
.AddAction("FileRepoPrint", "Print 2D code sheet ..", "\u2699");
if (fr is PackageContainerListLocal)
{
menu.AddAction(
"FileRepoMakeRelative", "Make AASX filenames relative ..", icon: "\u2699");
}

menu.AddAction("FileRepoAddCurrent", "Add current AAS", icon: "\u2699")
.AddAction("FileRepoAddToServer", "Add AASX File to File Repository", icon: "\u2699")
.AddAction("FileRepoMultiAdd", "Add multiple AASX files ..", icon: "\u2699")
.AddAction("FileRepoAddFromServer", "Add from REST server ..", icon: "\u2699")
.AddAction("FileRepoPrint", "Print 2D code sheet ..", icon: "\u2699");
}

var cm2 = DynamicContextMenu.CreateNew(
Expand Down

0 comments on commit 6644b67

Please sign in to comment.