<UserControl x:Class="WpfCtrlLib.Ui.QuotesCtrl.QuotesCard"
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="300" d:DesignWidth="300"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
>
<Grid Name="gQuotesCard" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<Grid.Resources>
<Style TargetType="DataGridCell" x:Key="cellStyle">
<Setter Property="Foreground" Value="White"/>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<DataGrid Grid.Row="0" x:Name="gQuotesCardList" CanUserSortColumns="True" FrozenColumnCount="1" Margin="2">
</DataGrid>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.Xml.Linq;
using WpfCtrlLib.Model.Quotes;
using WpfCtrlLib.Pub;
using WpfCtrlLib.Service.Quotes;
using WpfCtrlLib.Service.Quotes.Imp;
using WpfCtrlLib.Ui.UserCtrl;
using WpfCtrlLib.Util;
namespace WpfCtrlLib.Ui.QuotesCtrl
{
/// <summary>
/// QuotesCard.xaml 的交互逻辑
/// </summary>
public partial class QuotesCard : UserControl
{
private IQuotesPubService qcs = new QuotesPubServiceImpl();
public QuotesCard()
{
InitializeComponent();
DataGrid dg = new DataGrid();
List<Colums> list = qcs.getColumns();
double totalWidth = 1000;
Window win = Mgr.CurrentWindow;
if (win.Name == "quotes")
{
WinQuotes quotes = (WinQuotes)win;
QuotesPanel qp = quotes.qPanel;
QuotesContent qc = qp.Price;
qc.UpdateLayout();
//totalWidth = qc.ActualWidth;
}
else if (win.Name == "winTradeAndQuotes")
{
WinTradeAndQuotes tradeAndQuotes = (WinTradeAndQuotes)win;
QuotesPanel qp = tradeAndQuotes.quotesPanel;
QuotesContent qc = qp.Price;
qc.UpdateLayout();
//totalWidth = qc.ActualWidth;
}
totalWidth = totalWidth - 9;
this.gQuotesCard.Width = totalWidth;
double width = totalWidth / list.Count;
//
for (int i = 0; i < list.Count; i++)
{
DataGridTextColumn dtc = new DataGridTextColumn();
dtc.Header = StringUtil.I18N(list[i].Name);
Binding bind = new Binding(list[i].Name);
//PriceDataConverter con=new PriceDataConverter();
//bind.Converter = con;
dtc.Binding = bind;
dtc.Width = width;
dtc.IsReadOnly = true;
Style style = new Style(typeof(DataGridCell));
Setter set = new Setter(DataGridCell.ForegroundProperty, Brushes.Red);
Setter set1 = new Setter(DataGridCell.BackgroundProperty, Brushes.Black);
style.Setters.Add(set);
dtc.CellStyle = style;
Style headerStyle = new Style(typeof(DataGridColumnHeader));
Setter headerSet = new Setter(DataGridCell.ForegroundProperty, Brushes.DarkGray);
headerStyle.Setters.Add(headerSet);
headerStyle.Setters.Add(set1);
dtc.HeaderStyle = headerStyle;
dg.Columns.Add(dtc);
}
dg.Background = Brushes.Black;
this.gQuotesCard.Children.Add(dg);
}
public QuotesCard(List<FQContract> contracts)
{
InitializeComponent();
try
{
//DataGrid dg = new DataGrid();
DataGrid dg = this.gQuotesCardList;
List<Colums> list = qcs.getColumns();
//this.gQuotesCard.UpdateLayout();
//double w = this.gQuotesCard.ActualWidth;;
double totalWidth = 1000;
// Window win = Mgr.CurrentWindow;
if (Mgr.WinQuote!=null) {
WinQuotes quotes = (WinQuotes)Mgr.WinQuote;
QuotesPanel qp = quotes.qPanel;
QuotesContent qc = qp.Price;
qc.UpdateLayout();
//totalWidth = qc.ActualWidth;
}
else if (Mgr.WinTradeAndQuote!=null)
{
WinTradeAndQuotes tradeAndQuotes = (WinTradeAndQuotes)Mgr.WinTradeAndQuote;
QuotesPanel qp = tradeAndQuotes.quotesPanel;
QuotesContent qc = qp.Price;
qc.UpdateLayout();
//totalWidth = qc.ActualWidth;
}
// totalWidth = totalWidth;
//this.gQuotesCard.Width = totalWidth;
//this.gQuotesCard.UpdateLayout();
//double width = totalWidth/ list.Count;
//
for (int i = 0; i < list.Count; i++)
{
DataGridTextColumn dtc = new DataGridTextColumn();
dtc.Header = StringUtil.I18N(list[i].Name);
Binding bind = new Binding(list[i].Name);
if (list[i].Name == "NewPrice" || list[i].Name == "OpenPrice" || list[i].Name == "HighPrice" || list[i].Name == "ClosePrice" || list[i].Name == "BuyPrice" || list[i].Name == "SellPrice" || list[i].Name == "AvgPrice" || list[i].Name == "LowPrice")
{
PriceDataConverter priceConverter=new PriceDataConverter();
bind.Converter = priceConverter;
}
//dtc.Foreground = Brushes.White;
dtc.Binding = bind;
//dtc.Width = new DataGridLength();
dtc.IsReadOnly = true;
Style style = new Style(typeof(DataGridCell));
Setter set = new Setter(DataGridCell.ForegroundProperty, Brushes.Red);
Setter set1 = new Setter(DataGridCell.BackgroundProperty,Brushes.Black);
style.Setters.Add(set);
dtc.CellStyle = style;
Style headerStyle = new Style(typeof(DataGridColumnHeader));
Setter headerSet = new Setter(DataGridCell.ForegroundProperty, Brushes.DarkGray);
headerStyle.Setters.Add(headerSet);
headerStyle.Setters.Add(set1);
dtc.HeaderStyle = headerStyle;
//设置宽度
//DataGridLength.SizeToCells.;
//dtc.Width = DataGridLength.Auto;
dg.GridLinesVisibility = DataGridGridLinesVisibility.None;//设置没有边框
dg.Columns.Add(dtc);
}
//获取合同信息
ObservableCollection<QuotesPlateModel> oc = new ObservableCollection<QuotesPlateModel>();
List<QuotesPlateModel> contractsList = qcs.getPalteContractsInfo(contracts);
for (int i = 0; i < contractsList.Count; i++)
{
oc.Add(contractsList[i]);
}
//设置行样式
Style rowStyle=new Style(typeof(DataGridRow));
Trigger rowTrigger = new Trigger();//触发器
rowTrigger.Property = DataGridRow.IsMouseOverProperty;
rowTrigger.Value = true;
Setter trggerSet = new Setter(DataGridRow.BackgroundProperty, Brushes.Gold);
Setter rowSet = new Setter(DataGridRow.BackgroundProperty, Brushes.Black);
rowTrigger.Setters.Add(trggerSet);
rowStyle.Setters.Add(rowSet);
rowStyle.Triggers.Add(rowTrigger);
dg.RowStyle=rowStyle;
dg.CanUserAddRows = false;
dg.AutoGenerateColumns = false;
dg.HeadersVisibility = DataGridHeadersVisibility.Column;
dg.ItemsSource = oc;
/*DataGrid添加行双击击事件*/
dg.MouseDoubleClick += (object sender, MouseButtonEventArgs e) =>
{
Point aP = e.GetPosition(dg);
IInputElement obj = dg.InputHitTest(aP);
DependencyObject target = obj as DependencyObject;
while (target != null)
{
if (target is DataGridRow)
{
break;
}
target = VisualTreeHelper.GetParent(target);
}
DataGridRow row = target as DataGridRow;
if (row == null || row.DataContext == null) return;
QuotesPlateModel model = row.DataContext as QuotesPlateModel;
if (model == null) return;
Mgr.FlashService.Show(model.ContractID);
};
//添加选中事件
// dg.MouseDown+=dg_MouseDown;
dg.Background = Brushes.Black;
dg.SelectionChanged+=new SelectionChangedEventHandler(dg_SelectionChanged);
//this.gQuotesCard.Children.Add(dg);
}
catch (AppException app)
{
MessageBox.Show(app.Message, StringUtil.I18N("sys_info"), MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
string errString = ex.Message;
Console.WriteLine("=================errString:" + errString);
MessageBox.Show(errString);
//MessageBox.Show(StringUtil.I18N("sys_operation_failed"), StringUtil.I18N("sys_info"), MessageBoxButton.OK, MessageBoxImage.Information);
}
}
/// <summary>
/// 选中事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dg_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
DataGrid dg = (DataGrid)sender;
var items = dg.SelectedItems;
if (items.Count > 0) {
QuotesPlateModel model = (QuotesPlateModel)items[0];
//qcs.updatePriceStatistics(model);
}
}
catch (AppException app)
{
MessageBox.Show(app.Message, StringUtil.I18N("sys_info"), MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
string errString = ex.Message;
Console.WriteLine("=================errString:" + errString);
MessageBox.Show(StringUtil.I18N("sys_operation_failed"), StringUtil.I18N("sys_info"), MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
//控制表格价格的显示
[ValueConversion(typeof(string), typeof(string))]
public class PriceDataConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string result = "--";
string v = value.ToString();
if (v == "--")
{
return result;
}
result = StringUtil.GetPriceData(v, true);
//result = StringUtil.GetPrice(v);
return result;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
分享到:
相关推荐
香农代码的matlab 伊娃节肢动物群落的纬度梯度 标题:纬向梯度上的公会和分类群β多样性对比 code_mfiles Matlab中用于数据分析的数据和脚本 code_rfile R中的变化分区的数据和脚本 原始数据 Excel文件 可重复性说明...
说明 工作队列旨在协调生产者和工作线程池之间的工作。 当需要执行某个任务时,...用法 安装宝石: gem install work_queue运行代码: require 'rubygems'require 'work_queue'wq = WorkQueue . newwq . enqueue_b { pu
每次页面加载或用户在不同日期之间导航并将其填充到用户时,都可以从localStorage进行访问,以便他们可以添加或修改它们。 该应用程序允许用户使用显示的日期旁边的箭头向前和向后导航日期。 特征 从当前日期开始 ...
matlab导入excel代码make_work_easier 这是一个回购,用于研究或开发使工作更轻松有趣的工具,尤其是在我们从事机器人研究项目时,以下工作流程中的研究工作尤其如此。 :backhand_index_pointing_right: 如果您对更...
API是开发人员工具箱的重要组成部分,可以帮助您在代码中添加各种功能。 API甚至直接内置在浏览器中。在浏览器中加载网页后,将创建网页的对象表示形式( Document Object Model或DOM )。作为编程接口,DOM使我们...
Workout_tracker_17执照目录描述开发该应用程序以查看创建和跟踪日常锻炼。 该应用程序使用快速后端和前端,以从dbworkout保存和检索节点数据。 yuo可以在给定的一天中记录一次锻炼中的多个锻炼。 您还可以跟踪运动...
... 网络结构 首先,图像输入特征提取主干,提取特征; 其次,特征金字塔上采样到相同的尺寸,并进行特征级联得到特征F; 然后,特征F用于预测概率图(probability map P)和阈值图(threshold map T) ...
工作日 使用此便捷的小命令行工具在规划中心开始和结束工作日。 特征 向您的团队的Slack频道发布站立或正常消息。 更新pco-box 将Planning Center应用更新为... 并将其添加到公共dotfiles存储库中未包含的~/.secrets
Workout_Tracker-第17单元NoSQL作业:锻炼跟踪器对于此任务,您将创建一个锻炼追踪器。 在Develop文件夹中已经为您提供了前端代码。 此分配将要求您使用Mongoose模式创建Mongo数据库,并使用Express处理路由。用户的...
1、添加代码修改说明 如果是同时选中了多行代码,格式为 /*Start of CuiJin on xxxx年xx月xx日 Version(NetEye3.2)*/ if(){ …… }else{ …… } …… /*End of CuiJin on xxxx年xx月xx日 Version(NetEye3.2)...
redmine_code_review:代码评审插件,需要按配置代码版本库(SVN, GIT等) redmine_dashboard:仪表盘,方便调整任务 redmine_jquery_opentip:让redmine支持jquery redmine_lightbox2:附件截图、PDF预览框 redmine...
在Android源码树中添加userspace I2C读写工具(i2c-util) 本文使用的开发板是:杭州若格科技有限公司的全志R8。CPU:CPUARM Cortex-A8 更多芯片资料请参见全志官网: http://www.allwinnertech.com/clq/r/R8.html...
...当您遇到想要添加到列表中的新网站时,也可以通过打开扩展对话框菜单并添加完整或基本...要查看此扩展的源代码,请访问https://github.com/alexbudy/work_mode 感谢您考虑我的扩展,并感谢所有反馈! 支持语言:English
在Develop文件夹中已经为您提供了前端代码。 此分配将要求您使用Mongoose模式创建Mongo数据库,并使用Express处理路由。 用户的故事 作为用户,我希望能够查看创建并跟踪日常锻炼。 我希望能够在给定的一天中记录一...
支持生成多种结构的表格、图表,关键代码都添加了注释,简单易懂。 其中表格和图表都写了两种实现方式,既可以只传简单的参数生成多个同结构的表格和图表,也可以通过传对象的方式生成多种结构的对应图表或表格
为了使代码正常工作,请下载excel工作表,并将要处理的excel文件的路径以及工作表名称添加到代码开头的load_data函数中。 大多数代码是不言自明的,并带有适当的注释。 任何想要继续进行项目工作或分析完成的工作的...
c/c++用一个源文件,一个头文件实现的 优先队列定时器 源码,包含测试代码,可运行。 说明: 1、源码中包含三个文件qtimer.cpp、qtimer.h、test_main.cpp; 2、qtimer.cpp中会创建一个优先队列来管理定时任务,一个...
> 在前面,您可以使用登录名lala和密码password->登录在选项卡上的可以看到所有新闻(稍后,我将尝试向新闻添加批准,以便在当前代码适合的情况下,不会发布所有内容)-> 您可以从最前面添加新闻,该新闻将发布到该...
语言:English 此扩展允许您在单击中输入...要查看更多我的工作,请访问我的网站:AlexBudilovsky.com要查看此扩展的源代码,请访问以下:https://github.com/alexbudy/work_mode谢谢你考虑我的扩展,我很欣赏所有反馈!