//using System;
|
//using Android.Content;
|
//using Android.Views;
|
//using Android.Util;
|
//using Android.Runtime;
|
//using Android.Widget;
|
//using Android.OS;
|
//using Android.Views.Animations;
|
|
//namespace Shared
|
//{
|
// //已经全面检查了代码
|
// /// <summary>
|
// /// 在滑动事件下,可显示隐藏些自定义视图
|
// /// </summary>
|
// public class DrawerLayout : ViewGroup
|
// {
|
// AndroidDrawerLayout androidDrawerLayout;
|
|
// //uint lineColor = 0x62818181;
|
// ///// <summary>
|
// ///// 背景颜色
|
// ///// </summary>
|
// ///// <value>The color of the background.</value>
|
// //public virtual uint LineColor
|
// //{
|
// // get
|
// // {
|
// // return lineColor;
|
// // }
|
// // set
|
// // {
|
// // lineColor = value;
|
// // byte r, g, b, a;
|
// // r = (byte)(lineColor / 256 / 256 % 256);
|
// // g = (byte)(lineColor / 256 % 256);
|
// // b = (byte)(lineColor % 256);
|
// // a = (byte)(lineColor / 256 / 256 / 256 % 256);
|
// // lineLinearLayout.SetBackgroundColor(Android.Graphics.Color.Argb(a, r, g, b));
|
// // }
|
// //}
|
|
// /// <summary>
|
// /// 宽度设置或读取
|
// /// </summary>
|
// /// <value>The width.</value>
|
// public override int Width
|
// {
|
// get
|
// {
|
// return base.Width;
|
// }
|
// set
|
// {
|
// base.Width = value;
|
// if (!IsCanRefresh)
|
// {
|
// return;
|
// }
|
// var layoutParameters = androidDrawerLayout.LayoutParameters;
|
// layoutParameters.Width = Width;
|
// androidDrawerLayout.LayoutParameters = layoutParameters;
|
// }
|
// }
|
|
// /// <summary>
|
// /// 视图高度
|
// /// </summary>
|
// /// <value>The height.</value>
|
// public override int Height
|
// {
|
// get
|
// {
|
// return base.Height;
|
// }
|
// set
|
// {
|
// base.Height = value;
|
// if (!IsCanRefresh)
|
// {
|
// return;
|
// }
|
// var layoutParameters = androidDrawerLayout.LayoutParameters;
|
// layoutParameters.Height = Height;
|
// androidDrawerLayout.LayoutParameters = layoutParameters;
|
// }
|
// }
|
|
// Android.Widget.FrameLayout leftLinarLayout;
|
// //Android.Widget.LinearLayout rightLinarLayout;
|
// //Android.Widget.LinearLayout lineLinearLayout;
|
// /// <summary>
|
// /// 在滑动事件下,可显示隐藏些自定义视图
|
// /// </summary>
|
// public DrawerLayout()
|
// {
|
// viewGroup = new Android.Widget.RelativeLayout(Application.Activity);
|
// androidDrawerLayout = new AndroidDrawerLayout(Application.Activity, this) { };
|
|
// androidDrawerLayout.LeftToRightAction += () =>
|
// {
|
// openLeftMenu();
|
// };
|
// realViewGroup = androidDrawerLayout;
|
// leftLinarLayout = new Android.Widget.FrameLayout(Application.Activity) { Alpha = 0.0f };
|
// //rightLinarLayout = new Android.Widget.LinearLayout(Application.Activity) { Orientation = Android.Widget.Orientation.Horizontal, Alpha = 0.0f };
|
// //lineLinearLayout = new Android.Widget.LinearLayout(Application.Activity);
|
// //LineColor = lineColor;
|
// viewGroup.AddView(leftLinarLayout, new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.WrapContent, Android.Views.ViewGroup.LayoutParams.MatchParent));
|
|
// //viewGroup.AddView(rightLinarLayout, new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.WrapContent, Android.Views.ViewGroup.LayoutParams.MatchParent));
|
// viewGroup.AddView(androidDrawerLayout, new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.MatchParent));
|
// //viewGroup.AddView(lineLinearLayout, new Android.Widget.FrameLayout.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, DensityUtil.Dip2Px(1), Android.Views.GravityFlags.Bottom));
|
|
|
// }
|
|
|
|
// void openLeftMenu()
|
// {
|
// //if (androidDrawerLayout.isShowRight)
|
// //{
|
// // hideRightMenu();
|
// // return;
|
// //}
|
|
// if (leftLinarLayout.ChildCount == 0)
|
// return;
|
|
// androidDrawerLayout.isShowLeft = true;
|
|
// Android.Widget.FrameLayout.LayoutParams lp = (Android.Widget.FrameLayout.LayoutParams)leftLinarLayout.LayoutParameters;
|
// lp.RightMargin = 0;
|
// leftLinarLayout.LayoutParameters = lp;
|
// leftLinarLayout.Alpha = 1.0f;
|
|
|
// if (leftLinarLayout.Animation == null)
|
// {
|
// leftLinarLayout.Animation = new TranslateAnimation(
|
// Dimension.RelativeToSelf, -androidDrawerLayout.LayoutParameters.Width,
|
// Dimension.RelativeToSelf, 0,
|
// Dimension.RelativeToSelf, 0,
|
// Dimension.RelativeToSelf, 0);
|
// leftLinarLayout.Animation.Duration = 200;
|
// }
|
|
// // Animation = leftUIView.Animation;
|
// //Animation.Reset();
|
// //Animation.StartNow();
|
|
// leftLinarLayout.Animation.Reset();
|
// leftLinarLayout.Animation.StartNow();
|
|
|
// System.Console.WriteLine("DrawerLayout:openLeftMenu");
|
|
// // UIView.Animate (0.2f, 0.0f, UIViewAnimationOptions.BeginFromCurrentState, () => {
|
// // contentView.X = (int)leftUIView.Frame.Width;
|
// // leftUIView.Alpha = 1.0f;
|
// // }, () => {
|
// //
|
// // });
|
// }
|
|
// void hideLeftMenu()
|
// {
|
// androidDrawerLayout.isShowLeft = false;
|
// Android.Widget.FrameLayout.LayoutParams lp = (Android.Widget.FrameLayout.LayoutParams)leftLinarLayout.LayoutParameters;
|
// lp.RightMargin = androidDrawerLayout.LayoutParameters.Width;
|
// leftLinarLayout.LayoutParameters = lp;
|
// leftLinarLayout.Alpha = 0.0f;
|
// // UIView.Animate(0.2f,0.0f,UIViewAnimationOptions.BeginFromCurrentState,()=>{
|
// // contentView.X=0;
|
// // leftUIView.Alpha=0.0f;
|
// // },()=>{
|
// //
|
// // });
|
// }
|
|
|
|
|
// /// <summary>
|
// /// 子视图的宽度
|
// /// </summary>
|
// //int subViewWidth = 100;
|
|
// /// <summary>
|
// /// 增加左边视图
|
// /// </summary>
|
// /// <param name="view">View.</param>
|
// public void AddLeftView(View view)
|
// {
|
// leftLinarLayout.AddView(view.AndroidView, new Android.Views.ViewGroup.LayoutParams(androidDrawerLayout.LayoutParameters.Width, androidDrawerLayout.LayoutParameters.Height));
|
// leftLinarLayout.LayoutParameters.Width = androidDrawerLayout.LayoutParameters.Width;
|
// view.Parent = this;
|
// view.Width = androidDrawerLayout.LayoutParameters.Width;
|
// view.Height = androidDrawerLayout.LayoutParameters.Height;
|
// }
|
|
|
|
|
// class AndroidDrawerLayout : Android.Widget.FrameLayout
|
// {
|
// View _view;
|
// int mTouchSlop
|
// {
|
// get
|
// {
|
// var configuration = ViewConfiguration.Get(Context);
|
// //最小的滑动距离
|
// return configuration.ScaledTouchSlop;
|
// }
|
// }
|
// public AndroidDrawerLayout(Context context, View view)
|
// : base(context)
|
// {
|
// _view = view;
|
// }
|
|
// float mLastX, mLastY;
|
// internal bool isShowLeft;
|
// internal bool isShowRight;
|
// public Action RightToLeftAction;
|
// public Action LeftToRightAction;
|
// bool isActioned;
|
// bool action(MotionEvent e)
|
// {
|
// switch (e.Action)
|
// {
|
// case MotionEventActions.Down:
|
// //记录点击的最新X坐标
|
// mLastX = e.RawX;
|
// mLastY = e.RawY;
|
// Parent?.RequestDisallowInterceptTouchEvent(true);
|
// break;
|
// case MotionEventActions.Move:
|
// var x = e.RawX;
|
// var y = e.RawY;
|
// var deltaX = x - mLastX;
|
// var deltaY = y - mLastY;
|
// if (Math.Abs(deltaY) < Math.Abs(deltaX))
|
// {
|
// if (!isActioned)
|
// {
|
// //RightToLeftAction
|
// if (deltaX < -mTouchSlop)
|
// {
|
// isActioned = true;
|
// //parentDelay(true);
|
// System.Console.WriteLine("DrawerLayout:DispatchTouchEvent:RightToLeft");
|
// RightToLeftAction?.Invoke();
|
// }
|
// //LeftToRightAction
|
// if (mTouchSlop < deltaX)
|
// {
|
// isActioned = true;
|
// //parentDelay(true);
|
// System.Console.WriteLine("DrawerLayout:DispatchTouchEvent:LeftToRight");
|
// LeftToRightAction?.Invoke();
|
// }
|
// }
|
// return true;
|
// }
|
// else
|
// {
|
// //上下滑动时,允许父控件的拦截
|
// if (4 < Math.Abs(deltaY))
|
// {
|
// Parent?.RequestDisallowInterceptTouchEvent(false);
|
// }
|
// }
|
// break;
|
// }
|
// return false;
|
// }
|
|
// /// <summary>
|
// /// 执行OnInterceptTouchEvent和OnTouchEvent
|
// /// </summary>
|
// /// <returns><c>true</c>事件已经处理<c>false</c>事件没有处理</returns>
|
// /// <param name="e">E.</param>
|
// public override bool DispatchTouchEvent(MotionEvent e)
|
// {
|
// System.Console.WriteLine($"{GetType()} Height->{Height} Width->{Width} DispatchTouchEvent->{e.Action}");
|
// if (e.Action == MotionEventActions.Down)
|
// {
|
// isActioned = false;
|
// //还原允许拦截事件
|
// RequestDisallowInterceptTouchEvent(false);
|
// }
|
// return base.DispatchTouchEvent(e);
|
// }
|
|
// public override bool OnInterceptTouchEvent(MotionEvent e)
|
// {
|
// System.Console.WriteLine($"{GetType()} Height->{Height} Width->{Width} OnInterceptTouchEvent->{e.Action}");
|
// if (disallowIntercept)
|
// {
|
// return false;
|
// }
|
// if (action(e))
|
// {
|
// return true;
|
// }
|
// return base.OnInterceptTouchEvent(e);
|
// }
|
|
// /// <summary>
|
// /// 重写点击事件
|
// /// </summary>
|
// /// <returns><c>true</c>, if touch event was oned, <c>false</c> otherwise.</returns>
|
// /// <param name="e">E.</param>
|
// public override bool OnTouchEvent(MotionEvent e)
|
// {
|
// System.Console.WriteLine($"{GetType()} Height->{Height} Width->{Width} OnTouchEvent->{e.Action}");
|
// if (!isActioned)
|
// {
|
// _view.TouchEvent(e);
|
// }
|
// action(e);
|
// return true;
|
// }
|
// bool disallowIntercept;
|
// public override void RequestDisallowInterceptTouchEvent(bool disallowIntercept)
|
// {
|
// this.disallowIntercept = disallowIntercept;
|
// System.Console.WriteLine($"{GetType()} Height->{Height} RequestDisallowInterceptTouchEvent->{disallowIntercept}");
|
// base.RequestDisallowInterceptTouchEvent(disallowIntercept);
|
// Parent?.RequestDisallowInterceptTouchEvent(disallowIntercept);
|
// }
|
// }
|
// }
|
//}
|