示例#1
0
 /// <summary>
 /// Initializes the link.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="name">The link name.</param>
 /// <param name="onAttached">The callback to handle received attach.</param>
 protected Link(Session session, string name, OnAttached onAttached)
 {
     this.session = session;
     this.name = name;
     this.onAttached = onAttached;
     this.handle = session.AddLink(this);
     this.state = LinkState.Start;
 }
示例#2
0
文件: Link.cs 项目: kav-it/SharpLib
        /// <summary>
        /// Конструктор объекта
        /// </summary>
        /// <param name="typ">Тип канала</param>
        /// <param name="name">Имя канала</param>
        protected LinkBase(ModuleTyp typ, String name)
            : base(typ, name)
        {
            _server = false;
            _state  = LinkState.Closed;

            Opened  = null;
            Closed  = null;
            Error   = null;
            DataReceived = null;
        }
    public void SetLinkStateWith(TileNode node, bool on)
    {
        foreach (LinkState l in linkStates)
        {
            if (l.neighbour == node)
            {
                l.isOn = on;
                return;
            }
        }

        // not found? add
        LinkState ls = new LinkState();
        ls.neighbour = node;
        ls.isOn = on;
        linkStates.Add(ls);
    }
示例#4
0
 void Start()
 {
     linkstate = LinkState.unLinked;
     line      = GetComponent <LineRenderer>();
     destination.SetActive(false);
 }
示例#5
0
 /// <summary>
 /// 登录板卡。分为直连板卡登录和非直连板卡登录
 /// 直连板卡很简单,只要构造报文即可
 /// 非直连还需要通知建链等操作
 /// </summary>
 public virtual void Logon(NetElementConfig netElementAddress)
 {
     State = LinkState.Connecting;
 }
示例#6
0
 public void UpdateInfo(DragInfo drag, LinkState state)
 {
     SetSpite(state);
     UpdateSpriteTransform(drag.GetPosSource(), drag.GetPosDestination());
 }
示例#7
0
        /// <summary>
        /// Closes the link.
        /// </summary>
        /// <param name="error">The error.</param>
        /// <returns></returns>
        protected override bool OnClose(Error error)
        {
            lock (this.ThisLock)
            {
                if (this.state == LinkState.End)
                {
                    return true;
                }
                else if (this.state == LinkState.AttachSent)
                {
                    this.state = LinkState.DetachPipe;
                }
                else if (this.state == LinkState.Attached)
                {
                    this.state = LinkState.DetachSent;
                }
                else if (this.state == LinkState.DetachReceived)
                {
                    this.state = LinkState.End;
                }
                else
                {
                    throw new AmqpException(ErrorCode.IllegalState,
                        Fx.Format(SRAmqp.AmqpIllegalOperationState, "Close", this.state));
                }

                this.SendDetach(error);
                return this.state == LinkState.End;
            }
        }
示例#8
0
        internal virtual void OnAttach(uint remoteHandle, Attach attach)
        {
            lock (this.ThisLock)
            {
                if (this.state == LinkState.AttachSent)
                {
                    this.state = LinkState.Attached;
                }
                else if (this.state == LinkState.DetachPipe)
                {
                    this.state = LinkState.DetachSent;
                }
                else
                {
                    throw new AmqpException(ErrorCode.IllegalState,
                        Fx.Format(SRAmqp.AmqpIllegalOperationState, "OnAttach", this.state));
                }
            }

            if (this.onAttached != null)
            {
                this.onAttached(this, attach);
            }
        }
示例#9
0
 public Links(LinkState state)
 {
     State = state;
 }
