Ported the old tab renaming code into main
Needs to be cleaned up
This commit is contained in:
parent
035b84d065
commit
b664670a42
47 changed files with 644 additions and 337 deletions
|
|
@ -31,8 +31,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MatterControlLib;
|
||||
using MatterHackers.Agg;
|
||||
|
|
@ -552,7 +550,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
private async void Workspaces_Changed(object sender, WorkspacesChangedEventArgs e)
|
||||
private void Workspaces_Changed(object sender, WorkspacesChangedEventArgs e)
|
||||
{
|
||||
var workspace = e.Workspace;
|
||||
var activePrinter = workspace.Printer;
|
||||
|
|
@ -587,6 +585,26 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
public void HookupNameChangeCallback(ChromeTab partTab, PartWorkspace workspace)
|
||||
{
|
||||
var sourceItem = workspace.SceneContext?.EditContext?.SourceItem;
|
||||
|
||||
if (sourceItem != null)
|
||||
{
|
||||
async void UpdateTabName(object s, EventArgs e)
|
||||
{
|
||||
partTab.Title = sourceItem.Name;
|
||||
await ApplicationController.Instance.PersistUserWorkspaceTabs(false);
|
||||
}
|
||||
|
||||
sourceItem.NameChanged += UpdateTabName;
|
||||
|
||||
partTab.Closed += (s, e) => sourceItem.NameChanged -= UpdateTabName;
|
||||
|
||||
partTab.Title = sourceItem.Name;
|
||||
}
|
||||
}
|
||||
|
||||
private GuiWidget CreateNetworkStatusPanel(ThemeConfig theme)
|
||||
{
|
||||
var networkStatus = new GuiWidget()
|
||||
|
|
@ -753,32 +771,29 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
var menuTheme = ApplicationController.Instance.MenuTheme;
|
||||
var popupMenu = new PopupMenu(menuTheme);
|
||||
|
||||
if (printer != null)
|
||||
|
||||
var renameMenuItem = popupMenu.CreateMenuItem("Rename".Localize());
|
||||
renameMenuItem.Click += (s, e) =>
|
||||
{
|
||||
var renameMenuItem = popupMenu.CreateMenuItem("Rename".Localize());
|
||||
renameMenuItem.Click += (s, e) =>
|
||||
if (workspace != null)
|
||||
{
|
||||
if (workspace != null)
|
||||
{
|
||||
workspace.LibraryView.ActiveContainer.Rename(workspace.LibraryView.ActiveContainer.Items.FirstOrDefault());
|
||||
}
|
||||
else if (printer != null)
|
||||
{
|
||||
DialogWindow.Show(
|
||||
new InputBoxPage(
|
||||
"Rename Item".Localize(),
|
||||
"Name".Localize(),
|
||||
printer.Settings.GetValue(SettingsKey.printer_name),
|
||||
"Enter New Name Here".Localize(),
|
||||
"Rename".Localize(),
|
||||
(newName) =>
|
||||
{
|
||||
printer.Settings.SetValue(SettingsKey.printer_name, newName);
|
||||
}));
|
||||
}
|
||||
};
|
||||
}
|
||||
workspace.SceneContext?.EditContext?.SourceItem?.Rename();
|
||||
}
|
||||
else if (printer != null)
|
||||
{
|
||||
DialogWindow.Show(
|
||||
new InputBoxPage(
|
||||
"Rename Item".Localize(),
|
||||
"Name".Localize(),
|
||||
printer.Settings.GetValue(SettingsKey.printer_name),
|
||||
"Enter New Name Here".Localize(),
|
||||
"Rename".Localize(),
|
||||
(newName) =>
|
||||
{
|
||||
printer.Settings.SetValue(SettingsKey.printer_name, newName);
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var moveButtons = new FlowLayoutWidget();
|
||||
|
|
@ -873,6 +888,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
Name = "newPart" + tabControl.AllTabs.Count(),
|
||||
};
|
||||
|
||||
HookupNameChangeCallback(partTab, workspace);
|
||||
|
||||
EnableReduceWidth(partTab, theme);
|
||||
|
||||
tabControl.AddTab(partTab);
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public GuiWidget ContentPanel { get; set; }
|
||||
|
||||
private readonly JsonPathContext pathResolver = new JsonPathContext();
|
||||
private readonly JsonPathContext pathGetter = new JsonPathContext();
|
||||
private readonly IconButton flattenButton;
|
||||
private readonly IconButton removeButton;
|
||||
private readonly OverflowBar.OverflowMenuButton overflowButton;
|
||||
|
|
@ -343,7 +343,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
// Get the named property via reflection
|
||||
// Selector example: '$.Children<CylinderObject3D>'
|
||||
var match = pathResolver.Select(componentObject, selector).ToList();
|
||||
var match = pathGetter.Select(componentObject, selector).ToList();
|
||||
|
||||
//// - Add editor row for each
|
||||
foreach (var instance in match)
|
||||
|
|
|
|||
|
|
@ -696,7 +696,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
base.OnDraw(graphics2D);
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
public void HookupNameChange(PartWorkspace workspace)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
this.parentTabControl = null;
|
||||
this.TabContent = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue