Ejemplo n.º 1
0
        private void Init()
        {
            SetWillNotDraw(false);

            _listeners = new List <IShowcaseListener>();

            // make sure we add a global layout listener so we can adapt to changes
            //mLayoutListener = new UpdateOnGlobalLayout(this,mTarget);
            ViewTreeObserver.AddOnGlobalLayoutListener(this);

            // consume touch events
            SetOnTouchListener(this);

            _maskColour = ShowcaseConfig.DefaultMaskColour;
            Visibility  = ViewStates.Invisible;
            // setVisibility(INVISIBLE);


            var contentView = LayoutInflater.From(Context).Inflate(Resource.Layout.showcase_content, this, true);

            _contentBox      = contentView.FindViewById(Resource.Id.content_box);
            _titleTextView   = contentView.FindViewById <TextView>(Resource.Id.tv_title);
            _contentTextView = contentView.FindViewById <TextView>(Resource.Id.tv_content);
            _dismissButton   = contentView.FindViewById <TextView>(Resource.Id.tv_dismiss);
            _dismissButton.SetOnClickListener(this);
        }
Ejemplo n.º 2
0
        public PhotoViewAttacher(ImageView imageView, bool fromChatActivity, Context context)
        {
            mImageView        = new WeakReference <ImageView>(imageView);
            mFromChatActivity = fromChatActivity;
            mContext          = context;
            imageView.SetOnTouchListener(this);

            mViewTreeObserver = imageView.ViewTreeObserver;
            mViewTreeObserver.AddOnGlobalLayoutListener(this);

            // Make sure we using MATRIX Scale Type
            SetImageViewScaleTypeMatrix(imageView);

            if (!imageView.IsInEditMode)
            {
                // Create Gesture Detectors...
                mScaleDragDetector = VersionedGestureDetector.NewInstance(imageView.Context, this);

                mGestureDetector = new GestureDetector(imageView.Context, new MySimpleOnGestureListener(mLongClickListener));

                mGestureDetector.SetOnDoubleTapListener(this);

                // Finally, update the UI so that we're zoomable

                SetZoomable(true);
                Update();
            }
        }
        void AddLayoutListener()
        {
            _carouselViewLayoutListener              = new CarouselViewwOnGlobalLayoutListener();
            _carouselViewLayoutListener.LayoutReady += LayoutReady;

            ViewTreeObserver.AddOnGlobalLayoutListener(_carouselViewLayoutListener);
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.StudyDetail);

            string[] studyInfo = new string[] {
                $"检查时间: {MyStudyList.SelectedStudy.SampleTime.ToLocalTime():HH:mm:ss}",
                $"诊断结果: {MyStudyList.SelectedStudy.Diagnose}",
                $"诊断医生: {MyStudyList.SelectedStudy.DoctorName}",
            };
            ListView lsvStudyInfo         = FindViewById <ListView>(Resource.Id.lsvStudyInfo);
            ArrayAdapter <string> adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, studyInfo);

            lsvStudyInfo.Adapter = adapter;

            ImageView imgWave = FindViewById <ImageView>(Resource.Id.imgWave);

            //初始化绘制ECG波形对象
            MyDrawBioWave = new DrawBioWave(imgWave, MyStudyList.SelectedStudy.BioBuf);

            //onCreate时控件未显示,大小为0,不能直接初始化绘图对象,onStart,onResume都不行
            //System.NullReferenceException: Object reference not set to an instance of an object.
            observer = imgWave.ViewTreeObserver;
            observer.AddOnGlobalLayoutListener(this);
        }
