コード例 #1
0
        /// <summary>
        /// Updates the display of the crosshair representing the go location
        /// </summary>
        private void UpdateGoLocation()
        {
            if (Tree.SelectedNode.Tag is MapRegion)
            {
                MapRegion region = Tree.SelectedNode.Tag as MapRegion;

                if ((region.GoLocation.X == -1) && (region.GoLocation.Y == -1))
                    return;

                if ((m_CrossHair1 == null) || (m_CrossHair2 == null))
                {
                    // No existing crosshair
                    m_CrossHair1 = new MapCircle(3, new Point(region.GoLocation.X, region.GoLocation.Y), Map.Map, CrossHairColor);
                    m_CrossHair2 = new MapCross(4, CrossHairColor, new Point(region.GoLocation.X, region.GoLocation.Y), Map.Map);

                    Map.AddDrawObject(m_CrossHair1, false);
                    Map.AddDrawObject(m_CrossHair2, true);
                }
                else
                {
                    // There's an existing crosshair, so just update the current information
                    m_CrossHair1.Location = new Point(region.GoLocation.X, region.GoLocation.Y);
                    m_CrossHair2.Location = new Point(region.GoLocation.X, region.GoLocation.Y);

                    Map.Refresh();
                }
            }
            else
            {
                // This isn't a region. Remove cross hair if it exists
                if (m_CrossHair1 != null)
                {
                    Map.RemoveDrawObject(m_CrossHair1);
                    m_CrossHair1 = null;
                }
                if (m_CrossHair2 != null)
                {
                    Map.RemoveDrawObject(m_CrossHair2);
                    m_CrossHair2 = null;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Tree: BEFORE SELECT
        /// </summary>
        private void Tree_BeforeSelect(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
        {
            // Always reset the SetGo flag
            m_SetGo = false;

            // Selection removed
            if (Tree.SelectedNode != null)
            {
                // Revert colors
                Tree.SelectedNode.ForeColor = SystemColors.WindowText;
                Tree.SelectedNode.BackColor = SystemColors.Window;

                // Remove draw objects
                Map.RemoveAllDrawObjects();
                m_CrossHair1 = null;
                m_CrossHair2 = null;
            }
        }