Пример #1
0
        /// <summary>
        /// Gets the controls in pairs.
        /// </summary>
        /// <returns>List&lt;ControlPair&gt;.</returns>
        private List<ControlPair> GetControls()
        {
            var controls = new List<ControlPair>();
            for (var controlCounter = 0; controlCounter < Children.Count; controlCounter++)
            {
                var child = Children[controlCounter];
                var controlPair = new ControlPair(0d);

                if (SimpleView.GetIsStandAloneEditControl(child))
                    controlPair.Edit = child;
                else
                {
                    controlPair.Label = child;
                    if (SimpleView.GetSpanFullWidth(child))
                        controlPair.LabelSpansFullWidth = true;
                    else if (!SimpleView.GetIsStandAloneLabel(child))
                    {
                        var editControlIndex = controlCounter + 1;
                        if (Children.Count > editControlIndex)
                            controlPair.Edit = Children[editControlIndex];
                        controlCounter++; // We are skipping the next control since we already accounted for it

                        while (true) // We check if the next control might flow with the current edit control
                        {
                            if (Children.Count <= controlCounter + 1) break;
                            if (!SimpleView.GetFlowsWithPrevious(Children[controlCounter + 1])) break;
                            controlPair.AdditionalEditControls.Add(Children[controlCounter + 1]);
                            controlCounter++;
                        }
                    }
                }
                controls.Add(controlPair);
            }
            return controls;
        }
Пример #2
0
        /// <summary>Iterates over all the controls and returns them in columns and tuples</summary>
        /// <returns>Columns of control pairs</returns>
        protected virtual List<List<ControlPair>> GetColumns()
        {
            var columns = new List<List<ControlPair>> {new List<ControlPair>()};
            var currentColumn = columns[0];
            for (var controlCounter = 0; controlCounter < Children.Count; controlCounter++)
            {
                var child = Children[controlCounter];
                if (SimpleView.GetColumnBreak(child))
                {
                    columns.Add(new List<ControlPair>());
                    currentColumn = columns[columns.Count - 1];
                }

                var controlPair = new ControlPair(FlowWithPreviousSpacing);

                if (child is HeaderedContentControl || child is TabControl)
                    controlPair.Span = child;
                else
                {
                    if (IsControlStandAlone(child))
                        controlPair.Edit = child;
                    else
                    {
                        controlPair.Label = child;

                        var editControlIndex = controlCounter + 1;
                        if (Children.Count > editControlIndex)
                            controlPair.Edit = Children[editControlIndex];
                        controlCounter++; // We are skipping the next control since we already accounted for it
                    }

                    while (true) // We check whether the next control(s) flow(s) with the previous as secondary controls
                    {
                        if (Children.Count <= controlCounter + 1) break;
                        var nextChild = Children[controlCounter + 1];
                        if (!DoesControlFlowWithPrevious(nextChild)) break;
                        controlPair.SecondaryControls.Add(nextChild);
                        controlCounter++;
                    }
                }
                currentColumn.Add(controlPair);
            }
            return columns;
        }
Пример #3
0
 /// <summary>
 /// This method is used to measure the size of the label part of the pair
 /// </summary>
 /// <param name="controlPair">The control pair.</param>
 /// <returns>Size.</returns>
 protected virtual Size MeasureLabelSize(ControlPair controlPair)
 {
     if (controlPair.Label != null)
     {
         controlPair.Label.Measure(new Size(100000, 100000));
         return new Size(controlPair.Label.DesiredSize.Width, controlPair.Label.DesiredSize.Height);
     }
     return Size.Empty;
 }
Пример #4
0
 /// <summary>
 /// This method can be used to create custom label handling code.
 /// Override this method if you want to handle the label logic in a subclass.
 /// </summary>
 /// <param name="controlPair">The control pair for which the label needs to be handled.</param>
 /// <param name="currentX">The current X position in the overall layout.</param>
 /// <param name="currentY">The current Y position in the overall layout.</param>
 /// <param name="width">The suggested width for the label.</param>
 /// <param name="customLabelOffset">Set this parameter to move the X and Y coordinates as a result of custom handling</param>
 /// <returns>Return true if custom handling code takes over and no default label handling is needed</returns>
 protected virtual bool CustomLabelHandlingOverride(ControlPair controlPair, double currentX, double currentY, double width, Size customLabelOffset)
 {
     return false;
 }