Ejemplo n.º 5
0
        public PhotoViewDroidAttacher(ImageView imageView)
        {
            mImageView = new Java.Lang.Ref.WeakReference(imageView);
            imageView.DrawingCacheEnabled = true;
            imageView.SetOnTouchListener(this);
            ViewTreeObserver observer = imageView.ViewTreeObserver;

            if (null != observer)
            {
                observer.AddOnGlobalLayoutListener(this);
            }

            // Make sure we using MATRIX Scale Type
            SetImageViewScaleTypeMatrix(imageView);

            if (imageView.IsInEditMode)
            {
                return;
            }

            // Create Gesture Detectors...
            mScaleDragDetector = VersionedGestureDetector.NewInstance(
                imageView.Context, this);
            mGestureDetector = new GestureDetector(imageView.Context, new MSimpleOnGestureListener(this));


            mGestureDetector.SetOnDoubleTapListener(new DefaultOnDoubleTapListener(this));

            SetZoomable(true);
        }
Ejemplo n.º 6
0
        public void NotifyDataSetChanged()
        {
            tabsContainer.RemoveAllViews();
            tabCount = pager.Adapter.Count;
            View tabView;

            for (int i = 0; i < tabCount; i++)
            {
                if (pager.Adapter is ICustomTabProvider)
                {
                    tabView = ((ICustomTabProvider)pager.Adapter).GetCustomTabView(this, i);
                }
                else
                {
                    tabView = LayoutInflater.From(Context).Inflate(Resource.Layout.tab, this, false);
                }

                var title = pager.Adapter.GetPageTitle(i);

                AddTab(i, title, tabView);
            }

            UpdateTabStyles();

            ViewTreeObserver.AddOnGlobalLayoutListener(MyOnGlobalLayoutListner);
        }
Ejemplo n.º 7
0
        void myTabbedPage_Appearing(object sender, EventArgs e)
        {
            //_isFirstDesign = true;
            if (listener.Handle != IntPtr.Zero)
            {
                ViewTreeObserver.AddOnGlobalLayoutListener(listener);
            }

            if (heightDiff <= 100)
            {
                if (myTabbedPage.TabScreenLocation == TabGravity.Bottom)
                {
                    myTabbedPage.Padding = new Thickness(0, 0, 0, originalPadding);
                }
                else
                {
                    myTabbedPage.Padding = new Thickness(0, originalPadding, 0, 0);
                }

                ShowCustomMenu();
            }

            currentTabIndex = this.Element.Children.IndexOf(this.Element.CurrentPage);

            //if (currentTabIndex == 0 && myTabbedPage.Children[0].Navigation.NavigationStack.Count <= 2)
            //    SetCustomIcon("custom_setting");
            //else
            //    SetCustomIcon("empty_layout");

            mMenu.SetSelectedIndex(currentTabIndex);
        }
Ejemplo n.º 8
0
 protected override void OnElementChanged(ElementChangedEventArgs <Grid> e)
 {
     base.OnElementChanged(e);
     if (e.NewElement != null)
     {
         ViewTreeObserver.AddOnGlobalLayoutListener(this);
     }
 }
Ejemplo n.º 9
0
        public void MakeExpandable(string fullText, int maxLines)
        {
            mFullText = fullText;
            mMaxLines = maxLines;

            ViewTreeObserver vto = ViewTreeObserver;

            vto.AddOnGlobalLayoutListener(this);
        }
Ejemplo n.º 10
0
 protected override void OnResume()
 {
     base.OnResume();
     if (!m_scriptRun)
     {
         ViewTreeObserver vto = TheLayout.ViewTreeObserver;
         vto.AddOnGlobalLayoutListener(new LayoutListener());
         m_scriptRun = true;
     }
 }
Ejemplo n.º 11
0
        public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
        {
            base.OnConfigurationChanged(newConfig);

            View parent = (View)_sv.Parent;

            ViewTreeObserver observer = parent.ViewTreeObserver;

            observer.AddOnGlobalLayoutListener(this);
        }
Ejemplo n.º 12
0
 private void Initialize()
 {
     ViewTreeObserver.AddOnGlobalLayoutListener(new GlobalLayoutListener((obj) =>
     {
         ViewTreeObserver.RemoveOnGlobalLayoutListener(obj);
         // Generate simple Triangulation for initial draw
         Triangulation = new Triangulation(Width, Height);
         Triangulation.PropertyChanged += Triangulation_PropertyChanged;
         Invalidate();
     }));
 }
        void AddLayoutListener()
        {
            if (_carouselViewLayoutListener != null)
            {
                return;
            }

            _carouselViewLayoutListener              = new CarouselViewwOnGlobalLayoutListener();
            _carouselViewLayoutListener.LayoutReady += LayoutReady;

            ViewTreeObserver.AddOnGlobalLayoutListener(_carouselViewLayoutListener);
        }