示例#10
0
        public GraphicsPath DrawArrow(Graphics graphics, Pen inPen, Brush inBrush, Point point, Point point_2, double Size, bool Selected, LinkState state, bool cycling, int YOffset, bool Hovered)
        {
            GraphicsPath path = null;
            double       hyp  = Math.Sqrt(Math.Pow(point_2.Y - point.Y, 2) + Math.Pow(point.X - point_2.X, 2));

            if (hyp > 0)
            {
                Point Handle1 = new Point((int)((4 * point_2.X + point.X) / 5.0), point.Y);
                Point Handle2 = new Point((int)((4 * point.X + point_2.X) / 5.0), point_2.Y);

                if (cycling)
                {
                    int Y   = point.Y;
                    int Y_2 = point.Y + Math.Abs(point.Y - point_2.Y);

                    if (point.Y > point_2.Y)
                    {
                        Y   = point_2.Y;
                        Y_2 = point_2.Y + Math.Abs(point.Y - point_2.Y);
                    }

                    Y   += (int)(YOffset * Size);
                    Y_2 += (int)(YOffset * Size);

                    Handle1 = new Point((int)(point.X + 100 * Size), Y);
                    Handle2 = new Point((int)(point_2.X - 100 * Size), Y_2);
                }

                if (Hovered)
                {
                    path = new GraphicsPath();
                    path.AddBezier(point, Handle1, Handle2, point_2);
                    graphics.DrawPath(Layout.HoverPen, path);
                }
                else if (Selected)
                {
                    path = new GraphicsPath();
                    path.AddBezier(point, Handle1, Handle2, point_2);
                    graphics.DrawPath(Layout.FatPen, path);
                }

                path = new GraphicsPath();
                path.AddBezier(point, Handle1, Handle2, point_2);
                graphics.DrawPath(inPen, path);

                //if (Hovered == true && path != null)
                //{
                //    Console.WriteLine("je suis dans Draw 1");
                //    Pen pe = new Pen(Color.Blue, 2);
                //    graphics.DrawPath(pe, path);
                //}
                //if (Hovered == false && path != null)
                //{
                //    Console.WriteLine("je suis dans Draw 2");
                //    Pen pe = new Pen(Color.Red, 1);
                //    graphics.DrawPath(pe, path);
                //}

                //condition ? true : false



                //graphics.DrawBezier(inPen, point, Handle1, Handle2, point_2);

                if (Size > 0)
                {
                    int arrowSize = (int)(12 * Size);

                    //Start
                    if (state.StartArrow != LinksArrows.None)
                    {
                        DrawLinkBound(graphics, state.StartArrow, inBrush, point, arrowSize, 1);
                    }

                    //End
                    if (state.EndArrow != LinksArrows.None)
                    {
                        DrawLinkBound(graphics, state.EndArrow, inBrush, point_2, arrowSize, -1);
                    }
                }
            }
            return(path);
        }
示例#11
0
 public GraphicsPath DrawArrow(Graphics graphics, Pen inPen, Brush inBrush, Point point, Point point_2, double Size, bool Selected, LinkState state, bool Hovered)
 {
     return(DrawArrow(graphics, inPen, inBrush, point, point_2, Size, Selected, state, false, 0, Hovered));
 }
示例#12
0
文件: Link.cs 项目: kav-it/SharpLib
        public Boolean Open()
        {
            LastError = new ModuleError(ModuleErrorCode.None);

            TraceInfo(String.Format("Открытие {0}", LinkName));

            if (State == LinkState.Opened)
            {
                TraceWarn(String.Format("Уже открыт {0}", LinkName));

                return true;
            }

            State = LinkState.Opening;

            if (OnOpen())
            {
                State = LinkState.Opened;

                return true;
            }

            State = LinkState.Closed;

            return false;
        }
示例#13
0
文件: Link.cs 项目: kav-it/SharpLib
        public Boolean Close()
        {
            TraceInfo(String.Format("Закрытие {0}", LinkName));

            if (State == LinkState.Closed)
            {
                TraceWarn(String.Format("Уже закрыт {0}", LinkName));

                return true;
            }

            State = LinkState.Closing;

            OnClose();

            State = LinkState.Closed;

            return true;
        }
示例#14
0
文件: Agent.cs 项目: tuita520/Regulus
 public void Launch(LinkState link_state)
 {
     _LinkState = link_state;
     Launch();
 }
