Revise checkbox and selection behavior in Queue and Library views - Fixes #81695578

This commit is contained in:
John Lewin 2014-10-29 09:40:50 -07:00
parent 126e7fd0f6
commit 5c5e57f2be
4 changed files with 82 additions and 2 deletions

View file

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------
// <copyright file="ConditionalClickWidget.cs" company="MatterHackers Inc.">
// 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.
// </copyright>
//-----------------------------------------------------------------------
namespace MatterHackers.MatterControl
{
using System;
/// <summary>
/// The ConditionalClickWidget provides a ClickWidget that conditionally appears on the control surface to capture mouse input
/// </summary>
public class ConditionalClickWidget : ClickWidget
{
/// <summary>
/// The delegate which provides the Enabled state
/// </summary>
private Func<bool> enabledCallback;
/// <summary>
/// Initializes a new instance of the ConditionalClickWidget class.
/// </summary>
/// <param name="enabledCallback">The delegate to </param>
public ConditionalClickWidget(Func<bool> enabledCallback)
{
this.enabledCallback = enabledCallback;
}
/// <summary>
/// Determines if the control is enabled
/// </summary>
public override bool Enabled
{
get
{
return this.enabledCallback();
}
set
{
throw new InvalidOperationException("Cannot set Enabled on ConditionalClickWidget");
}
}
}
}

View file

@ -108,6 +108,7 @@
<Compile Include="ConfigurationPage\PrintLeveling\LevelWizardBase.cs" />
<Compile Include="ConfigurationPage\PrintLeveling\PrintLevelingData.cs" />
<Compile Include="ConfigurationPage\SettingsViewBase.cs" />
<Compile Include="ControlElements\ConditionalClickWidget.cs" />
<Compile Include="CrashTracker.cs" />
<Compile Include="CustomWidgets\AltGroupBox.cs" />
<Compile Include="CustomWidgets\DoubleSolidSlider.cs" />

View file

@ -161,7 +161,8 @@ namespace MatterHackers.MatterControl.PrintLibrary
primaryContainer.AddChild(primaryFlow);
primaryClickContainer = new ClickWidget();
// 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;
@ -178,7 +179,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
AddHandlers();
}
ClickWidget primaryClickContainer;
ConditionalClickWidget primaryClickContainer;
SlideWidget getItemActionButtons()
{

View file

@ -86,6 +86,7 @@ namespace MatterHackers.MatterControl.PrintQueue
SlideWidget actionButtonContainer;
GuiWidget selectionCheckBoxContainer;
public CheckBox selectionCheckBox;
ConditionalClickWidget conditionalClickContainer;
public bool IsHoverItem
{
@ -186,11 +187,18 @@ namespace MatterHackers.MatterControl.PrintQueue
editControls.Visible = false;
}
// The ConditionalClickWidget supplies a user driven Enabled property based on a delegate of your choosing
conditionalClickContainer = new ConditionalClickWidget(() => queueDataView.EditMode);
conditionalClickContainer.HAnchor = HAnchor.ParentLeftRight;
conditionalClickContainer.VAnchor = VAnchor.ParentBottomTop;
conditionalClickContainer.Click += onLibraryItemClick;
topToBottomLayout.AddChild(topContentsFlowLayout);
this.AddChild(topToBottomLayout);
actionButtonContainer = getItemActionButtons();
actionButtonContainer.Visible = false;
this.AddChild(conditionalClickContainer);
this.AddChild(actionButtonContainer);