Example #1
0
        public WallCoordinate(string wallPosition)
        {
            // exemplo: :w=7,0 l=2,38 r

            /* string[] posD =
             *          posD[0] = :w=7,0
             *          posD[1] = l=2,38
             *          posD[2] (toChar) = r
             *
             * var widD = posD[0].Substring(3).Split(',');
             * widD = :w=7,0
             *            ele começa a partir do = (primeiro caracterer é o 7, então o valor 0 do array é o 7)
             *             widthX = TextHandling.Parse(widD[0]) = 7
             *             widthY = TextHandling.Parse(widD[1]); = 0
             *
             * var lenD = posD[1].Substring(2).Split(',');
             * lenD = l=2,38
             *             lengthX = TextHandling.Parse(lenD[0]); = 2
             *             lengthY = TextHandling.Parse(lenD[1]); = 38
             *
             * */
            var posD = wallPosition.Split(' ');

            side = posD[2].ToCharArray()[0];

            var widD = posD[0].Substring(3).Split(',');

            widthX = TextHandling.Parse(widD[0]);
            widthY = TextHandling.Parse(widD[1]);

            var lenD = posD[1].Substring(2).Split(',');

            lengthX = TextHandling.Parse(lenD[0]);
            lengthY = TextHandling.Parse(lenD[1]);
        }
Example #2
0
        void WC_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                switch (TextHandling.Parse(e.Result)) // todo again later on
                {
                case 0:
                {
                    ErrorForm ef = new ErrorForm();
                    ef.label2.Text = "Invalid username/password!";
                    ef.Show();
                    break;
                }

                case 1:     // Login successful
                {
                    WebProxy proxy = WebProxy.GetDefaultProxy();
                    proxy.UseDefaultCredentials = true;
                    System.Net.WebClient WC = new System.Net.WebClient();
                    string requestString    = GlobalSettings.Website_URL + "/getuser.php?email=" + TextBox1.Text;
                    WC.Proxy = proxy;
                    ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                    WC.DownloadStringCompleted += new DownloadStringCompletedEventHandler(WC_DownloadStringCompleted2);
                    WC.DownloadStringAsync(new Uri(requestString));
                    break;
                }

                case 3:
                {
                    ErrorForm ef = new ErrorForm();
                    ef.label2.Text = "Database not found.";
                    ef.Show();
                    break;
                }

                case 4:
                {
                    ErrorForm ef = new ErrorForm();
                    ef.label2.Text = "User table not found.";
                    ef.Show();
                    break;
                }
                }
            }

            catch (Exception)
            {
                ErrorForm ef = new ErrorForm();
                ef.label2.Text = "A unknown error occurred!";
                ef.Show();
            }
        }
Example #3
0
        internal static ServerMessage SerializeSongInventory(HybridDictionary songs)
        {
            ServerMessage serverMessage = new ServerMessage(Outgoing.SongsLibraryMessageComposer);

            serverMessage.AppendInt32(songs.Count);
            foreach (UserItem userItem in songs.Values)
            {
                uint songID = (uint)TextHandling.Parse(userItem.ExtraData);
                serverMessage.AppendUInt(userItem.Id);
                serverMessage.AppendUInt(songID);
            }
            return(serverMessage);
        }
        public static ServerMessage SerializeSongInventory(HybridDictionary songs)
        {
            var Message = new ServerMessage(Outgoing.SerializeInvSongs);

            Message.AppendInt32(songs.Count);
            foreach (UserItem userItem in songs.Values)
            {
                var songId = TextHandling.Parse(userItem.ExtraData);
                Message.AppendUInt(userItem.Id);
                Message.AppendInt32(songId);
            }
            return(Message);
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WallCoordinate"/> class.
        /// </summary>
        /// <param name="wallPosition">The wall position.</param>
        public WallCoordinate(string wallPosition)
        {
            var posD = wallPosition.Split(' ');

            side = posD[2] == "l" ? 'l' : 'r';
            var widD = posD[0].Substring(3).Split(',');

            widthX = TextHandling.Parse(widD[0]);
            widthY = TextHandling.Parse(widD[1]);
            var lenD = posD[1].Substring(2).Split(',');

            lengthX = TextHandling.Parse(lenD[0]);
            lengthY = TextHandling.Parse(lenD[1]);
        }
Example #6
0
        internal static ServerMessage SerializeSongInventory(Hashtable songs)
        {
            ServerMessage message = new ServerMessage(333);

            message.AppendInt32(songs.Count);

            foreach (UserItem userItem in songs.Values)
            {
                uint songID = (uint)TextHandling.Parse(userItem.ExtraData);

                message.AppendUInt(userItem.Id);
                message.AppendUInt(songID);
            }

            return(message);
        }
Example #7
0
        public WallCoordinate(string wallPosition)
        {
            string[] posD = wallPosition.Split(' ');
            if (posD[2] == "l")
            {
                side = 'l';
            }
            else
            {
                side = 'r';
            }

            string[] widD = posD[0].Substring(3).Split(',');
            widthX = TextHandling.Parse(widD[0]);
            widthY = TextHandling.Parse(widD[1]);

            string[] lenD = posD[1].Substring(2).Split(',');
            lengthX = TextHandling.Parse(lenD[0]);
            lengthY = TextHandling.Parse(lenD[1]);
        }
Example #8
0
        void WC_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                switch (TextHandling.Parse(e.Result))
                {
                case 0:
                {
                    //continue
                    break;
                }

                case 1:
                {
                    //continue
                    break;
                }

                case 2:
                {
                    //continue
                    break;
                }

                default:
                {
                    ReportForm ef = new ReportForm();
                    ef.label2.Text = e.Result.ToString();
                    ef.Show();
                    break;
                }
                }
            }
            catch (Exception)
            {
                //we assume the server is down.
                Environment.Exit(0);
            }
        }
Example #9
0
 public SongItem(UserItem item)
 {
     this.itemID   = item.Id;
     this.songID   = TextHandling.Parse(item.ExtraData);
     this.baseItem = item.GetBaseItem();
 }
Example #10
0
 public SongItem(UserItem item)
 {
     itemID   = (int)item.Id;
     songID   = TextHandling.Parse(item.ExtraData);
     baseItem = item.mBaseItem;
 }
Example #11
0
 public SongItem(UserItem item)
 {
     this.itemID   = item.Id;
     this.songID   = TextHandling.Parse(item.Data.ToString());
     this.baseItem = item.GetBaseItem();
 }