示例#15
0
        /// <summary>
        /// Accesses the item at an index.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <returns>The element at the index.</returns>
        /// <exception cref="InvalidOperationException">Thrown if the array has been detached.</exception>
        /// <exception cref="ArgumentException">Thrown if the value being saved cannot be linked.</exception>
        public TEntity this[int index]
        {
            get
            {
                Covenant.Requires <InvalidOperationException>(jArray != null, DetachedError);

                if (context == null)
                {
                    return(null);
                }

                if (list[index].Link == null)
                {
                    return(null);
                }
                else if (list[index].Entity != null)
                {
                    if (list[index].IsDeletedFunc())
                    {
                        list[index] = new LinkState();  // Clears any cached data
                    }
                    else
                    {
                        return(list[index].Entity);
                    }
                }

                // If we get to this point, the list element has a link but no entity.
                // We'll try to load it from the context.

                Func <bool> isDeletedFunc;

                var entity = context.LoadEntity <TEntity>(list[index].Link, out isDeletedFunc);

                if (entity == null)
                {
                    return(null);
                }

                // $note(jeff.lill):
                //
                // We need to disable notification here because logically, we're not
                // modifying the list.  Rather, we're just loading and caching the
                // linked entity.

                notifyDisabled = true;

                try
                {
                    list[index] = new LinkState()
                    {
                        Link          = list[index].Link,
                        Entity        = entity,
                        IsDeletedFunc = isDeletedFunc
                    };
                }
                finally
                {
                    notifyDisabled = false;
                }

                return(entity);
            }

            set
            {
                Covenant.Requires <InvalidOperationException>(jArray != null, DetachedError);

                var link = GetLink(value);

                jArray[index] = link;
                list[index]   = new LinkState()
                {
                    Link = link
                };
            }
        }
示例#16
0
 public ADDirSyncLink(ADObjectId link, LinkState state)
 {
     this.Link  = link;
     this.State = state;
 }
示例#17
0
        internal void Abort(Error error)
        {
            this.OnAbort(error);

            if (this.state != LinkState.End)
            {
                this.state = LinkState.End;
                this.NotifyClosed(error);
            }
        }
示例#18
0

        
示例#19
0
        internal bool OnDetach(Detach detach)
        {
            lock (this.ThisLock)
            {
                if (this.state == LinkState.DetachSent)
                {
                    this.state = LinkState.End;
                }
                else if (this.state == LinkState.Attached)
                {
                    this.SendDetach(null);
                    this.state = LinkState.End;
                }
                else
                {
                    throw new AmqpException(ErrorCode.IllegalState,
                        Fx.Format(SRAmqp.AmqpIllegalOperationState, "OnDetach", this.state));
                }

                this.OnClose(detach.Error);
                this.NotifyClosed(detach.Error);
                return true;
            }
        }
示例#20
0
 private void _IrosState(LinkState state)
 {
     _state = state;
     Logger(String.Format("Mega LinkState became " + state.ToString()));
     _wakeUp.Set();
 }
示例#21
0
        internal void SendAttach(bool role, uint initialDeliveryCount, Attach attach)
        {
            Fx.Assert(this.state == LinkState.Start, "state must be Start");
            this.state = LinkState.AttachSent;
            attach.LinkName = this.name;
            attach.Handle = this.handle;
            attach.Role = role;
            if (!role)
            {
                attach.InitialDeliveryCount = initialDeliveryCount;
            }

            this.session.SendCommand(attach);
        }
示例#22
0
 internal static void AddLinks(List <ADDirSyncLink> result, MultiValuedProperty <ADObjectId> links, LinkState state, ADPropertyDefinition propertyDefinition)
 {
     if (links != null)
     {
         foreach (ADObjectId link in links)
         {
             result.Add(ADDirSyncHelper.CreateSyncLinks(link, state, propertyDefinition));
         }
     }
 }
 public TorrentFileLink()
 {
     this._fsFileInfos = new List<FileSystemFileInfo>();
     this._linkedFsFileIndex = -1;
     this._state = LinkState.None;
 }
 public TorrentFileLink()
 {
     this._fsFileInfos       = new List <FileSystemFileInfo>();
     this._linkedFsFileIndex = -1;
     this._state             = LinkState.None;
 }