Esempio n. 1
0
        void ShowValue()
        {
            textBox.Foreground = _ForeBrush;

            if (DataMode == LynxUpDownDataMode.LongMode)
            {
                textBox.Text = LongValue.ToString();
                return;
            }
            string s = "0";

            if (DataMode == LynxUpDownDataMode.DecimalMode)
            {
                s = DecimalValue.ToString();
            }
            if (DataMode == LynxUpDownDataMode.DoubleMode)
            {
                s = DoubleValue.ToString();
            }
            int f = s.LastIndexOf('.');

            if (f == -1)
            {
                textBox.Text = s;
            }
            else
            {
                int l = f + _floatNum + 1;
                if (l > s.Length)
                {
                    l = s.Length;
                }
                textBox.Text = s.Substring(0, l);
            }
        }
Esempio n. 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            long   LongValue;
            string defaultRtn = "0x00000000";

            if (value != null)
            {
                if (Int64.TryParse(value.ToString(), out LongValue))
                {
                    if (LongValue > -1)
                    {
                        return("0x" + LongValue.ToString(ConstantReadOnly.HexLineInfoStringFormat, CultureInfo.InvariantCulture).ToUpper());
                    }
                    else
                    {
                        return(defaultRtn);
                    }
                }
                else
                {
                    return(defaultRtn);
                }
            }
            else
            {
                return(defaultRtn);
            }
        }
Esempio n. 3
0
 public override string ToString()
 {
     if (StrValue != null)
     {
         return(StrValue);
     }
     if (IntValue != null)
     {
         return(IntValue.ToString());
     }
     if (LongValue != null)
     {
         return(LongValue.ToString());
     }
     if (DoubleValue != null)
     {
         return(DoubleValue.ToString());
     }
     if (DateValue != null)
     {
         return(DateValue.Value.ToShortDateString());
     }
     if (DecimalValue != null)
     {
         return(DecimalValue.Value.ToString(CultureInfo.InvariantCulture));
     }
     if (ArrayValue != null)
     {
         return(string.Join(", ", ArrayValue));
     }
     return(string.Empty);
 }
Esempio n. 4
0
        public SearchResult FindMatch(SearchParameters options)
        {
            int index;

            bool isStartIndex = Index == options.SearchFromWordIndex;

            if ((!isStartIndex || options.SearchFromField <= FieldTypes.Value) && (options.SearchFields & FieldTypes.Value) == FieldTypes.Value)
            {
                index = LongValue.ToString().FindMatch(options, isStartIndex && options.SearchFromField == FieldTypes.Value ? options.SearchFromFieldIndex : 0);

                if (index >= 0)
                {
                    return new SearchResult {
                               Field = FieldTypes.Value, FieldIndex = index
                    }
                }
                ;
            }

            if ((!isStartIndex || options.SearchFromField <= FieldTypes.Chars) && (options.SearchFields & FieldTypes.Chars) == FieldTypes.Chars)
            {
                index = ToString(true).FindMatch(options, isStartIndex && options.SearchFromField == FieldTypes.Chars ? options.SearchFromFieldIndex : 0);

                if (index >= 0)
                {
                    return new SearchResult {
                               Field = FieldTypes.Chars, FieldIndex = index
                    }
                }
                ;
            }

            if ((!isStartIndex || options.SearchFromField <= FieldTypes.Instruction) && (options.SearchFields & FieldTypes.Instruction) == FieldTypes.Instruction)
            {
                var instruction = InstructionSet.Instance.GetInstruction(this[MixInstruction.OpcodeByte], new FieldSpec(this[MixInstruction.FieldSpecByte]));
                if (instruction == null)
                {
                    return(null);
                }

                var instance = instruction.CreateInstance(this);
                if (instance == null)
                {
                    return(null);
                }

                index = new InstructionText(instance).InstanceText.FindMatch(options, isStartIndex && options.SearchFromField == FieldTypes.Instruction ? options.SearchFromFieldIndex : 0);

                if (index >= 0)
                {
                    return new SearchResult {
                               Field = FieldTypes.Instruction, FieldIndex = index
                    }
                }
                ;
            }

            return(null);
        }
