Esempio n. 1
0
    private static void CreateButton(Group parent)
    {
        Button btn1 = new Button
        {
            Text         = @"Click to mask me for 3 seconds :)",
            Icon         = Resources.Load <Texture>("Icons/star_big"),
            SkinClass    = typeof(ButtonSkin5),
            Left         = 100,
            Top          = 100,
            Width        = 250,
            Height       = 250,
            FocusEnabled = false
        };

        btn1.Click += new EventHandler(delegate
        {
            int count = 0;

            LoadingMask mask = new LoadingMask(btn1);

            Timer t = new Timer(1, 3)
            {
                TickOnStart = true
            };
            t.Tick += delegate
            {
                mask.SetMessage(string.Format("Masking... {0} seconds", count));
                count++;
            };
            t.Complete += delegate { mask.Unmask(); };
            t.Start();
        });
        parent.AddChild(btn1);
    }
Esempio n. 2
0
        /// <summary>
        /// Shows the global loading mask on it's own viewpoet
        /// </summary>
        /// <param name="message"></param>
        public static void Show(string message)
        {
            if (null != _mask) // destroy the previous mask
            {
                _mask.Unmask();
            }

            //GlobalLoadingMaskStage.Instance.Plugins[0].Initialize(GlobalLoadingMaskStage.Instance); // temp. fix (because CreationComplete not yet executed). Meditate on this!
            //GlobalLoadingMaskStage.Instance.DispatchEvent(new LoadingEvent(LoadingEvent.START, message));

            if (!_runOnce)
            {
                /* There's a glitch of not showing the first time. Investigate why this blobk is needed */
                var inst = GlobalLoadingMaskStage.Instance;
                inst.ValidateNow();
                _runOnce = true;
            }

            _mask = new LoadingMask(GlobalLoadingMaskStage.Instance, message);
        }
Esempio n. 3
0
 /// <summary>
 /// Fires after the message is sent
 /// </summary>
 /// <param name="e"></param>
 private void MessageSentHandler(Event e)
 {
     _mask.Unmask();
     _mask = null;
     _timer.RemoveEventListener(Timer.COMPLETE, MessageSentHandler);
     Alert.Show("Info", "Message sent!", AlertButtonFlag.Ok,
                delegate
     {
         SetFocus();
     });
 }
Esempio n. 4
0
 /// <summary>
 /// Fires after the message is sent
 /// </summary>
 /// <param name="e"></param>
 private void LogInHandler(Event e)
 {
     _mask.Unmask();
     _mask = null;
     _timer.RemoveEventListener(Timer.COMPLETE, LogInHandler);
     DispatchLoginEvent();
     Alert.Show("Info", "You are logged in.", AlertButtonFlag.Ok,
                delegate
     {
         SetFocus();
     });
 }
Esempio n. 5
0
        protected override void CommitProperties()
        {
            base.CommitProperties();

            if (_imageUrlChanged)
            {
                _imageUrlChanged = false;

                _mask = new LoadingMask(ContentGroup, "Loading image...");
                var cursor = CursorManager.Instance.SetCursor(CursorType.Wait);

                var oldBounds = Rectangle.FromWidthAndHeight(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                oldBounds = oldBounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));

                ImageLoader.Load(_imageUrl, delegate(Texture texture)
                {
                    //Debug.Log("texture size: " + texture.width + ", " + texture.height);
                    _image.Texture = texture;
                    _image.Visible = false;

                    // reset explicit size to allow measurement
                    ExplicitWidth  = null;
                    ExplicitHeight = null;

                    ValidateSize(true);

                    var newBounds = Rectangle.FromWidthAndHeight(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                    // center on screen
                    newBounds = newBounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));
                    //Debug.Log("newBounds: " + newBounds);

                    // return to the old size immediatelly, because of the flicker
                    Width  = oldBounds.Width;
                    Height = oldBounds.Height;

                    #region Alternative

                    //SetActualSize(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                    //PopupManager.Instance.CenterPopUp(this);

                    #endregion

                    Defer(delegate
                    {
                        // tween the window size
                        //var newBounds = Bounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));
                        ScaleBoundsTween tween = new ScaleBoundsTween(this, oldBounds, newBounds)
                        {
                            Callback = delegate
                            {
                                _image.Visible = true; // show image
                                //_image.SkipRender(2); // avoid flicker
                                _image.Alpha = 0;

                                // fade in the image
                                FadeIn fadeIn = new FadeIn
                                {
                                    Duration = 1
                                };
                                fadeIn.Play(_image);
                            }
                        };
                        tween.Play();
                    }, 1);

                    //GlobalLoadingMask.Hide();
                    _mask.Unmask();
                    CursorManager.Instance.RemoveCursor(cursor);
                });
            }
        }
