Exemplo n.º 1
0
 public override void TouchesMoved(NSSet touches, UIEvent evt)
 {
     OnTouch(touches, (position, id, handle) =>
     {
         UiTask.BeginInvoke(() => TouchPad.Instance.ProcessMove(id, position, DateTime.Now));
     });
 }
Exemplo n.º 2
0
        void IItemsConsumer.Removed(object item)
        {
            lock (_recalcLock)
            {
                _recalculate = true;
            }

            UiView view = null;

            lock (_childrenLock)
            {
                if (_bindingToElement.TryGetValue(item, out view))
                {
                    _bindingToElement.Remove(item);
                }
            }

            if (view != null)
            {
                UiTask.BeginInvoke(() =>
                {
                    view.ViewRemoved();
                    _children.Remove(view);
                });
            }
        }
Exemplo n.º 3
0
        public void OnNew(string template)
        {
            if (!Document.Current.IsModified)
            {
                ChangeTemplate(template);
                Document.Instance.New();
                HideElement("FileMenu");
                return;
            }

            MessageBox.YesNoCancel(SaveChangesQuestion,
                                   () =>
            {
                UiTask.BeginInvoke(() =>
                {
                    if (SaveInternal())
                    {
                        ChangeTemplate(template);
                        Document.Instance.New();
                    }
                });
            },
                                   () =>
            {
                ChangeTemplate(template);
                Document.Instance.New();
            },
                                   () =>
            {
                HideElement("FileMenu");
            });
        }
Exemplo n.º 4
0
        protected override void Draw(ref UiViewDrawParameters parameters)
        {
            float opacity = parameters.Opacity;

            if (opacity == 0)
            {
                return;
            }

            DrawBackground(ref parameters);

            UiViewDrawParameters drawParams = parameters;

            drawParams.Opacity             = opacity;
            drawParams.Transition          = 1 - DisplayVisibility;
            drawParams.TransitionRectangle = ScreenBounds;

            drawParams.TransitionMode = DisplayVisibility == 1 ? TransitionMode.None : (Visible ? TransitionMode.Show : TransitionMode.Hide);

            if (DisplayVisibility == 1 && !_alreadyFullyVisible)
            {
                _alreadyFullyVisible = true;

                UiTask.BeginInvoke(() => CallDelegate("PageShown"));
            }

            for (int idx = 0; idx < _children.Count; ++idx)
            {
                _children[idx].ViewDraw(ref drawParams);
            }
        }
Exemplo n.º 5
0
 void _image_ValueChanged(Texture2D newValue)
 {
     UiTask.BeginInvoke(() =>
     {
         SetForceRecalcFlag();
         Parent.RecalcLayout();
     });
 }
Exemplo n.º 6
0
 static void Window_ClientSizeChanged(object sender, EventArgs e)
 {
     UiTask.BeginInvoke(() =>
     {
         GameController.UpdateScale(AppMain.Current);
         AppMain.Current.SizeChanged();
     });
 }
Exemplo n.º 7
0
 void Window_DidResize(object sender, EventArgs e)
 {
     UiTask.BeginInvoke(() =>
     {
         GameController.UpdateScale(_appMain);
         _appMain.SizeChanged();
     });
 }
Exemplo n.º 8
0
        void _expanded_ValueChanged(bool newValue)
        {
            UiTask.BeginInvoke(() => ForceUpdate());

            if (newValue)
            {
                CallDelegate("ExpandStarted");
            }
        }
Exemplo n.º 9
0
        void IItemsConsumer.RemovedAll()
        {
            lock (_childrenLock)
            {
                _children.Clear();
                _bindingToElement.Clear();
            }

            UiTask.BeginInvoke(() => RecalculateAll());
        }
Exemplo n.º 10
0
 protected void Text_ValueChanged()
 {
     if (Parent != null)
     {
         UiTask.BeginInvoke(() =>
         {
             SetForceRecalcFlag();
             Parent.RecalcLayout();
         });
     }
 }
