/*
* Copyright(c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.ComponentModel;
using System.Collections.Generic;
using Tizen.NUI.Binding;
using Tizen.NUI.BaseComponents;
namespace Tizen.NUI.Components
{
///
/// ButtonGroup is a group of buttons which can be set common property
///
/// 3
[EditorBrowsable(EditorBrowsableState.Never)]
public class ButtonGroup : BindableObject, global::System.IDisposable
{
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ItemheightProperty = BindableProperty.Create(nameof(Itemheight), typeof(float), typeof(ButtonGroup), 0.0f, propertyChanged: (bindable, oldValue, newValue) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
if (btGroup.itemGroup != null && newValue != null)
{
foreach (Button btn in btGroup.itemGroup)
{
btn.Style.SizeHeight = (float)newValue;
}
btGroup.itemheight = (float)newValue;
}
},
defaultValueCreator: (bindable) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
return btGroup.itemheight;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ItemPointSizeProperty = BindableProperty.Create(nameof(ItemPointSize), typeof(float), typeof(ButtonGroup), 0.0f, propertyChanged: (bindable, oldValue, newValue) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
if (btGroup.itemGroup != null && newValue != null)
{
foreach (Button btn in btGroup.itemGroup)
{
btn.Style.Text.PointSize = (float)newValue;
}
btGroup.itemPointSize = (float)newValue;
}
},
defaultValueCreator: (bindable) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
return btGroup.itemPointSize;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ItemFontFamilyProperty = BindableProperty.Create(nameof(ItemFontFamily), typeof(string), typeof(ButtonGroup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
if (btGroup.itemGroup != null && newValue != null)
{
foreach (Button btn in btGroup.itemGroup)
{
btn.Style.Text.FontFamily = (string)newValue;
}
btGroup.itemFontFamily = (string)newValue;
}
},
defaultValueCreator: (bindable) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
return btGroup.itemFontFamily;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ItemTextColorProperty = BindableProperty.Create(nameof(ItemTextColor), typeof(Color), typeof(ButtonGroup), Color.Black, propertyChanged: (bindable, oldValue, newValue) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
if (btGroup.itemGroup != null && newValue != null)
{
foreach (Button btn in btGroup.itemGroup)
{
btn.Style.Text.TextColor = (Color)newValue;
}
btGroup.itemTextColor = (Color)newValue;
}
},
defaultValueCreator: (bindable) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
return btGroup.itemTextColor;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ItemTextAlignmentProperty = BindableProperty.Create(nameof(ItemTextAlignment), typeof(HorizontalAlignment), typeof(ButtonGroup), new HorizontalAlignment(), propertyChanged: (bindable, oldValue, newValue) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
if (btGroup.itemGroup != null && newValue != null)
{
foreach (Button btn in btGroup.itemGroup)
{
btn.Style.Text.HorizontalAlignment = (HorizontalAlignment)newValue;
}
btGroup.itemTextAlignment = (HorizontalAlignment)newValue;
}
},
defaultValueCreator: (bindable) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
return btGroup.itemTextAlignment;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty OverLayBackgroundColorSelectorProperty = BindableProperty.Create(nameof(OverLayBackgroundColorSelector), typeof(Selector), typeof(ButtonGroup), new Selector(), propertyChanged: (bindable, oldValue, newValue) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
if (btGroup.itemGroup != null && newValue != null)
{
foreach (Button btn in btGroup.itemGroup)
{
btn.Style.Overlay.BackgroundColor = (Selector)newValue;
}
btGroup.overLayBackgroundColorSelector = (Selector)newValue;
}
},
defaultValueCreator: (bindable) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
return btGroup.overLayBackgroundColorSelector;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ItemBackgroundImageUrlProperty = BindableProperty.Create(nameof(ItemBackgroundImageUrl), typeof(string), typeof(ButtonGroup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
if (btGroup.itemGroup != null && newValue != null)
{
foreach (Button btn in btGroup.itemGroup)
{
if (btn.Style.BackgroundImage == null)
{
btn.Style.BackgroundImage = new Selector();
}
btn.Style.BackgroundImage = (string)newValue;
}
btGroup.itemBackgroundImageUrl = (string)newValue;
}
},
defaultValueCreator: (bindable) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
return btGroup.itemBackgroundImageUrl;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ItemBackgroundBorderProperty = BindableProperty.Create(nameof(ItemBackgroundBorder), typeof(Rectangle), typeof(ButtonGroup), new Rectangle(), propertyChanged: (bindable, oldValue, newValue) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
if (btGroup.itemGroup != null && newValue != null)
{
foreach (Button btn in btGroup.itemGroup)
{
btn.BackgroundImageBorder = (Rectangle)newValue;
}
btGroup.itemBackgroundBorder = (Rectangle)newValue;
}
},
defaultValueCreator: (bindable) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
return btGroup.itemBackgroundBorder;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ItemShadowUrlProperty = BindableProperty.Create(nameof(ItemShadowUrl), typeof(string), typeof(ButtonGroup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
if (btGroup.itemGroup != null && newValue != null)
{
foreach (Button btn in btGroup.itemGroup)
{
if (btn.Style.Shadow.ResourceUrl == null)
{
btn.Style.Shadow.ResourceUrl = new Selector();
}
btn.Style.Shadow.ResourceUrl = (string)newValue;
}
btGroup.itemShadowUrl = (string)newValue;
}
},
defaultValueCreator: (bindable) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
return btGroup.itemShadowUrl;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ItemShadowBorderProperty = BindableProperty.Create(nameof(ItemShadowBorder), typeof(Rectangle), typeof(ButtonGroup), new Rectangle(), propertyChanged: (bindable, oldValue, newValue) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
if (btGroup.itemGroup != null && newValue != null)
{
foreach (Button btn in btGroup.itemGroup)
{
btn.Style.Shadow.Border = (Rectangle)newValue;
}
btGroup.itemShadowBorder = (Rectangle)newValue;
}
},
defaultValueCreator: (bindable) =>
{
ButtonGroup btGroup = (ButtonGroup)bindable;
return btGroup.itemShadowBorder;
});
///
/// Construct an button group.
///
/// root view
[EditorBrowsable(EditorBrowsableState.Never)]
public ButtonGroup(View view) : base()
{
itemGroup = new List