private void seatGrid_MouseDown(object sender, MouseButtonEventArgs e) { object j = e.OriginalSource; if (j is ScrollViewer) { Point p = e.GetPosition(seatGrid); GridRowLocation = (int)p.Y / 48; GridColLocation = (int)p.X / 48; if (rdbSeat.IsChecked == true) { UserCtl.CtlSeat seat = new UserCtl.CtlSeat(); seat.txtSeatNo.TextChanged += new TextChangedEventHandler(txtSeatNo_TextChanged); seat.Seat.PositionX = GridColLocation; seat.Seat.ShortSeatNo = serialNum; seat.Seat.PositionY = GridRowLocation; //RotateTransform rotateTransform2 = new RotateTransform(90); //rotateTransform2.CenterX = 96; //rotateTransform2.CenterY = 96; //seat.RenderTransform = rotateTransform2; //seat.RenderTransformOrigin = new Point(0.5, 0.5); this.seatGrid.Children.Add(seat); Grid.SetColumn(seat, GridColLocation); Grid.SetRow(seat, GridRowLocation); serialNum = SeatNumAdd(serialNum); } else if (rdbNote.IsChecked == true) { UserCtl.CtlNode node = new UserCtl.CtlNode(); node.txtNote.TextChanged += new TextChangedEventHandler(txtNote_TextChanged); node.Note.PositionX = GridColLocation; node.Note.PositionY = GridRowLocation; node.Note.Remark = temptxt; this.seatGrid.Children.Add(node); Grid.SetColumn(node, GridColLocation); Grid.SetRow(node, GridRowLocation); } } e.Handled = true; }
private void button2_Click(object sender, RoutedEventArgs e) { SeatConfig.Code.SeatCanvas seatCanvas = new Code.SeatCanvas(); seatCanvas.RoomNo = textBox3.Text; if (string.IsNullOrEmpty(seatCanvas.RoomNo)) { MessageBox.Show("阅览室编号不能为空"); return; } seatCanvas.SeatCol = textBox2.Text; seatCanvas.SeatRow = textBox1.Text; viewModel.Room.SeatList.Seats.Clear(); viewModel.Room.SeatList.Notes.Clear(); viewModel.Room.SeatList.RoomNo = seatCanvas.RoomNo; foreach (UIElement element in seatGrid.Children) { if (element is SeatConfig.UserCtl.CtlSeat) { UserCtl.CtlSeat seat = element as UserCtl.CtlSeat; seat.Seat.SeatNo = seatCanvas.RoomNo + seat.Seat.ShortSeatNo; seat.Seat.ReadingRoomNum = seatCanvas.RoomNo; viewModel.Room.SeatList.Seats.Add(seat.Seat.SeatNo, seat.Seat); } else if (element is SeatConfig.UserCtl.CtlNode) { UserCtl.CtlNode note = element as UserCtl.CtlNode; viewModel.Room.SeatList.Notes.Add(note.Note); // seatCanvas.notes.Add(note.Note); } } try { viewModel.UpdateSeat(); MessageBox.Show("保存成功"); } catch (Exception ex) { MessageBox.Show("座位保存失败" + ex.Message); } }