Exemplo n.º 11
0
 public void DoActionWhenUnfocused(EmptyArgsVoidDelegate action)
 {
     if (!Focused)
     {
         action();
     }
     else
     {
         UiTask.BeginInvoke(() => DoActionWhenUnfocused(action));
     }
 }
Exemplo n.º 12
0
        static void Window_ClientSizeChanged(object sender, EventArgs e)
        {
            UiTask.BeginInvoke(() =>
            {
                double unit = Math.Min((double)AppMain.Current.GraphicsDevice.Viewport.Width / 640.0,
                                       (double)AppMain.Current.GraphicsDevice.Viewport.Height / 480.0);

                unit = Math.Min(1, unit);

                UiUnit.FontUnit = UiUnit.Unit = unit;
            });
        }
Exemplo n.º 13
0
        public void LockListener(int pointerId, object listener)
        {
            UiTask.BeginInvoke(() =>
            {
                _gesture.GestureType = GestureType.CapturedByOther;
                _gesture.TouchId     = pointerId;
                _gesture.ResetState();
                _gesture.CapturePointer(listener);

                OnGesture();
            });
        }
Exemplo n.º 14
0
        void NativeInput.ITextEdit.Return()
        {
            UiTask.BeginInvoke(() =>
            {
                object ret = CallDelegate("Return");

                if (!(ret is bool && (bool)ret))
                {
                    OnApply();
                    Unfocus();
                }
            });
        }
Exemplo n.º 15
0
        void IItemsConsumer.Removed(object item)
        {
            lock (_childrenLock)
            {
                UiView view;
                if (_bindingToElement.TryGetValue(item, out view))
                {
                    _children.Remove(view);
                    _bindingToElement.Remove(item);
                }
            }

            UiTask.BeginInvoke(() => RecalculateAll());
        }
Exemplo n.º 16
0
        void _expanded_ValueChanged(bool newValue)
        {
            UiTask.BeginInvoke(() =>
            {
                ForceUpdate();
                SetForceRecalcFlag();
                Parent.RecalcLayout();
            });

            if (newValue)
            {
                CallDelegate("ExpandStarted");
            }
        }
Exemplo n.º 17
0
        public void SaveAs()
        {
            UiTask.BeginInvoke(() =>
            {
                string path = Platform.SaveFileDialog("Save file", "Map file (*.smf)|*.smf|All files|*.*", ".smf");

                if (path != null)
                {
                    Document.Instance.Save(path);
                }

                HideElement("FileMenu");
            });
        }
Exemplo n.º 18
0
        void IItemsConsumer.RemovedAll()
        {
            lock (_childrenLock)
            {
                foreach (var child in _children)
                {
                    child.ViewRemoved();
                }
                _children.Clear();
                _bindingToElement.Clear();
            }

            UiTask.BeginInvoke(() => RecalculateAll());
        }
Exemplo n.º 19
0
        internal void AppDeactivated()
        {
            UiTask.BeginInvoke(() =>
            {
                foreach (var element in _elements)
                {
                    _gesture.TouchId = element.Key;
                    _gesture.ResetState();

                    OnGesture();
                }

                _elements.Clear();
            });
        }
Exemplo n.º 20
0
        public void Unfocus()
        {
            _textField.Visibility = Android.Views.ViewStates.Invisible;

            _textField.TextChanged  -= HandleEditingChanged;
            _textField.FocusChange  -= HandleFocusChange;
            _textField.EditorAction -= HandleEditorAction;

            UiTask.BeginInvoke(() =>
            {
                if (CurrentFocus == this)
                {
                    HideKeyboard(_textField);
                }
            });
        }
Exemplo n.º 21
0
        void NativeInput.ITextEdit.LostFocus()
        {
            Focused = false;

            if (_lostFocusCancels)
            {
                if (!_applied)
                {
                    Text.Format("{0}", _original);
                    OnCancel();
                }
            }
            else
            {
                OnApply();
            }

            UiTask.BeginInvoke(() => CallDelegate("LostFocus"));
        }
