wxr
2023-06-06 592974441a4df95fffd9167c90192da1a390b1c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using System;
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.Views;
using Android.Widget;
using HDL_ON_Android;
 
namespace GateWay.Droid.FengLinVideo.widget
{
    public class TipDiaglog : Dialog, View.IOnClickListener, View.IOnTouchListener
    {
        private Context mContext = null;
 
        private string titleText = "提示";
        private string contentText = "";
        private string confirmText = "确认";
        private bool isClose = false;
 
        private TextView contentView = null;
        private TextView titleView = null;
        private TextView okView = null;
        public object Tag = null;
        private OnConfirmClickListener onConfirmClickListener;
 
        public TipDiaglog(Context context) : base(context, Resource.Style.DialogTheme)
        {
            this.mContext = context;
        }
 
        public void SetAutoClose(bool bol)
        {
            this.isClose = bol;
        }
 
        public void SetTitleText(string _titleText)
        {
            titleText = _titleText;
            if (titleView != null)
            {
                titleView.SetText(titleText, null);                
            }
        }
 
        public void SetContentText(string _contentText)
        {
            contentText = _contentText;
            if (contentView != null)
            {
                contentView.SetText(contentText, null);
            }
        }
 
        public void SetConfirmText(string text)
        {
            confirmText = text;
            if (okView != null)
            {
                okView.SetText(confirmText, null);
            }
        }
 
        public override void Create()
        {
            base.Create();
 
            try
            {
                SetContentView(Resource.Layout.dialog_tip);
 
                contentView = (TextView)FindViewById(Resource.Id.tv_content);
                titleView = (TextView)FindViewById(Resource.Id.tv_title);
                okView = (TextView)FindViewById(Resource.Id.tv_ok);
 
                contentView.SetText(contentText, null);
                titleView.SetText(titleText, null);
                okView.SetText(confirmText, null);
 
                okView.SetOnTouchListener(this);
                okView.SetOnClickListener(this);
            }
            catch (Exception e)
            {
                string error = e.Message;
            }
        }
 
        public override void OnWindowFocusChanged(bool hasFocus)
        {
            base.OnWindowFocusChanged(hasFocus);
 
            try
            {
                Display display = ((Activity)mContext).WindowManager.DefaultDisplay;
                
                WindowManagerLayoutParams p = Window.Attributes;
                Point point = new Point();
                display.GetSize(point);
                p.Width = (int)(point.X * 0.7);                
                Window.SetGravity(GravityFlags.Center);
            }
            catch (Exception e)
            {
                string ss = e.Message;
            }
        }
 
        public void SetConfirmClickListener(OnConfirmClickListener l)
        {
            onConfirmClickListener = l;
        }
 
        public void OnClick(View v)
        {
            if (v.Equals(okView))
            {
                if (onConfirmClickListener != null)
                    onConfirmClickListener.onSureClick(this, v, isClose);
            }
        }
 
        public bool OnTouch(View v, MotionEvent e)
        {
            if (e.Action == MotionEventActions.Down)
            {
                v.SetBackgroundResource(Resource.Drawable.sure_background_sel);
            }
            else if (e.Action == MotionEventActions.Up)
            {
                v.SetBackgroundResource(Resource.Drawable.sure_background_def);
            }
 
            return false;
 
        }
 
        public interface OnConfirmClickListener
        {
            void onSureClick(TipDiaglog dialoog, View v,bool bol);
        }
 
    }
}