Esempio n. 1
0
    public EditorBar(Rect barArea, bool handles, HandleAction action)
    {
        drawArea = barArea;
        if (handles)
        {
          this.handles = new BarHandle[2] { new BarHandle(), new BarHandle() };
        }

        if (texture == null)
        {
          texture = Resources.LoadAssetAtPath("Assets/RwtM/Textures/Editor/bartexture_1px.png", typeof(Texture2D)) as Texture2D;
        }
    }
Esempio n. 2
0
    public EditorBar(Rect barArea, bool handles, HandleAction action)
    {
        drawArea = barArea;
        if (handles)
        {
            this.handles = new BarHandle[2] {
                new BarHandle(), new BarHandle()
            };
        }

        if (texture == null)
        {
            texture = Resources.LoadAssetAtPath("Assets/RwtM/Textures/Editor/bartexture_1px.png", typeof(Texture2D)) as Texture2D;
        }
    }
    public void Atacar(GameObject enemigo)
    {
        ataque                 = new HandleAction();
        ataque.atacante        = heroe.nombre;
        ataque.tipoAtacante    = HandleAction.TipoAtacante.PERSONAJE;
        ataque.atacanteGameObj = this.gameObject;
        ataque.ataque          = heroe.ataque;

        //Seleccionamos el objetivo
        ataque.objetivoGameObj = enemigo;

        //Añadimos la accion al sistema de batalla
        sistemaTurnos.RealizarAccion(ataque);

        StartCoroutine(Accion(enemigo));

        estadoTurno = EstadoTurno.ESPERANDO;
    }
    public void LanzarMagia(AtaqueBase magia, GameObject enemigo)
    {
        ataque                 = new HandleAction();
        ataque.atacante        = heroe.nombre;
        ataque.tipoAtacante    = HandleAction.TipoAtacante.PERSONAJE;
        ataque.atacanteGameObj = gameObject;
        ataque.ataque          = magia;

        //Seleccionamos el objetivo
        ataque.objetivoGameObj = enemigo;

        //Eliminar Mana
        heroe.manaActual -= magia.coste;
        sistemaTurnos.sistemaDMG.GastarMana();

        //Añadimos la accion al sistema de batalla
        sistemaTurnos.RealizarAccion(ataque);

        StartCoroutine(Accion(enemigo));
    }
    private void JugarTurno()
    {
        //Creamos una accion para el enemigo
        accion                 = new HandleAction();
        accion.atacante        = enemigo.nombre;
        accion.tipoAtacante    = HandleAction.TipoAtacante.ENEMIGO;
        accion.atacanteGameObj = this.gameObject;
        accion.ataque          = enemigo.ataque;

        //Seleccionamos un objetivo aleatorio para atacar
        int eleccion = Random.Range(0, sistemaTurnos.heroesCombate.Count);

        while (sistemaTurnos.heroesCombate[eleccion].CompareTag("Muerto"))
        {
            eleccion = Random.Range(0, sistemaTurnos.heroesCombate.Count);
        }

        objetivo = sistemaTurnos.heroesCombate[eleccion];
        accion.objetivoGameObj = objetivo;

        //Añadimos la accion al sistema de batalla
        sistemaTurnos.RealizarAccion(accion);
    }
        //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();
        }
        //Modify SetPrice
        public void ShowDialogWin(string caption, OrderTask orderTask,string origin, HandleAction action)
        {
            if (this._ModifyPriceDialogWin == null)
            {
                this._ModifyPriceDialogWin = new XamDialogWindow()
                {
                    Width = 250,
                    Height = 150,
                    Header = caption,
                    StartupPosition = Infragistics.Controls.Interactions.StartupPosition.Center,
                    IsModal = true,
                    CloseButtonVisibility = Visibility.Collapsed,
                    MinimizeButtonVisibility = Visibility.Collapsed,
                    MaximizeButtonVisibility = Visibility.Collapsed,
                };
            }
            this._HandleAction = action;
            this._OrderTask = orderTask;
            this._Origin = origin;
            TextBlock ModifyPriceLable = new TextBlock()
            {
                Name = "ModifyPriceLable",
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = "Input new Price:",
                Margin = new Thickness(5),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            TextBox NewPriceText = new TextBox()
            {
                Name = "NewPriceText",
                Width = 100,
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = orderTask.SetPrice,
                Margin = new Thickness(5),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left,
                TextAlignment = TextAlignment.Right
            };
            this._NewPriceElement = NewPriceText;

            StackPanel ModifyPricePanle = new StackPanel() { Name = "captionPanel", Orientation = Orientation.Horizontal };
            ModifyPricePanle.Margin = new Thickness(15, 0, 0, 0);
            ModifyPricePanle.HorizontalAlignment = HorizontalAlignment.Left;
            ModifyPricePanle.VerticalAlignment = VerticalAlignment.Center;
            ModifyPricePanle.Children.Add(ModifyPriceLable);
            ModifyPricePanle.Children.Add(NewPriceText);

            Grid.SetRow(ModifyPricePanle, 0);

            //按钮
            Button ModifyPriceOk = new Button() { Name = "ModifyPriceOkBtn", Content = "OK", Width = 60, Height = 24, TabIndex = 1, Margin = new Thickness(25, 0, 0, 0) };
            Button ModifyPriceCancel = new Button() { Name = "ModifyPriceCancelBtn", Content = "Cancel", Width = 60, Height = 24, Margin = new Thickness(25, 0, 0, 0) };
            ModifyPriceOk.Click += new RoutedEventHandler(ModifyPriceOkBtn_Click);
            ModifyPriceCancel.Click += new RoutedEventHandler(ModifyPriceCancelBtn_Click);

            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.Children.Add(ModifyPriceOk);
            panel.Children.Add(ModifyPriceCancel);
            panel.VerticalAlignment = VerticalAlignment.Bottom;
            panel.HorizontalAlignment = HorizontalAlignment.Center;
            panel.Margin = new Thickness(5);
            Grid.SetRow(panel, 1);

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

            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(40) });
            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(40) });
            layoutGrid.Children.Add(ModifyPricePanle);
            layoutGrid.Children.Add(panel);

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

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

            this._ModifyPriceDialogWin.Show();
        }
        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;
            }
        }
    public void HacerDMG(HandleAction accion)
    {
        HeroeBase   heroe;
        EnemigoBase enemigo;
        int         daño   = 0;
        AtaqueBase  ataque = accion.ataque;

        float modificadorFuerza       = 0.5f;
        float modificadorInteligencia = 0.5f;

        if (accion.atacanteGameObj.CompareTag("Player"))
        {
            heroe   = accion.atacanteGameObj.GetComponent <HeroeStateMachine>().heroe;
            enemigo = accion.objetivoGameObj.GetComponent <EnemigoStateMachine>().enemigo;

            if (accion.ataque.tipoAtaque.Equals(AtaqueBase.TipoAtaque.FISICO))
            {
                daño = Mathf.RoundToInt((((heroe.fuerza * modificadorFuerza) + accion.ataque.damage) - (enemigo.resistenciaF)));
            }
            else if (accion.ataque.tipoAtaque.Equals(AtaqueBase.TipoAtaque.MAGICO))
            {
                daño = Mathf.RoundToInt((((heroe.inteligencia * modificadorInteligencia) + accion.ataque.damage) - (enemigo.resistenciaM)) * calcularModificador(ataque, enemigo));
            }

            if (daño < 0)
            {
                daño = 0;
            }

            accion.damage = daño;
            accion.objetivoGameObj.GetComponent <EnemigoStateMachine>().enemigo.vidaActual -= accion.damage;

            if (accion.objetivoGameObj.GetComponent <EnemigoStateMachine>().enemigo.vidaActual < 0)
            {
                accion.objetivoGameObj.GetComponent <EnemigoStateMachine>().enemigo.vidaActual = 0;
            }

            accion.objetivoGameObj.GetComponent <EnemigoStateMachine>().AnimacionRecibirDMG();
            statHandler.ActualizarInfo();
        }
        else if (accion.atacanteGameObj.CompareTag("Enemigo"))
        {
            enemigo = accion.atacanteGameObj.GetComponent <EnemigoStateMachine>().enemigo;
            heroe   = accion.objetivoGameObj.GetComponent <HeroeStateMachine>().heroe;

            if (accion.ataque.tipoAtaque.Equals(AtaqueBase.TipoAtaque.FISICO))
            {
                daño = Mathf.RoundToInt((((enemigo.fuerza * modificadorFuerza) + accion.ataque.damage) - (heroe.resistenciaF)));
            }
            else if (accion.ataque.tipoAtaque.Equals(AtaqueBase.TipoAtaque.MAGICO))
            {
                daño = Mathf.RoundToInt((((enemigo.inteligencia * modificadorInteligencia) + accion.ataque.damage) - (heroe.resistenciaM)));
            }

            if (daño < 0)
            {
                daño = 0;
            }

            accion.damage = daño;
            accion.objetivoGameObj.GetComponent <HeroeStateMachine>().heroe.vidaActual -= accion.damage;

            if (accion.objetivoGameObj.GetComponent <HeroeStateMachine>().heroe.vidaActual < 0)
            {
                accion.objetivoGameObj.GetComponent <HeroeStateMachine>().heroe.vidaActual = 0;
            }

            accion.objetivoGameObj.GetComponent <HeroeStateMachine>().AnimacionRecibirDMG();
        }

        SpawnDMG(daño, accion.objetivoGameObj, "daño");
        sistemaMenus.sistemaBreak.IncrementarBarra(daño * 0.015f);
    }