Esempio n. 5
0
        public override string ToString()
        {
            try
            {
                Type propType = !IsTie ? AnchorAttributePropertyInfo.PropertyType
                    : TieValueType;

                if (propType.Equals(typeof(int)) || propType.Equals(typeof(long))
                    || propType.Equals(typeof(byte)))
                {
                    return LongValue.ToString();
                }
                else
                    if (propType.Equals(typeof(float)) || propType.Equals(typeof(double)))
                {
                    return DoubleValue.ToString();
                }
                else
                    if (propType.Equals(typeof(decimal)))
                {
                    return DecimalValue.ToString();
                }
                else
                    if (propType.Equals(typeof(string)))
                {
                    return StringValue;
                }
                else
                    if (propType.Equals(typeof(bool)))
                {
                    return BoolValue.ToString();
                }
                else
                    if (propType.Equals(typeof(DateTime)))
                {
                    return TimeValue.ToString();
                }
                else
                    if (propType.Equals(typeof(Guid)))
                {
                    return TimeValue.ToString();
                }
                else
                {
                    return base.ToString();
                }
            }
            catch
            {
                //TODO : write to logger
                return null;
            }
        }
Esempio n. 6
0
        public override string ToString()
        {
            var    type = _typesStrings[(int)Type];
            string value;

            switch (Type)
            {
            case IndexValueType.String:
                value = StringValue;
                break;

            case IndexValueType.StringArray:
                throw new NotSupportedException();

            case IndexValueType.Bool:
                value = BooleanValue ? IndexValue.Yes : IndexValue.No;
                break;

            case IndexValueType.Int:
                value = IntegerValue.ToString(CultureInfo.InvariantCulture);
                break;

            case IndexValueType.IntArray:
                //throw new NotSupportedException();
                //UNDONE: Investigate this modification because it can cause deserialization- or parsing errors.
                value = $"[{string.Join(",", IntegerArrayValue.Select(x => x.ToString()))}]";
                break;

            case IndexValueType.Long:
                value = LongValue.ToString(CultureInfo.InvariantCulture);
                break;

            case IndexValueType.Float:
                value = SingleValue.ToString(CultureInfo.InvariantCulture);
                break;

            case IndexValueType.Double:
                value = DoubleValue.ToString(CultureInfo.InvariantCulture);
                break;

            case IndexValueType.DateTime:
                value = DateTimeValue.ToString("yyyy-MM-dd HH:mm:ss.ffff");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return($"{value}:{type}");
        }
Esempio n. 7
0
        public override string ToString()
        {
            switch (Type)
            {
            case PrimitiveType.IntegerLong:
                return(LongValue.ToString(CultureInfo.InvariantCulture));

            case PrimitiveType.IntegerBig:
                return(BigIntegerValue.ToString(CultureInfo.InvariantCulture));

            case PrimitiveType.Decimal:
                return(DecimalValue.ToString(CultureInfo.InvariantCulture));

            default:
                Debug.Fail($"Cannot handle unknown primitive type {Type}.");
                return(null);
            }
        }
Esempio n. 8
0
        public override string ToString()
        {
            var    type = "SABILFDT"[(int)Type];
            string value;

            switch (Type)
            {
            case IndexValueType.String:
                value = StringValue;
                break;

            case IndexValueType.StringArray:
                throw new NotSupportedException();

            case IndexValueType.Bool:
                value = BooleanValue ? IndexValue.Yes : IndexValue.No;
                break;

            case IndexValueType.Int:
                value = IntegerValue.ToString(CultureInfo.InvariantCulture);
                break;

            case IndexValueType.Long:
                value = LongValue.ToString(CultureInfo.InvariantCulture);
                break;

            case IndexValueType.Float:
                value = SingleValue.ToString(CultureInfo.InvariantCulture);
                break;

            case IndexValueType.Double:
                value = DoubleValue.ToString(CultureInfo.InvariantCulture);
                break;

            case IndexValueType.DateTime:
                value = DateTimeValue.ToString("yyyy-MM-dd HH:mm:ss.ffff");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return($"{value}:{type}");
        }
Esempio n. 9
0
        public override string ToString()
        {
            switch (_type)
            {
            case Type.Int:
                return(IntValue.ToString());

            case Type.Short:
                return(ShortValue.ToString());

            case Type.UInt:
                return(UIntValue.ToString());

            case Type.ULong:
                return(ULongValue.ToString());

            case Type.UShort:
                return(UShortValue.ToString());

            case Type.Long:
            default:
                return(LongValue.ToString());
            }
        }
Esempio n. 10
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            if (DialogBase.Actived())
            {
                DebugConsole.Log("Hide");
                DialogBase.Hide();
            }
            else
            {
                DebugConsole.Log("Show");
                DialogBase.Show("ESC", "Are you sure to exit game?", QuitGame);
            }
        }

        if (m_broadcastMsg != "")
        {
            // 有系统消息,平移吧
            GameObject goBroadcast = GameObject.Find("BroadcastText");
            Vector3    pos         = goBroadcast.transform.localPosition;
            pos.x -= 50 * Time.deltaTime;
            goBroadcast.transform.localPosition = pos;

            // 从600~-600
            if (goBroadcast.transform.localPosition.x < -600)
            {
                m_broadcastMsg = "";
            }
        }
        else
        {
            m_broadcastMsg = Lobby.getInstance().GetBroadcast();
            if (m_broadcastMsg != "")
            {
                GameObject goBroadcast = GameObject.Find("BroadcastText");
                goBroadcast.GetComponent <Text>().text = m_broadcastMsg;
                goBroadcast.transform.localPosition    = new Vector3(600, 0, 0);
            }
        }

        if (m_net == null || !m_net.IsRunning())
        {
            // 主动结束了
            return;
        }

        if (m_net.CheckReconnect())
        {
            CheckLogin();

            DialogReconnect.Hide();
        }

        ProtoPacket packet = new ProtoPacket();

        if (m_net.RecvTryDequeue(ref packet))
        {
            DebugConsole.Log("Reception handle cmdId:" + packet.cmdId);
            switch (packet.cmdId)
            {
            case Constants.Lion_QuickLoginInfo:
            {
                Lobby.getInstance().UserInfo = (LionUserInfo)packet.proto; // 更新LionUser
                m_login = true;
                UpdateUserInfoUI();                                        // 更新大厅主界面中信息
                if (packet.callback != null)
                {
                    packet.callback();
                }
            }
            break;

            case Constants.Lion_GetProfile:
            {
                LionUserInfo usrInfo = (LionUserInfo)packet.proto;        // 更新LionUser
                if (usrInfo.UserId == Lobby.getInstance().UId)
                {
                    Lobby.getInstance().UserInfo = usrInfo;
                }
                Lobby.getInstance().QueryUserInfo = usrInfo;

                if (packet.callback != null)
                {
                    // 通常这里显示个人信息对话框
                    packet.callback();
                }
            }
            break;

            case Constants.Lion_GetTigerStat:
            {
                Lobby.getInstance().TigerStatInfo = (TigerStat)packet.proto;
                if (packet.callback != null)
                {
                    packet.callback();
                }
            }
            break;

            case Constants.Lion_GetFriendRequests:
            case Constants.Lion_GetFriends:
            {
                Lobby.getInstance().FriendIDArray = (LongArray)packet.proto;
                if (packet.callback != null)
                {
                    GetFriendSummary(packet.callback);
                }
                else
                {
                    GetFriendSummary(ShowFriendsDlg);
                }
            }
            break;

            case Constants.Lion_GetFriendSummary:
            {
                Lobby.getInstance().CurrentSummaryList = (FriendSummaryList)packet.proto;
                DebugConsole.Log("Summary count:" + Lobby.getInstance().CurrentSummaryList.Data.Count);
                if (packet.callback != null)
                {
                    packet.callback();
                }
            }
            break;

            case Constants.Lion_IgnoreFriend:
            case Constants.Lion_AcceptFriend:
            case Constants.Lion_AddFriend:
            case Constants.Lion_DeleteFriend:
            {
                Status stat = (Status)packet.proto;
                if (stat.Code == 0)        // successful
                {
                    if (packet.callback != null)
                    {
                        packet.callback();
                    }
                }
                else
                {
                    DebugConsole.Log(stat.Desc);
                }
            }
            break;

            case Constants.Lion_Redirect:
            {
                Lobby.getInstance().RedirectInfo = (RedirectResp)packet.proto;
                // 切换到游戏场景中
                //m_net.Close();
                DebugConsole.Log("Reception enter slot scene");
                Global.NextSceneName = "slot";
                SceneManager.LoadScene("loading");
            }
            break;

            case Constants.Lion_UpdateProfile:
            {
                DebugConsole.Log("Lion_UpdateProfile");
                Status stat = (Status)packet.proto;
                if (stat.Code == 0)        // successful
                {
                    if (packet.callback != null)
                    {
                        packet.callback();
                    }
                }
                else
                {
                    DebugConsole.Log(stat.Desc);
                }
            }
            break;

            case Constants.Lion_NotifyWeeklyLogin:
            {
                // 连续登录奖励
                // NotifyWeeklyLogin 返回的intvalue是0-6,0表示今天登陆了(昨天没登录)
                IntValue iv = (IntValue)packet.proto;
                DialogDailyBonus.Show(iv.Value);

                //ExplodeCoin.Show();
            }
            break;

            case Constants.Lion_TakeLoginBonus:
            {
                LongArray la = (LongArray)packet.proto;
                // la[0] 奖励金币数
                // la[1] 最终总数
                if (la.Data.Count >= 2)
                {
                    Lobby.getInstance().UserInfo.Gold = la.Data[1];
                    // 若有动画,在此添加
                    JumpAndMoveCoins(6, UpdateUserInfoUI);
                }
            }
            break;

            case Constants.Lion_NotifyFreeBonus:
            {
                // 第一次登陆的时候,数据库里面没有数据,所以返回0
                // 后端推送,倒计时剩余时间长度(毫秒),如果小于等于0,直接显示奖励
                // 免费奖励
                LongValue lv       = (LongValue)packet.proto;
                long      curEpoch = (System.DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;
                Lobby.getInstance().FreeBonusEpoch = curEpoch + lv.Value;
                UpdateCountDown();
            }
            break;

            case Constants.Lion_TakeFreeBonus:
            {
                LongArray la = (LongArray)packet.proto;
                if (la.Data.Count >= 2)
                {
                    Lobby.getInstance().UserInfo.Gold = la.Data[1];
                    // 若有动画,在此添加
                    FlyCoin(Constants.Bonus_Free);
                    UpdateUserInfoUI();
                }
            }
            break;

            case Constants.Lion_BuyItem:
            {
                Status stat = (Status)packet.proto;
                // 更新购买相关的:金币 or 背包
                DebugConsole.Log("Buy item return:" + stat.Code.ToString());
                if (stat.Code == 0)        // successful
                {
                    if (packet.callback != null)
                    {
                        packet.callback();
                    }
                }
                else
                {
                    DebugConsole.Log(stat.Desc);
                }
            }
            break;

            case Constants.Lion_Register:
            {
                Status stat = (Status)packet.proto;
                DebugConsole.Log("Register by email return:" + stat.Code.ToString());
                if (stat.Code == 0)        // successful
                {
                    if (packet.callback != null)
                    {
                        packet.callback();
                    }
                }
                else
                {
                    DebugConsole.Log(stat.Desc);
                    DialogBase.Show("Register by email", "Error:" + stat.Desc);
                }
            }
            break;

            case Constants.Lion_ModPass:
            {
                Status stat = (Status)packet.proto;
                DebugConsole.Log("Modify password return:" + stat.Code.ToString());
                if (stat.Code == 0)        // successful
                {
                    if (packet.callback != null)
                    {
                        packet.callback();
                    }
                }
                else
                {
                    DebugConsole.Log(stat.Desc);
                    DialogBase.Show("Modify password", "Error:" + stat.Desc);
                }
            }
            break;

            case Constants.Lion_RefreshGold:
            {
                LongValue lv = (LongValue)packet.proto;
                DebugConsole.Log("Refresh gold:" + lv.ToString());
                Lobby.getInstance().UserInfo.Gold = lv.Value;
                UpdateUserInfoUI();
            }
            break;

            case Constants.Lion_GetShopItems:
            {
                Lobby.getInstance().ShopList = (ShopList)packet.proto;
                DebugConsole.Log("ShopName:" + Lobby.getInstance().ShopList.ShopName);
                if (packet.callback != null)
                {
                    packet.callback();
                }
            }
            break;

            case Constants.Lion_BroadcastSystemMessage:
            {
                Tools.PlayNotification(Constants.Audio.Audio_Notification);
                StringValue sv = (StringValue)packet.proto;
                Lobby.getInstance().AddBroadcast(sv.Value);
            }
            break;

            case Constants.Lion_GetItems:
            {
                //
                Lobby.getInstance().UserItemList = (UserItemList)packet.proto;

                if (packet.callback != null)
                {
                    packet.callback();
                }
                else
                {
                    DialogBag.Show(null);
                }
            }
            break;

            case Constants.Reconnect:
            {
                // 展示重连对话框,直到重连成功
                if (packet.msgId == 1)
                {
                    ProtoNet.WriteLog("Reconnecting...");
                    // 3s后Display中重连
                    m_net.CheckReconnect(3);
                    DialogReconnect.Show();
                }
            }
            break;

            case Constants.Error:
            {
                // 展示错误
                Status stat = (Status)packet.proto;
                string err  = "Error:" + stat.Code.ToString() + "-" + stat.Desc;
                DialogBase.Show("ERROR", err);
            }
            break;

            default:
            {
                DebugConsole.Log("Reception invalid cmdId:" + packet.cmdId);
            }
            break;
            }
        }
    }
Esempio n. 11
0
File: Json.cs Progetto: aata/szotar
 protected override void Write(TextWriter tw, int indentation)
 {
     tw.Write(IsIntegral
         ? LongValue.ToString(CultureInfo.InvariantCulture)
         : DoubleValue.ToString(CultureInfo.InvariantCulture));
 }
Esempio n. 12
0
 public override string ToString()
 {
     return(IsInteger ? LongValue.ToString() : DoubleValue.ToString());
 }