Ejemplo n.º 14
0
        public static void AddOnGlobalLayoutAction(this ViewTreeObserver observer, Action callback)
        {
            GlobalLayoutSingleFireListener listener = null;

            listener = new GlobalLayoutSingleFireListener(() =>
            {
                if (observer.IsAlive)
                {
                    callback();
                }
            });
            observer.AddOnGlobalLayoutListener(listener);
        }
Ejemplo n.º 15
0
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.fragment_run, container, false);

            mStartedTextView   = view.FindViewById <TextView>(Resource.Id.run_startedTextView);
            mLatitudeTextView  = view.FindViewById <TextView>(Resource.Id.run_latitudeTextView);
            mLongitudeTextView = view.FindViewById <TextView>(Resource.Id.run_longitudeTextView);
            mAltitudeTextView  = view.FindViewById <TextView>(Resource.Id.run_altitudeTextView);
            mDurationTextView  = view.FindViewById <TextView>(Resource.Id.run_durationTextView);

            mStartButton = view.FindViewById <Button>(Resource.Id.run_startButton);
            mStopButton  = view.FindViewById <Button>(Resource.Id.run_stopButton);

            mStartButton.Click += (object sender, EventArgs e) => {
                CurrentRun = mRunManager.StartNewRun();
                mGoogleMap.Clear();
                mMapShouldFollow = true;
                UpdateUI();
            };

            mStopButton.Click += (object sender, EventArgs e) => {
                mRunManager.StopRun(CurrentRun);
                CurrentRun = null;
                UpdateUI();
            };

            mGoogleMap = ((MapFragment)FragmentManager.FindFragmentById(Resource.Id.mapFrag)).Map;
            mGoogleMap.MyLocationEnabled = true;
            mGoogleMap.MapType           = GoogleMap.MapTypeHybrid;
            mGoogleMap.PolylineClick    += (object sender, GoogleMap.PolylineClickEventArgs e) => {
                Console.WriteLine("***** Polyline Clicked");
                mPolyline.Width = 20;
                mPolyline.Color = Color.Red;
            };
            mGoogleMap.MapClick += (object sender, GoogleMap.MapClickEventArgs e) => {
                Console.WriteLine("***** Map Clicked");
                mPolyline.Width = mPolyLineOriginalWidth;
                mPolyline.Color = Color.Black;
            };

            mMapLayout = view.FindViewById <LinearLayout>(Resource.Id.mapLayout);
            ViewTreeObserver vto = mMapLayout.ViewTreeObserver;

            vto.AddOnGlobalLayoutListener(this);

            return(view);
        }
Ejemplo n.º 16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.DiagnoseDetail);

            string[] studyInfo = new string[] {
                $"检查时间: {MyStudyList.SelectedStudy.SampleTime.ToLocalTime():HH:mm:ss}",
                $"患者姓名: {MyStudyList.SelectedStudy.PatientName}",
            };
            ListView lsvStudyInfo = FindViewById <ListView>(Resource.Id.lsvStudyInfo);

            lsvStudyInfo.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, studyInfo);

            ImageView imgWave = FindViewById <ImageView>(Resource.Id.imgWave);

            //初始化绘制ECG波形对象
            MyDrawBioWave = new DrawBioWave(imgWave, MyStudyList.SelectedStudy.BioBuf);

            //onCreate时控件未显示,大小为0,不能直接初始化绘图对象,onStart,onResume都不行
            //System.NullReferenceException: Object reference not set to an instance of an object.
            observer = imgWave.ViewTreeObserver;
            observer.AddOnGlobalLayoutListener(this);

            //诊断结果列表
            DiagnoseList = new List <string>()
            {
                "正常", "轻度异常", "严重异常"
            };
            DiagnoseAdapter     = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, DiagnoseList);
            spnDiagnose         = FindViewById <Spinner>(Resource.Id.spnDiagnose);
            spnDiagnose.Adapter = DiagnoseAdapter;

            //自动分析
            Button btnAutoAnalyse = FindViewById <Button>(Resource.Id.btnAutoAnalyse);

            btnAutoAnalyse.Click += (s1, e1) => AutoAnalyse();

            //完成诊断
            Button btnSave = FindViewById <Button>(Resource.Id.btnSave);

            btnSave.Click += (s1, e1) => SaveStudy();
        }
