예제 #1
0
 private void New_bt_Click(object sender, RoutedEventArgs e)
 {
     New n = new New();
     n.ShowDialog();
     if (n.iOK)
     {
         try
         {
             int w = Convert.ToInt32(n.Width_tb.Text);
             int h = Convert.ToInt32(n.Height_tb.Text);
             m_TimeMap = Convert.ToInt32(n.Time_tb.Text);
             CreateMap(w, h);
         }
         catch (System.Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
예제 #2
0
        private void Edit_bt_Click(object sender, RoutedEventArgs e)
        {
            New n = new New();
            n.Width_tb.Text = m_WidthMap.ToString();
            n.Height_tb.Text = m_HieghtMap.ToString();
            n.Time_tb.Text = m_TimeMap.ToString();
            n.ShowDialog();
            if (n.iOK)
            {
                try
                {
                    Mouse.OverrideCursor = Cursors.Wait;
                    m_TimeMap = Convert.ToInt32(n.Time_tb.Text);
                    int w = Convert.ToInt32(n.Width_tb.Text);
                    int h = Convert.ToInt32(n.Height_tb.Text);
                    if (w != m_WidthMap || h != m_HieghtMap)
                    {
                        // Copy du lieu map cu vao bo nho tam
                        int[,] mapOld = new int[m_WidthMap, m_HieghtMap];

                        for (int i = 0; i < m_WidthMap; i++)
                        {
                            for (int j = 0; j < m_HieghtMap; j++)
                            {
                                mapOld[i,j] = m_MapTitle[i, j].Index;
                            }
                        }
                        int wOld = m_WidthMap;
                        int hOld = m_HieghtMap;
                        // Tao map moi
                        CreateMap(w, h);
                        int mW = Math.Min(wOld, w);
                        int mH = Math.Min(hOld, h);

                        for (int i = 0; i < mW; i++)
                        {
                            for (int j = 0; j < mH; j++)
                            {
                                m_MapTitle[i, j].Index = mapOld[i, j];
                            }
                        }
                    }

                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    Mouse.OverrideCursor = null;
                }
            }
        }