/// <summary> /// Отсюда обрабатываются нажатия на кнопки с типами /// </summary> private void B_Lake_Click(object sender, EventArgs e) { _typeItem = new Lake(); _typeItemInner = _typeItem.GetCopy(); _typeItemOuter = _typeItem.GetCopy(); ChangeBackColors((Button)sender, Tool_hydrography, Tool_area); }
private void B_ImpossibleRiver_Click(object sender, EventArgs e) { _typeItem = new ImpassableRiver(); _typeItemInner = _typeItem.GetCopy(); _typeItemOuter = _typeItem.GetCopy(); ChangeBackColors((Button)sender, Tool_hydrography, Tool_line); }
private void pictureBox1_MouseClick(object sender, MouseEventArgs e) { if (pictureBox1.Image != null) //если есть картинка { if (Btn_create_P && _typeItem != null) //если была нажата кнопка создания координат привязки { if (e.Button == MouseButtons.Right && _tempItems.Count != 0) { if (_typeItem.Sequence is Items.Line) { if (_typeItem.IsImpossible) { FragmentSequence(_tempItemsInner, _typeItemInner, _tempItems.Last().CurrentPoint); FragmentSequence(_tempItemsOuter, _typeItemOuter, _tempItems.Last().CurrentPoint); _tempItems[_tempItems.Count - 1] = new Item(_allItems, this, _tempItems.Last().CurrentPoint, _typeItem, _typeItem); _tempItemsInner.Add(_tempItems.Last()); _tempItemsOuter.Add(_tempItems.Last()); _typeItemInner.Sequence.SetItems(_tempItemsInner); _typeItemOuter.Sequence.SetItems(_tempItemsOuter); _allItems.Add(_tempItems.Last()); } _allLines.Add(_typeItem.Sequence as Items.Line); } else if (_typeItem.Sequence is Items.Area) { if (_typeItem.IsImpossible) { _tempItems.Add(_tempItems.First()); _typeItem.Sequence.SetItems(_tempItems); ReplaceItem(); _tempItems.Add(_tempItems[1]); _typeItem.Sequence.SetItems(_tempItems); ReplaceItem(); FragmentSequence(_tempItemsInner, _typeItemInner, _tempItemsInner.First().CurrentPoint); FragmentSequence(_tempItemsOuter, _typeItemOuter, _tempItemsOuter.First().CurrentPoint); _tempItemsInner.Last().Next = _tempItemsInner.First(); _tempItemsInner.First().Previous = _tempItemsInner.Last(); _tempItemsOuter.Last().Next = _tempItemsOuter.First(); _tempItemsOuter.First().Previous = _tempItemsOuter.Last(); _typeItemInner.Sequence.SetItems(_tempItemsInner); _typeItemOuter.Sequence.SetItems(_tempItemsOuter); _allAreas.Add(_typeItemInner.Sequence as Area); _allAreas.Add(_typeItemOuter.Sequence as Area); } else { FragmentSequence(_tempItems, _typeItem, _tempItems.First().CurrentPoint); _tempItems.Last().Next = _tempItems.First(); _tempItems.First().Previous = _tempItems.Last(); _typeItem.Sequence.SetItems(_tempItems); _allAreas.Add(_typeItem.Sequence as Items.Area); } } _tempItems.Clear(); _tempItemsInner.Clear(); _tempItemsOuter.Clear(); _typeItem = _typeItem.GetCopy(); _typeItemInner = _typeItem.GetCopy(); _typeItemInner = _typeItem.GetCopy(); //DrawConnections(_tempItems, new Pen(Brushes.Purple, 1)); } else if (e.Button == MouseButtons.Left) { Point localPoint = new Point(e.Location.X * 100 / Scale_img, e.Location.Y * 100 / Scale_img); //_item = new Item(_allItems, this, localPoint, _typeItem); //_allItems.Add(_item); if (_typeItem.Sequence is Items.Single) { //_item = new Item(localPoint, this, _typeItem); //_tempItems.Add(_item); //_typeItem.Sequence.SetItems(_tempItems); _item = new Item(_allItems, this, localPoint, _typeItem); _tempItems.Add(_item); _typeItem.Sequence.SetItems(_tempItems); _allSingles.Add(_typeItem.Sequence as Items.Single); _allItems.Add(_item); //DrawConnections(_tempItems, new Pen(Brushes.Purple, 1)); _tempItems.Clear(); _typeItem = _typeItem.GetCopy(); } else { if (_tempItems.Count != 0) { if (_typeItem.IsImpossible) { //_item = new Item(_allItems, this, localPoint, _typeItem, _typeItem); _item = new Item(localPoint, this, _typeItem); _tempItems.Add(_item); _typeItem.Sequence.SetItems(_tempItems); if (_tempItems.Count >= 3) { ReplaceItem(); } } else { _item = new Item(_allItems, this, localPoint, _typeItem); // Добавляем промежуточные точки FragmentSequence(_tempItems, _typeItem, _item.CurrentPoint); _allItems.Add(_item); _item.Previous = _tempItems.Last(); _tempItems.Last().Next = _item; _tempItems.Add(_item); _typeItem.Sequence.SetItems(_tempItems); } } else { _item = new Item(_allItems, this, localPoint, _typeItem); _tempItems.Add(_item); _typeItem.Sequence.SetItems(_tempItems); if (_typeItem.IsImpossible) { if (_typeItem.Sequence is Line) { _allItems.Add(_item); _tempItemsInner.Add(_item); _tempItemsOuter.Add(_item); _typeItemInner.Sequence.SetItems(_tempItemsInner); _typeItemOuter.Sequence.SetItems(_tempItemsOuter); } } else { _allItems.Add(_item); } } //DrawConnections(_tempItems, new Pen(Brushes.Purple, 1)); } label_Way.Text = _item.CurrentPoint + "|id = " + _item.ID; } } } }