/// <summary> /// get panel below splitter /// </summary> /// <param name="splitter"></param> /// <returns></returns> public Panel GetPanelBySplitter(SplitterWithExpander splitter) { int index = this.Controls.GetChildIndex(splitter); Panel panel = this.Controls[index - 1] as Panel; // get the panel below splitter return(panel); }
/// <summary> /// create splitter with expander /// </summary> /// <returns></returns> protected override Splitter CreateDefaultSplitterControl(string name) { IDesignerHost host = this.GetService(typeof(IDesignerHost)) as IDesignerHost; SplitterWithExpander splitter = host.CreateComponent(typeof(SplitterWithExpander)) as SplitterWithExpander; splitter.Initialize(SplitterThinkness, name); splitter.PropertyChanged += Splitter_PropertyChanged; return(splitter); }
/// <summary> /// set the visibility of panel when expander is expanded/ collapsed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Splitter_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "IsExpanded") { SplitterWithExpander splitterWithExpander = ((SplitterWithExpander)(sender)); Panel panel = GetPanelBySplitter(splitterWithExpander); panel.Visible = splitterWithExpander.IsExpanded; // set the visibility of panel OnIsExpandedChangedChanged(panel); // raise isexpanded changed event } }
/// <summary> /// Show the panel if it is not visible /// </summary> /// <param name="panel"></param> public void EnsureExpanded(Panel panel) { if (!panel.Visible) { int index = Controls.GetChildIndex(panel); SplitterWithExpander splitterWithExpander = Controls[index + 1] as SplitterWithExpander; splitterWithExpander.IsExpanded = true; } }
protected override bool GetHitTest(Point point) { SplitterWithExpander splitter = this.Component as SplitterWithExpander; bool result = base.GetHitTest(point); point = splitter.PointToClient(point); SplitterHitTestArea hitTestResult = splitter.HitTest(point); if (hitTestResult == SplitterHitTestArea.Expander) { return(true); } return(false); }
/// <summary> /// update the text of splitter /// </summary> /// <param name="index"></param> /// <param name="text"></param> public void UpdateSplitterText(int index, string text) { SplitterWithExpander splitter = Splitters[index] as SplitterWithExpander; splitter.UpdateText(text); }