public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string source = (string)value; Image imageOjb = (Image)parameter; if (source == "record_stop_icon.png") { ImageAttributes.SetBlendColor(imageOjb, Color.Red); } else if (source == "recording_icon_pause.png") { ImageAttributes.SetBlendColor(imageOjb, (Color)Application.Current.Resources["AO012L3"]); } return(source); }
void UpdateColor() { // For case that STT is On, recording_stt_icon.png ImageAttributes.SetBlendColor(RecordingSttImage, (Color)Application.Current.Resources["AO0210"]); // Recorder ImageAttributes.SetBlendColor(VoiceRecorderBtnEffectImage, (Color)Application.Current.Resources["AO028"]); ImageAttributes.SetBlendColor(VoiceRecorderBtnEffectImage2, (Color)Application.Current.Resources["AO028"]); ImageAttributes.SetBlendColor(VoiceRecorderBtnBgImage, (Color)Application.Current.Resources["AO014L1"]); ImageAttributes.SetBlendColor(VoiceRecorderBtnStopImage, (Color)Application.Current.Resources["AO014L3"]); // Record Controller in Left ImageAttributes.SetBlendColor(RecordControllerCancelBgImage, (Color)Application.Current.Resources["AO012L1"]); ImageAttributes.SetBlendColor(RecordingIconCancelImage, (Color)Application.Current.Resources["AO012L3"]); // Record Controller in Right ImageAttributes.SetBlendColor(RecordControllerPauseBgImage, (Color)Application.Current.Resources["AO012L1"]); ImageAttributes.SetBlendColor(RecordingIconPauseImage, (Color)Application.Current.Resources["AO012L3"]); }
public RecordListPage(MainPageModel viewModel) { BindingContext = ViewModel = viewModel; // Subscribe notification of locale changes to update text based on locale MessagingCenter.Subscribe <App>(this, MessageKeys.UpdateByLanguageChange, (obj) => { UpdateUI(); }); InitializeComponent(); ImageAttributes.SetBlendColor(NoImage, Color.FromRgba(94, 94, 94, 77)); // Binding for ContextPopupEffectBehavior's properties // BindingContext is not inherited by Behavior and Effect. // Source of Binding should be specified explicitly. CheckedCounterBehavior.SetBinding(ContextPopupEffectBehavior.AcceptTextProperty, new Binding("SelectOptionMessage1", BindingMode.OneWay, source: BindingContext)); CheckedCounterBehavior.SetBinding(ContextPopupEffectBehavior.AcceptCommandProperty, new Binding("SelectCommand1", BindingMode.OneWay, source: BindingContext)); CheckedCounterBehavior.SetBinding(ContextPopupEffectBehavior.CancelTextProperty, new Binding("SelectOptionMessage2", BindingMode.OneWay, source: BindingContext)); CheckedCounterBehavior.SetBinding(ContextPopupEffectBehavior.CancelCommandProperty, new Binding("SelectCommand2", BindingMode.OneWay, source: BindingContext)); CheckedCounterBehavior.SetBinding(ContextPopupEffectBehavior.VisibilityProperty, new Binding("PopupVisibility", BindingMode.TwoWay, source: BindingContext)); }
/// <summary> /// Constructor for this class /// It defines UIs for this row /// </summary> /// <param name="alarmRecord">AlarmRecord</param> public AlarmEditSlider(AlarmRecord alarmRecord) { BindingContext = alarmRecord; HorizontalOptions = LayoutOptions.FillAndExpand; //VerticalOptions = LayoutOptions.Start; HeightRequest = 120; /// volume image beside slider volumeImage = new Image() { HeightRequest = 50, WidthRequest = 50, Source = alarmRecord.IsMute ? "alarm/01_volume_vibration.png" : "alarm/00_volume_icon.png", }; ImageAttributes.SetBlendColor(volumeImage, Color.FromRgba(50, 150, 166, 204)); // volume image depends on 'IsMute' value of AlarmModel.BindableAlarmRecord // When volume is mute, volume image changes to vibration image. volumeImage.SetBinding(Image.SourceProperty, new Binding("IsMute", BindingMode.Default, new MuteToImageSourceConverter(), source: AlarmModel.BindableAlarmRecord)); /// slider to change volume slider = new Slider() { WidthRequest = 720 - (32 + 50 + 32 + 32), Value = AlarmModel.BindableAlarmRecord.Volume, HeightRequest = 50, }; // Slider's Value affect volume of AlarmModel.BindableAlarmRecord //slider.SetBinding(Slider.ValueProperty, new Binding("Volume", BindingMode.OneWayToSource, source: AlarmModel.BindableAlarmRecord)); slider.SetBinding(Slider.ValueProperty, new Binding("Volume", BindingMode.TwoWay, source: AlarmModel.BindableAlarmRecord)); Children.Add(volumeImage, Constraint.RelativeToParent((parent) => { return(32); }), Constraint.RelativeToParent((parent) => { return((120 - 50) / 2); })); Children.Add(slider, Constraint.RelativeToParent((parent) => { return(32 + 50 + 20); }), Constraint.RelativeToParent((parent) => { return((120 - 50) / 2); })); }
/// <summary> /// To initialize components of the operation item /// </summary> void InitializeComponent() { _bgButton = new Image { Source = "apps_list_item_bg.png", }; var gestureRecognizer = new LongTapGestureRecognizer(); //When tap event is invoked. add pressed color to square image. gestureRecognizer.TapStarted += (s, e) => { //change forground blend color of image ImageAttributes.SetBlendColor(_bgButton, Color.FromRgb(213, 228, 240)); }; //If tap is released. set default color to square image. gestureRecognizer.TapCanceled += (s, e) => { //revert forground blend color of image ImageAttributes.SetBlendColor(_bgButton, Color.Default); //Invoke selected event to consumer. SendSelected(); }; //Set default color to square image. gestureRecognizer.TapCompleted += (s, e) => { //revert forground blend color of image ImageAttributes.SetBlendColor(_bgButton, Color.Default); //Invoke selected event to consumer. SendSelected(); }; GestureRecognizers.Add(gestureRecognizer); Children.Add( _bgButton, Constraint.RelativeToParent((parent) => { return(0); }), Constraint.RelativeToParent((parent) => { return(0); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToParent((parent) => { return(parent.Height); })); _icon = new Image() { }; _icon.Source = ImageSource.FromFile(_data.IconPath); ImageAttributes.SetBlendColor(_bgButton, Color.FromRgb(213, 228, 240)); Children.Add( _icon, Constraint.RelativeToParent((parent) => { return(parent.Width * 0.0778); }), Constraint.RelativeToParent((parent) => { return(parent.Height * 0.2740); }), Constraint.RelativeToParent((parent) => { return(parent.Width * 0.2772); }), Constraint.RelativeToParent((parent) => { return(parent.Height * 0.4475); })); _caption = new Label { VerticalOptions = LayoutOptions.CenterAndExpand, FontSize = 18, LineBreakMode = LineBreakMode.CharacterWrap, }; _caption.Text = _data.Id; Children.Add( _caption, Constraint.RelativeToParent((parent) => { return(parent.Width * 0.425); }), Constraint.RelativeToParent((parent) => { return(0); }), Constraint.RelativeToParent((parent) => { return(parent.Width * 0.5); }), Constraint.RelativeToParent((parent) => { return(parent.Height); })); }
/// <summary> /// Initialize Recording page /// </summary> public void Init() { RecordingTimeLabel.TextColor = Color.White; ImageAttributes.SetBlendColor(RecordingIconPauseImage, (Color)Application.Current.Resources["AO012L3"]); ((RecordingPageModel)ViewModel).Init(); }
/// <summary> /// Draws alarm list /// </summary> /// <returns>Returns RelativeLayout</returns> protected virtual RelativeLayout Draw() { /// Need to get bindable context to assign list value AlarmRecord alarmData = (AlarmRecord)BindingContext; /// If binding context is null, can't proceed further action if (alarmData == null) { return(null); } alarmData.PrintProperty(); /// Alarm item layout should be set if null if (alarmItemLayout == null) { // The layout of item cell alarmItemLayout = new RelativeLayout { HeightRequest = 22 + 93 + 29, }; // Time Label timeLabel = new Label() { Text = (((App)Application.Current).Is24hourFormat) ? alarmData.ScheduledDateTime.ToString("HH:mm") : alarmData.ScheduledDateTime.ToString("hh:mm"), Style = alarmData.AlarmState == AlarmStates.Inactive ? AlarmStyle.ATO001D : AlarmStyle.ATO001, }; // to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(timeLabel, FontWeight.Light); /// Style set for time label for normal case timeLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.Default, new AlarmStateToPropertyConverter(), AlarmModelComponent.Time)); /// Needs to set binding context for scheduled time timeLabel.SetBinding(Label.TextProperty, new Binding("ScheduledDateTime", BindingMode.Default, new ScheduledDateTimeToTextConverter(), LabelType.Time)); // Added to layout alarmItemLayout.Children.Add(timeLabel, Constraint.RelativeToParent((parent) => { return(32); }), Constraint.RelativeToParent((parent) => { return(22); })); // AM/PM Label amPmLabel = new Label() { //the text of AM/PM label Text = (((App)Application.Current).Is24hourFormat) ? "" : alarmData.ScheduledDateTime.ToString("tt"), Style = alarmData.AlarmState == AlarmStates.Inactive ? AlarmStyle.ATO002D : AlarmStyle.ATO002, }; // to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(amPmLabel, FontWeight.Light); //amPmLabel.IsVisible = (((Tizen.App)Application.Current).Is24hourFormat) ? false : true; amPmLabel.SetBinding(Label.IsVisibleProperty, new Binding("AlarmDateFormat", BindingMode.Default, new DateFormatToVisibleConverter())); // Set style depending on alarm state amPmLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.Default, new AlarmStateToPropertyConverter(), AlarmModelComponent.AmPm)); amPmLabel.SetBinding(Label.TextProperty, new Binding("ScheduledDateTime", BindingMode.Default, new ScheduledDateTimeToTextConverter(), LabelType.AmPm)); // Added to layout alarmItemLayout.Children.Add(amPmLabel, Constraint.RelativeToView(timeLabel, (parent, sibling) => sibling.X + sibling.Width + 10), Constraint.RelativeToView(timeLabel, (parent, sibling) => sibling.Y + 36)); // Repeat Image repeatImage = new Image { Source = "alarm/clock_ic_repeat.png", WidthRequest = 38, HeightRequest = 38, }; // Bind repeat Image's visibiliy to weekly repeating value repeatImage.SetBinding(Image.IsVisibleProperty, new Binding("Repeat", mode: BindingMode.Default)); // Set repeat image's blending color on alarm state ImageAttributes.SetBlendColor(repeatImage, alarmData.AlarmState == AlarmStates.Inactive ? Color.FromHex("66000000") : Color.FromHex("FFFFFF")); repeatImage.SetBinding(ImageAttributes.BlendColorProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.Repeat)); // Added to layout alarmItemLayout.Children.Add(repeatImage, Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)), Constraint.RelativeToParent((parent) => (22 + 93) - (43 + 43))); /// Alarm Name Label alamNameLabel = new Label(); /// For alarm name label, to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(alamNameLabel, FontWeight.Normal); /// Bind alarm lable's style to alarm state alamNameLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.Name)); /// Bind label's text property to AlarmMode's AlarmName. alamNameLabel.SetBinding(Label.TextProperty, "AlarmName"); // Update alarm name label's TranslationX property value according to repeat image's visibility alamNameLabel.SetBinding(Label.TranslationXProperty, new Binding("Repeat", BindingMode.OneWay, converter: new AlarmNameLabelPositionConverter())); // Bind alarm name label's visibility alamNameLabel.SetBinding(Label.IsVisibleProperty, new Binding("IsVisibleDateLabel", BindingMode.Default, new DateLabelVisibleToVisibility(), false)); //alamNameLabel.Text = alarmData.AlarmName; // Added to relative layout alarmItemLayout.Children.Add(alamNameLabel, Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)), Constraint.RelativeToParent((parent) => (22 + 93 - (43 + 43)))); /// WeekDays Label weekDaysLabel = new Label() { FormattedText = alarmData.GetFormatted(alarmData.WeekFlag, alarmData.AlarmState < AlarmStates.Inactive ? true : false), IsVisible = !alarmData.IsVisibleDateLabel, Style = alarmData.AlarmState == AlarmStates.Inactive ? AlarmStyle.ATO004D : AlarmStyle.ATO004, }; // to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(weekDaysLabel, FontWeight.Normal); /// Style set for time label for normal case weekDaysLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.Weekly)); /// Sets binding context for weekdays label weekDaysLabel.SetBinding(Label.FormattedTextProperty, new Binding("WeekdayRepeatText", BindingMode.Default)); weekDaysLabel.SetBinding(Label.IsVisibleProperty, new Binding("IsVisibleDateLabel", BindingMode.Default, new DateLabelVisibleToVisibility(), false)); /// Adds to relative layout alarmItemLayout.Children.Add(weekDaysLabel, Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)), Constraint.RelativeToParent((parent) => (22 + 93) - 43)); // Date label // DateLabel is only visible when the alarm name is empty and repeat weekly is Never. dateLabel = new Label { Text = alarmData.ScheduledDateTime.ToString("ddd, d MMM"), }; // to meet To meet thin attribute for font, need to use custom feature FontFormat.SetFontWeight(dateLabel, FontWeight.Normal); dateLabel.SetBinding(Label.IsVisibleProperty, new Binding("IsVisibleDateLabel", BindingMode.Default, new DateLabelVisibleToVisibility(), true)); dateLabel.SetBinding(Label.StyleProperty, new Binding("AlarmState", BindingMode.Default, new AlarmStateToPropertyConverter(), AlarmModelComponent.Date)); alarmItemLayout.Children.Add(dateLabel, Constraint.RelativeToParent((parent) => (720 - 104 - 32 - 268)), Constraint.RelativeToParent((parent) => 22)); /// Switch object to represent that the alarm is active or not switchObj = new Switch { HeightRequest = 72, WidthRequest = 72, IsToggled = alarmData.AlarmState == AlarmStates.Inactive ? false : true, }; /// Bind IsToggled property to alarm state //switchObj.SetBinding(Switch.IsToggledProperty, new Binding("AlarmState", BindingMode.OneWay, new AlarmStateToPropertyConverter(), AlarmModelComponent.State)); /// Adds to relative layout alarmItemLayout.Children.Add(switchObj, Constraint.RelativeToParent((parent) => { return(720 - 104); }), Constraint.RelativeToParent((parent) => { return(22 + 93 - 72); })); /// Adds an event switchObj.Toggled += (s, e) => { //Switch sObj = s as Switch; ///// Needs valid parent to proceed //if (sObj.Parent == null || sObj.Parent.Parent == null) //{ // return; //} ///// Need binding context to check state //AlarmRecord am = (AlarmRecord)((AlarmListCell)sObj.Parent.Parent).BindingContext; //if (am == null) //{ // return; //} AlarmRecord am = (AlarmRecord)BindingContext; /// Modify state and re-draw it. Redraw must be called to redraw //am.AlarmState = e.Value ? AlarmStates.Active : AlarmStates.Inactive; if (e.Value) { AlarmModel.ReactivatelAlarm(am); } else { AlarmModel.DeactivatelAlarm(am); } AlarmModel.PrintAll("After switch is toggled..."); }; } else { switchObj.IsVisible = true; } return(alarmItemLayout); }
View CreateView() { var layout = new RelativeLayout { }; var backgroundImage = new Image { Source = new FileImageSource { File = "list_item_bg.png" }, Aspect = Aspect.Fill, }; layout.Children.Add( backgroundImage, Constraint.RelativeToParent((parent) => { return(0); }), Constraint.RelativeToParent((parent) => { return(0); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToParent((parent) => { return(parent.Height); })); var descriptionLabel = new Label { Text = "Description", HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.EndAndExpand, FontSize = 30, FontAttributes = FontAttributes.Bold, }; descriptionLabel.SetBinding(Label.TextProperty, "Title"); var pathLabel = new Label { Text = "Path", HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.StartAndExpand, FontSize = 25, TextColor = Color.FromRgb(146, 146, 146), LineBreakMode = LineBreakMode.CharacterWrap }; pathLabel.SetBinding(Label.TextProperty, "Path"); layout.Children.Add(descriptionLabel, Constraint.RelativeToParent((parent) => { return(parent.Width * 0.0431); }), Constraint.RelativeToParent((parent) => { return(parent.Height * 0.3084); })); layout.Children.Add(pathLabel, Constraint.RelativeToParent((parent) => { return(parent.Width * 0.0431); }), Constraint.RelativeToParent((parent) => { return(parent.Height * 0.5198); }), Constraint.RelativeToParent((parent) => { return(parent.Width * (1 - 2 * 0.0431)); })); var gestureRecognizer = new LongTapGestureRecognizer(); gestureRecognizer.TapStarted += (s, e) => { //change foreground blend color of image ImageAttributes.SetBlendColor(backgroundImage, Color.FromRgb(213, 228, 240)); }; gestureRecognizer.TapCanceled += (s, e) => { //revert foreground blend color of image ImageAttributes.SetBlendColor(backgroundImage, Color.Default); }; gestureRecognizer.TapCompleted += (s, e) => { //revert foreground blend color of image ImageAttributes.SetBlendColor(backgroundImage, Color.Default); }; layout.GestureRecognizers.Add(gestureRecognizer); return(layout); }