/// <summary> /// Occurs when tab button is removed /// </summary> /// <param name="button">button removed</param> protected override void OnButtonRemoved(UnitButton button) { Form page = (Form)button.Page; page.FormClosing -= OnPageClosing; page.FormClosed -= OnPageClosed; page.ParentChanged -= OnPageParentChanged; PagesPanel.Remove(page); DockableFormInfo info = null; for (int index = _cachedInfos.Count - 1; index >= 0; index--) { if (_cachedInfos[index].Button == button) { info = _cachedInfos[index]; _cachedInfos.RemoveAt(index); info.ExplicitDisposing -= OnInfoDisposing; info.SelectedChanged -= OnInfoSelectedChanged; break; } } EventHandler <FormEventArgs> handler = FormRemoved; if (handler != null) { FormEventArgs args = new FormEventArgs(page, info.Id); handler(this, args); } }
/// <summary> /// Add a new tab page /// </summary> /// <param name="pageInfo">tab page info</param> public void Add(DockableFormInfo pageInfo) { if (pageInfo.AllowedDock != AllowedDock && AllowedDock != DockAllowed.Unknown) { throw new InvalidOperationException("Err"); } pageInfo.DockableForm.SetBounds(-15000, 0, PagesPanel.Width, PagesPanel.Height); pageInfo.DockableForm.Dock = DockStyle.None; PagesPanel.Add(pageInfo.DockableForm); _cachedInfos.Add(pageInfo); pageInfo.ExplicitDisposing += OnInfoDisposing; pageInfo.SelectedChanged += OnInfoSelectedChanged; pageInfo.HostContainerDock = HostContainerDock; pageInfo.DockableForm.FormClosing += OnPageClosing; pageInfo.DockableForm.FormClosed += OnPageClosed; pageInfo.DockableForm.ParentChanged += OnPageParentChanged; AddButton(pageInfo.Button); IsFocused = true; }
/// <summary> /// Occurs when pages context menu button was clicked /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event arguments</param> private void OnPagesContextMenuClick(object sender, EventArgs e) { EventHandler <FormEventArgs> handler = ContextMenuClick; if (handler != null) { DockableFormInfo info = GetPageInfo(PagesPanel.GetFormAt(SelectedIndex)); FormEventArgs args = new FormEventArgs(info.DockableForm, info.Id); handler(this, args); } }
void layout() { var height = (float)Screen.height; var width = (standardWidth / standardHeight) * height; if (width < Screen.width) { width = Screen.width; height = (standardHeight / standardWidth) * width; } PagesPanel.GetComponent <RectTransform>().sizeDelta = new Vector2(width * PagesPanel.transform.childCount, height); PagesPanel.GetComponent <GridLayoutGroup>().cellSize = new Vector2(width, height); GuidePanel.GetComponent <ScrollRect>().normalizedPosition = new Vector2(0, 0.5f); currentNor = GuidePanel.GetComponent <ScrollRect>().normalizedPosition; var pointsHeight = KeenLove.AdaptedDistance(8, KeenLove.StandardSize.y, false); var pointsWidth = KeenLove.AdaptedDistance((KeenLove.StandardSize.x - 158 * 2), KeenLove.StandardSize.x); var pointsPoy = KeenLove.AdaptedDistance(40, KeenLove.StandardSize.y, false); PointsImage.rectTransform.sizeDelta = new Vector2(pointsWidth, pointsHeight); PointsImage.rectTransform.anchoredPosition3D = new Vector3(0, pointsPoy, 0); }