コード例 #1
0
ファイル: Alerm.xaml.cs プロジェクト: peisheng/EASYFRAMEWORK
        public Alerm(Entity.StockInfo stockInfo, string stockCode)
        {
            InitializeComponent();
            WindHelper.SetWindowStartLocationOnRightButtom(this);
            Entity.SettingEntity entity = EntityHelper.GetSetting(stockCode);
            string  winTitle = string.Empty;
            if (entity != null && stockInfo != null)
            {
                txtCostPrice.Text = entity.BuyCostPrice;
                txtBuyVol.Text = entity.BuyVol;
                txtCurrentPrice.Text = stockInfo.LatestPrice;
                decimal latestPrice = Convert.ToDecimal(stockInfo.LatestPrice);
                decimal buyCostPrice = Convert.ToDecimal(entity.BuyCostPrice);
                if (latestPrice > buyCostPrice)
                {
                    winTitle = "赢利";
                }
                else
                {
                    winTitle = "亏损";
                }
                int buyVol = Convert.ToInt32(entity.BuyVol);
                txtMakeMoney.Text = ((latestPrice - buyCostPrice) * buyVol).ToString();
                txtMakeRate.Text = ((latestPrice - buyCostPrice) / buyCostPrice * 100).ToString() + " %";
                txtStockCode.Text = stockInfo.Code;
                txtStockName.Text = stockInfo.Name;
            }
            this.Title = stockInfo.Code + " - " + stockInfo.Name + winTitle + "预警";         
                ;

                TimerTool tool = new TimerTool(30.seconds(), () => {
                    this.Close();                
                });
                tool.Run();
        }
コード例 #2
0
        public Setting()
        {
            InitializeComponent();
            TimerTool tool = new TimerTool(1.seconds(), () => {
                foreach(var item in  this.GetVisuals<TextBox>())
                {
                    item.Width = 140;
                }

                foreach (var item in this.GetVisuals<Button>())
                {
                    item.Width = 70;
                    item.Height = 30;
                    item.VerticalAlignment = VerticalAlignment.Top;
                }
 
            },false);
            tool.Run();
            bindLtConfig();
            
        }
コード例 #3
0
 private void btnStartWatching_Click(object sender, RoutedEventArgs e)
 {
     TimerTool tool = new TimerTool(20.seconds(), () => {
         StockSetttings settings = EntityHelper.GetSettings();
         var list = settings.SetttingList.Where(p => p.IsActived == true).ToList();
         foreach (var entity in list)
         {
             string stockCode = entity.StockCode;
             decimal buyCostPrice = Convert.ToDecimal(entity.BuyCostPrice);
             decimal alarmLossRate = Convert.ToDecimal(entity.AlarmLossStopPoint);
             decimal alarmMakeRate = Convert.ToDecimal(entity.AlarmMakeStopPoint);
             StockInfo info = StockHelper.GetStockInfo(stockCode);
             
            
             if (info != null)
             {
                 Debug.WriteLine("CODE:"+info.Code);
                 Debug.WriteLine("Name:"+info.Name);
                 Debug.WriteLine("当前价格:" + info.LatestPrice);
                 decimal currentPrice = Convert.ToDecimal(info.LatestPrice);
                 decimal nowRate = (currentPrice - buyCostPrice) / buyCostPrice * 100;
                 if (nowRate > 0 && nowRate >= alarmMakeRate)
                 {
                     Alerm alerm = new Alerm(info, stockCode);
                     alerm.Show();
                 }
                 else if (nowRate < 0 && Math.Abs(nowRate) > alarmLossRate)
                 {
                     Alerm alerm = new Alerm(info, stockCode);
                     alerm.Show();
                 }
             }
             else
             {
                 //记录找不到相应的股票
             } 
         }
     
     },true);
     tool.Run(); 
 }