-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Workspace Version="1.3.0.875" X="58.8025412446486" Y="-33.626820427704" zoom="0.954042924882813" ScaleFactor="1" Name="Home" Description="" RunType="Automatic" RunPeriod="1000" HasRunWithoutCrash="True"> | ||
<NamespaceResolutionMap /> | ||
<Elements> | ||
<archilabUI.InputToggle.InputToggle guid="82446402-46b0-4cf5-84ef-ae1f6c13ba3c" type="archilabUI.InputToggle.InputToggle" nickname="Input Toggle" x="97.0405537288289" y="178.452665427908" isVisible="true" isUpstreamVisible="true" lacing="Disabled" isSelectedInput="True" IsFrozen="false" isPinned="false" /> | ||
<CoreNodeModels.Input.StringInput guid="336219d9-61fa-4ee6-a022-6d656973ce0c" type="CoreNodeModels.Input.StringInput" nickname="String" x="340.219599564724" y="171.351359303558" isVisible="true" isUpstreamVisible="true" lacing="Disabled" isSelectedInput="True" IsFrozen="false" isPinned="false"> | ||
<System.String>some string</System.String> | ||
<System.String value="some string" /> | ||
</CoreNodeModels.Input.StringInput> | ||
<DSRevitNodesUI.Categories guid="2cef9e78-1d01-472b-a265-c95fb09d69c6" type="DSRevitNodesUI.Categories" nickname="Categories" x="338.181259017963" y="240.942755344061" isVisible="true" isUpstreamVisible="true" lacing="Disabled" isSelectedInput="True" IsFrozen="false" isPinned="false" index="2:AdaptivePoints_Planes" /> | ||
<CoreNodeModels.Input.DoubleSlider guid="ad8bb3e0-5170-46fc-a2c0-68a6596586d6" type="CoreNodeModels.Input.DoubleSlider" nickname="Number Slider" x="337.042035444359" y="337.27909446896" isVisible="true" isUpstreamVisible="true" lacing="Disabled" isSelectedInput="True" IsFrozen="false" isPinned="false"> | ||
<System.Double>1</System.Double> | ||
<Range min="0" max="100" step="0.1" /> | ||
</CoreNodeModels.Input.DoubleSlider> | ||
</Elements> | ||
<Connectors /> | ||
<Notes /> | ||
<Annotations /> | ||
<Presets /> | ||
<Cameras> | ||
<Camera Name="Background Preview" eyeX="-17" eyeY="24" eyeZ="50" lookX="12" lookY="-13" lookZ="-58" upX="0" upY="1" upZ="0" /> | ||
</Cameras> | ||
</Workspace> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Windows.Data; | ||
|
||
namespace archilabUI.InputToggle | ||
{ | ||
public class BoolToStringConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
return (bool) value ? "Toggle Off" : "Toggle On"; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.Collections.Generic; | ||
using Autodesk.DesignScript.Runtime; | ||
using Dynamo.Graph.Nodes; | ||
using Dynamo.ViewModels; | ||
using ProtoCore.AST.AssociativeAST; | ||
using GalaSoft.MvvmLight.Command; | ||
|
||
namespace archilabUI.InputToggle | ||
{ | ||
[NodeName("Input Toggle")] | ||
[NodeCategory("archilab.Core.Utilities")] | ||
[NodeDescription("Use this node to toggle the IsInput for ALL nodes in the definition ON/OFF.")] | ||
[IsDesignScriptCompatible] | ||
public class InputToggle : NodeModel | ||
{ | ||
public WorkspaceViewModel WorkspaceViewModel { get; set; } | ||
public RelayCommand ToggleInput { get; set; } | ||
|
||
private bool _toggleState = true; | ||
public bool ToggleState { | ||
get { return _toggleState; } | ||
set { _toggleState = value; RaisePropertyChanged("ToggleState"); } | ||
} | ||
|
||
public InputToggle() | ||
{ | ||
RegisterAllPorts(); | ||
ArgumentLacing = LacingStrategy.Disabled; | ||
|
||
ToggleInput = new RelayCommand(OnToggleInput); | ||
} | ||
|
||
private void OnToggleInput() | ||
{ | ||
ToggleState = !ToggleState; | ||
foreach (var node in WorkspaceViewModel.Nodes) | ||
{ | ||
if (!node.IsInput) continue; | ||
|
||
node.IsSetAsInput = ToggleState; | ||
} | ||
} | ||
|
||
[IsVisibleInDynamoLibrary(false)] | ||
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes) | ||
{ | ||
return new[] | ||
{ | ||
AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<UserControl x:Class="archilabUI.InputToggle.InputToggleView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:archilabUI.InputToggle" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" d:DesignWidth="300"> | ||
<Grid> | ||
<Grid.Resources> | ||
<local:BoolToStringConverter x:Key="BoolToString" /> | ||
</Grid.Resources> | ||
<Button x:Name="ButtonToggle" | ||
Content="{Binding ToggleState, Converter={StaticResource BoolToString}}" | ||
Command="{Binding ToggleInput}" | ||
HorizontalAlignment="Stretch" | ||
Margin="0" | ||
VerticalAlignment="Stretch"/> | ||
|
||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
| ||
namespace archilabUI.InputToggle | ||
{ | ||
/// <summary> | ||
/// Interaction logic for InputToggleView.xaml | ||
/// </summary> | ||
public partial class InputToggleView | ||
{ | ||
public InputToggleView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Dynamo.Controls; | ||
using Dynamo.Wpf; | ||
|
||
namespace archilabUI.InputToggle | ||
{ | ||
internal class InputToggleViewCustomization : INodeViewCustomization<InputToggle> | ||
{ | ||
private InputToggle _viewModel; | ||
private InputToggleView _view; | ||
|
||
public void CustomizeView(InputToggle model, NodeView nodeView) | ||
{ | ||
_viewModel = model; | ||
_viewModel.WorkspaceViewModel = nodeView.ViewModel.WorkspaceViewModel; | ||
_view = new InputToggleView | ||
{ | ||
DataContext = model, | ||
MaxHeight = 300, | ||
MaxWidth = 200 | ||
}; | ||
nodeView.inputGrid.Children.Add(_view); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters