Example #1
0
		public PopupDialogContainer(PopupArguments popupArguments)
		{
			_popupArguments = popupArguments;
			_popup = popupArguments.Popup;

			_popup.CloseRequest += OnCloseRequest;
		}
Example #2
0
        public PopupDialogContainer(PopupArguments popupArguments)
        {
            _popupArguments = popupArguments;
            _popup = popupArguments.Popup;

            _dialog = new Dialog(Forms.Context);
            _dialog.RequestWindowFeature((int)WindowFeatures.NoTitle);

            _popup.CloseRequest += OnCloseRequest;
        }
Example #3
0
    PopupBase Load(ePopupMode mode)     //加载弹出框
    {
        PopupBase result = null;

        //Debug.LogFormat("Load {0}", mode);
        if (mPopupCache.TryGetValue(mode, out result) == true)         //如果字典中已经有了就直接返回
        {
            return(result);
        }

        string classname = string.Format("Popup{0}", mode.ToString());      //根据不同的mode获取不停的预设体来创建弹出框
        string path      = string.Format("Prefab/Popup/{0}", classname);    //生成路径
        //Debug.LogFormat("{0}", path);
        Object loadPrefab = Resources.Load(path, typeof(GameObject));       //加载预设体

        if (loadPrefab != null)
        {
            //设置预设体的信息
            GameObject obj = (Instantiate(loadPrefab) as GameObject);             //实例化一个弹出框 并把它转换为GameObj类型
            obj.transform.parent        = contents.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.SetActive(false);

            var popup_base = obj.GetComponent <PopupBase>();       //为啥能得到这个控件
            if (mPopupCache.ContainsKey(mode) == false)            //如果没有这个类型的弹出框
            {
                mPopupCache.Add(mode, popup_base);                 //讲预设体和对应的mode名称存入字典当中
            }

            return(popup_base);
        }
        else
        {
            Debug.LogError("Resources.Load() failed. " + path);
        }

        return(result);
    }
Example #4
0
    public PopupBase GetPopup(PopupType type)
    {
        foreach (var po in popupPool)
        {
            if (po.popupType == type)
            {
                return(po);
            }
        }

        foreach (var po in PopupPrefabs)
        {
            if (po.popupType == type)
            {
                PopupBase _popup = (PopupBase)Instantiate(po, PopupCanvas.transform);
                popupPool.Add(_popup);
                return(_popup);
            }
        }

        //   PopupBase popup = Popups[(int) type];
        //  popup.PopupType = type;
        return(null);
    }
Example #5
0
 private void ClearActivePopup()
 {
     activePopup = null;
 }
Example #6
0
 private void SetActivePopup(PopupBase popup)
 {
     activePopup = popup;
 }
Example #7
0
 private void ClosePopup(PopupBase popup)
 {
     popup.gameObject.SetActive(false);
     ClearActivePopup();
     DisableTransparentLayer();
 }
Example #8
0
 private void ShowPopup(PopupBase popup)
 {
     EnableTransparentLayer();
     popup.gameObject.SetActive(true);
     SetActivePopup(popup);
 }
        private async void BtnLogs_ClickedAsync(object sender, EventArgs e)
        {
            if (!await Methods.AppSettings.ValidateStoragePermission())
            {
                return;
            }

            var stkContainer = new StackLayout()
            {
                Style           = (Style)Application.Current.Resources["PopUpCenter"],
                BackgroundColor = Color.Blue
            };

            var btnClear = new CustomButton()
            {
                Text = "Clear logs"
            };


            var horizontalList = new HorizontalList();

            horizontalList.ItemTemplate = new DataTemplate(() =>
            {
                var stk = new StackLayout {
                    Style = (Style)Application.Current.Resources["FormFloatLeft"]
                };
                var lblNr = new Label
                {
                    Style               = (Style)Application.Current.Resources["Log"],
                    HorizontalOptions   = LayoutOptions.Start,
                    MinimumWidthRequest = 30
                };
                lblNr.SetBinding(Label.TextProperty, "Number");

                var lblText = new Label
                {
                    Style = (Style)Application.Current.Resources["Log"]
                };
                lblText.SetBinding(Label.TextProperty, "Content");

                stk.Children.Add(lblNr);
                stk.Children.Add(lblText);
                return(stk);
            });
            stkContainer.Children.Add(btnClear);
            stkContainer.Children.Add(horizontalList);


            var popUpPage = new PopupBase();

            popUpPage.Content          = stkContainer;
            popUpPage.BackgroundColor  = Color.Transparent;
            horizontalList.ItemsSource = Methods.AppSettings.Logger.GetLog().Select((x, i) => new { Number = i + 1, Content = x }).ToList();
            btnClear.Clicked          += new EventHandler((o, s) =>
            {
                Methods.AppSettings.Logger?.Clear();
                horizontalList.ItemsSource = Methods.AppSettings.Logger.GetLog().Select((x, i) => new { Number = i + 1, Content = x }).ToList();
            });
            horizontalList.SelectedItemChanged += new EventHandler(async(s, o) =>
            {
                var pop  = new PopupBase();
                var grid = new Grid
                {
                    BackgroundColor   = Color.White,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    Padding           = 5
                };
                var scroll = new ScrollView()
                {
                    Orientation     = ScrollOrientation.Vertical,
                    VerticalOptions = LayoutOptions.FillAndExpand
                };
                grid.RowDefinitions.Add(new RowDefinition());
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                Label ed = new Label()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.Start,
                    Style             = (Style)Application.Current.Resources["BaseText"],
                };
                scroll.Content = grid;
                grid.Children.Add(ed, 0, 0);
                pop.Content    = scroll;
                pop.Appearing += new EventHandler((ss, oo) => { ed.Text = (horizontalList.SelectedItem as dynamic).Content; });
                pop.Open();
            });
            popUpPage.Open();
        }
Example #10
0
    public void ShowPopup(PopupType type, PopupShowType option = PopupShowType.ReplaceCurrent, Action onYes = null, Action onNo = null)
    {
        PopupBase dialog = GetPopup(type);

        ShowPopup(dialog, option, onYes, onNo);
    }
Example #11
0
 private void OnePopupOpened(PopupBase popup)
 {
     CanvasPanel.gameObject.SetActive(true);
     popup.gameObject.SetActive(true);
 }
Example #12
0
 public void RemovePopup(PopupBase popup)
 {
     popupList.Remove(popup);
     Destroy(popup.gameObject);
 }
Example #13
0
 public PopupInfo(ePopupMode _mode, PopupBase _obj, params object[] _parms)         //构造函数
 {
     mode  = _mode;
     obj   = _obj;
     parms = _parms;
 }
Example #14
0
 public void Add(string popupName, PopupBase popup)
 {
     _popupCache.Add(popupName, popup);
 }
Example #15
0
 public PopupItem(PopupBase p, Action <object> c)
 {
     popupBase = p;
     callback  = c;
 }
Example #16
0
 public void ClosePopup(PopupBase popup)
 {
     GameObject.Destroy(popup.gameObject);
 }