using System.ComponentModel;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Binding;
+using System.Windows.Input;
namespace Tizen.NUI.Components
{
[EditorBrowsable(EditorBrowsableState.Never)]
public class Control : VisualView
{
+ /// Internal used.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty CommandProperty = BindableProperty.Create("Command", typeof(ICommand), typeof(Control), null, propertyChanged: (bo, o, n) => ((Control)bo).OnCommandChanged());
+
+ /// Internal used.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create("CommandParameter", typeof(object), typeof(Button), null,
+ propertyChanged: (bindable, oldvalue, newvalue) => ((Button)bindable).CommandCanExecuteChanged(bindable, EventArgs.Empty));
+
/// <summary> Control style. </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- protected string style;
+ protected string StyleName { get; set; }
private TapGestureDetector tapGestureDetector = new TapGestureDetector();
- private bool isFocused = false;
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
[EditorBrowsable(EditorBrowsableState.Never)]
public Control() : base()
{
- ViewStyle viewStyle = StyleManager.Instance.GetComponentStyle(this.GetType());
+ var cur_type = this.GetType();
+ ViewStyle viewStyle = null;
+
+ do
+ {
+ if (cur_type.Equals(typeof(Tizen.NUI.Components.Control))) break;
+ viewStyle = StyleManager.Instance.GetComponentStyle(cur_type);
+ cur_type = cur_type.BaseType;
+ }
+ while (viewStyle == null);
if (viewStyle != null)
{
}
ApplyStyle(viewStyle);
- this.style = styleSheet;
+ this.StyleName = styleSheet;
+
+ Initialize(StyleName);
+ }
- Initialize(style);
+ /// Internal used.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ICommand Command
+ {
+ get { return (ICommand)GetValue(CommandProperty); }
+ set { SetValue(CommandProperty, value); }
}
- internal void ApplyAttributes(View view, ViewStyle viewStyle)
+ /// Internal used.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public object CommandParameter
{
- view.CopyFrom(viewStyle);
+ get { return GetValue(CommandParameterProperty); }
+ set { SetValue(CommandParameterProperty, value); }
}
/// <summary>
/// <since_tizen> 6 </since_tizen>
internal bool StateFocusableOnTouchMode { get; set; }
- internal bool IsFocused => (isFocused || HasFocus());
+ internal bool IsFocused { get; set; } = false;
+
+ internal void CommandCanExecuteChanged(object sender, EventArgs eventArgs)
+ {
+ ICommand cmd = Command;
+ if (cmd != null)
+ cmd.CanExecute(CommandParameter);
+ }
+
+ internal void OnCommandChanged()
+ {
+ if (Command != null)
+ {
+ Command.CanExecuteChanged += CommandCanExecuteChanged;
+ CommandCanExecuteChanged(this, EventArgs.Empty);
+ }
+ }
/// <summary>
/// Dispose Control and all children on it.
[EditorBrowsable(EditorBrowsableState.Never)]
public override void OnFocusGained()
{
- isFocused = true;
+ IsFocused = true;
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public override void OnFocusLost()
{
- isFocused = false;
+ IsFocused = false;
}
/// <summary>
{
case PointStateType.Down:
ControlState = ControlStates.Pressed;
- return true;
+ break;
case PointStateType.Interrupted:
case PointStateType.Up:
if (ControlState == ControlStates.Pressed)
{
ControlState = ControlStates.Normal;
}
- return true;
+ break;
default:
break;
}
}
/// <summary>
- /// Update by attributes.
+ /// Update by style.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override ViewStyle GetViewStyle()
+ protected override ViewStyle CreateViewStyle()
{
return new ControlStyle();
}