public СBasketUserControl(CPriorityDirection priorityDirection, bool notModify) { InitializeComponent(); for (int i = 0; i < priorityDirection.GetCount(); i++) { Add(priorityDirection.GetDirectionWithProfile(i + 1), notModify); } }
public void Add(CDirectionWithProfile directionWithProfile, bool notModify) { _heightDirectoryUserControls = 0; NotModify = notModify; if (PriorityDirection == null) { PriorityDirection = new CPriorityDirection(directionWithProfile); } else { PriorityDirection.AddDirection(directionWithProfile); foreach (CDirectoryUserControl directoryUserControl in _directoryUserControls) { ((Grid)this.Content).Children.Remove(directoryUserControl); } _directoryUserControls.Clear(); } double height = 0; for (int i = 0; i < PriorityDirection.GetCount(); i++) { CDirectionWithProfile localDirectionWithProfile = PriorityDirection.GetDirectionWithProfile(i + 1); CDirectoryUserControl directoryUserControl; if (NotModify) { directoryUserControl = new CDirectoryUserControl(localDirectionWithProfile, -1, EMove.Null, NotModify); } else { if (PriorityDirection.GetCount() == 1) { directoryUserControl = new CDirectoryUserControl(localDirectionWithProfile, i + 1, EMove.Null, NotModify); } else { if (i == 0) { directoryUserControl = new CDirectoryUserControl(localDirectionWithProfile, i + 1, EMove.Down, NotModify); } else if (i == PriorityDirection.GetCount() - 1) { directoryUserControl = new CDirectoryUserControl(localDirectionWithProfile, i + 1, EMove.Up, NotModify); } else { directoryUserControl = new CDirectoryUserControl(localDirectionWithProfile, i + 1, EMove.DownUp, NotModify); } } } directoryUserControl.HorizontalAlignment = HorizontalAlignment.Left; directoryUserControl.VerticalAlignment = VerticalAlignment.Top; directoryUserControl.Margin = new Thickness(0, height, 0, 0); height = height + directoryUserControl.Height; directoryUserControl.ButtonMoveUp += DirectoryUserControlMoveUp; directoryUserControl.ButtonMoveDown += DirectoryUserControlMoveDown; if (Width > 0) { directoryUserControl.SetResizeWidth(Width - scrollBar.Width);; } _directoryUserControls.Add(directoryUserControl); _heightDirectoryUserControls = _heightDirectoryUserControls + directoryUserControl.Height; directoryUserControl.ButtonAdd += AddIntoBasket; ((Grid)this.Content).Children.Add(directoryUserControl); } if (_heightDirectoryUserControls > Height) { scrollBar.Maximum = _heightDirectoryUserControls - Height; } }