Skip to content

Commit

Permalink
feature | made 'ReadOnly' common to all controls
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Pohatu committed Sep 20, 2024
1 parent 79f1007 commit 08a01a7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
1 change: 1 addition & 0 deletions TsGui/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
</Style>

<Style x:Key="ControlStyle">
<Setter Property="Control.IsEnabled" Value="{Binding ControlEnabled}"/>
<Setter Property="Control.Height" Value="{Binding ControlStyle.Height}"/>
<Setter Property="Control.Width" Value="{Binding ControlStyle.Width}"/>
<Setter Property="Control.Margin" Value="{Binding ControlStyle.Margin}"/>
Expand Down
11 changes: 9 additions & 2 deletions TsGui/View/GuiOptions/GuiOptionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@ public string LiveValue
}
}
}



protected bool _controlenabled = true;
public bool ControlEnabled
{
get { return this._controlenabled; }
set { this._controlenabled = value; this.OnPropertyChanged(this, "ControlEnabled"); }
}

public GuiOptionBase(ParentLayoutElement Parent):base(Parent)
{
this.UserControl = new GuiOptionBaseUI();
Expand Down Expand Up @@ -124,6 +130,7 @@ private void OnControlLostFocus(object sender, RoutedEventArgs e)
this.HelpText = XmlHandler.GetStringFromXml(InputXml, "HelpText", this.HelpText);
this.ShowGridLines = XmlHandler.GetBoolFromXml(InputXml, "ShowGridLines", this.Parent.ShowGridLines);
this.InactiveValue = XmlHandler.GetStringFromXml(InputXml, "InactiveValue", this.InactiveValue);
this.ControlEnabled = !XmlHandler.GetBoolFromXml(InputXml, "ReadOnly", !this._controlenabled);
this.SetLayoutRightLeft();

XAttribute xa = InputXml.Attribute("ID");
Expand Down
8 changes: 1 addition & 7 deletions TsGui/View/GuiOptions/TsFreeText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,7 @@ public CharacterCasing CharacterCasing
set { this._charactercasing = value; this.OnPropertyChanged(this, "CharacterCasing"); }
}

protected bool _controlenabled = true;
public bool ControlEnabled
{
get { return this._controlenabled; }
set { this._controlenabled = value; this.OnPropertyChanged(this, "ControlEnabled"); }
}

#endregion

//Constructor
Expand Down Expand Up @@ -182,7 +177,6 @@ private void SetDefaults()
}

this.CharacterCasing = XmlHandler.GetCharacterCasingFromXml(InputXml, "CharacterCasing", this.CharacterCasing);
this.ControlEnabled = !XmlHandler.GetBoolFromXml(InputXml, "ReadOnly", !this._controlenabled);
}

//Handle UI events
Expand Down
2 changes: 1 addition & 1 deletion TsGui/View/GuiOptions/TsFreeTextUI.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

<!-- Binding created in code to allowing setting delay -->
<TextBox x:Name="TextBox"
Style="{StaticResource FreeTextStyle}" CharacterCasing="{Binding CharacterCasing}" IsEnabled="{Binding ControlEnabled}"/>
Style="{StaticResource FreeTextStyle}" CharacterCasing="{Binding CharacterCasing}"/>
</UserControl>
5 changes: 0 additions & 5 deletions documentation/options/FreeText.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* [CharacterCasing](#charactercasing)
* [Delay](#delay)
* [MaxLength](#maxlength)
* [ReadOnly](#readonly)
* [Example XML](#example-xml)

## Overview
Expand All @@ -23,10 +22,6 @@ The Delay property is the time in milliseconds between the user entering text an
### MaxLength
The maximum length of string that can be entered into the textbox. The textbox will not allow the user to enter more characters.

### ReadOnly
When set to true, this will 'grey out' the text box control so the user can't edit the value. This is different from using the [Groups & Toggles](/documentation/features/GroupsAndToggles.md) feature which will disable both the control and the label and also change or remove the value of the GuiOption. **ReadOnly** will only disable the control.



## Example XML

Expand Down
5 changes: 5 additions & 0 deletions documentation/options/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [Common Configuration Elements](#common-configuration-elements)
* [Variable](#variable)
* [SetValue](#setvalue)
* [ReadOnly](#readonly)
* [GuiOptions](#guioptions)
* [GuiOption Layout Elements](#guioption-layout-elements)
* [Label](#label)
Expand All @@ -28,6 +29,10 @@ Set the variable name. By default this will configure the Task Sequence variable
To set the default value for the option, you use the ```<SetValue>``` element. This can contain one or more [Queries](/documentation/features/Queries.md) that will generate the value. Note that a ```<Value>``` element is actually a type of query that contains a static value.


### ReadOnly
When set to true, this will 'grey out' the control so the user can't edit the value. This is different from using the [Groups & Toggles](/documentation/features/GroupsAndToggles.md) feature which will disable both the control and the label and also change or remove the value of the GuiOption. **ReadOnly** will only disable the control.


## GuiOptions
A TsGui user interface is built with one or more ```<GuiOption Type="xxx">``` elements. Each different type creates a different type of control. These are added to the layout as outlined in the [Layout](/documentation/Layout.md) documentation.

Expand Down

0 comments on commit 08a01a7

Please sign in to comment.