Esempio n. 10
0
 public void RealizarAccion(HandleAction accion)
 {
     listaAcciones.Add(accion);
 }
Esempio n. 11
0
 private void ShowConfirmOrderFrm(bool canDealerViewAccountInfo, OrderTask orderTask,HandleAction action)
 {
     string message = string.Empty;
     string title = string.Empty;
     this.GetAccountInforCaption(action,out message,out title);
     if (canDealerViewAccountInfo)
     {
         //just test data
         AccountInformation accountInfor = ConsoleClient.Instance.GetAcountInfo(orderTask.ExchangeCode, orderTask.Transaction.Id);
         if (accountInfor == null)
         {
             this._App._CommonDialogWin.ShowDialogWin("Get account information failed!","Error");
             return;
         }
         this._App._ConfirmOrderDialogWin.ShowDialogWin(accountInfor, title, orderTask, action);
     }
     else
     {
         if (MessageBox.Show(message, title, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             this.Commit(orderTask, string.Empty, (decimal)orderTask.Lot);
         }
     }
 }
Esempio n. 12
0
        //修改价格
        void ModifyPriceHandle(bool yesOrNo, string newPrice, OrderTask orderTask, HandleAction action)
        {
            if (yesOrNo)
            {
                if (action == HandleAction.OnOrderModify)
                {
                    //Check Modify Price DailyMaxMove
                    InstrumentClient instrument = orderTask.Transaction.Instrument;
                    if (OrderTaskManager.IsLimitedPriceByDailyMaxMove(newPrice, instrument))
                    {
                        string msg = "Out of daily max move,previous close price is " + instrument.PreviousClosePrice;
                        this._CommonDialogWin.ShowDialogWin(msg, "Alert");
                        return;
                    }
                    bool? isValidPrice = false;
                    isValidPrice = OrderTaskManager.IsValidPrice(instrument,decimal.Parse(newPrice));

                    if(isValidPrice.HasValue)
                    {
                        if (isValidPrice.Value)
                        {
                            orderTask.BestPrice = newPrice;
                            orderTask.SetPrice = newPrice;
                        }
                    }
                }
            }
        }
Esempio n. 13
0
 private void GetAccountInforCaption(HandleAction action,out string message, out string title)
 {
     message = string.Empty;
     title = string.Empty;
     switch (action)
     {
         case HandleAction.OnOrderAccept:
             message = "Accept the order?";
             title = "Confirm";
             break;
         case HandleAction.OnOrderExecute:
             message = "Execute the order?";
             title = "Execute";
             break;
     }
 }
Esempio n. 14
0
 //成交单
 void ExecuteOrderHandle(bool yesOrNo, OrderTask orderTask, HandleAction action)
 {
     if (yesOrNo)
     {
         switch(action)
         {
             case HandleAction.None:
                 break;
             case HandleAction.OnOrderAccept:
                 this.Commit(orderTask, string.Empty, (decimal)orderTask.Lot);
                 break;
             case HandleAction.OnOrderExecute:
                 this.Commit(orderTask, string.Empty, (decimal)orderTask.Lot);
                 break;
         }
     }
 }
        //Reject Order DialogWin
        public void ShowRejectOrderWin(string rejectMessage, OrderTask orderTask, HandleAction action)
        {
            if (this._RejectOrderDialogWin == null)
            {
                this._RejectOrderDialogWin = new XamDialogWindow()
                {
                    Width = 300,
                    Height = 140,
                    Header = "Confirm",
                    StartupPosition = Infragistics.Controls.Interactions.StartupPosition.Center,
                    IsModal = true,
                    CloseButtonVisibility = Visibility.Collapsed,
                    MinimizeButtonVisibility = Visibility.Collapsed,
                    MaximizeButtonVisibility = Visibility.Collapsed,
                };
            }
            this._OrderTask = orderTask;
            this._HandleAction = action;
            TextBlock alertLable = new TextBlock()
            {
                Name = "AlertLable",
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = "Are you sure?",
                Margin = new Thickness(5),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            TextBlock RejectOrderMessage = new TextBlock()
            {
                Name = "RejectOrderMessage",
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = rejectMessage,
                Margin = new Thickness(5,15,0,0),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            StackPanel RejectOrderPanel = new StackPanel() { Name = "RejectOrderPanel", Orientation = Orientation.Vertical };
            RejectOrderPanel.Margin = new Thickness(15, 0, 0, 0);
            RejectOrderPanel.HorizontalAlignment = HorizontalAlignment.Left;
            RejectOrderPanel.VerticalAlignment = VerticalAlignment.Center;
            RejectOrderPanel.Children.Add(alertLable);
            RejectOrderPanel.Children.Add(RejectOrderMessage);

            Grid.SetRow(RejectOrderPanel, 0);

            //按钮
            Button RejectOrderOk = new Button() { Name = "RejectOrderOk", Content = "Yes", Width = 60, Height = 24, TabIndex = 1, Margin = new Thickness(25, 5, 0, 0) };
            Button RejectOrderCancel = new Button() { Name = "RejectOrderCancel", Content = "No", Width = 60, Height = 24, Margin = new Thickness(25, 5, 0, 0) };
            RejectOrderOk.Click += new RoutedEventHandler(RejectOrderOk_Click);
            RejectOrderCancel.Click += new RoutedEventHandler(RejectOrderCancel_Click);

            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.Children.Add(RejectOrderOk);
            panel.Children.Add(RejectOrderCancel);
            panel.VerticalAlignment = VerticalAlignment.Bottom;
            panel.HorizontalAlignment = HorizontalAlignment.Center;
            panel.Margin = new Thickness(5);
            Grid.SetRow(panel, 1);

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

            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
            layoutGrid.Children.Add(RejectOrderPanel);
            layoutGrid.Children.Add(panel);

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

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

            this._RejectOrderDialogWin.Show();
        }
Esempio n. 16
0
 //NB: using various fields with various names is future work
 public override HandleAction ToHandleAction(string target = "", HandleAction prev = null)
 => new B.TearOne()
 {
     Name = B.SystemPlan.Dealias(Name), Target = "value"
 };
Esempio n. 17
0
 //取消单
 void RejectOrderHandle(bool yesOrNo, OrderTask orderTask, HandleAction action)
 {
     if (yesOrNo)
     {
         switch (action)
         {
             case HandleAction.OnOrderRejectPlace:
                 this.CancelTransaction(orderTask);
                 break;
             case HandleAction.OnOrderCancel:
                 this.CancelTransaction(orderTask);
                 break;
             case HandleAction.OnLMTExecute:
                 var s = "";
                 this.Commit(orderTask, string.Empty, (decimal)orderTask.Lot);
                 break;
         }
     }
 }
Esempio n. 18
0
 private void ShowConfirmOrderFrm(bool canDealerViewAccountInfo, OrderTask orderTask,HandleAction action)
 {
     string message = string.Empty;
     string title = string.Empty;
     this.GetAccountInforCaption(action,out message,out title);
     if (canDealerViewAccountInfo)
     {
         //just test data
         Manager.Common.AccountInformation accountInfor = ConsoleClient.Instance.GetAcountInfo(Guid.Empty);
         this._App._ConfirmOrderDialogWin.ShowDialogWin(accountInfor, title, orderTask, action);
     }
     else
     {
         if (MessageBox.Show(message, title, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             this.Commit(orderTask, string.Empty, (decimal)orderTask.Lot);
         }
     }
 }
Esempio n. 19
0
        public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            bool hasCSFileChanged     = false;
            bool needRestartOmnisharp = false;

            HandleAction action = (string path, string type, bool hasRemoveAction, string oldFile) =>
            {
                FileChangedWithAllowedCheck(path, type, oldFile);
                if (!hasCSFileChanged)
                {
                    hasCSFileChanged = Utility.IsCSharpScript(path);
                }

                // WORKAROUND: If have rename action for cs file, we need to restart Omnisharp
                // to take the intellisense back.
                if (!string.IsNullOrEmpty(oldFile) && !needRestartOmnisharp)
                {
                    needRestartOmnisharp = Utility.IsCSharpScript(oldFile);
                    if (needRestartOmnisharp)
                    {
                        var lockFile = PathManager.OmnisharpRestartLockFile();
                        if (!File.Exists(lockFile))
                        {
                            File.WriteAllText(PathManager.OmnisharpRestartLockFile(), "");
                        }
                    }
                }

                if (hasRemoveAction)
                {
                    if (Utility.IsFileAllowed(path))
                    {
                        ALLOWED_FILES_CACHE.Add(Path.GetFullPath(path));
                    }

                    if (!string.IsNullOrEmpty(oldFile))
                    {
                        ALLOWED_FILES_CACHE.Remove(Path.GetFullPath(oldFile));
                    }
                }
                else
                {
                    if (Utility.IsFileAllowed(path))
                    {
                        ALLOWED_FILES_CACHE.Add(Path.GetFullPath(path));
                    }
                }
            };

            foreach (string path in deletedAssets)
            {
                Utility.Log("deleting " + path);
                action(path, "delete", true);
            }

            for (int i = 0; i < movedAssets.Length; i++)
            {
                Utility.Log(string.Format("move {0} to {1}", movedFromAssetPaths[i], movedAssets[i]));
                action(movedAssets[i], "rename", true, movedFromAssetPaths[i]);
            }

            foreach (string path in importedAssets)
            {
                Utility.Log("chaning " + path);
                action(path, "change", false);
            }

            Utility.Log("hasCSFileChanged = " + hasCSFileChanged);

            if (hasCSFileChanged)
            {
#if !DISABLE_UCE_ASSOCIATION
                FileWatcher.SyncSolution();
#else
                FileWatcher.SendSyncProjectRequests();
#endif
            }

            File.WriteAllLines(PathManager.GetGoToFileCachePath(), ALLOWED_FILES_CACHE.ToArray());
        }