Beispiel #1
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            try
            {
                string t = Clipboard.GetText();
                if (!String.IsNullOrEmpty(t))
                {
                    MemoryStream  m         = new MemoryStream(Encoding.ASCII.GetBytes(t));
                    cLootItemRule lr        = new cLootItemRule();
                    bool          ruleIsNew = true;
                    if (CtrlPressed && CurrentRule != null)
                    {
                        //MessageBox.Show("replacing current rule");
                        lr        = CurrentRule;
                        ruleIsNew = false;
                    }
                    lr.Read(new StreamReader(m), LootRules.UTLFileVersion);

                    if (ruleIsNew)
                    {
                        addRuleToList(lr);
                    }
                    else
                    {
                        lstRules.Items[CurrentRuleNum] = lr.name;
                    }
                    lstRules.Invalidate();
                    lstRequirements.Invalidate();

                    FileChanged = true;
                }
            }
            catch (Exception ex)
            {
            }
        }
        void PasteRuleFromClipboard(bool checkhash)
        {
            try
            {
                string raw_t = Clipboard.GetText();

                //Split it up
                if (string.IsNullOrEmpty(raw_t))
                {
                    MessageBox.Show("Invalid rule format in clipboard."); return;
                }
                string[] split_raw_t = raw_t.Split('#');
                if (split_raw_t.Length < 2)
                {
                    MessageBox.Show("Invalid rule format in clipboard."); return;
                }
                string t_proposed_hash = split_raw_t[0];
                string t = string.Join("#", split_raw_t, 1, split_raw_t.Length - 1);

                //Verify hash
                System.Security.Cryptography.SHA256Managed c = new System.Security.Cryptography.SHA256Managed();
                System.Text.UTF8Encoding e = new UTF8Encoding();
                byte[] rep     = e.GetBytes(t);
                string hashstr = Convert.ToBase64String(c.ComputeHash(rep));
                if (checkhash)
                {
                    if (!string.Equals(hashstr, t_proposed_hash, StringComparison.Ordinal))
                    {
                        MessageBox.Show("Invalid rule format in clipboard."); return;
                    }
                }

                if (!String.IsNullOrEmpty(t))
                {
                    MemoryStream  m         = new MemoryStream(Encoding.ASCII.GetBytes(t));
                    cLootItemRule lr        = new cLootItemRule();
                    bool          ruleIsNew = true;
                    if (CtrlPressed && CurrentRule != null)
                    {
                        ruleIsNew = false;
                    }
                    lr.Read(new StreamReader(m), LootRules.UTLFileVersion);

                    if (ruleIsNew)
                    {
                        AddRuleToList(lr);
                    }
                    else
                    {
                        int oldind = CurrentRuleNum;
                        AddRuleToList(lr, true);
                        DeleteRule(oldind);
                    }
                    lstRules.Invalidate();
                    lstRequirements.Invalidate();

                    FileChanged = true;
                }
            }
            catch { }
        }
Beispiel #3
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            try
            {
                string t = Clipboard.GetText();
                if (!String.IsNullOrEmpty(t))
                {
                    MemoryStream m = new MemoryStream(Encoding.ASCII.GetBytes(t));
                    cLootItemRule lr = new cLootItemRule();
                    bool ruleIsNew = true;
                    if (CtrlPressed && CurrentRule != null)
                    {
                        //MessageBox.Show("replacing current rule");
                        lr = CurrentRule;
                        ruleIsNew = false;
                    }
                    lr.Read(new StreamReader(m), LootRules.UTLFileVersion);

                    if (ruleIsNew)
                    {
                        addRuleToList(lr);
                    }
                    else
                    {
                        lstRules.Items[CurrentRuleNum] = lr.name;
                    }
                    lstRules.Invalidate();
                    lstRequirements.Invalidate();

                    FileChanged = true;
                }
            }
            catch (Exception ex)
            {

            }
        }