/// <summary> /// Gets the 'HitArea' for the item /// </summary> /// <param name="objArg"></param> /// <returns>eHitArea (move, resize, etc)</returns> private eHitArea GetHitArea(MouseEventArgs objArg) { // WeekDayView item WeekDayView wv = this.Parent as WeekDayView; if (wv != null) { return(GetWeekDayHitArea(objArg)); } // MonthView item MonthView mv = this.Parent as MonthView; if (mv != null) { return(GetMonthHitArea(mv, objArg)); } // TimeLineView item TimeLineView tv = this.Parent as TimeLineView; if (tv != null) { return(GetTimeLineHitArea(objArg)); } // Nowhere we recognize return(eHitArea.None); }
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName.Equals("HeightRequest")) { if (Content == null) { double unit = this.HeightRequest / 7; Color bg = this.BackgroundColor; Color btnBg = Color.FromHex("1FC2F3"); Color btnText = new Color(243, 254, 252); DateTime now = DateTime.Now; weekDayView = new WeekDayView() { BackgroundColor = bg, HeightRequest = unit }; scrollMonthDateViewEx = new ScrollMonthDateViewEx() { BackgroundColor = bg, HeightRequest = (this.HeightRequest - unit * 2), Date = now }; //上下月按钮与标题 Button previous = new Button() { Text = "<", BackgroundColor = btnBg, TextColor = btnText, BorderRadius = 0, WidthRequest = unit, HorizontalOptions = LayoutOptions.Start }; Button next = new Button() { Text = ">", BackgroundColor = btnBg, TextColor = btnText, BorderRadius = 0, WidthRequest = unit, HorizontalOptions = LayoutOptions.End }; Label year = new Label() { TextColor = Color.Black, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center }; Binding binding = new Binding(); binding.Source = scrollMonthDateViewEx; binding.Path = "Date"; binding.Converter = new Date2StringConverter(); binding.Mode = BindingMode.OneWay; year.SetBinding(Label.TextProperty, binding); previous.Clicked += (sender, e) => { scrollMonthDateViewEx.Date = scrollMonthDateViewEx.Date.AddMonths(-1); }; next.Clicked += (sender, e) => { scrollMonthDateViewEx.Date = scrollMonthDateViewEx.Date.AddMonths(1); }; StackLayout yearView = new StackLayout() { Orientation = StackOrientation.Horizontal, Children = { previous, year, next }, BackgroundColor = bg, Spacing = 0, HeightRequest = unit }; if (Device.RuntimePlatform.Equals(Device.iOS)) { previous.Margin = new Thickness(5, 5, 0, 5); next.Margin = new Thickness(0, 5, 5, 5); } //组装 Content = new StackLayout() { Orientation = StackOrientation.Vertical, Children = { yearView, weekDayView, scrollMonthDateViewEx }, Spacing = 0, }; } } else if (propertyName.Equals("Date")) { scrollMonthDateViewEx.Date = this.Date; } else if (propertyName.Equals("Thing")) { scrollMonthDateViewEx.Thing = this.Thing; } else if (propertyName.Equals("Click")) { scrollMonthDateViewEx.Click = this.Click; } }