Exemplo n.º 1
0
        public override void Scrolled(UIScrollView scrollView)
        {
            if (ShouldIgnoreScrolling(scrollView))
            {
                return;
            }

            var width   = _finalButtonSize;
            var count   = _buttons.Count;
            var ioffset = scrollView.ContentOffset.X / (float)count;

            if (ioffset > width)
            {
                width = ioffset + 1;
            }

            for (var i = count - 1; i >= 0; i--)
            {
                var b    = _buttons[i];
                var rect = b.Frame;
                b.Frame = new RectangleF(scrollView.Frame.Width + (count - (i + 1)) * ioffset, 0, width, rect.Height);
            }

            if (scrollView.ContentOffset.X == 0)
            {
                IsOpen = false;
                SetButtonsShowing(false);
                RestoreHighlight(scrollView);

                s_scrollViewBeingScrolled = null;
                ClearCloserRecognizer(GetContextCell(scrollView));
                ClosedCallback?.Invoke();
            }
        }
Exemplo n.º 2
0
 internal void SafeAddClosed(ClosedCallback callback)
 {
     this.Closed += callback;
     if (this.IsDetaching)
     {
         callback(this, this.Error);
     }
 }
Exemplo n.º 3
0
        private void CloseExecute()
        {
            if (Closed)
            {
                return;
            }

            Closed = true;
            ClosedCallback?.Invoke(this);
            CloseRequested?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a callback to be called when the object is called.
        /// This method guarantees that the callback is invoked even if
        /// it is registered after the object is closed.
        /// </summary>
        /// <param name="callback">The callback to be invoked.</param>
        public void AddClosedCallback(ClosedCallback callback)
        {
            lock (this)
            {
                if (!this.closedCalled)
                {
                    this.Closed += callback;
                    return;
                }
            }

            callback(this, this.error);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a container host object with multiple address.
 /// </summary>
 /// <param name="addressUriList">The list of listen addresses.</param>
 /// <param name="certificate">The service certificate for TLS.</param>
 /// <param name="userInfo">The credentials required by SASL PLAIN authentication. It is of form "user:password".</param>
 public ContainerHost(IList <Uri> addressUriList, X509Certificate2 certificate, string userInfo)
 {
     this.containerId       = string.Join("-", this.GetType().Name, Guid.NewGuid().ToString("N"));
     this.certificate       = certificate;
     this.linkCollection    = new LinkCollection(this.containerId);
     this.onLinkClosed      = this.OnLinkClosed;
     this.messageProcessors = new Dictionary <string, MessageProcessor>(StringComparer.OrdinalIgnoreCase);
     this.requestProcessors = new Dictionary <string, RequestProcessor>(StringComparer.OrdinalIgnoreCase);
     this.listeners         = new ConnectionListener[addressUriList.Count];
     for (int i = 0; i < addressUriList.Count; i++)
     {
         this.listeners[i] = new ConnectionListener(addressUriList[i], userInfo, this);
         this.listeners[i].AMQP.ContainerId = this.containerId;
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a container host object with multiple address.
 /// </summary>
 /// <param name="addressList">The list of listen addresses.</param>
 /// <remarks>
 /// Transport and protocol settings (TCP, SSL, SASL and AMQP) can be
 /// set on the listeners of the host after it is created.
 /// </remarks>
 public ContainerHost(IList <string> addressList)
 {
     this.containerId       = string.Join("-", this.GetType().Name, Guid.NewGuid().ToString("N"));
     this.customTransports  = new Dictionary <string, TransportProvider>(StringComparer.OrdinalIgnoreCase);
     this.linkCollection    = new LinkCollection(this.containerId);
     this.onLinkClosed      = this.OnLinkClosed;
     this.messageProcessors = new Dictionary <string, MessageProcessor>(StringComparer.OrdinalIgnoreCase);
     this.requestProcessors = new Dictionary <string, RequestProcessor>(StringComparer.OrdinalIgnoreCase);
     this.messageSources    = new Dictionary <string, MessageSource>(StringComparer.OrdinalIgnoreCase);
     this.listeners         = new ConnectionListener[addressList.Count];
     for (int i = 0; i < addressList.Count; i++)
     {
         this.listeners[i] = new ConnectionListener(addressList[i], this);
         this.listeners[i].AMQP.ContainerId = this.containerId;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a container host object with multiple addresses.
 /// <param name="addressList">The list of listen addresses.</param>
 /// </summary>
 public ContainerHost(IList <Address> addressList)
 {
     this.containerId       = Connection.MakeAmqpContainerId();
     this.customTransports  = new Dictionary <string, TransportProvider>(StringComparer.OrdinalIgnoreCase);
     this.linkCollection    = new LinkCollection(this.containerId);
     this.onLinkClosed      = this.OnLinkClosed;
     this.messageProcessors = new Dictionary <string, MessageProcessor>(StringComparer.OrdinalIgnoreCase);
     this.requestProcessors = new Dictionary <string, RequestProcessor>(StringComparer.OrdinalIgnoreCase);
     this.messageSources    = new Dictionary <string, MessageSource>(StringComparer.OrdinalIgnoreCase);
     this.listeners         = new ConnectionListener[addressList.Count];
     for (int i = 0; i < addressList.Count; i++)
     {
         this.listeners[i] = new ConnectionListener(addressList[i], this);
         this.listeners[i].AMQP.ContainerId = this.containerId;
     }
 }
Exemplo n.º 8
0
        internal void NotifyClosed(Error error)
        {
            ManualResetEvent temp = this.endEvent;

            if (temp != null)
            {
                temp.Set();
            }

            ClosedCallback closed = this.Closed;

            if (closed != null)
            {
                closed(this, error);
            }
        }
Exemplo n.º 9
0
        //播放玩家升级后剧情
        public bool PlayLevelUpStory(ClosedCallback callBack)
        {
            bool result = false;

            closedCallback = callBack;

            ScriptLevelUpEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_LEVEL_UP) as ScriptLevelUpEntry;

            result = Singleton <StoryMode> .Instance.StoryExits(entry);

            if (result)
            {
                Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback);
            }

            return(result);
        }
Exemplo n.º 10
0
        //播放完成任务后剧情
        public bool PlayFinishTaskStory(uint taskId, ClosedCallback callBack)
        {
            bool result = false;

            closedCallback = callBack;

            ScriptFinishTaskEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_TASK_FINISHED) as ScriptFinishTaskEntry;

            entry.TaskId = taskId.ToString();
            result       = Singleton <StoryMode> .Instance.StoryExits(entry);

            if (result)
            {
                Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback);
            }

            return(result);
        }
Exemplo n.º 11
0
        //播放出场景剧情
        public bool PlayExitSceneStory(uint mapId, ClosedCallback callBack)
        {
            bool result = false;

            closedCallback = callBack;

            ScriptExitSceneEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_EXIT_SCENE) as ScriptExitSceneEntry;

            entry.SceneId = mapId.ToString();
            result        = Singleton <StoryMode> .Instance.StoryExits(entry);

            if (result)
            {
                Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback);
            }

            return(result);
        }
