public void SetContentIndex(IDockContent content, int index) { int oldIndex = Contents.IndexOf(content); if (oldIndex == -1) throw(new ArgumentException(Strings.DockPane_SetContentIndex_InvalidContent)); if (index < 0 || index > Contents.Count - 1) if (index != -1) throw(new ArgumentOutOfRangeException(Strings.DockPane_SetContentIndex_InvalidIndex)); if (oldIndex == index) return; if (oldIndex == Contents.Count - 1 && index == -1) return; Contents.Remove(content); if (index == -1) Contents.Add(content); else if (oldIndex < index) Contents.AddAt(content, index - 1); else Contents.AddAt(content, index); RefreshChanges(); }
public void SetContentIndex(IDockContent content, int index) { int oldIndex = Contents.IndexOf(content); if (oldIndex == -1) { throw (new ArgumentException(Resources.DockPane_SetContentIndex_InvalidContent)); } if (index < 0 || index > Contents.Count - 1) { if (index != -1) { throw (new ArgumentOutOfRangeException(Resources.DockPane_SetContentIndex_InvalidIndex)); } } if (oldIndex == index) { return; } if (oldIndex == Contents.Count - 1 && index == -1) { return; } Contents.Remove(content); if (index == -1) { Contents.Add(content); } else if (oldIndex < index) { Contents.AddAt(content, index - 1); } else { Contents.AddAt(content, index); } RefreshChanges(); }
public void SetContentIndex(Content c, int index) { int oldIndex = Contents.IndexOf(c); if (oldIndex == -1) { throw(new ArgumentException(ResourceHelper.GetString("ContentWindow.SetContentIndex.InvalidContent"))); } if (index < 0 || index > Contents.Count - 1) { if (index != -1) { throw(new ArgumentOutOfRangeException(ResourceHelper.GetString("ContentWindow.SetContentIndex.InvalidIndex"))); } } if (oldIndex == index) { return; } if (oldIndex == Contents.Count - 1 && index == -1) { return; } Contents.Remove(c); if (index == -1) { Contents.Add(c); } else if (oldIndex < index) { Contents.AddAt(c, index - 1); } else { Contents.AddAt(c, index); } Refresh(); }