public void PlaceActivityControlAt(int column, int row, IActivityControl activityControl, ActivityControlsLink sourceActivityControlsLink){ var control = (Control) activityControl; Controls.Add(control); control.Location = new Point(column*CellWH, row*CellWH); control.Size = new Size(CellWH, CellWH); control.BringToFront(); InitLinkControlBy(control, sourceActivityControlsLink); }
void activityControl_OnClickActivityControl(IActivityControl activityControl) { InvertSelectionFor(activityControl); SelectFirstSelectedIfNoSelection(activityControl); if (ShiftKeyIsPressed && SelectedSomeActivityControls) { SelectActivityControlsInRange(_firstSelectedActivityControl, activityControl); return; } ClearAllSelection(); ReplaceFirstSelectedWith(activityControl); AddRemoveToSelectedList(activityControl); }
private void SelectActivityControlsInRange(IActivityControl firstSelectedActivityControl, IActivityControl currentActivityControl){ Position startPosition = GetPosOf(firstSelectedActivityControl); Position finishPosition = GetPosOf(currentActivityControl); //изменить чтобы упорядочить по углам ClearAllSelection(); for (int column = startPosition.Column; column <= finishPosition.Column; column++){ for (int row = startPosition.Row; row <= finishPosition.Row; row++){ IActivityControl activityControl = ActivityControls[column, row]; if (activityControl == null) continue; activityControl.Selected = true; AddToSelectedList(activityControl); } } }
private void SelectFirstSelectedIfNoSelection(IActivityControl activityControl){ if (_firstSelectedActivityControl == null) _firstSelectedActivityControl = activityControl; }
private Position GetPosOf(IActivityControl activityControl){ for (int column = 0; column < _columnCount; column++){ for (int row = 0; row < _rowCount; row++){ if (ActivityControls[column, row] != activityControl) continue; return new Position(column, row); } } throw new Exception("Position is undefined for control"); }
private void ReplaceFirstSelectedWith(IActivityControl activityControl){ _firstSelectedActivityControl = activityControl; }
private static void ChangeSelectionColorFor(IActivityControl activityControl){ ((Control) activityControl).BackColor = activityControl.Selected ? Color.DarkGray : activityControl.DefaultBGColor; }
private void RemoveFromSelectedList(IActivityControl activityControl){ if (_selectedActivityControls.Contains(activityControl)) _selectedActivityControls.Remove(activityControl); ChangeSelectionColorFor(activityControl); }
public ActivityControlsController(DesignFieldControl designFieldControl){ _designFieldControl = designFieldControl; ActivityControls = new IActivityControl[_columnCount,_rowCount]; _designFieldControl.OnClickInPos += designFieldControl_OnClickInPos; }
public static void InitControlBy(IActivityControl activityControl, Control groupBox, params Control[] controls){ var control = (Control)activityControl; activityControl.DefaultBGColor = control.BackColor; groupBox.Size = new Size(control.Width - CellSpan*2, control.Height - CellSpan*2); groupBox.Location = new Point(CellSpan, CellSpan); control.Click += ChangeSelection; groupBox.Click += ChangeSelectionForParent; foreach (var subControl in controls) subControl.Click += ChangeSelectionForParentofParent; }
private static void InvertSelectionFor(IActivityControl activityControl){ activityControl.Selected = !activityControl.Selected; }
void ActivityControlsController_OnDoubleClickActivityControl(IActivityControl activityControl) { if (OnExpandCompositeActivity != null) OnExpandCompositeActivity(activityControl.Activity); }
public void RegisterActivityControl(IActivityControl activityControl, BaseActivity sourceActivity, ActivityControlsLink sourceActivityControlsLink, int column, int row) { ActivityControls[column, row] = activityControl; activityControl.SourceActivity = sourceActivity; activityControl.OnClickActivityControl += activityControl_OnClickActivityControl; _designFieldControl.PlaceActivityControlAt(column, row, activityControl, sourceActivityControlsLink); activityControl.Init(); }
private bool AddToSelectedList(IActivityControl activityControl){ if (!activityControl.Selected) return false; if (!_selectedActivityControls.Contains(activityControl)) _selectedActivityControls.Add(activityControl); ChangeSelectionColorFor(activityControl); return true; }
public ActivityControlsLink(IActivityControl sourceActivityControl, NeighbourDirections sourceOutputDirection) { _sourceActivityControl = sourceActivityControl; _sourceOutputDirection = sourceOutputDirection; }
private static void ChangeSelectionFor(IActivityControl activityControl){ activityControl.FireOnClickActivityControl(); }
private void AddRemoveToSelectedList(IActivityControl activityControl){ if (AddToSelectedList(activityControl)) return; RemoveFromSelectedList(activityControl); }