Exemplo n.º 12
0
        //播放主角走到某区域剧情
        public bool PlayHeroArriveStory(uint mapId, Vector3 pos, ClosedCallback callBack)
        {
            bool result = false;

            closedCallback = callBack;

            ScriptHeroArriveAreaEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_HERO_ARRIVE_AREA) as ScriptHeroArriveAreaEntry;

            entry.SceneId  = mapId.ToString();
            entry.Position = pos;
            result         = Singleton <StoryMode> .Instance.StoryExits(entry);

            if (result)
            {
                Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback);
            }

            return(result);
        }
Exemplo n.º 13
0
        //播放主角HP更改剧情
        public bool PlayHeroHpChangeStory(ClosedCallback callBack)
        {
            bool result = false;

            closedCallback = callBack;

            ScriptHpChangeEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_HP_CHANGE) as ScriptHpChangeEntry;

            entry.RoleType = string.Empty;
            entry.Id       = StoryConst.SELF_ID;
            result         = Singleton <StoryMode> .Instance.StoryExits(entry);

            if (result)
            {
                Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback);
            }

            return(result);
        }
Exemplo n.º 14
0
        //播放怪物HP更改剧情
        public bool PlayMonsterHpChangeStory(string monsterId, ClosedCallback callBack)
        {
            bool result = false;

            closedCallback = callBack;

            ScriptHpChangeEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_HP_CHANGE) as ScriptHpChangeEntry;

            entry.RoleType = StoryConst.MONSTER;
            entry.Id       = monsterId;
            result         = Singleton <StoryMode> .Instance.StoryExits(entry);

            if (result)
            {
                Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback);
            }

            return(result);
        }
Exemplo n.º 15
0
        //播放阶段战斗剧情
        public bool PlayFightStageStory(uint mapId, uint stageId, uint monsterId, ClosedCallback callBack)
        {
            bool result = false;

            closedCallback = callBack;

            ScriptFightStageEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_FIGHT_STAGE) as ScriptFightStageEntry;

            entry.SceneId   = mapId.ToString();
            entry.StageId   = stageId.ToString();
            entry.MonsterId = monsterId.ToString();
            result          = Singleton <StoryMode> .Instance.StoryExits(entry);

            if (result)
            {
                Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback);
            }

            return(result);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Called when the connection was closed.
 /// </summary>
 private void OnClosed(bool remote)
 {
     ClosedCallback?.Invoke(this, remote);
 }