Exemplo n.º 22
0
        public void Open()
        {
            UiTask.BeginInvoke(() =>
            {
                string path = Platform.OpenFileDialog("Open file", "Map file (*.smf)|*.smf|All files|*.*");

                if (path != null)
                {
                    if (!Document.Current.IsModified)
                    {
                        Open(path);
                        HideElement("FileMenu");
                        return;
                    }

                    MessageBox.YesNoCancel(SaveChangesQuestion,
                                           () =>
                    {
                        UiTask.BeginInvoke(() =>
                        {
                            if (SaveInternal())
                            {
                                Open(path);
                            }
                        });
                    },
                                           () =>
                    {
                        Open(path);
                    },
                                           () =>
                    {
                        HideElement("FileMenu");
                    });
                }
                else
                {
                    HideElement("FileMenu");
                }
            });
        }
Exemplo n.º 23
0
        void _visiblityFlag_ValueChanged(bool newValue)
        {
            if (newValue)
            {
                if (_showSpeed == float.MaxValue)
                {
                    DisplayVisibility = 1;

                    if (Parent != null)
                    {
                        UiTask.BeginInvoke(() =>
                        {
                            SetForceRecalcFlag();
                            RecalcLayout();
                            Parent.RecalcLayout();
                        });
                    }
                }
            }
            else
            {
                if (_hideSpeed == float.MaxValue)
                {
                    DisplayVisibility = 0;

                    if (Parent != null)
                    {
                        UiTask.BeginInvoke(() =>
                        {
                            SetForceRecalcFlag();
                            RecalcLayout();
                            Parent.RecalcLayout();
                        });
                    }
                }
            }

            ForceUpdate();
        }
Exemplo n.º 24
0
        void ITextConsumer.OnLostFocus()
        {
            if (Focused)
            {
                UiTask.BeginInvoke(() => CallDelegate("LostFocus"));
            }

            Focused = false;

            if (_lostFocusCancels)
            {
                if (!_applied)
                {
                    Text.Format("{0}", _original);
                    OnCancel();
                }
            }
            else
            {
                OnApply();
            }

            AppMain.Current.ReleaseFocus(_textInput);
        }
Exemplo n.º 25
0
        void OnImageResponse(IAsyncResult state)
        {
            try
            {
                HttpWebRequest request = state.AsyncState as HttpWebRequest;

                WebResponse response = request.EndGetResponse(state);

                if (!response.ContentType.ToLowerInvariant().Contains("image"))
                {
                    UiTask.BeginInvoke(() =>
                    {
                        Image = RemoteImageCache.Instance.NoImage;
                        foreach (var client in _clients)
                        {
                            client.ImageUpdated();
                        }
                    });

                    response.Dispose();
                    return;
                }

                MemoryStream stream = new MemoryStream();

                Stream responseStream = response.GetResponseStream();

                responseStream.CopyTo(stream);
                response.Dispose();

                stream.Seek(0, SeekOrigin.Begin);

                UiTask.BeginInvoke(() =>
                {
                    GraphicsDevice device = AdvancedDrawBatch.OnePixelWhiteTexture.GraphicsDevice;

                    try
                    {
                        Image = Texture2D.FromStream(device, stream);
                    }
                    catch
                    {
                        Image = RemoteImageCache.Instance.NoImage;
                    }

                    foreach (var client in _clients)
                    {
                        client.ImageUpdated();
                    }
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                UiTask.BeginInvoke(() =>
                {
                    Image = RemoteImageCache.Instance.NoImage;
                    foreach (var client in _clients)
                    {
                        client.ImageUpdated();
                    }
                });
            }
        }
Exemplo n.º 26
0
 public bool OnBack()
 {
     UiTask.BeginInvoke(() => ExtendedKeyboardManager.Instance.Remove(this));
     return(true);
 }
Exemplo n.º 27
0
 void IItemsConsumer.Recalculate()
 {
     UiTask.BeginInvoke(() => RecalculateAll());
 }
Exemplo n.º 28
0
 void IItemsConsumer.Added(object item, int index)
 {
     UiTask.BeginInvoke(() => RecalculateAll());
     InsertItem(item, index);
 }