예제 #1
0
        protected virtual void OnSendFail()
        {
            if (IsDisposed)
            {
                return;
            }

            UnregisterInstance();

            if (Parent is SuperGump)
            {
                ((SuperGump)Parent).RemoveChild(this);
            }

            if (InstancePoller != null)
            {
                InstancePoller.Dispose();
                InstancePoller = null;
            }

            Linked.ForEachReverse(g => g.OnLinkSendFail(this));

            if (OnActionSend != null)
            {
                OnActionSend(this, false);
            }
        }
예제 #2
0
        protected virtual void OnSend()
        {
            if (IsDisposed)
            {
                return;
            }

            LastAutoRefresh = DateTime.UtcNow;

            RegisterInstance();

            if (Parent is SuperGump)
            {
                ((SuperGump)Parent).AddChild(this);
            }

            if (InstancePoller == null)
            {
                InitPollTimer();
            }
            else
            {
                InstancePoller.Running = EnablePolling;
            }

            Linked.ForEachReverse(g => g.OnLinkSend(this));

            PlaySendSound();

            if (OnActionSend != null)
            {
                OnActionSend(this, true);
            }
        }
예제 #3
0
        protected virtual void OnHidden(bool all)
        {
            if (IsDisposed)
            {
                return;
            }

            Linked.ForEachReverse(g => g.OnLinkHidden(this));

            PlayHideSound();

            if (OnActionHide != null)
            {
                OnActionHide(this, all);
            }
        }
예제 #4
0
        protected virtual void OnSend()
        {
            if (IsDisposed)
            {
                return;
            }

            LastAutoRefresh = DateTime.UtcNow;

            RegisterInstance();

            if (Parent is SuperGump)
            {
                ((SuperGump)Parent).AddChild(this);
            }

            if (InstancePoller == null)
            {
                InitPollTimer();
            }
            else if (!InstancePoller.Running)
            {
                InstancePoller.Running = EnablePolling;
            }

            Linked.ForEachReverse(g => g.OnLinkSend(this));

            PlaySendSound();

            if (OnActionSend != null)
            {
                OnActionSend(this, true);
            }

            if (Modal && User != null && User.Holding != null)
            {
                Timer.DelayCall(TimeSpan.FromSeconds(1.0), User.DropHolding);
            }
        }
예제 #5
0
        protected virtual void OnClosed(bool all)
        {
            if (IsDisposed)
            {
                return;
            }

            UnregisterInstance();

            if (InstancePoller != null)
            {
                InstancePoller.Dispose();
                InstancePoller = null;
            }

            Linked.ForEachReverse(g => g.OnLinkClosed(this));

            PlayCloseSound();

            if (OnActionClose != null)
            {
                OnActionClose(this, all);
            }
        }
예제 #6
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            IsDisposed = true;
            IsOpen     = Hidden = false;

            if (OnActionDispose != null)
            {
                VitaNexCore.TryCatch(OnActionDispose, this);
            }

            VitaNexCore.TryCatch(OnDispose);
            VitaNexCore.TryCatch(UnregisterInstance);

            Linked.ForEachReverse(g => VitaNexCore.TryCatch(Unlink, g));
            Children.ForEachReverse(g => VitaNexCore.TryCatch(RemoveChild, g));
            Entries.ForEachReverse(e => VitaNexCore.TryCatch(DisposeEntry, e));

            if (InstancePoller != null)
            {
                VitaNexCore.TryCatch(InstancePoller.Dispose);
            }

            VitaNexCore.TryCatch(OnDisposed);

            ObjectPool.Free(ref _Linked);
            ObjectPool.Free(ref _Children);

            ObjectPool.Free(ref _Controls);
            ObjectPool.Free(ref _Layout);

            ObjectPool.Free(ref _Buttons);
            ObjectPool.Free(ref _TileButtons);
            ObjectPool.Free(ref _Switches);
            ObjectPool.Free(ref _Radios);
            ObjectPool.Free(ref _TextInputs);
            ObjectPool.Free(ref _LimitedTextInputs);

            ObjectPool.Free(ref _TextTooltips);

            Entries.Free(true);

            NextButtonID    = 1;
            NextSwitchID    = 0;
            NextTextInputID = 0;

            OnActionSend        = null;
            OnActionClose       = null;
            OnActionHide        = null;
            OnActionRefresh     = null;
            OnActionDispose     = null;
            OnActionClick       = null;
            OnActionDoubleClick = null;

            LastButtonClicked     = null;
            LastTileButtonClicked = null;

            ButtonHandler           = null;
            TileButtonHandler       = null;
            SwitchHandler           = null;
            RadioHandler            = null;
            TextInputHandler        = null;
            LimitedTextInputHandler = null;

            Parent = null;
            User   = null;

            InstancePoller = null;

            VitaNexCore.TryCatch(OnAfterDisposed);
        }
예제 #7
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            //Console.WriteLine("SuperGump Disposing: {0} (0x{1:X})", GetType(), Serial);
            //GC.SuppressFinalize(this);

            IsDisposed = true;
            IsOpen     = Hidden = false;

            VitaNexCore.TryCatch(OnDispose);
            VitaNexCore.TryCatch(UnregisterInstance);

            VitaNexCore.TryCatch(
                () =>
            {
                if (Linked != null)
                {
                    Linked.ForEachReverse(Unlink);
                    Linked.Free(true);
                }
            });

            VitaNexCore.TryCatch(
                () =>
            {
                if (Children != null)
                {
                    Children.ForEachReverse(RemoveChild);
                    Children.Free(true);
                }
            });

            VitaNexCore.TryCatch(
                () =>
            {
                if (InstancePoller != null)
                {
                    InstancePoller.Dispose();
                }
            });

            VitaNexCore.TryCatch(
                () =>
            {
                if (Entries != null)
                {
                    Entries.ForEachReverse(
                        e =>
                    {
                        if (e is IDisposable)
                        {
                            VitaNexCore.TryCatch(((IDisposable)e).Dispose);
                        }
                    });
                }
            });

            VitaNexCore.TryCatch(OnDisposed);

            VitaNexCore.TryCatch(
                () =>
            {
                if (Buttons != null)
                {
                    Buttons.Clear();
                }

                if (TileButtons != null)
                {
                    TileButtons.Clear();
                }

                if (Switches != null)
                {
                    Switches.Clear();
                }

                if (Radios != null)
                {
                    Radios.Clear();
                }

                if (TextInputs != null)
                {
                    TextInputs.Clear();
                }

                if (LimitedTextInputs != null)
                {
                    LimitedTextInputs.Clear();
                }

                if (Entries != null)
                {
                    Entries.Free(true);
                }

                if (Layout != null)
                {
                    Layout.Clear();
                }
            });

            NextButtonID    = 1;
            NextSwitchID    = 0;
            NextTextInputID = 0;

            OnActionSend        = null;
            OnActionClose       = null;
            OnActionHide        = null;
            OnActionRefresh     = null;
            OnActionDispose     = null;
            OnActionClick       = null;
            OnActionDoubleClick = null;

            LastButtonClicked = null;

            Buttons       = null;
            ButtonHandler = null;

            TileButtons       = null;
            TileButtonHandler = null;

            Switches      = null;
            SwitchHandler = null;

            Radios       = null;
            RadioHandler = null;

            TextInputs       = null;
            TextInputHandler = null;

            LimitedTextInputs       = null;
            LimitedTextInputHandler = null;

            Layout = null;

            Linked   = null;
            Children = null;

            Parent = null;
            User   = null;

            InstancePoller = null;
        }