Exemplo n.º 17
0
        public override void Scrolled(UIScrollView scrollView)
        {
            if (ShouldIgnoreScrolling(scrollView))
            {
                return;
            }

            var rightWidth = _finalRightButtonSize;
            var rightCount = _rightButtons.Count;
            var leftWidth  = _finalLeftButtonSize;
            var leftCount  = _leftButtons.Count;

            if (!UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                //TODO : iOS 8.0 이전 버전에서 확인 해야함.
                _container.Frame = new RectangleF(scrollView.Frame.Width, 0, scrollView.ContentOffset.X, scrollView.Frame.Height);
            }
            else
            {
                if (scrollView.ContentOffset.X > 0.0f && rightCount > 0)
                {
                    SetRightButtonsShowing(true);
                    var irightoffset = scrollView.ContentOffset.X / (float)rightCount;

                    if (irightoffset > rightWidth)
                    {
                        rightWidth = irightoffset + 1;
                    }

                    for (var i = rightCount - 1; i >= 0; i--)
                    {
                        var b    = _rightButtons[i];
                        var rect = b.Frame;
                        b.Frame = new RectangleF(scrollView.Frame.Width + (rightCount - (i + 1)) * irightoffset, 0, rightWidth, rect.Height);
                    }
                }

                if (scrollView.ContentOffset.X < 0.0f && leftCount > 0)
                {
                    SetLeftButtonsShowing(true);
                    var ileftoffset = -scrollView.ContentOffset.X / (float)leftCount;

                    if (ileftoffset > leftWidth)
                    {
                        leftWidth = ileftoffset + 1;
                    }

                    //스크롤시 버튼 사이즈 조절 <- 약간의 에니메이션 효과
                    //아래 코드 주석 처리시 버튼 사이즈 변경 없이 스크롤
                    for (var i = 0; i < leftCount; i++)
                    {
                        var b    = _leftButtons[i];
                        var rect = b.Frame;
                        var x    = -(leftCount - (i + 1)) * ileftoffset;
                        b.Frame = new RectangleF(x - leftWidth, 0, leftWidth, rect.Height);
                        //b.Frame = new RectangleF(x, 0, -ileftoffset, rect.Height);
                    }
                }
            }

            if (scrollView.ContentOffset.X == 0)
            {
                //IsOpen = false;
                SetLeftButtonsShowing(false);
                SetRightButtonsShowing(false);
                RestoreHighlight(scrollView);

                s_scrollViewBeingScrolled = null;
                ClearCloserRecognizer(scrollView);
                ClosedCallback?.Invoke();
            }
        }
            // ClosedCallback is a delegate to determine if caller has closed. If so, we bail out of open operation
            public NeighborOpenAsyncResult(PeerNeighbor neighbor, PeerNodeAddress remoteAddress, Binding binding,
                PeerService service, ClosedCallback closedCallback, TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.neighbor = neighbor;

                IAsyncResult result = null;
                try
                {
                    result = neighbor.BeginOpen(remoteAddress, binding, service, closedCallback, timeout,
                        Fx.ThunkCallback(new AsyncCallback(OnOpen)), null);
                    if (result.CompletedSynchronously)
                    {
                        neighbor.EndOpen(result);
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e)) throw;
                    neighbor.TraceEventHelper(TraceEventType.Warning, TraceCode.PeerNeighborOpenFailed, SR.GetString(SR.TraceCodePeerNeighborOpenFailed));
                    throw;
                }

                // Indicate [....] completion to the caller
                if (result.CompletedSynchronously)
                    base.Complete(true);
            }
                public OpenAsyncResult(PeerNeighbor neighbor, PeerNodeAddress remoteAddress, Binding binding,
                    PeerService service, ClosedCallback closedCallback, TimeSpan timeout,
                    AsyncCallback callback, object state)
                    : base(callback, state)
                {
                    Fx.Assert(remoteAddress != null && remoteAddress.IPAddresses.Count > 0, "Non-empty IPAddress collection expected");

                    this.timeoutHelper = new TimeoutHelper(timeout);
                    this.neighbor = neighbor;
                    this.currentIndex = 0;
                    this.completedSynchronously = true;         // initially
                    this.remoteAddress = remoteAddress;
                    this.service = service;
                    this.binding = binding;
                    this.onOpen = Fx.ThunkCallback(new AsyncCallback(OnOpen));
                    this.closed = closedCallback;
                    BeginOpen();
                }
 // Begin opening of a neighbor channel to 'to'. instanceContext is where the remote 
 // endpoint should send messages to (it will be a reference to PeerNeighborManager).
 public IAsyncResult BeginOpen(PeerNodeAddress remoteAddress, Binding binding,
     PeerService service, ClosedCallback closedCallback, TimeSpan timeout,
     AsyncCallback callback, object asyncState)
 {
     this.initiator = true;
     this.listenAddress = remoteAddress;
     OpenAsyncResult result = new OpenAsyncResult(this, remoteAddress, binding, service,
         closedCallback, timeout, callback, state);
     return result;
 }
Exemplo n.º 21
0
 /// <summary>
 /// Called when the connection was closed.
 /// </summary>
 /// <param name="remote">true, if the connection was closed by the remote host; false, if
 ///   the connection was closed locally.</param>
 protected virtual void OnClosed(bool remote)
 {
     ClosedCallback?.Invoke(this, remote);
 }
Exemplo n.º 22
0
 internal static extern WebRTCErrorCode SetClosedCb(IntPtr dataChanndelHandle, ClosedCallback callback, IntPtr userData = default);
Exemplo n.º 23
0
 internal void SafeAddClosed(ClosedCallback callback)
 {
     this.Closed += callback;
     if (this.IsDetaching)
     {
         callback(this, this.Error);
     }
 }