Пример #1
0
 public Condition(Context context)
 {
     #region 时间控件
     year  = new YearTimeCondition(context);
     month = new MonthCondition(context);
     day   = new DayTimeCondition(context, this);
     year.TimeChangeLisenter  = day;
     month.TimeChangeLisenter = day;
     hour    = new HourTimeCondition(context);
     minutes = new MinutesTimeCondition(context);
     #endregion
     #region 监听时间改变
     var intentFilter = new IntentFilter();
     intentFilter.AddAction(Intent.ActionTimeTick);//每分钟变化
     TimeChangeReceiver timeChangeReceiver = new TimeChangeReceiver();
     context.RegisterReceiver(timeChangeReceiver, intentFilter);
     timeChangeReceiver.condition = this;
     #endregion
     #region  空教室
     EmptyRoomOnlyButton                = ((Activity)context).FindViewById <ToggleButton>(Resource.Id.EmptyRoomOnly);
     EmptyRoomOnlyButton.Checked        = EmptyRoomOnly;
     EmptyRoomOnlyButton.CheckedChange += (sender, args) =>
     {
         EmptyRoomOnly = args.IsChecked;
     };
     #endregion
     #region 时间
     SetNowButton         = ((Activity)context).FindViewById <ToggleButton>(Resource.Id.SetNow);
     SetNowButton.Checked = NowTime;
     SetScroll(!NowTime);
     SetNowButton.CheckedChange += (sender, args) =>
     {
         NowTime = args.IsChecked;
         if (NowTime)
         {
             SetTimeToNow();
         }
         SetScroll(!NowTime);
     };
     #endregion
 }
Пример #2
0
        public Condition(Context context, SearchRoom searchRoom, RecyclerView.Adapter roomlist_adapter)
        {
            this.context          = context;
            this.searchRoom       = searchRoom;
            this.roomlist_adapter = roomlist_adapter;
            #region 中二病
            TextView  中二病          = ((Activity)context).FindViewById <TextView>(Resource.Id.中二病Text);
            ImageView 中二病imageView = ((Activity)context).FindViewById <ImageView>(Resource.Id.中二病imageView);
            ImageView LeftMenuHead = ((Activity)context).FindViewById <ImageView>(Resource.Id.imageButton1);
            中二病imageView.Click += 中二病imageView_Click;
            中二病.Click          += 中二病imageView_Click;
            void 中二病imageView_Click(object sender, EventArgs e)
            {
                if (中二病Flag)
                {
                    中二病.Text = "普通模式";
                    中二病Flag  = false;
                    LeftMenuHead.SetImageDrawable(context.GetDrawable(Resource.Drawable.ic_launcher_foreground_HD));
                    SetTime();
                }
                else
                {
                    中二病.Text = "中二病模式";
                    中二病Flag  = true;
                    LeftMenuHead.SetImageDrawable(context.GetDrawable(Resource.Drawable.APPButtonImage));
                    SetTime();
                }
            }

            #endregion
            #region 监听时间改变
            var intentFilter = new IntentFilter();
            intentFilter.AddAction(Intent.ActionTimeTick);//每分钟变化
            TimeChangeReceiver timeChangeReceiver = new TimeChangeReceiver();
            context.RegisterReceiver(timeChangeReceiver, intentFilter);
            timeChangeReceiver.condition = this;
            #endregion
            #region  空教室
            EmptyRoomSwitch        = ((Activity)context).FindViewById <LinearLayout>(Resource.Id.EmptyRoomSwitch);
            EmptyRoomText          = ((Activity)context).FindViewById <TextView>(Resource.Id.EmptyRoomText);
            EmptyRoomSwitch.Click += (sender, args) =>
            {
                if (EmptyRoomFlag)
                {
                    EmptyRoomFlag      = false;
                    EmptyRoomText.Text = "全部教室";
                }
                else
                {
                    EmptyRoomFlag      = true;
                    EmptyRoomText.Text = "空教室";
                }
                searchRoom.ResetShowDatas(this);         //显示数据应用更改
                roomlist_adapter.NotifyDataSetChanged(); //显示数据刷新
            };
            #endregion
            #region 时间
            TimeLockButton = ((Activity)context).FindViewById <Button>(Resource.Id.TimeLockButton);
            WeekText       = ((Activity)context).FindViewById <TextView>(Resource.Id.WeekText);
            TimeText       = ((Activity)context).FindViewById <TextView>(Resource.Id.TimeText);
            SetTimeToNow(); //初始化时间
            SetTime();      //应用更改
            WeekText.Click += (sender, args) =>
            {
                ChangeWeek();
            };//改变周
            TimeText.Click += (sender, args) =>
            {
                ChangeTime();
            };//改变时间
            #endregion
        }