コード例 #1
0
        private static string GetIconName(ToxUserStatus status, ToxConnectionStatus connStatus, bool hasUnreadMessages)
        {
            string result;

            if (connStatus == ToxConnectionStatus.None)
            {
                result = "tox_dot_offline";
            }
            else
            {
                switch (status)
                {
                case ToxUserStatus.None:
                    result = "tox_dot_online";
                    break;

                case ToxUserStatus.Away:
                    result = "tox_dot_idle";
                    break;

                case ToxUserStatus.Busy:
                    result = "tox_dot_busy";
                    break;

                default:
                    result = "tox_dot_online";     //we don't know about this status, just show 'online'
                    break;
                }
            }

            return(result + (hasUnreadMessages ? "_notification" : string.Empty));
        }
コード例 #2
0
 public ToxDataInfo(ToxId id, string name, string statusMessage, ToxUserStatus status, ToxKey secretKey)
 {
     this.Id            = id;
     this.Name          = name;
     this.StatusMessage = statusMessage;
     this.Status        = status;
     this.SecretKey     = secretKey;
 }
コード例 #3
0
ファイル: FriendViewModel.cs プロジェクト: ShaunHolt/OneTox
 private void SetFriendStatus(ToxUserStatus status)
 {
     if (_toxModel.IsFriendOnline(FriendNumber))
     {
         Status = (ExtendedToxUserStatus)status;
     }
     else
     {
         Status = ExtendedToxUserStatus.Offline;
     }
 }
コード例 #4
0
 private void UpdateComponent()
 {
     this.connectionStatus           = ToxConnectionStatus.None;
     this.userStatus                 = ToxUserStatus.None;
     this.notification               = false;
     this.mouseOverBackColor         = Color.Transparent;
     this.mouseOutBackColor          = this.pictureBox.BackColor;
     this.pictureBox.Layout         += this.OnPictureBoxLayout;
     this.pictureBox.Click          += this.OnPictureBoxClick;
     this.pictureBox.MouseEnter     += this.OnPictureBoxMouseEnter;
     this.pictureBox.MouseLeave     += this.OnPictureBoxMouseLeave;
     this.notificationTimer          = new Timer();
     this.notificationTimer.Enabled  = false;
     this.notificationTimer.Interval = 250;
     this.notificationTimer.Tick    += this.OnNotificationTimerTick;
     this.notificationCounter        = 0;
     this.UpdateControl();
 }
コード例 #5
0
ファイル: Utilities.cs プロジェクト: hexafluoride/Detox
        public static Status ToxStatusToDetoxStatus(ToxUserStatus status, ToxConnectionStatus conn)
        {
            if (conn == ToxConnectionStatus.None)
            {
                return(Status.Offline);
            }

            switch (status)
            {
            case ToxUserStatus.Away:
                return(Status.Away);

            case ToxUserStatus.Busy:
                return(Status.Busy);

            case ToxUserStatus.None:
            default:
                return(Status.Available);
            }
        }
コード例 #6
0
        private static int GetStatusPriority(bool isOnline, ToxUserStatus status)
        {
            if (!isOnline)
            {
                return(4);
            }

            switch (status)
            {
            case ToxUserStatus.None:
                return(0);

            case ToxUserStatus.Away:
                return(1);

            case ToxUserStatus.Busy:
                return(2);

            default:
                return(3);
            }
        }
コード例 #7
0
        private static string GetColor(ToxUserStatus status, ToxConnectionStatus connStatus)
        {
            if (connStatus == ToxConnectionStatus.None)
            {
                return("ToxDotOfflineBrush");
            }

            switch (status)
            {
            case ToxUserStatus.None:
                return("ToxDotOnlineBrush");

            case ToxUserStatus.Away:
                return("ToxDotIdleBrush");

            case ToxUserStatus.Busy:
                return("ToxDotBusyBrush");

            default:
                return("ToxDotOnlineBrush");
            }
        }
コード例 #8
0
ファイル: MainWindow.xaml.cs プロジェクト: kstaruch/Toxy
 private void tox_OnUserStatus(int friendnumber, ToxUserStatus status)
 {
     var friend = this.ViewModel.GetFriendObjectByNumber(friendnumber);
     if (friend != null)
     {
         friend.ToxStatus = status;
     }
 }
コード例 #9
0
 public StatusEventArgs(int friendNumber, ToxUserStatus status)
     : base(friendNumber)
 {
     Status = status;
 }
コード例 #10
0
 private void SetFriendStatus(ToxUserStatus status)
 {
     if (ToxModel.Instance.IsFriendOnline(FriendNumber))
     {
         Status = (ExtendedToxUserStatus) status;
     }
     else
     {
         Status = ExtendedToxUserStatus.Offline;
     }
 }
