示例#1
0
        // Method:      SendEncrypted_Click()
        // Description: This method takes the message from textbox, and send it over on
        //              the established TCP stream encrypted with Bruce Scheneir's algorithm.
        private void SendEncrypted_Click(object sender, EventArgs e)
        {
            // get message from textbox to be sent
            string msg = TypeBox.Text;

            if (msg == "")
            {
                return;
            }

            TypeBox.Clear();
            StreamWriter sw;
            string       key = "#981#-";

            // encrypt it and add the key to let the other server/client know that it is
            // encrypyed
            string encrypted = key + b.Encrypt_CBC(msg);

            try
            {
                // establish writer to write to stream
                if (ServerItIs)
                {
                    sw = new StreamWriter(client.GetStream());
                }
                else
                {
                    sw = new StreamWriter(RunTheClient.GetStream());
                }

                sw.AutoFlush = true;

                // send encrypted message
                sw.WriteLine(encrypted);

                // add to chat history
                ChatHistory.Items.Add("Me: " + msg);
                TypeBox.Focus();
                ScrollToBottom();
            }
            catch (Exception)
            {
                MessageBox.Show("No clients have connected yet... Try again later!", "Error 643");
            }
        }
示例#2
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            ItemsList.RemoveAt(ItemsListBox.SelectedIndex);
            ListBind.DataSource = null;
            ListBind.DataSource = ItemsList;

            NameBox.Clear();
            TypeBox.Clear();
            DescriptionBox.Clear();
            MightBox.Clear();
            DefenceBox.Clear();
            WeightBox.Clear();
            ItemWeightBox.Clear();
            PropertiesBox.Clear();

            foreach (int i in RequirementsCheckedListBox.CheckedIndices)
            {
                RequirementsCheckedListBox.SetItemChecked(i, false);
            }
        }
示例#3
0
        // Method:      SendNormal_Click()
        // Description: This method takes the message from textbox, and send it over on
        //              the established TCP stream (unencrypted).
        private void SendNormal_Click(object sender, EventArgs e)
        {
            // get message from interface and make sure it is not empty
            string msg = TypeBox.Text;

            if (msg == "")
            {
                return;
            }

            // clear typebox after reading message
            TypeBox.Clear();
            StreamWriter sw;

            try
            {
                // start the stream based on whether or not it is server
                if (ServerItIs)
                {
                    sw = new StreamWriter(client.GetStream());
                }
                else
                {
                    sw = new StreamWriter(RunTheClient.GetStream());
                }

                sw.AutoFlush = true;

                // write message to stream
                sw.WriteLine(msg);

                // add the chat history
                ChatHistory.Items.Add("Me: " + msg);
                TypeBox.Focus();
                ScrollToBottom();
            }
            catch (Exception)
            {
                MessageBox.Show("No clients have connected yet... Try again later!", "Error 643");
            }
        }
示例#4
0
 private void Clear_All_Entries()
 {
     NameBox.Clear();
     USNBox.Clear();
     TypeBox.Clear();
     AmountBox.Clear();
     AmountToBox.Clear();
     YearList.SelectedItems.Clear();
     YearToList.SelectedItems.Clear();
     MonthList.Visible    = false;
     MonthToList.Visible  = false;
     DayList.Visible      = false;
     DayToList.Visible    = false;
     HourList.Visible     = false;
     HourToList.Visible   = false;
     MinuteList.Visible   = false;
     MinuteToList.Visible = false;
     AMPMList.Visible     = false;
     AMPMToList.Visible   = false;
     DataView.DataSource  = null;
 }
示例#5
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            string        name, type, description;
            int           weight, might, defence, carryweight;
            List <string> requirements = new List <string>();
            List <string> properties;
            List <Tuple <string, int> > bonus = new List <Tuple <string, int> >();

            if (NameBox.Text == "")
            {
                MessageBox.Show("Puste pole na imię!");
                return;
            }
            else
            {
                name = NameBox.Text;
            }

            if (TypeBox.Text == "")
            {
                MessageBox.Show("Puste pole określające typ przedmiotu!");
                return;
            }
            else
            {
                type = TypeBox.Text;
            }

            if (DescriptionBox.Text == "")
            {
                MessageBox.Show("Puste pole opisu!");
                return;
            }
            else
            {
                description = DescriptionBox.Text;
            }

            int.TryParse(ItemWeightBox.Text, out weight);
            if (weight == 0)
            {
                MessageBox.Show("Błąd w polu określającym wagę przedmiotu!");
                return;
            }

            bool might_result       = int.TryParse(MightBox.Text, out might);
            bool defence_result     = int.TryParse(DefenceBox.Text, out defence);
            bool carryweight_result = int.TryParse(WeightBox.Text, out carryweight);

            if (!might_result || !defence_result || !carryweight_result)
            {
                MessageBox.Show("Błąd w polach określających bonusy!");
                return;
            }
            else
            {
                Tuple <string, int> MightTuple       = new Tuple <string, int>("Might", might);
                Tuple <string, int> DefenceTuple     = new Tuple <string, int>("Defence", defence);
                Tuple <string, int> CarryWeightTuple = new Tuple <string, int>("CarryWeight", carryweight);
                bonus.Add(MightTuple);
                bonus.Add(DefenceTuple);
                bonus.Add(CarryWeightTuple);
            }

            if (RequirementsCheckedListBox.CheckedItems.Count == 0)
            {
                requirements.Add("Any");
            }
            else
            {
                foreach (object item in RequirementsCheckedListBox.CheckedItems)
                {
                    requirements.Add(item.ToString());
                }
            }

            properties = new List <string>(PropertiesBox.Lines);

            Item New_Item = new Item(name, type, description, requirements, bonus, properties, weight);

            ItemsList.Add(New_Item);
            ListBind.DataSource = null;
            ListBind.DataSource = ItemsList;

            NameBox.Clear();
            TypeBox.Clear();
            DescriptionBox.Clear();
            MightBox.Clear();
            DefenceBox.Clear();
            WeightBox.Clear();
            ItemWeightBox.Clear();
            PropertiesBox.Clear();

            foreach (int i in RequirementsCheckedListBox.CheckedIndices)
            {
                RequirementsCheckedListBox.SetItemChecked(i, false);
            }
        }