private void New_Click(object sender, RoutedEventArgs e) { _dlgNew = new WindownNew(); _dlgNew.ShowDialog(); if (_dlgNew.IsOK != true) { return; } Mouse.OverrideCursor = Cursors.Wait; _LabelWidth.Content = _Width = _dlgNew.MapWidth; _LabelHeight.Content = _Height = _dlgNew.MapHeight; _NameMap.Content = _dlgNew.MapName; _labelXPos.Content = _XPos = _dlgNew.XPos; _LabelYPos.Content = _YPos = _dlgNew.YPos; _Level = _dlgNew.LEVEL; _Life = _dlgNew.TIMES; _WrapPanelMain.Children.Clear(); _WrapPanelMain.Width = 25 * (1 + _Width); _WrapPanelMain.Height = 25 * (1 + _Height); _MapTitle = new MyImage[_Width, _Height]; for (int j = 0; j < _Height; j++) { TextBlock Num = new TextBlock(); Num.Height = 25; Num.Width = 25; Num.Text = (_Height - 1 - j).ToString(); Num.TextAlignment = TextAlignment.Center; _WrapPanelMain.Children.Add(Num); for (int i = 0; i < _Width; i++) { _MapTitle[i, j] = new MyImage(); _MapTitle[i, j].Index = 0; _MapTitle[i, j].MouseLeftButtonDown += EditorMap; _MapTitle[i, j].Margin = new Thickness(0, 0, 0, 0); _MapTitle[i, j].Height = 25; _MapTitle[i, j].Width = 25; _MapTitle[i, j].ToolTip = "[" + i.ToString() + "," + (_Height - 1 - j).ToString() + "]"; _WrapPanelMain.Children.Add(_MapTitle[i, j]); } } for (int i = 0; i < _Width + 1; i++) { TextBlock Num = new TextBlock(); Num.Text = (i - 1).ToString(); if (i == 0) { Num.Text = " "; } Num.Height = 25; Num.Width = 25; Num.TextAlignment = TextAlignment.Center; _WrapPanelMain.Children.Add(Num); } Mouse.OverrideCursor = null; }
private void DeleteEditorMap(object sender, MouseButtonEventArgs e) { MyImage fe1 = (MyImage)e.Source; fe1.Index = 0; }
private void EditorMap(object sender, MouseButtonEventArgs e) { MyImage fe1 = (MyImage)e.Source; fe1.Index = _listBox1.SelectedIndex; }
private void Open_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "Document"; // Default file name dlg.DefaultExt = ".txt"; // Default file extension dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension // Show open file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document string filename = dlg.FileName; string[] s1 = dlg.SafeFileName.Split('.'); _NameMap.Content = s1[0]; TextReader tr = new StreamReader(filename); string s = tr.ReadLine(); string[] st = s.Split(' '); _labelXPos.Content = _XPos = Convert.ToInt32(st[0]); _LabelYPos.Content = _YPos = Convert.ToInt32(st[1]); _LabelWidth.Content = _Width = Convert.ToInt32(st[2]); _LabelHeight.Content = _Height = Convert.ToInt32(st[3]); _LabelLevel.Content = _Level = Convert.ToInt32(st[4]); _LabelTime.Content = _Life = Convert.ToInt32(st[5]); _WrapPanelMain.Children.Clear(); _WrapPanelMain.Width = 25 * (1 + _Width); _WrapPanelMain.Height = 25 * (1 + _Height); _MapTitle = new MyImage[_Width, _Height]; for (int j = 0; j < _Height; j++) { TextBlock Num = new TextBlock(); Num.Height = 25; Num.Width = 25; Num.Text = (_Height - 1 - j).ToString(); Num.TextAlignment = TextAlignment.Center; _WrapPanelMain.Children.Add(Num); string sj = tr.ReadLine(); string[] sj1 = sj.Split(' '); for (int i = 0; i < _Width; i++) { _MapTitle[i, j] = new MyImage(); _MapTitle[i, j].Index = Convert.ToInt32(sj1[i]); _MapTitle[i, j].MouseLeftButtonDown += EditorMap; _MapTitle[i, j].Margin = new Thickness(0, 0, 0, 0); _MapTitle[i, j].Height = 25; _MapTitle[i, j].Width = 25; _MapTitle[i, j].ToolTip = "[" + i.ToString() + "," + (_Height - 1 - j).ToString() + "]"; _WrapPanelMain.Children.Add(_MapTitle[i, j]); } } for (int i = 0; i < _Width + 1; i++) { TextBlock Num = new TextBlock(); Num.Text = (i - 1).ToString(); if (i == 0) { Num.Text = " "; } Num.Height = 25; Num.Width = 25; Num.TextAlignment = TextAlignment.Center; _WrapPanelMain.Children.Add(Num); } tr.Close(); } }