コード例 #11
0
ファイル: ToxEventArgs.cs プロジェクト: WELL-E/SharpTox
 public StatusEventArgs(int friendNumber, ToxUserStatus status)
     : base(friendNumber)
 {
     Status = status;
 }
コード例 #12
0
        internal static ToxDataInfo FromToxData(ToxData data)
        {
            try
            {
                ToxId         id            = null;
                string        name          = null;
                string        statusMessage = null;
                ToxUserStatus status        = ToxUserStatus.None;
                byte[]        secretKey     = null;

                using (var stream = new MemoryStream(data.Bytes))
                    using (var reader = new BinaryReader(stream))
                    {
                        stream.Position += sizeof(uint);

                        uint cookie = reader.ReadUInt32();
                        if (cookie != ToxConstants.Cookie)
                        {
                            throw new Exception("Invalid cookie, this doesn't look like a tox profile");
                        }

                        uint length = reader.ReadUInt32();
                        long left   = reader.BaseStream.Length - reader.BaseStream.Position;

                        while (left >= length)
                        {
                            var type = ReadStateType(reader);

                            if (type == StateType.EOF)
                            {
                                break;
                            }

                            switch (type)
                            {
                            case StateType.NospamKeys:
                                int    nospam    = reader.ReadInt32();
                                byte[] publicKey = reader.ReadBytes(ToxConstants.PublicKeySize);

                                secretKey = reader.ReadBytes(ToxConstants.SecretKeySize);
                                id        = new ToxId(publicKey, nospam);
                                break;

                            case StateType.Name:
                                name = Encoding.UTF8.GetString(reader.ReadBytes((int)length), 0, (int)length);
                                break;

                            case StateType.StatusMessage:
                                statusMessage = Encoding.UTF8.GetString(reader.ReadBytes((int)length), 0, (int)length);
                                break;

                            case StateType.Status:
                                status = (ToxUserStatus)reader.ReadByte();
                                break;

                            default:
                            case StateType.Dht:
                            case StateType.Friends:
                            case StateType.TcpRelay:
                            case StateType.PathNode:
                                stream.Position += length; //skip this
                                break;

                            case StateType.Corrupt:
                                throw new Exception("This Tox save file is corrupt");
                            }

                            left = reader.BaseStream.Length - reader.BaseStream.Position;
                            if (left < sizeof(uint))
                            {
                                break;
                            }
                            else
                            {
                                length = reader.ReadUInt32();
                            }
                        }
                    }

                return(new ToxDataInfo()
                {
                    Id = id,
                    Name = name,
                    StatusMessage = statusMessage,
                    Status = status,
                    SecretKey = new ToxKey(ToxKeyType.Secret, secretKey)
                });
            }
            catch { return(null); }
        }
コード例 #13
0
ファイル: ToxFunctions.cs プロジェクト: Tornjk/SharpTox
 public static extern void SetStatus(ToxHandle tox, ToxUserStatus status);
コード例 #14
0
ファイル: ToxFunctions.cs プロジェクト: tf2017/toxofone
 internal static extern void SelfSetStatus(ToxHandle tox, ToxUserStatus status);
コード例 #15
0
ファイル: MainWindow.xaml.cs プロジェクト: kstaruch/Toxy
        private void SetStatus(ToxUserStatus? newStatus)
        {
            if (newStatus == null)
                newStatus = tox.GetSelfUserStatus();
            else
                tox.SetUserStatus(newStatus.GetValueOrDefault());

            this.ViewModel.MainToxyUser.ToxStatus = newStatus.GetValueOrDefault();
        }
コード例 #16
0
ファイル: ToxEventArgs.cs プロジェクト: kelumKP/SharpTox
 public UserStatusEventArgs(int friendNumber, ToxUserStatus userStatus)
     : base(friendNumber)
 {
     UserStatus = userStatus;
 }
コード例 #17
0
ファイル: ToxFunctions.cs プロジェクト: WELL-E/SharpTox
 internal static extern void SelfSetStatus(ToxHandle tox, ToxUserStatus status);
コード例 #18
0
ファイル: Tox.cs プロジェクト: catterpiler/SharpTox
        /// <summary>
        /// Sets the user status of this tox instance.
        /// </summary>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool SetUserStatus(ToxUserStatus status)
        {
            if (disposed)
                throw new ObjectDisposedException(GetType().FullName);

            return ToxFunctions.SetUserStatus(tox, (byte)status) == 0;
        }