Merge branch 'master' of https://github.com/MatterHackers/MatterControl
This commit is contained in:
commit
8c8cce6193
11 changed files with 201 additions and 266 deletions
|
|
@ -92,8 +92,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
AddChild(topToBottomItemList);
|
||||
|
||||
AddAllItems();
|
||||
|
||||
this.MouseLeaveBounds += new EventHandler(control_MouseLeaveBounds);
|
||||
}
|
||||
|
||||
public delegate void HoverValueChangedEventHandler(object sender, EventArgs e);
|
||||
|
|
@ -148,45 +146,11 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
this.editMode = value;
|
||||
if (this.editMode == false)
|
||||
{
|
||||
this.ClearSelectedItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int HoverIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return hoverIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < -1 || value >= topToBottomItemList.Children.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
if (value != hoverIndex)
|
||||
{
|
||||
hoverIndex = value;
|
||||
OnHoverIndexChanged();
|
||||
|
||||
for (int index = 0; index < topToBottomItemList.Children.Count; index++)
|
||||
{
|
||||
GuiWidget child = topToBottomItemList.Children[index];
|
||||
if (index == HoverIndex)
|
||||
while (SelectedItems.Count > 1)
|
||||
{
|
||||
((LibraryRowItem)child.Children[0]).IsHoverItem = true;
|
||||
SelectedItems.RemoveAt(SelectedItems.Count - 1);
|
||||
}
|
||||
else if (((LibraryRowItem)child.Children[0]).IsHoverItem == true)
|
||||
{
|
||||
((LibraryRowItem)child.Children[0]).IsHoverItem = false;
|
||||
}
|
||||
child.Invalidate();
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -225,62 +189,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
}
|
||||
}
|
||||
|
||||
public int SelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return selectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < -1 || value >= topToBottomItemList.Children.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
selectedIndex = value;
|
||||
OnSelectedIndexChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public GuiWidget SelectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedIndex != -1)
|
||||
{
|
||||
return Children[SelectedIndex];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
for (int i = 0; i < Children.Count; i++)
|
||||
{
|
||||
if (Children[SelectedIndex] == value)
|
||||
{
|
||||
SelectedIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PrintItemWrapper SelectedPart
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedIndex >= 0)
|
||||
{
|
||||
return LibraryDataView.CurrentLibraryProvider.GetPrintItemWrapperAsync(SelectedIndex).Result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int Count
|
||||
{
|
||||
get
|
||||
|
|
@ -298,10 +206,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
itemHolder.AddChild(child);
|
||||
itemHolder.VAnchor = VAnchor.FitToChildren;
|
||||
topToBottomItemList.AddChild(itemHolder, indexInChildrenList);
|
||||
|
||||
itemHolder.MouseEnterBounds += new EventHandler(itemToAdd_MouseEnterBounds);
|
||||
itemHolder.MouseLeaveBounds += new EventHandler(itemToAdd_MouseLeaveBounds);
|
||||
itemHolder.ParentChanged += new EventHandler(itemHolder_ParentChanged);
|
||||
}
|
||||
|
||||
public void ClearSelected()
|
||||
|
|
@ -317,7 +221,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
foreach (LibraryRowItem item in SelectedItems)
|
||||
{
|
||||
item.isSelectedItem = false;
|
||||
item.selectionCheckBox.Checked = false;
|
||||
}
|
||||
this.SelectedItems.Clear();
|
||||
|
|
@ -397,14 +300,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
}
|
||||
}
|
||||
|
||||
public void RemoveSelectedIndex()
|
||||
{
|
||||
if (SelectedIndex >= 0 && SelectedIndex < Count)
|
||||
{
|
||||
RemoveChild(SelectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveSelectedItems()
|
||||
{
|
||||
foreach (LibraryRowItem item in SelectedItems)
|
||||
|
|
@ -476,47 +371,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
}
|
||||
}
|
||||
|
||||
private void control_MouseLeaveBounds(object sender, EventArgs e)
|
||||
{
|
||||
HoverIndex = -1;
|
||||
}
|
||||
|
||||
private void itemHolder_ParentChanged(object sender, EventArgs e)
|
||||
{
|
||||
FlowLayoutWidget itemHolder = (FlowLayoutWidget)sender;
|
||||
itemHolder.MouseEnterBounds -= new EventHandler(itemToAdd_MouseEnterBounds);
|
||||
itemHolder.MouseLeaveBounds -= new EventHandler(itemToAdd_MouseLeaveBounds);
|
||||
itemHolder.ParentChanged -= new EventHandler(itemHolder_ParentChanged);
|
||||
}
|
||||
|
||||
private void itemToAdd_MouseEnterBounds(object sender, EventArgs e)
|
||||
{
|
||||
GuiWidget widgetEntered = ((GuiWidget)sender);
|
||||
for (int index = 0; index < topToBottomItemList.Children.Count; index++)
|
||||
{
|
||||
GuiWidget child = topToBottomItemList.Children[index];
|
||||
if (child == widgetEntered)
|
||||
{
|
||||
HoverIndex = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void itemToAdd_MouseLeaveBounds(object sender, EventArgs e)
|
||||
{
|
||||
GuiWidget widgetLeft = ((GuiWidget)sender);
|
||||
|
||||
if (SelectedIndex >= 0)
|
||||
{
|
||||
if (widgetLeft != topToBottomItemList.Children[SelectedIndex])
|
||||
{
|
||||
widgetLeft.BackgroundColor = new RGBA_Bytes();
|
||||
widgetLeft.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LibraryDataReloaded(object sender, EventArgs e)
|
||||
{
|
||||
UiThread.RunOnIdle(AddAllItems);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,13 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
public abstract class LibraryRowItem : GuiWidget
|
||||
{
|
||||
public bool isSelectedItem = false;
|
||||
public bool IsSelectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return libraryDataView.SelectedItems.Contains(this);
|
||||
}
|
||||
}
|
||||
public CheckBox selectionCheckBox;
|
||||
public RGBA_Bytes WidgetBackgroundColor;
|
||||
public RGBA_Bytes WidgetTextColor;
|
||||
|
|
@ -47,10 +53,8 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
protected TextWidget partLabel;
|
||||
protected SlideWidget rightButtonOverlay;
|
||||
protected GuiWidget selectionCheckBoxContainer;
|
||||
private bool editMode = false;
|
||||
private bool isHoverItem = false;
|
||||
private LinkButtonFactory linkButtonFactory = new LinkButtonFactory();
|
||||
private ConditionalClickWidget primaryClickContainer;
|
||||
private GuiWidget thumbnailWidget;
|
||||
|
||||
private event EventHandler unregisterEvents;
|
||||
|
|
@ -63,18 +67,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
public string ItemName { get; protected set; }
|
||||
|
||||
public bool EditMode
|
||||
{
|
||||
get { return editMode; }
|
||||
set
|
||||
{
|
||||
if (this.editMode != value)
|
||||
{
|
||||
this.editMode = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsHoverItem
|
||||
{
|
||||
get { return isHoverItem; }
|
||||
|
|
@ -110,6 +102,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
if (this.libraryDataView.EditMode)
|
||||
{
|
||||
this.selectionCheckBox.Checked = this.IsSelectedItem;
|
||||
selectionCheckBoxContainer.Visible = true;
|
||||
rightButtonOverlay.Visible = false;
|
||||
}
|
||||
|
|
@ -120,7 +113,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
base.OnDraw(graphics2D);
|
||||
|
||||
if (this.isSelectedItem)
|
||||
if (this.IsSelectedItem)
|
||||
{
|
||||
this.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
|
||||
this.partLabel.TextColor = RGBA_Bytes.White;
|
||||
|
|
@ -199,13 +192,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
primaryContainer.AddChild(primaryFlow);
|
||||
|
||||
// The ConditionalClickWidget supplies a user driven Enabled property based on a delegate of your choosing
|
||||
primaryClickContainer = new ConditionalClickWidget(() => libraryDataView.EditMode);
|
||||
primaryClickContainer.HAnchor = HAnchor.ParentLeftRight;
|
||||
primaryClickContainer.VAnchor = VAnchor.ParentBottomTop;
|
||||
|
||||
primaryContainer.AddChild(primaryClickContainer);
|
||||
|
||||
rightButtonOverlay = GetItemActionButtons();
|
||||
rightButtonOverlay.Visible = false;
|
||||
|
||||
|
|
@ -236,7 +222,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
private void AddHandlers()
|
||||
{
|
||||
//ActiveTheme.Instance.ThemeChanged.RegisterEvent(onThemeChanged, ref unregisterEvents);
|
||||
primaryClickContainer.Click += onLibraryItemClick;
|
||||
GestureFling += (object sender, FlingEventArgs eventArgs) =>
|
||||
{
|
||||
if (!this.libraryDataView.EditMode)
|
||||
|
|
@ -252,7 +237,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
}
|
||||
this.Invalidate();
|
||||
};
|
||||
//selectionCheckBox.CheckedStateChanged += selectionCheckBox_CheckedStateChanged;
|
||||
}
|
||||
|
||||
private void onAddLinkClick(object sender, EventArgs e)
|
||||
|
|
@ -267,50 +251,40 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
}
|
||||
}
|
||||
|
||||
private void onLibraryItemClick(object sender, EventArgs e)
|
||||
{
|
||||
if (this.libraryDataView.EditMode == false)
|
||||
{
|
||||
//UiThread.RunOnIdle((state) =>
|
||||
//{
|
||||
// openPartView(state);
|
||||
//});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.isSelectedItem == false)
|
||||
{
|
||||
this.isSelectedItem = true;
|
||||
this.selectionCheckBox.Checked = true;
|
||||
libraryDataView.SelectedItems.Add(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isSelectedItem = false;
|
||||
this.selectionCheckBox.Checked = false;
|
||||
libraryDataView.SelectedItems.Remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onThemeChanged(object sender, EventArgs e)
|
||||
{
|
||||
//Set background and text color to new theme
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
private void selectionCheckBox_CheckedStateChanged(object sender, EventArgs e)
|
||||
public override void OnMouseDown(MouseEventArgs mouseEvent)
|
||||
{
|
||||
if (selectionCheckBox.Checked == true)
|
||||
if (this.libraryDataView.EditMode)
|
||||
{
|
||||
this.isSelectedItem = true;
|
||||
libraryDataView.SelectedItems.Add(this);
|
||||
if (this.IsSelectedItem)
|
||||
{
|
||||
libraryDataView.SelectedItems.Remove(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
libraryDataView.SelectedItems.Add(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isSelectedItem = false;
|
||||
libraryDataView.SelectedItems.Remove(this);
|
||||
// we only have single selection
|
||||
if (this.IsSelectedItem)
|
||||
{
|
||||
// It is aleady selected, do nothing.
|
||||
}
|
||||
else
|
||||
{
|
||||
libraryDataView.SelectedItems.Clear();
|
||||
libraryDataView.SelectedItems.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
base.OnMouseDown(mouseEvent);
|
||||
}
|
||||
|
||||
private void SetDisplayAttributes()
|
||||
|
|
|
|||
|
|
@ -48,12 +48,12 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
LibraryProvider parentProvider;
|
||||
PrintItemCollection printItemCollection;
|
||||
int collectionIndex;
|
||||
public int CollectionIndex { get; private set; }
|
||||
|
||||
public LibraryRowItemCollection(PrintItemCollection collection, int collectionIndex, LibraryDataView libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget)
|
||||
: base(libraryDataView, thumbnailWidget)
|
||||
{
|
||||
this.collectionIndex = collectionIndex;
|
||||
this.CollectionIndex = collectionIndex;
|
||||
this.parentProvider = parentProvider;
|
||||
this.printItemCollection = collection;
|
||||
this.ItemName = printItemCollection.Name;
|
||||
|
|
@ -85,12 +85,12 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
public override void RemoveFromCollection()
|
||||
{
|
||||
int collectionItemCollectionCount = LibraryDataView.CurrentLibraryProvider.GetCollectionChildCollectionCount(collectionIndex);
|
||||
int collectionItemItemCount = LibraryDataView.CurrentLibraryProvider.GetCollectionItemCount(collectionIndex);
|
||||
int collectionItemCollectionCount = LibraryDataView.CurrentLibraryProvider.GetCollectionChildCollectionCount(CollectionIndex);
|
||||
int collectionItemItemCount = LibraryDataView.CurrentLibraryProvider.GetCollectionItemCount(CollectionIndex);
|
||||
|
||||
if (collectionItemCollectionCount > 0 || collectionItemItemCount > 0)
|
||||
{
|
||||
string message = collectionNotEmtyMessage.FormatWith(LibraryDataView.CurrentLibraryProvider.GetCollectionItem(collectionIndex).Name);
|
||||
string message = collectionNotEmtyMessage.FormatWith(LibraryDataView.CurrentLibraryProvider.GetCollectionItem(CollectionIndex).Name);
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
// Let the user know this collection is not empty and check if they want to delete it.
|
||||
|
|
@ -99,7 +99,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
}
|
||||
else
|
||||
{
|
||||
LibraryDataView.CurrentLibraryProvider.RemoveCollection(collectionIndex);
|
||||
LibraryDataView.CurrentLibraryProvider.RemoveCollection(CollectionIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
if (messageBoxResponse)
|
||||
{
|
||||
LibraryDataView.CurrentLibraryProvider.RemoveCollection(collectionIndex);
|
||||
LibraryDataView.CurrentLibraryProvider.RemoveCollection(CollectionIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
public bool isActivePrint = false;
|
||||
LibraryProvider libraryProvider;
|
||||
private int itemIndex;
|
||||
public int ItemIndex { get; private set; }
|
||||
double thumbnailWidth = 0;
|
||||
|
||||
public PrintItemWrapper printItemInstance = null;
|
||||
|
|
@ -73,7 +73,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
this.ItemName = libraryProvider.GetPrintItemName(itemIndex);
|
||||
this.libraryProvider = libraryProvider;
|
||||
this.itemIndex = itemIndex;
|
||||
this.ItemIndex = itemIndex;
|
||||
|
||||
CreateGuiElements();
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
get
|
||||
{
|
||||
return libraryProvider.IsItemProtected(itemIndex);
|
||||
return libraryProvider.IsItemProtected(ItemIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
if (printItemInstance == null)
|
||||
{
|
||||
printItemInstance = await libraryProvider.GetPrintItemWrapperAsync(this.itemIndex, ReportProgressRatio);
|
||||
printItemInstance = await libraryProvider.GetPrintItemWrapperAsync(this.ItemIndex, ReportProgressRatio);
|
||||
}
|
||||
|
||||
return printItemInstance;
|
||||
|
|
@ -170,7 +170,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
base.OnDraw(graphics2D);
|
||||
|
||||
if (this.isSelectedItem)
|
||||
if (this.IsSelectedItem)
|
||||
{
|
||||
this.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
|
||||
this.partLabel.TextColor = RGBA_Bytes.White;
|
||||
|
|
@ -223,7 +223,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
public async override void RemoveFromCollection()
|
||||
{
|
||||
LibraryDataView.CurrentLibraryProvider.RemoveItem(itemIndex);
|
||||
LibraryDataView.CurrentLibraryProvider.RemoveItem(ItemIndex);
|
||||
}
|
||||
|
||||
protected override SlideWidget GetItemActionButtons()
|
||||
|
|
@ -287,7 +287,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
protected async override void RemoveThisFromPrintLibrary()
|
||||
{
|
||||
// TODO: The LibraryProvider does not need a printitemwrapper to remove an item! Why not an interger like the others?
|
||||
LibraryDataView.CurrentLibraryProvider.RemoveItem(itemIndex);
|
||||
LibraryDataView.CurrentLibraryProvider.RemoveItem(ItemIndex);
|
||||
}
|
||||
|
||||
private void ExportQueueItemWindow_Closed(object sender, EventArgs e)
|
||||
|
|
@ -318,15 +318,13 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
}
|
||||
else
|
||||
{
|
||||
if (this.isSelectedItem == false)
|
||||
if (this.IsSelectedItem == false)
|
||||
{
|
||||
this.isSelectedItem = true;
|
||||
this.selectionCheckBox.Checked = true;
|
||||
libraryDataView.SelectedItems.Add(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isSelectedItem = false;
|
||||
this.selectionCheckBox.Checked = false;
|
||||
libraryDataView.SelectedItems.Remove(this);
|
||||
}
|
||||
|
|
@ -411,12 +409,10 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
if (selectionCheckBox.Checked == true)
|
||||
{
|
||||
this.isSelectedItem = true;
|
||||
libraryDataView.SelectedItems.Add(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isSelectedItem = false;
|
||||
libraryDataView.SelectedItems.Remove(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
private static CreateFolderWindow createFolderWindow = null;
|
||||
private static RenameItemWindow renameItemWindow = null;
|
||||
private static TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
||||
private static TextImageButtonFactory navigationButtonFactory = new TextImageButtonFactory();
|
||||
private TextImageButtonFactory editButtonFactory = new TextImageButtonFactory();
|
||||
private TextWidget navigationLabel;
|
||||
private FlowLayoutWidget breadCrumbDisplayHolder;
|
||||
|
|
@ -162,8 +163,8 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
//allControls.AddChild(navigationPanel);
|
||||
allControls.AddChild(searchPanel);
|
||||
allControls.AddChild(breadCrumbDisplayHolder);
|
||||
allControls.AddChild(itemOperationButtons);
|
||||
allControls.AddChild(breadCrumbDisplayHolder);
|
||||
libraryDataView = new LibraryDataView();
|
||||
allControls.AddChild(libraryDataView);
|
||||
allControls.AddChild(buttonPanel);
|
||||
|
|
@ -272,7 +273,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
Button renameFromLibraryButton = editButtonFactory.Generate("Rename".Localize());
|
||||
renameFromLibraryButton.Margin = new BorderDouble(3, 0);
|
||||
editButtonsEnableData.Add(new ButtonEnableData(true, false));
|
||||
editButtonsEnableData.Add(new ButtonEnableData(false, false));
|
||||
itemOperationButtons.AddChild(renameFromLibraryButton);
|
||||
|
||||
renameFromLibraryButton.Click += (sender, e) =>
|
||||
|
|
@ -281,9 +282,24 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
if (renameItemWindow == null)
|
||||
{
|
||||
string currentName = "currentName";
|
||||
LibraryRowItem rowItem = libraryDataView.SelectedItems[0];
|
||||
LibraryRowItemPart partItem = rowItem as LibraryRowItemPart;
|
||||
LibraryRowItemCollection collectionItem = rowItem as LibraryRowItemCollection;
|
||||
|
||||
string currentName = libraryDataView.SelectedItems[0].ItemName;
|
||||
|
||||
renameItemWindow = new RenameItemWindow(currentName, (returnInfo) =>
|
||||
{
|
||||
{
|
||||
if (partItem != null)
|
||||
{
|
||||
LibraryDataView.CurrentLibraryProvider.RenameItem(partItem.ItemIndex, returnInfo.newName);
|
||||
}
|
||||
else if (collectionItem != null)
|
||||
{
|
||||
LibraryDataView.CurrentLibraryProvider.RenameCollection(collectionItem.CollectionIndex, returnInfo.newName);
|
||||
}
|
||||
|
||||
libraryDataView.SelectedItems.Clear();
|
||||
});
|
||||
|
||||
renameItemWindow.Closed += (sender2, e2) => { renameItemWindow = null; };
|
||||
|
|
@ -310,7 +326,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
editButtonsEnableData.Add(new ButtonEnableData(true, true));
|
||||
itemOperationButtons.AddChild(addToQueueButton);
|
||||
|
||||
itemOperationButtons.Visible = false;
|
||||
editButtonFactory.FixedWidth = oldWidth;
|
||||
}
|
||||
|
||||
|
|
@ -325,6 +340,12 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
public void SetBreadCrumbs(object sender, EventArgs e)
|
||||
{
|
||||
navigationButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
navigationButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
navigationButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
navigationButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
navigationButtonFactory.FixedHeight = 22 * TextWidget.GlobalPointSizeScaleRatio;
|
||||
|
||||
breadCrumbDisplayHolder.CloseAndRemoveAllChildren();
|
||||
LibraryProvider currentProvider = LibraryDataView.CurrentLibraryProvider;
|
||||
bool first = true;
|
||||
|
|
@ -346,8 +367,8 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
breadCrumbDisplayHolder.AddChild(separator);
|
||||
}
|
||||
|
||||
Button installUpdateLink = textImageButtonFactory.Generate(localCurrentProvider.Name);
|
||||
installUpdateLink.Click += (sender2, e2) =>
|
||||
Button gotoProviderButton = navigationButtonFactory.Generate(localCurrentProvider.Name);
|
||||
gotoProviderButton.Click += (sender2, e2) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
|
|
@ -355,7 +376,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
libraryDataView.RebuildView();
|
||||
});
|
||||
};
|
||||
breadCrumbDisplayHolder.AddChild(installUpdateLink);
|
||||
breadCrumbDisplayHolder.AddChild(gotoProviderButton);
|
||||
first = false;
|
||||
}
|
||||
|
||||
|
|
@ -406,9 +427,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
enterEditModeButton.Visible = false;
|
||||
leaveEditModeButton.Visible = true;
|
||||
libraryDataView.EditMode = true;
|
||||
itemOperationButtons.Visible = true;
|
||||
breadCrumbDisplayHolder.Visible = false;
|
||||
SetEditButtonsStates();
|
||||
}
|
||||
|
||||
private void leaveEditModeButtonClick(object sender, EventArgs e)
|
||||
|
|
@ -416,9 +434,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
enterEditModeButton.Visible = true;
|
||||
leaveEditModeButton.Visible = false;
|
||||
libraryDataView.EditMode = false;
|
||||
itemOperationButtons.Visible = false;
|
||||
breadCrumbDisplayHolder.Visible = true;
|
||||
SetEditButtonsStates();
|
||||
}
|
||||
|
||||
private void searchButtonClick(object sender, EventArgs e)
|
||||
|
|
@ -448,7 +463,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
for(int buttonIndex=0; buttonIndex<itemOperationButtons.Children.Count; buttonIndex++)
|
||||
{
|
||||
bool enabledStateToSet = (selectedCount > 0 && libraryDataView.EditMode);
|
||||
bool enabledStateToSet = (selectedCount > 0);
|
||||
var child = itemOperationButtons.Children[buttonIndex];
|
||||
var button = child as Button;
|
||||
if (button != null)
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
|
|||
string sourceDir = Path.Combine(rootPath, currentDirectoryDirectories[collectionIndexToRename]);
|
||||
if (Directory.Exists(sourceDir))
|
||||
{
|
||||
string destDir = Path.Combine(Path.GetDirectoryName(sourceDir), sourceDir);
|
||||
string destDir = Path.Combine(Path.GetDirectoryName(sourceDir), newName);
|
||||
Directory.Move(sourceDir, destDir);
|
||||
Stopwatch time = Stopwatch.StartNew();
|
||||
// Wait for up to some amount of time for the directory to be gone.
|
||||
|
|
|
|||
84
PrinterCommunication/Io/TrackPrinterPosition.cs
Normal file
84
PrinterCommunication/Io/TrackPrinterPosition.cs
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.GCodeVisualizer;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
||||
{
|
||||
public class TrackPrinterPosition : GCodeFileProxy
|
||||
{
|
||||
public RootedObjectEventHandler DestinationChanged = new RootedObjectEventHandler();
|
||||
|
||||
private Vector3 currentDestination;
|
||||
|
||||
private double currentExtruderDestination;
|
||||
|
||||
public Vector3 CurrentDestination { get { return currentDestination; } }
|
||||
|
||||
public TrackPrinterPosition(GCodeFile source)
|
||||
: base(source)
|
||||
{
|
||||
}
|
||||
|
||||
private string KeepTrackOfPostionAndDestination(string lineBeingSent)
|
||||
{
|
||||
if (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 "))
|
||||
{
|
||||
Vector3 newDestination = currentDestination;
|
||||
if (PrinterConnectionAndCommunication.Instance.MovementMode == PrinterMachineInstruction.MovementTypes.Relative)
|
||||
{
|
||||
newDestination = Vector3.Zero;
|
||||
}
|
||||
|
||||
GCodeFile.GetFirstNumberAfter("X", lineBeingSent, out newDestination.x);
|
||||
GCodeFile.GetFirstNumberAfter("Y", lineBeingSent, out newDestination.y);
|
||||
GCodeFile.GetFirstNumberAfter("Z", lineBeingSent, out newDestination.z);
|
||||
|
||||
GCodeFile.GetFirstNumberAfter("E", lineBeingSent, out currentExtruderDestination);
|
||||
GCodeFile.GetFirstNumberAfter("F", lineBeingSent, out currentFeedRate);
|
||||
|
||||
if (PrinterConnectionAndCommunication.Instance.MovementMode == PrinterMachineInstruction.MovementTypes.Relative)
|
||||
{
|
||||
newDestination += currentDestination;
|
||||
}
|
||||
|
||||
if (currentDestination != newDestination)
|
||||
{
|
||||
currentDestination = newDestination;
|
||||
DestinationChanged.CallEvents(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
return lineBeingSent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1065,10 +1065,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
FoundStringEventArgs foundStringEventArgs = e as FoundStringEventArgs;
|
||||
|
||||
double tempBeingSet = 0;
|
||||
if (GCodeFile.GetFirstNumberAfter("S", foundStringEventArgs.LineToCheck, ref tempBeingSet))
|
||||
if (GCodeFile.GetFirstNumberAfter("S", foundStringEventArgs.LineToCheck, out tempBeingSet))
|
||||
{
|
||||
double exturderIndex = 0;
|
||||
if (GCodeFile.GetFirstNumberAfter("T", foundStringEventArgs.LineToCheck, ref exturderIndex))
|
||||
if (GCodeFile.GetFirstNumberAfter("T", foundStringEventArgs.LineToCheck, out exturderIndex))
|
||||
{
|
||||
// we set the private variable so that we don't get the callbacks called and get in a loop of setting the temp
|
||||
int extruderIndex0Based = Math.Min((int)exturderIndex, MAX_EXTRUDERS - 1);
|
||||
|
|
@ -1608,9 +1608,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
|
||||
string lineToParse = foundStringEventArgs.LineToCheck;
|
||||
Vector3 positionRead = Vector3.Zero;
|
||||
GCodeFile.GetFirstNumberAfter("X:", lineToParse, ref positionRead.x);
|
||||
GCodeFile.GetFirstNumberAfter("Y:", lineToParse, ref positionRead.y);
|
||||
GCodeFile.GetFirstNumberAfter("Z:", lineToParse, ref positionRead.z);
|
||||
GCodeFile.GetFirstNumberAfter("X:", lineToParse, out positionRead.x);
|
||||
GCodeFile.GetFirstNumberAfter("Y:", lineToParse, out positionRead.y);
|
||||
GCodeFile.GetFirstNumberAfter("Z:", lineToParse, out positionRead.z);
|
||||
|
||||
// The first position read is the target position.
|
||||
lastReportedPosition = positionRead;
|
||||
|
|
@ -1622,13 +1622,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
if (secondXPosition != -1)
|
||||
{
|
||||
Vector3 currentPositionRead = Vector3.Zero;
|
||||
GCodeFile.GetFirstNumberAfter("X:", lineToParse, ref currentPositionRead.x, secondXPosition - 1);
|
||||
GCodeFile.GetFirstNumberAfter("Y:", lineToParse, ref currentPositionRead.y, secondXPosition - 1);
|
||||
GCodeFile.GetFirstNumberAfter("Z:", lineToParse, ref currentPositionRead.z, secondXPosition - 1);
|
||||
GCodeFile.GetFirstNumberAfter("X:", lineToParse, out currentPositionRead.x, secondXPosition - 1);
|
||||
GCodeFile.GetFirstNumberAfter("Y:", lineToParse, out currentPositionRead.y, secondXPosition - 1);
|
||||
GCodeFile.GetFirstNumberAfter("Z:", lineToParse, out currentPositionRead.z, secondXPosition - 1);
|
||||
|
||||
lastReportedPosition = currentPositionRead;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (currentDestination != positionRead)
|
||||
{
|
||||
|
|
@ -1649,7 +1649,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
string temperatureString = foundStringEventArgs.LineToCheck;
|
||||
{
|
||||
double readExtruderTemp = 0;
|
||||
if (GCodeFile.GetFirstNumberAfter("T:", temperatureString, ref readExtruderTemp))
|
||||
if (GCodeFile.GetFirstNumberAfter("T:", temperatureString, out readExtruderTemp))
|
||||
{
|
||||
if (actualExtruderTemperature[0] != readExtruderTemp)
|
||||
{
|
||||
|
|
@ -1661,7 +1661,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
for (int extruderIndex = 0; extruderIndex < MAX_EXTRUDERS; extruderIndex++)
|
||||
{
|
||||
string multiExtruderCheck = "T{0}:".FormatWith(extruderIndex);
|
||||
if (GCodeFile.GetFirstNumberAfter(multiExtruderCheck, temperatureString, ref readExtruderTemp))
|
||||
if (GCodeFile.GetFirstNumberAfter(multiExtruderCheck, temperatureString, out readExtruderTemp))
|
||||
{
|
||||
if (actualExtruderTemperature[extruderIndex] != readExtruderTemp)
|
||||
{
|
||||
|
|
@ -1677,7 +1677,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
{
|
||||
double readBedTemp = 0;
|
||||
if (GCodeFile.GetFirstNumberAfter("B:", temperatureString, ref readBedTemp))
|
||||
if (GCodeFile.GetFirstNumberAfter("B:", temperatureString, out readBedTemp))
|
||||
{
|
||||
if (actualBedTemperature != readBedTemp)
|
||||
{
|
||||
|
|
@ -2099,7 +2099,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
lineBeingSent = lineBeingSent.ToUpper().Trim();
|
||||
if (lineBeingSent.StartsWith("G0") || lineBeingSent.StartsWith("G1"))
|
||||
{
|
||||
if (GCodeFile.GetFirstNumberAfter("E", lineBeingSent, ref gcodeRequestedExtrusionPosition))
|
||||
if (GCodeFile.GetFirstNumberAfter("E", lineBeingSent, out gcodeRequestedExtrusionPosition))
|
||||
{
|
||||
double delta = gcodeRequestedExtrusionPosition - previousGcodeRequestedExtrusionPosition;
|
||||
if (extruderMode == PrinterMachineInstruction.MovementTypes.Relative)
|
||||
|
|
@ -2114,7 +2114,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
else if (lineBeingSent.StartsWith("G92"))
|
||||
{
|
||||
if (GCodeFile.GetFirstNumberAfter("E", lineBeingSent, ref gcodeRequestedExtrusionPosition))
|
||||
if (GCodeFile.GetFirstNumberAfter("E", lineBeingSent, out gcodeRequestedExtrusionPosition))
|
||||
{
|
||||
previousGcodeRequestedExtrusionPosition = gcodeRequestedExtrusionPosition;
|
||||
currentActualExtrusionPosition = gcodeRequestedExtrusionPosition;
|
||||
|
|
@ -2132,7 +2132,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
if (lineBeingSent.StartsWith("G0") || lineBeingSent.StartsWith("G1"))
|
||||
{
|
||||
double feedRate = 0;
|
||||
if (GCodeFile.GetFirstNumberAfter("F", lineBeingSent, ref feedRate))
|
||||
if (GCodeFile.GetFirstNumberAfter("F", lineBeingSent, out feedRate))
|
||||
{
|
||||
lineBeingSent = GCodeFile.ReplaceNumberAfter('F', lineBeingSent, feedRate * FeedRateRatio);
|
||||
}
|
||||
|
|
@ -2403,12 +2403,12 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
newDestination = Vector3.Zero;
|
||||
}
|
||||
|
||||
GCodeFile.GetFirstNumberAfter("X", lineBeingSent, ref newDestination.x);
|
||||
GCodeFile.GetFirstNumberAfter("Y", lineBeingSent, ref newDestination.y);
|
||||
GCodeFile.GetFirstNumberAfter("Z", lineBeingSent, ref newDestination.z);
|
||||
GCodeFile.GetFirstNumberAfter("X", lineBeingSent, out newDestination.x);
|
||||
GCodeFile.GetFirstNumberAfter("Y", lineBeingSent, out newDestination.y);
|
||||
GCodeFile.GetFirstNumberAfter("Z", lineBeingSent, out newDestination.z);
|
||||
|
||||
GCodeFile.GetFirstNumberAfter("E", lineBeingSent, ref currentExtruderDestination);
|
||||
GCodeFile.GetFirstNumberAfter("F", lineBeingSent, ref currentFeedRate);
|
||||
GCodeFile.GetFirstNumberAfter("E", lineBeingSent, out currentExtruderDestination);
|
||||
GCodeFile.GetFirstNumberAfter("F", lineBeingSent, out currentFeedRate);
|
||||
|
||||
if (movementMode == PrinterMachineInstruction.MovementTypes.Relative)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ namespace MatterHackers.MatterControl
|
|||
&& lineBeingSent[2] == ' ')
|
||||
{
|
||||
double extruderDelta = 0;
|
||||
GCodeFile.GetFirstNumberAfter("E", lineBeingSent, ref extruderDelta);
|
||||
GCodeFile.GetFirstNumberAfter("E", lineBeingSent, out extruderDelta);
|
||||
double feedRate = 0;
|
||||
GCodeFile.GetFirstNumberAfter("F", lineBeingSent, ref feedRate);
|
||||
GCodeFile.GetFirstNumberAfter("F", lineBeingSent, out feedRate);
|
||||
|
||||
string newLine = "G1 ";
|
||||
|
||||
|
|
@ -94,9 +94,9 @@ namespace MatterHackers.MatterControl
|
|||
if (movementMode == PrinterMachineInstruction.MovementTypes.Relative)
|
||||
{
|
||||
Vector3 relativeMove = Vector3.Zero;
|
||||
GCodeFile.GetFirstNumberAfter("X", lineBeingSent, ref relativeMove.x);
|
||||
GCodeFile.GetFirstNumberAfter("Y", lineBeingSent, ref relativeMove.y);
|
||||
GCodeFile.GetFirstNumberAfter("Z", lineBeingSent, ref relativeMove.z);
|
||||
GCodeFile.GetFirstNumberAfter("X", lineBeingSent, out relativeMove.x);
|
||||
GCodeFile.GetFirstNumberAfter("Y", lineBeingSent, out relativeMove.y);
|
||||
GCodeFile.GetFirstNumberAfter("Z", lineBeingSent, out relativeMove.z);
|
||||
outPosition = PrintLevelingPlane.Instance.ApplyLevelingRotation(relativeMove);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3427,3 +3427,15 @@ Translated:Delete folder?
|
|||
English:Cloud Library
|
||||
Translated:Cloud Library
|
||||
|
||||
English:Rename
|
||||
Translated:Rename
|
||||
|
||||
English:Rename Item:
|
||||
Translated:Rename Item:
|
||||
|
||||
English:New Name
|
||||
Translated:New Name
|
||||
|
||||
English:Enter New Name Here
|
||||
Translated:Enter New Name Here
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit a47251fec43c5d873c2ad1853381c5e83d8f4446
|
||||
Subproject commit 625d71a6c7b2300f015f91f2eaea32f61e764c3d
|
||||
Loading…
Add table
Add a link
Reference in a new issue