Ejemplo n.º 17
0
 private void Init(IAttributeSet attrs)
 {
     scrollVelocity = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip,
                                                     DEFAULT_SCROLL_VELOCITY_DP, Context.Resources.DisplayMetrics);
     touchScrollable = true;
     if (null != attrs)
     {
         TypedArray ta = Context.ObtainStyledAttributes(attrs, Resource.Styleable.DragLayout);
         overScroll     = ta.GetInt(Resource.Styleable.DragLayout_overScroll, OVER_SCROLL_ALL);
         scrollVelocity = ta.GetDimensionPixelSize(
             Resource.Styleable.DragLayout_scrollVelocity, scrollVelocity);
         maxScrollTime   = ta.GetInt(Resource.Styleable.DragLayout_maxScrollTime, 0);
         touchScrollable = ta.GetBoolean(Resource.Styleable.DragLayout_touchScrollable, touchScrollable);
         ta.Recycle();
     }
     gestureHelper   = GestureHelper.CreateDefault(Context);
     layerScroller   = new Scroller(Context);
     velocityTracker = VelocityTracker.Obtain();
     ViewTreeObserver.AddOnGlobalLayoutListener(new DragLayoutListener(this));
 }
Ejemplo n.º 18
0
 private void AttachLayoutListener()
 {
     layoutListener = new LayoutListener(this);
     ViewTreeObserver.AddOnGlobalLayoutListener(layoutListener);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Create an AmbilWarnaDialog.
        /// </summary>
        /// <param name="context"> activity context </param>
        /// <param name="color"> current color </param>
        /// <param name="supportsAlpha"> whether alpha/transparency controls are enabled </param>
        /// <param name="listener"> an OnAmbilWarnaListener, allowing you to get back error or OK </param>
        public AmbilWarnaDialog(Context context, int color, bool supportsAlpha, IOnAmbilWarnaListener listener)
        {
            var supportsAlpha1 = supportsAlpha;

            _listener = listener;

            if (!supportsAlpha)
            {
                // remove alpha if not supported
                color = color | unchecked ((int)0xff000000);
            }

            Android.Graphics.Color.ColorToHSV(color.ToColor(), _currentColorHsv);
            _alpha = Android.Graphics.Color.GetAlphaComponent(color);

            View view = LayoutInflater.From(context).Inflate(R.Layout.ambilwarna_dialog, null);

            _viewHue    = view.FindViewById(R.Id.ambilwarna_viewHue);
            _viewSatVal = (AmbilWarnaSquare)view.FindViewById(R.Id.ambilwarna_viewSatBri);
            _viewCursor = (ImageView)view.FindViewById(R.Id.ambilwarna_cursor);
            var viewOldColor = view.FindViewById(R.Id.ambilwarna_oldColor);
            var viewNewColor = view.FindViewById(R.Id.ambilwarna_newColor);

            _viewTarget         = (ImageView)view.FindViewById(R.Id.ambilwarna_target);
            _viewContainer      = (ViewGroup)view.FindViewById(R.Id.ambilwarna_viewContainer);
            _viewAlphaOverlay   = view.FindViewById(R.Id.ambilwarna_overlay);
            _viewAlphaCursor    = (ImageView)view.FindViewById(R.Id.ambilwarna_alphaCursor);
            _viewAlphaCheckered = (ImageView)view.FindViewById(R.Id.ambilwarna_alphaCheckered);

            // Hide/show alpha
            _viewAlphaOverlay.Visibility   = supportsAlpha ? ViewStates.Visible : ViewStates.Gone;
            _viewAlphaCursor.Visibility    = supportsAlpha ? ViewStates.Visible : ViewStates.Gone;
            _viewAlphaCheckered.Visibility = supportsAlpha ? ViewStates.Visible : ViewStates.Gone;

            _viewSatVal.SetHue(Hue);
            viewOldColor.SetBackgroundColor(color.ToColor());
            viewNewColor.SetBackgroundColor(color.ToColor());


            _viewHue.Touch += (sender, e) =>
            {
                if (e.Event.Action == MotionEventActions.Move ||
                    e.Event.Action == MotionEventActions.Down ||
                    e.Event.Action == MotionEventActions.Up)
                {
                    float y = e.Event.GetY();
                    if (y < 0.0f)
                    {
                        y = 0.0f;
                    }
                    if (y > _viewHue.MeasuredHeight)
                    {
                        // To avoid jumping the cursor from bottom to top.
                        y = _viewHue.MeasuredHeight - 0.001f;
                    }
                    float hue = 360.0f - 360.0f / _viewHue.MeasuredHeight * y;

                    // HACK
                    // if (hue == 360.0f)
                    if (Math.Abs(hue - 360.0f) < Tolerance)
                    {
                        hue = 0.0f;
                    }

                    Hue = hue;

                    // Update view
                    _viewSatVal.SetHue(Hue);
                    MoveCursor();
                    viewNewColor.SetBackgroundColor(Color.ToColor());
                    UpdateAlphaView();

                    //return true;
                    e.Handled = true;
                }

                //return false;
                e.Handled = false;
            };


            if (supportsAlpha)
            {
                _viewAlphaCheckered.Touch += (sender, e) =>
                {
                    if (e.Event.Action == MotionEventActions.Move ||
                        e.Event.Action == MotionEventActions.Down ||
                        e.Event.Action == MotionEventActions.Up)
                    {
                        float y = e.Event.GetY();

                        if (y < 0.0f)
                        {
                            y = 0.0f;
                        }

                        if (y > _viewAlphaCheckered.MeasuredHeight)
                        {
                            y = _viewAlphaCheckered.MeasuredHeight - 0.001f;                             // to avoid jumping the cursor from bottom to top.
                        }

                        var a = (int)Math.Round(255.0f - 255.0f / _viewAlphaCheckered.MeasuredHeight * y);
                        Alpha = a;

                        // Update view
                        MoveAlphaCursor();
                        int col = Color;
                        int c   = a << 24 | col & 0x00ffffff;
                        viewNewColor.SetBackgroundColor(c.ToColor());

                        //return true;
                        e.Handled = true;
                    }

                    //return false;
                    e.Handled = false;
                };
            }


            _viewSatVal.Touch += (sender, e) =>
            {
                if (e.Event.Action == MotionEventActions.Move ||
                    e.Event.Action == MotionEventActions.Down ||
                    e.Event.Action == MotionEventActions.Up)
                {
                    float x = e.Event.GetX();                     // Touch event are in dp units.
                    float y = e.Event.GetY();

                    if (x < 0.0f)
                    {
                        x = 0.0f;
                    }

                    if (x > _viewSatVal.MeasuredWidth)
                    {
                        x = _viewSatVal.MeasuredWidth;
                    }

                    if (y < 0.0f)
                    {
                        y = 0.0f;
                    }

                    if (y > _viewSatVal.MeasuredHeight)
                    {
                        y = _viewSatVal.MeasuredHeight;
                    }

                    Sat = 1.0f / _viewSatVal.MeasuredWidth * x;
                    Val = 1.0f - 1.0f / _viewSatVal.MeasuredHeight * y;

                    // Update view
                    MoveTarget();
                    viewNewColor.SetBackgroundColor(Color.ToColor());

                    //return true;
                    e.Handled = true;
                }

                //return false;
                e.Handled = false;
            };


            Dialog = new AlertDialog.Builder(context)
                     .SetPositiveButton(
                Android.Resource.String.Ok,
                (sender, e) =>
            {
                // Set Listener
                listener?.OnOk(this, Color);

                // EventHandler
                OnOk(this, Color);
            }
                ).SetNegativeButton(
                Android.Resource.String.Cancel,
                (sender, e) =>
            {
                // Set Listener
                listener?.OnCancel(this);

                // EventHandler
                OnCancel(this);
            }
                ).SetOnCancelListener(
                // If back button is used, call back our listener.
                new MyDialogInterfaceOnCancelListener(
                    (dlg) =>
            {
                // Set Listener
                listener?.OnCancel(this);

                // EventHandler
                OnCancel(this);
            })
                ).Create();


            // Kill all padding from the dialog window
            Dialog.SetView(view, 0, 0, 0, 0);

            // Move cursor & target on first draw
            ViewTreeObserver vto = view.ViewTreeObserver;
            var vtoListener      = new MyVtoOnGlobalLayoutListener();

            vtoListener.GlobalLayoutEvent += delegate
            {
                MoveCursor();

                if (supportsAlpha1)
                {
                    MoveAlphaCursor();
                }
                MoveTarget();

                if (supportsAlpha1)
                {
                    UpdateAlphaView();
                }

                //view.ViewTreeObserver.RemoveGlobalOnLayoutListener(vtoListener); // obsolete
                RemoveOnGlobalLayoutCompatListener(view, vtoListener);
            };

            vto.AddOnGlobalLayoutListener(vtoListener);
        }
Ejemplo n.º 20
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.TabbedPage> e)
        {
            base.OnElementChanged(e);

            if (!_isFirstDesign)
            {
                return;
            }

            if (e.OldElement != null)
            {
                listener.GlobalLayout -= listener_GlobalLayout;
                ViewTreeObserver.RemoveOnGlobalLayoutListener(listener);
            }

            if (e.NewElement != null)
            {
                listener.GlobalLayout += listener_GlobalLayout;
                ViewTreeObserver.AddOnGlobalLayoutListener(listener);
            }

            myTabbedPage = (MvvmAspire.Controls.TabbedPage)Element;

            if (_activity == null)
            {
                _activity = this.Context as Activity;

                if (myTabbedPage.TabScreenLocation == TabGravity.Bottom)
                {
                    mMenu = new CustomMenuPopUp(this.Context, this, _activity.LayoutInflater);
                }
                else
                {
                    mMenu = new CustomMenu(this.Context, this, _activity.LayoutInflater);
                }

                mMenu.SetBadgeLocation(myTabbedPage.BadgeLocation);
                mMenu.SetItemsCountInLine(myTabbedPage.ActiveIcons.Count);
                if (myTabbedPage.BackgroundDrawable != null && myTabbedPage.SelectedDrawable != null)
                {
                    mMenu.SetBackgroundDrawable(myTabbedPage.BackgroundDrawable.File, myTabbedPage.SelectedDrawable.File);
                }

                if (myTabbedPage.TabScreenLocation == TabGravity.Bottom)
                {
                    originalPadding = myTabbedPage.Padding.Bottom;
                }
                else
                {
                    originalPadding = myTabbedPage.Padding.Top;
                }
            }

            if (childrenIcons.Count == 0)
            {
                for (int i = 0; i < myTabbedPage.Children.Count; i++)
                {
                    if (myTabbedPage.Children[i].Icon.File != null)
                    {
                        childrenIcons.Add(myTabbedPage.Children[i].Icon.File);
                    }
                }
            }

            myTabbedPage.Appearing    += myTabbedPage_Appearing;
            myTabbedPage.Disappearing += myTabbedPage_Disappearing;
        }
Ejemplo n.º 21
0
 protected override void OnAttachedToWindow()
 {
     base.OnAttachedToWindow();
     ViewTreeObserver.AddOnGlobalLayoutListener(this);
 }