Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex < 0)
            {
                return;
            }
            var pair = Commands.ElementAt(listBox1.SelectedIndex);
            var v    = new NewCommand(pair.Key, pair.Value);

            v.ShowDialog();
            if (v.IsOK)
            {
                Commands.Remove(pair.Key);
                Commands.Add(v.Key, v.Value);
                RefreshCommands();
            }
        }
Esempio n. 2
0
        public void Connect(string secret, string IP = "127.0.0.1", int port = 6502)
        {
            // create adapter for Murmur_1.3.0.dll
            serverInstance = new MurmurAdapter.Adapter("1.3.0").Instance;
            serverInstance.Connect(IP, port, secret);

            foreach (var s in serverInstance.GetAllServers())
            {
                if (s.Value.IsRunning())
                {
                    server = s.Value;
                    break;
                }
            }

            if (server != null)
            {
                SerializableDictionary <int, VirtualServerEntity.Channel> channels = server.GetAllChannels();
                for (int i = 0; i < channels.Keys.Count; i++)
                {
                    int cID = channels.ElementAt(i).Key;
                    if (cID > 0) //We cant remove the root channel
                    {
                        server.RemoveChannel(cID);
                        Console.WriteLine("Removed channel: " + cID);
                        //i--;
                    }
                }

                rootChannelID = server.AddChannel(RootChannelName, 0);

                connected = true;
                Console.WriteLine("Found Murmur server!");
            }
            else
            {
                connected = false;
                Console.WriteLine($"No Murmur server running, please start a murmur server on {IP}:{port.ToString()}");
            }
        }
Esempio n. 3
0
        private async void LoadData()
        {
            //SOLVED: go over how inherited base interface can become the generic list
            // so far IEnumerable can hold the different list type, but why
            // enumerable is just a general blanket of lazily getting information, converting that to a more
            // structured type seemed to do the trick
            _sqLiteConnection = await Xamarin.Forms.DependencyService.Get <ISQLite>().GetConnection();

            IEnumerable <IDataTable> tableToEnumerable = new List <IDataTable>();
            List <IDataTable>        listData;

            switch (currentTitle)
            {
            case "Power":
                tableToEnumerable = _sqLiteConnection.Table <Power>().ToList();
                break;

            case "Mastery":
                tableToEnumerable = _sqLiteConnection.Table <Mastery>().ToList();
                break;

            case "User":
                tableToEnumerable = _sqLiteConnection.Table <User>().ToList();
                break;

            case "War":
                tableToEnumerable = _sqLiteConnection.Table <War>().ToList();
                break;

            case "Friends":
                tableToEnumerable = _sqLiteConnection.Table <Friends>().ToList();
                break;

            case "Human":
                tableToEnumerable = _sqLiteConnection.Table <Human>().ToList();
                break;
            }
            listData = tableToEnumerable.ToList();


            int tmp = nQueue[currentTitle];

            int index = listData.Count() - nQueue[currentTitle];

            index = index - 1;


            // if random enabled
            if (randomBool)
            {
                Random random = new Random();
                index = random.Next(0, listData.Count());
            }


            // sets all the current notification information
            title   = listData[index].Title;
            message = listData[index].Description;

            //logic for next notification


            // subtract the queue int of current notification subject to keep track of next index
            nQueue[currentTitle] = nQueue[currentTitle] - 1;

            // check for index overflow
            if (nQueue[currentTitle] < 0)
            {
                nQueue[currentTitle] = listData.Count() - 1;
            }


            //if (nQueue[currentTitle] == 0)
            //{
            //    nQueue[currentTitle] = listData.Count() - 1;
            //}

            // index of next table
            nextElementIndex = currentElementIndex + 1;


            // if next table index overflows that means its time to restart the table index and move up the notification index
            if (nextElementIndex >= nQueue.Count)
            {
                nextElementIndex = 0;
            }

            // nextIndex for example:
            // Power has 48 counts which is the elementMax, nQueue[Power] start with 47
            // elementMax - nQueue[Power]
            // 48 - 47 = 1 which is the index (make sure to subtract by 1)
            // nQueue[Power] = 47 --> nQueue[Power] = 46
            // next iteration
            // 48 - 46 = 2 and so on...
            //
            // Last index occasion, nQueue[Power] = 0
            // 48 - 0 = 48 and we subtract by 1 so the next index is set to -1
            // so restart the nQueue[Power] count once it reach 0
            // nQueue[Power] = maxElement - 1 --> 48 - 1 = 47

            //PeakNextTableElementMax();

            nextNotifTableName = nQueue.ElementAt(nextElementIndex).Key;
            //nextIndex = nextElementMax - nQueue[nextNotifTableName];

            //if (nQueue[nextNotifTableName] == 0)
            //{
            //    nQueue[nextNotifTableName] = nextElementMax - 1;
            //}
        }