예제 #1
0
      /// <summary/>
      protected override void BeginTransition(TransitionEventArgs e) {
         AddBackSnapshot(e);
         AddFrontSnapshot(e);

         var prop = (Direction.IsHorizontal() ? TranslateTransform.XProperty : TranslateTransform.YProperty);
         var value = 0.0;
         switch (Direction) {
            case MoveDirection.Up:
               value = -e.Bounds.Height;
               break;
            case MoveDirection.Down:
               value = +e.Bounds.Height;
               break;
            case MoveDirection.Left:
               value = -e.Bounds.Width;
               break;
            case MoveDirection.Right:
               value = +e.Bounds.Width;
               break;
         }

         var txBack = new TranslateTransform();
         txBack.SetValue(prop, 0.0);
         e.BackSnapshot.RenderTransform = txBack;
         AddAnimation(e, txBack, prop, 0.0, value);

         var txFront = new TranslateTransform();
         txFront.SetValue(prop, -value);
         e.FrontSnapshot.RenderTransform = txFront;
         AddAnimation(e, txFront, prop, -value, 0.0);
      }
예제 #2
0
    /// <summary>
    /// Draws the legend for the chart component
    /// </summary>
    protected virtual void DrawLegend()
    {
      if(_legendPosition == LegendLocation.NONE)
      {
        return;
      }
      
      string [] seriesLabels = _model.SeriesLabels;
      int seriesCount = seriesLabels.Length;
      
      Color[] seriesColors = _model.SeriesColors;

      UIElement rectElem;
      TextBlock labelElem;
      double iconHeight = 0.0, iconWidth = 0.0;
      double marginLeft =  _marginLeft;
      Canvas legendGroup = new Canvas();
      bool animate = (_animationDuration>0);
      List<UIElement> labelElems = LabelElements;
      
      _chartCanvas.Children.Add(legendGroup);

      if(_isPerspective)
      {
        marginLeft += _XOFFSET_PERSPECTIVE;
      }

      double width = _chartCanvas.Width, height = _chartCanvas.Height;
      double gridWidth = (width - marginLeft - _marginRight),
             gridHeight = (height - _marginTop - _marginBottom);
      
      if(animate)
      {
        labelElems.Add(legendGroup);
        legendGroup.Opacity = 0;
      }

      double dx = 0, dy = 0, tx = marginLeft, ty = height - _marginBottom;
      bool drawSideWays = (_legendPosition == LegendLocation.START || 
                          _legendPosition == LegendLocation.END);
      
      string legendTextXAML = _currentLookAndFeel.GetLegendTextXAML();
      string legendIconXAML = _currentLookAndFeel.GetLegendIconXAML();
      
      double maxWidth = 0.0, maxHeight = 0.0, textHeight;
      
      for (int i = 0; i < seriesCount; ++i)
      {
        if(drawSideWays)
          dx = 0;
          
        rectElem = XamlReader.Load(legendIconXAML) as UIElement;
        
        if (i == 0)
        {
          iconHeight = (double)rectElem.GetValue(Canvas.HeightProperty);
          iconWidth = (double)rectElem.GetValue(Canvas.WidthProperty);
        }
        
        rectElem.SetValue(Canvas.LeftProperty, dx);
        
        SetFillOnElement(rectElem, seriesColors[i]);



        legendGroup.Children.Add(rectElem);

        dx += 1.5 * iconWidth;

        labelElem = XamlReader.Load(legendTextXAML) as TextBlock;
        labelElem.Text = seriesLabels[i];
        textHeight = labelElem.ActualHeight;
        
        labelElem.SetValue(Canvas.LeftProperty, dx);

        labelElem.SetValue(Canvas.TopProperty,
                     (dy - textHeight) - ((iconHeight > textHeight) ? ((iconHeight - textHeight)/2) : 0));
        rectElem.SetValue(Canvas.TopProperty, 
                     (dy - iconHeight) - ((textHeight > iconHeight) ? ((textHeight - iconHeight)/2) : 0));
        
        legendGroup.Children.Add(labelElem);
        
        
        if(!drawSideWays)
          dx += labelElem.ActualWidth + iconWidth;
        else
          dy += 1.5 * iconHeight;
        
        if(i == 0 && !drawSideWays)
        {
          if (_legendPosition == LegendLocation.TOP)
          {
            ty = SetLegendTopAdjustment(_marginTop+labelElem.ActualHeight);
            _marginTop += labelElem.ActualHeight + _TEXT_MARGIN;
          }
          else
          {
            ty = SetLegendBottomAdjustment(ty);
            _marginBottom += labelElem.ActualHeight + _TEXT_MARGIN;
          }
        }
        
        if(drawSideWays)
        {
          maxWidth = Math.Max(maxWidth, labelElem.ActualWidth);
          maxHeight = Math.Max(maxHeight, labelElem.ActualHeight);
        }
      }
      
      if(!drawSideWays && gridWidth > dx)
        tx = (gridWidth - dx) / 2 + marginLeft;
      
      if(drawSideWays)
      {
        maxWidth += 1.5 * iconWidth;

        if (_legendPosition == LegendLocation.START)
        {
          tx = this.SetLegendLeftAdjustment(_marginLeft);
          _marginLeft += maxWidth + _TEXT_MARGIN;
        }
        else
        {
          _marginRight += maxWidth + _TEXT_MARGIN;
          tx = width - _marginRight + _TEXT_MARGIN;
          tx = this.SetLegendRightAdjustment(tx);
        }
        
        if(gridHeight > dy)
          ty = (gridHeight - maxHeight) / 2 + _marginTop;
        else
          ty = gridHeight + _marginTop - maxHeight;
      }
      
      TranslateTransform transform = new TranslateTransform();
      
      transform.SetValue(TranslateTransform.XProperty, tx);
      transform.SetValue(TranslateTransform.YProperty, ty);
      
      legendGroup.RenderTransform = transform; 
    }
예제 #3
0
        void _content_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            FrameworkElement content = sender as FrameworkElement;
            if (content != null)
            {
                TransformGroup tGroup = new TransformGroup();
                TranslateTransform translate = new TranslateTransform();
                translate.SetValue(FrameworkElement.NameProperty, "RollTransform" + Guid.NewGuid().ToString());
                if (IsExpanded)
                {
                    translate.Y = 0;
                    VisualStateManager.GoToState(this as Control, Expand, false);
                }
                else
                {
                    translate.Y = -content.ActualHeight;
                    VisualStateManager.GoToState(this as Control, Collapse, false);
                }

                tGroup.Children.Add(translate);
                content.RenderTransform = tGroup;

                _RollUpStoryboardName = "RollUp" + Guid.NewGuid().ToString();
                _RollDownStoryboardName = "RollDown" + Guid.NewGuid().ToString();

                _SetupYTranslationStoryboard(translate, _RollUpStoryboardName, -content.ActualHeight);
                _SetupYTranslationStoryboard(translate, _RollDownStoryboardName, 0);
            }
        }
예제 #4
0
 public static void SetPercentFromLeft(TranslateTransform element, double value)
 {
     element.SetValue(PercentFromLeftProperty, value);
 }
예제 #5
0
 public static void SetOuterWidth(TranslateTransform element, double value)
 {
     element.SetValue(OuterWidthProperty, value);
 }