private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F2)
     {
         // change comment text
         CommentMapping cm = lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedItem as CommentMapping;
         if (cm != null)
         {
             CommentForm cf = new CommentForm();
             cf.SetComment(cm);
             cf.ShowDialog();
         }
         lbMappingsDict[mappingsTabs.SelectedTab.Text].Items[lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedIndex] = cm;
     }
     else if (e.KeyCode == Keys.F3)
     {
         // create new comment
         if (lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedIndex >= 0)
         {
             CreateNewMapping(true, lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedIndex);
         }
         else
         {
             CreateNewMapping(true, lbMappingsDict[mappingsTabs.SelectedTab.Text].Items.Count - 2);
         }
     }
     else if (e.KeyCode == Keys.F4)
     {
         // create new mapping
         if (lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedIndex >= 0)
         {
             CreateNewMapping(false, lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedIndex);
         }
         else
         {
             CreateNewMapping(false, lbMappingsDict[mappingsTabs.SelectedTab.Text].Items.Count - 2);
         }
     }
     else if ((e.KeyCode == Keys.F5) || (e.KeyCode == Keys.Delete))
     {
         if (lbMappingsDict[mappingsTabs.SelectedTab.Text].Items.Count >= 0)
         {
             Program.mappings.mappings[mappingsTabs.SelectedTab.Text].Remove(lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedItem as Mapping);
             lbMappingsDict[mappingsTabs.SelectedTab.Text].Items.Remove(lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedItem);
         }
     }
     else if (e.Control)
     {
         if (e.KeyCode == Keys.Oemplus)
         {
             tbMoveUp_Click(sender, e);
         }
         else if (e.KeyCode == Keys.OemMinus)
         {
             tbMoveDown_Click(sender, e);
         }
     }
 }
Beispiel #2
0
        private void editCommentText()
        {
            CommentMapping cm = lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedItem as CommentMapping;

            if (cm != null)
            {
                CommentForm cf = new CommentForm();
                cf.SetComment(cm);
                cf.ShowDialog();
            }
            lbMappingsDict[mappingsTabs.SelectedTab.Text].Items[lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedIndex] = cm;
        }
        private void CreateNewMapping(bool comment, int location)
        {
            Mapping m = null;

            if (comment)
            {
                CommentMapping cm = new CommentMapping();
                CommentForm    cf = new CommentForm();
                cf.SetComment(cm);
                cf.ShowDialog();
                m = cm;
            }
            else // province map
            {
                m = new ProvinceMapping();
            }
            Program.mappings.mappings[mappingsTabs.SelectedTab.Text].Insert(location, m);
            lbMappingsDict[mappingsTabs.SelectedTab.Text].Items.Insert(location, m);
            lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedItem = m;
        }
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F2)
     {
         // change comment text
         CommentMapping cm = lbMappings.SelectedItem as CommentMapping;
         if (cm != null)
         {
             CommentForm cf = new CommentForm();
             cf.SetComment(cm);
             cf.ShowDialog();
         }
         lbMappings.Items[lbMappings.SelectedIndex] = cm;
     }
     else if (e.KeyCode == Keys.F3)
     {
         // create new comment
         if (lbMappings.SelectedIndex >= 0)
             CreateNewMapping(true, lbMappings.SelectedIndex);
         else
             CreateNewMapping(true, lbMappings.Items.Count - 2);
     }
     else if (e.KeyCode == Keys.F4)
     {
         // create new mapping
         if (lbMappings.SelectedIndex >= 0)
             CreateNewMapping(false, lbMappings.SelectedIndex);
         else
             CreateNewMapping(false, lbMappings.Items.Count - 2);
     }
     else if (e.Control)
     {
         if (e.KeyCode == Keys.Oemplus)
         {
             tbMoveUp_Click(sender, e);
         }
         else if (e.KeyCode == Keys.OemMinus)
         {
             tbMoveDown_Click(sender, e);
         }
     }
 }
 private void CreateNewMapping(bool comment, int location)
 {
     Mapping m = null;
     if (comment)
     {
         CommentMapping cm = new CommentMapping();
         CommentForm cf = new CommentForm();
         cf.SetComment(cm);
         cf.ShowDialog();
         m = cm;
     }
     else // province map
     {
         m = new ProvinceMapping();
     }
     Program.mappings.mappings.Insert(location, m);
     lbMappings.Items.Insert(location, m);
     lbMappings.SelectedItem = m;
 }