コード例 #1
0
ファイル: Binding.cs プロジェクト: RemSoftDev/Wouter
        public static void Make <T> (Activity activity, int ResourceId, T obj, Expression <Func <T, Visibility> > property, NotifySinker sink = null)
        {
            var box = activity.FindViewById(ResourceId);
            var memberExpression = (MemberExpression)property.Body;
            var propertyInfo     = (PropertyInfo)memberExpression.Member;

            box.Visibility = ((Visibility)propertyInfo.GetValue(obj, null)) == Visibility.Visible ? Android.Views.ViewStates.Visible : Android.Views.ViewStates.Gone;

            if (sink != null)
            {
                sink.Add(propertyInfo.Name, () => {
                    box.Visibility = ((Visibility)propertyInfo.GetValue(obj, null)) == Visibility.Visible ? Android.Views.ViewStates.Visible : Android.Views.ViewStates.Gone;
                });
            }
        }
コード例 #2
0
ファイル: Binding.cs プロジェクト: RemSoftDev/Wouter
        public static void Make <T> (Activity activity, int ResourceId, T obj, Expression <Func <T, bool> > property, NotifySinker sink = null)
        {
            var box = activity.FindViewById <CheckBox> (ResourceId);
            var memberExpression = (MemberExpression)property.Body;
            var propertyInfo     = (PropertyInfo)memberExpression.Member;

            box.Checked        = (bool)propertyInfo.GetValue(obj, null);
            box.CheckedChange += (sender, e) => {
                propertyInfo.SetValue(obj, box.Checked, null);
            };

            if (sink != null)
            {
                sink.Add(propertyInfo.Name, () => {
                    box.Checked = ((bool)propertyInfo.GetValue(obj, null));
                });
            }
        }
コード例 #3
0
ファイル: Binding.cs プロジェクト: RemSoftDev/Wouter
        public static void Make <T> (Activity activity, int ResourceId, T obj, Expression <Func <T, String> > property, NotifySinker sink = null)
        {
            var box = activity.FindViewById <EditText> (ResourceId);
            var memberExpression = (MemberExpression)property.Body;
            var propertyInfo     = (PropertyInfo)memberExpression.Member;

            box.Text         = (String)propertyInfo.GetValue(obj, null);
            box.TextChanged += (sender, e) => {
                propertyInfo.SetValue(obj, box.Text, null);
            };

            if (sink != null)
            {
                sink.Add(propertyInfo.Name, () => {
                    box.Text = ((String)propertyInfo.GetValue(obj, null));
                });
            }
        }
コード例 #4
0
ファイル: Binding.cs プロジェクト: RemSoftDev/Wouter
        public static void Make <T> (Activity activity, int ResourceId, T obj, Expression <Func <T, DateTime> > property, NotifySinker sink = null)
        {
            var box = activity.FindViewById <EditText> (ResourceId);
            var memberExpression = (MemberExpression)property.Body;
            var propertyInfo     = (PropertyInfo)memberExpression.Member;

            box.Text         = ((DateTime)propertyInfo.GetValue(obj, null)).ToShortTimeString();
            box.TextChanged += (sender, e) => {
                DateTime time = DateTime.MinValue;
                if (DateTime.TryParse(box.Text, out time))
                {
                    propertyInfo.SetValue(obj, time, null);
                }
            };

            if (sink != null)
            {
                sink.Add(propertyInfo.Name, () => {
                    box.Text = ((DateTime)propertyInfo.GetValue(obj, null)).ToShortTimeString();
                });
            }
        }