//private bool _tryGetNewPath(int[] path, NAV_DIRECTION dir, int depth) //{ // int index = path.Count() - 1 - depth; // int currentDepthIndex = path[index]; // path[index] += (dir == NAV_DIRECTION.UP) ? -1 : 1; // if (_validatePath(path)) // { // return true; // } // else // { // return _tryGetNewPath(path, dir, depth + 1); // } //} private int _indexOf(RModelObjectNavigatorPathLevel level) { int levelIndex = _levels.IndexOf(level); if (levelIndex < 0) { throw new Exception("Указанный уровень не принадлежит навигатору"); } return levelIndex; }
private bool _navigate(RModelObjectNavigatorPathLevel level, NAV_DIRECTION dir) { if (this._current == null) throw new Exception("Текущий объект не задан"); int cnt = _indexOf(level) + 1; int[] newPath = new int[cnt]; for (int ii = 0; ii < cnt; ii++) { newPath[ii] = _levels[ii].Index; } if (_tryGetNewPath(ref newPath, dir)) { for (int ii = 0; ii < _levels.Count(); ii++) { _levels[ii].Index = (ii < cnt) ? newPath[ii] : 0; } _updatePointer(); return true; } else { return false; } }
private Control _createLevelControls(Control owner, RModelObjectNavigatorPathLevel level, int x) { const int btnWidth = 40; Panel p = new Panel(); p.Location = new System.Drawing.Point(x, 0); Label l = new Label(); p.Controls.Add(l); l.Text = level.UiControlName; l.TextAlign = System.Drawing.ContentAlignment.MiddleRight; l.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); l.AutoSize = true; int labWidth = l.Width; l.AutoSize = false; l.Width = labWidth; l.Height = owner.Height; p.Width = labWidth + 2 * btnWidth + 1; RNavigatorButton b = new RNavigatorButton(level, NAV_DIRECTION.UP); //b.Text = "UP"; p.Controls.Add(b); b.Width = btnWidth; b.Height = owner.Height; b.Left = l.Width; b.Top = 0; b.Click += new System.EventHandler(this._navButtonClick); b.BackgroundImage = global::Platform.Resource.arrow151; b.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; b.FlatStyle = System.Windows.Forms.FlatStyle.Flat; b = new RNavigatorButton(level, NAV_DIRECTION.DOWN); //b.Text = "DOWN"; p.Controls.Add(b); b.Width = btnWidth; b.Height = owner.Height; b.Left = l.Width+btnWidth + 1; b.Top = 0; b.Click += new System.EventHandler(this._navButtonClick); b.BackgroundImage = global::Platform.Resource.caret; b.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; b.FlatStyle = System.Windows.Forms.FlatStyle.Flat; owner.Controls.Add(p); p.Parent = owner; return p; }