Ejemplo n.º 1
0
        /// <summary>
        /// Implement the single-click behavior for this handle, to toggle the
        /// expansion state of the <see cref="T:Northwoods.Go.IGoCollapsible" /> that this handle is in.
        /// </summary>
        /// <param name="evt"></param>
        /// <param name="view"></param>
        /// <returns>true if the parent <see cref="P:Northwoods.Go.IGoCollapsible.Collapsible" /> property is true</returns>
        /// <remarks>
        /// If <see cref="P:Northwoods.Go.IGoCollapsible.IsExpanded" /> is true, this calls <see cref="M:Northwoods.Go.IGoCollapsible.Collapse" />;
        /// otherwise this calls <see cref="M:Northwoods.Go.IGoCollapsible.Expand" />.
        /// If the view is non-null, this method calls <see cref="M:Northwoods.Go.GoView.StartTransaction" />
        /// and <see cref="M:Northwoods.Go.GoView.FinishTransaction(System.String)" />, with a transaction name specified by
        /// the value of <see cref="F:Northwoods.Go.GoUndoManager.CollapsedName" /> or <see cref="F:Northwoods.Go.GoUndoManager.ExpandedName" />.
        /// </remarks>
        public override bool OnSingleClick(GoInputEventArgs evt, GoView view)
        {
            IGoCollapsible goCollapsible = FindCollapsible();

            if (goCollapsible == null)
            {
                return(false);
            }
            string tname = null;

            try
            {
                view?.StartTransaction();
                if (goCollapsible.IsExpanded)
                {
                    goCollapsible.Collapse();
                    tname = "Collapsed";
                }
                else
                {
                    goCollapsible.Expand();
                    tname = "Expanded";
                }
            }
            finally
            {
                view?.FinishTransaction(tname);
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Unlike a regular <see cref="T:Northwoods.Go.GoCollapsibleHandle" />, subgraph handles
        /// treat a Ctrl-click when expanding as a command to call <see cref="M:Northwoods.Go.GoSubGraph.ExpandAll" />.
        /// </summary>
        /// <param name="evt"></param>
        /// <param name="view"></param>
        /// <returns></returns>
        public override bool OnSingleClick(GoInputEventArgs evt, GoView view)
        {
            GoSubGraph goSubGraph = base.Parent as GoSubGraph;

            if (goSubGraph == null || !goSubGraph.Collapsible)
            {
                return(false);
            }
            view?.StartTransaction();
            string text = null;

            if (goSubGraph.IsExpanded)
            {
                goSubGraph.Collapse();
                text = "Collapsed SubGraph";
            }
            else if (evt.Control)
            {
                goSubGraph.ExpandAll();
                text = "Expanded All SubGraphs";
            }
            else
            {
                goSubGraph.Expand();
                text = "Expanded SubGraph";
            }
            view?.FinishTransaction(text);
            return(true);
        }