C#--工作笔记(直方图单个UserControls)

<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);
        }
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值