private void lbMappings_SelectedIndexChanged(object sender, EventArgs e)
        {
            srcSelection.Clear();
            destSelection.Clear();

            if (lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedItem == (Object)newMappingItem) // reference test!
            {
                CreateNewMapping(false, lbMappingsDict[mappingsTabs.SelectedTab.Text].Items.Count - 2);
            }
            else if (lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedItem == (Object)newCommentItem) // reference test!
            {
                CreateNewMapping(true, lbMappingsDict[mappingsTabs.SelectedTab.Text].Items.Count - 2);
            }
            else
            {
                ProvinceMapping m = lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedItem as ProvinceMapping;
                if (m != null)
                {
                    srcSelection.AddRange(m.srcProvs);
                    destSelection.AddRange(m.destProvs);
                }
            }

            if (!skipSelPBRedraw)
            {
                createSelPBs(false);
            }
        }
        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;
        }
Beispiel #3
0
        private void pbSource_MouseUp(object sender, MouseEventArgs e)
        {
            Color    c = bmpSrc.GetPixel(srcPt.X, srcPt.Y);
            Province p = null;

            if (srcChroma.TryGetValue(c.ToArgb(), out p))
            {
                ProvinceMapping m = lbMappings.SelectedItem as ProvinceMapping;
                if (p.mapping != null && p.mapping != m)
                {
                    // the province is mapped, but not to the current mapping;
                    // switch to this province's mapping
                    skipSelPBRedraw         = true;
                    lbMappings.SelectedItem = p.mapping;
                    skipSelPBRedraw         = false;
                    createSelPBs(false);
                }
                else
                {
                    // the province is mapped to the current mapping, or is unmapped
                    // alter this mapping for the province
                    if (m != null)
                    {
                        if (m.srcProvs.Contains(p))
                        {
                            m.srcProvs.Remove(p);
                            p.mapping = null;
                        }
                        else
                        {
                            m.srcProvs.Add(p);
                            p.mapping = m;
                        }
                        skipSelPBRedraw = true;
                        lbMappings.Items[lbMappings.SelectedIndex] = m;
                        skipSelPBRedraw = false;
                        createSelPBs(false);
                    }
                }
            }
        }
        private void pbTarget_MouseUp(object sender, MouseEventArgs e)
        {
            Color    c = bmpDest.GetPixel(destPt.X, destPt.Y);
            Province p = null;

            if (destChroma.TryGetValue(c.ToArgb(), out p))
            {
                ProvinceMapping m = lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedItem as ProvinceMapping;
                if ((p.mappings.ContainsKey(mappingsTabs.SelectedTab.Text)) && (p.mappings[mappingsTabs.SelectedTab.Text] != m))
                {
                    // the province is mapped, but not to the current mapping;
                    // switch to this province's mapping
                    skipSelPBRedraw = true;
                    lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedItem = p.mappings[mappingsTabs.SelectedTab.Text];
                    skipSelPBRedraw = false;
                    createSelPBs(false);
                }
                else
                {
                    // the province is mapped to the current mapping, or is unmapped
                    // alter this mapping for the province
                    if (m != null)
                    {
                        if (m.destProvs.Contains(p))
                        {
                            m.destProvs.Remove(p);
                            p.mappings.Remove(mappingsTabs.SelectedTab.Text);
                        }
                        else
                        {
                            m.destProvs.Add(p);
                            p.mappings.Add(mappingsTabs.SelectedTab.Text, m);
                        }
                        skipSelPBRedraw = true;
                        lbMappingsDict[mappingsTabs.SelectedTab.Text].Items[lbMappingsDict[mappingsTabs.SelectedTab.Text].SelectedIndex] = m;
                        skipSelPBRedraw = false;
                        createSelPBs(false);
                    }
                }
            }
        }
 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;
 }