Пример #1
0
 protected void SetOperands(int operands)
 {
     if (operands > 0)
     {
         int curCount = contentGrid.Children.Count;
         if (operands > curCount)
         {
             double height = contentGrid.Height;
             double width  = 0.0f;
             for (int i = 0; i < operands - curCount; i += 1)
             {
                 RowDefinition row = new RowDefinition();
                 contentGrid.RowDefinitions.Add(row);
                 NumberPanel p = new NumberPanel(_DataWidth);
                 width = p.GetActualWidth();
                 contentGrid.Children.Add(p);
                 Grid.SetRow(p, contentGrid.RowDefinitions.Count - 1);
                 height += p.Height;
             }
             SetUiWidthHeight(width, height);
         }
         else
         {
             if (curCount > 0)
             {
                 contentGrid.Children.RemoveRange(operands - 1, curCount - operands);
                 NumberPanel p = new NumberPanel(_DataWidth);
                 SetUiWidthHeight(contentGrid.ActualWidth, contentGrid.ActualHeight - p.Height * (curCount - operands));
             }
         }
     }
 }
Пример #2
0
        protected void SetDataWidth(int dataWidth)
        {
            double?panelWidth = null;
            double newHeight  = 0.0f;

            _DataWidth = dataWidth;
            foreach (UIElement e in contentGrid.Children)
            {
                NumberPanel p = e as NumberPanel;
                newHeight += p.Height;
                p.Render(dataWidth);
                panelWidth = p.GetActualWidth();
            }
            if (panelWidth > 0.0f)
            {
                SetUiWidthHeight((double)panelWidth, newHeight);
            }
        }