<UserControl x:Class="Health365IIProjectView.Cylinder3DControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="30">
<StackPanel x:Name="sp" Loaded="StackPanel_Loaded">
</StackPanel>
</UserControl>
=============================================================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Health365IIProjectView
{
/// <summary>
/// Plume3DControl.xaml 的交互逻辑
/// </summary>
public partial class Cylinder3DControl : UserControl
{
private Rectangle _rectLeft;
private Rectangle _rectTop;
private Rectangle _rectRight;
public Cylinder3DControl()
{
InitializeComponent();
sp.Orientation = Orientation.Horizontal;
_rectLeft = new Rectangle()
{
VerticalAlignment = VerticalAlignment.Bottom
};
sp.Children.Add(_rectLeft);
_rectTop = new Rectangle()
{
VerticalAlignment = VerticalAlignment.Top,
RenderTransform = new SkewTransform(-45, 0, 0, 0)
};
sp.Children.Add(_rectTop);
_rectRight = new Rectangle()
{
VerticalAlignment = VerticalAlignment.Bottom,
RenderTransform = new SkewTransform(0, -45, 0, 0)
};
sp.Children.Add(_rectRight);
}
private void StackPanel_Loaded(object sender, RoutedEventArgs e)
{
}
/// <summary>
/// 初始化直方图
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="colorList"></param>
public void InitSettingCylinder3DControl(double width, double height, Color[] colorList)
{
SettingPlume3DSize(width, height);
SettingPlume3DColors(colorList);
}
/// <summary>
/// 设置直方图颜色
/// </summary>
/// <param name="colorList"></param>
public void SettingPlume3DColors(Color[] colorList)
{
_rectLeft.Fill = new SolidColorBrush(colorList[0]);
_rectTop.Fill = new SolidColorBrush(colorList[1]);
_rectRight.Fill = new SolidColorBrush(colorList[2]);
}
/// <summary>
/// 设置直方图尺寸
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
public void SettingPlume3DSize(double width, double height)
{
_rectLeft.Width = width;
_rectLeft.Height = height;
_rectTop.Width = width;
_rectTop.Height = width / 3;
_rectTop.Margin = new Thickness(-width / 3 * 2, 0, 0, 0);
_rectRight.Width = width / 3;
_rectRight.Height = height;
_rectRight.Margin = new Thickness(-width / 3, 0, 0, 0);
}
}
}