Esempio n. 6
0
    private static void CreateButton(Group parent)
    {
        Button btn1 = new Button
        {
            Text = @"Click to mask me for 3 seconds :)",
            Icon = Resources.Load<Texture>("Icons/star_big"),
            SkinClass = typeof (ButtonSkin5),
            Left = 100,
            Top = 100,
            Width = 250,
            Height = 250,
            FocusEnabled = false
        };
        btn1.Click += new EventHandler(delegate
        {
            int count = 0;

            LoadingMask mask = new LoadingMask(btn1);
            
            Timer t = new Timer(1, 3) {TickOnStart = true};
            t.Tick += delegate
            {
                mask.SetMessage(string.Format("Masking... {0} seconds", count));
                count++;
            };
            t.Complete += delegate { mask.Unmask(); };
            t.Start();
        });
        parent.AddChild(btn1);
    }
Esempio n. 7
0
        protected override void CommitProperties()
        {
            base.CommitProperties();

            if (_imageUrlChanged)
            {
                _imageUrlChanged = false;

                _mask = new LoadingMask(ContentGroup, "Loading image...");
                var cursor = CursorManager.Instance.SetCursor(CursorType.Wait);

                var oldBounds = Rectangle.FromWidthAndHeight(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                oldBounds = oldBounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));
                
                ImageLoader.Load(_imageUrl, delegate(Texture texture)
                {
                    //Debug.Log("texture size: " + texture.width + ", " + texture.height);
                    _image.Texture = texture;
                    _image.Visible = false;
                    
                    // reset explicit size to allow measurement
                    ExplicitWidth = null;
                    ExplicitHeight = null;

                    ValidateSize(true);
                    
                    var newBounds = Rectangle.FromWidthAndHeight(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                    // center on screen
                    newBounds = newBounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));
                    //Debug.Log("newBounds: " + newBounds);

                    // return to the old size immediatelly, because of the flicker
                    Width = oldBounds.Width;
                    Height = oldBounds.Height;

                    #region Alternative

                    //SetActualSize(GetExplicitOrMeasuredWidth(), GetExplicitOrMeasuredHeight());
                    //PopupManager.Instance.CenterPopUp(this);

                    #endregion

                    Defer(delegate
                    {
                        // tween the window size
                        //var newBounds = Bounds.CenterInside(Rectangle.FromSize(SystemManager.Instance.ScreenSize));
                        ScaleBoundsTween tween = new ScaleBoundsTween(this, oldBounds, newBounds)
                        {
                            Callback = delegate
                            {
                                _image.Visible = true; // show image
                                //_image.SkipRender(2); // avoid flicker
                                _image.Alpha = 0;

                                // fade in the image
                                FadeIn fadeIn = new FadeIn
                                {
                                    Duration = 1
                                };
                                fadeIn.Play(_image);
                            }
                        };
                        tween.Play();
                    }, 1);

                    //GlobalLoadingMask.Hide();
                    _mask.Unmask();
                    CursorManager.Instance.RemoveCursor(cursor);
                });
            }
        }