Ejemplo n.º 1
0
        //Account Information
        public void ShowDialogWin(AccountInfor accountInfor, string caption, OrderTask orderTask, HandleAction action)
        {
            if (this._ConfirmOrderDialogWin == null)
            {
                this._ConfirmOrderDialogWin = new XamDialogWindow()
                {
                    Width = 350,
                    Height = 450,
                    Header = caption,
                    StartupPosition = Infragistics.Controls.Interactions.StartupPosition.Center,
                    IsModal = true,
                    CloseButtonVisibility = Visibility.Collapsed,
                    MinimizeButtonVisibility = Visibility.Collapsed,
                    MaximizeButtonVisibility = Visibility.Collapsed,
                };
                this._OrderTask = orderTask;
                this._HandleAction = action;
            }
            else
            {
                this._ConfirmOrderDialogWin.Width = 350;
                this._ConfirmOrderDialogWin.Height = 450;
                this._ConfirmOrderDialogWin.Header = caption;
                this._ConfirmOrderDialogWin.Content = null;
            }
            TextBlock BLLable = new TextBlock()
            {
                Name = "BL",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "BL",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock BalanceLable = new TextBlock()
            {
                Name = "Balance",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "Balance",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock EquityLable = new TextBlock()
            {
                Name = "Equity",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "Equity",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock NecessaryLable = new TextBlock()
            {
                Name = "Necessary",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "Necessary",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock UsableLable = new TextBlock()
            {
                Name = "Usable",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "Usable",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock TotalBuyLable = new TextBlock()
            {
                Name = "TotalBuy",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "TotalBuy",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock TotalSellLable = new TextBlock()
            {
                Name = "TotalSell",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "TotalSell",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock NetLable = new TextBlock()
            {
                Name = "Net",
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = "Net",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock SetPriceLable = new TextBlock()
            {
                Name = "SetPrice",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "SetPrice",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock ExecutePriceLable = new TextBlock()
            {
                Name = "ExecutePrice",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "ExecutePrice",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock LotLable = new TextBlock()
            {
                Name = "Lot",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "Lot",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            StackPanel captionPanel = new StackPanel() { Name = "captionPanel", Orientation = Orientation.Vertical };
            captionPanel.Margin = new Thickness(0, 10, 0, 0);
            captionPanel.HorizontalAlignment = HorizontalAlignment.Center;
            captionPanel.VerticalAlignment = VerticalAlignment.Center;
            captionPanel.Children.Add(BLLable);
            captionPanel.Children.Add(BalanceLable);
            captionPanel.Children.Add(EquityLable);
            captionPanel.Children.Add(NecessaryLable);
            captionPanel.Children.Add(UsableLable);
            captionPanel.Children.Add(TotalBuyLable);
            captionPanel.Children.Add(TotalSellLable);
            captionPanel.Children.Add(NetLable);
            captionPanel.Children.Add(SetPriceLable);
            captionPanel.Children.Add(ExecutePriceLable);
            captionPanel.Children.Add(LotLable);

            Grid.SetRow(captionPanel, 0);
            Grid.SetColumn(captionPanel, 0);

            //Value Column
            CheckBox BLCheckBox = new CheckBox()
            {
                Name = "BLText",
                Foreground = new SolidColorBrush(Colors.White),
                IsChecked = true,
                Margin = new Thickness(8),
                IsEnabled = true,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock BalanceText = new TextBlock()
            {
                Name = "BalanceText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.Balance.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock EquityText = new TextBlock()
            {
                Name = "EquityText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.Equity.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock NecessaryText = new TextBlock()
            {
                Name = "NecessaryText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.Necessary.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock UsableText = new TextBlock()
            {
                Name = "UsableText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.Usable.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock TotalBuyText = new TextBlock()
            {
                Name = "TotalBuyText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.BuyLotBalanceSum.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock TotalSellText = new TextBlock()
            {
                Name = "TotalSellText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.SellLotBalanceSum.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock NetText = new TextBlock()
            {
                Name = "NetText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = (accountInfor.BuyLotBalanceSum - accountInfor.SellLotBalanceSum).ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock SetPriceText = new TextBlock()
            {
                Name = "SetPriceText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = orderTask.SetPrice,
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock ExecutePriceText = new TextBlock()
            {
                Name = "ExecutePriceText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = orderTask.SetPrice,
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBox LotText = new TextBox()
            {
                Name = "LotText",
                Width = 100,
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = orderTask.Lot.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right,
                TextAlignment = TextAlignment.Right
            };

            StackPanel valuePanel = new StackPanel() { Name = "valuePanel", Orientation = Orientation.Vertical };
            valuePanel.Margin = new Thickness(0, 10, 0, 0);
            valuePanel.HorizontalAlignment = HorizontalAlignment.Right;
            valuePanel.VerticalAlignment = VerticalAlignment.Center;
            valuePanel.Children.Add(BLCheckBox);
            valuePanel.Children.Add(BalanceText);
            valuePanel.Children.Add(EquityText);
            valuePanel.Children.Add(NecessaryText);
            valuePanel.Children.Add(UsableText);
            valuePanel.Children.Add(TotalBuyText);
            valuePanel.Children.Add(TotalSellText);
            valuePanel.Children.Add(NetText);
            valuePanel.Children.Add(SetPriceText);
            valuePanel.Children.Add(ExecutePriceText);
            valuePanel.Children.Add(LotText);

            Grid.SetRow(valuePanel, 0);
            Grid.SetColumn(valuePanel, 1);

            //按钮
            Button ok = new Button() { Name = "okBtn", Content = "Yes", Width = 60, Height = 25, TabIndex = 1, Margin = new Thickness(25, 0, 0, 0) };
            Button cancel = new Button() { Name = "cancelBtn", Content = "No", Width = 60, Height = 25, Margin = new Thickness(25, 0, 0, 0) };
            ok.Click += new RoutedEventHandler(ok_Click);
            cancel.Click += new RoutedEventHandler(cancel_Click);

            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.Children.Add(ok);
            panel.Children.Add(cancel);
            panel.VerticalAlignment = VerticalAlignment.Bottom;
            panel.HorizontalAlignment = HorizontalAlignment.Center;
            panel.Margin = new Thickness(5);
            Grid.SetRow(panel, 1);
            Grid.SetColumnSpan(panel, 2);

            Grid layoutGrid = new Grid();

            LinearGradientBrush brush = new LinearGradientBrush();
            brush.StartPoint = new Point(0.5, 0);
            brush.EndPoint = new Point(0.5, 1);
            GradientStop stop = new GradientStop();

            stop = new GradientStop();
            stop.Color = Colors.LightGray;
            stop.Offset = 0.25;

            stop = new GradientStop();
            stop.Color = Color.FromArgb(0XFF, 0x4F, 0x4F, 0x4F);
            stop.Offset = 0.65;
            brush.GradientStops.Add(stop);

            layoutGrid.Background = brush;

            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(350) });
            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
            layoutGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(160) });
            layoutGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(160) });
            layoutGrid.Children.Add(captionPanel);
            //layoutGrid.Children.Add(scrollViewer2);
            layoutGrid.Children.Add(valuePanel);
            layoutGrid.Children.Add(panel);

            this._ConfirmOrderDialogWin.Content = layoutGrid;
            int columnSpan = this._LayoutContainer.ColumnDefinitions.Count;
            int rowSpan = this._LayoutContainer.RowDefinitions.Count;
            if (columnSpan > 0) Grid.SetColumnSpan(this._ConfirmOrderDialogWin, columnSpan);
            if (rowSpan > 0) Grid.SetRowSpan(this._ConfirmOrderDialogWin, rowSpan);

            if (!this._LayoutContainer.Children.Contains(this._ConfirmOrderDialogWin))
            {
                this._LayoutContainer.Children.Add(this._ConfirmOrderDialogWin);
            }

            this._ConfirmOrderDialogWin.Show();
        }
Ejemplo n.º 2
0
        public void ShowDialogWin(AccountInfor accountInfor, string caption, OrderTask orderTask, UIElement uIElement, HandleAction action)
        {
            this.ShowDialogWin(accountInfor, caption, orderTask, action);

            var captionPanel = this._ConfirmOrderDialogWin.FindName("captionPanel") as StackPanel;
            if (captionPanel != null)
            {
                captionPanel.Children.Add(uIElement);

                this._ConfirmOptionElement = uIElement;
                this._OrderTask = orderTask;
                this._HandleAction = action;
            }
        }