public BoxCollider2DRect(MonoBehaviour go) : base(go)
 {
     this.transform = go.transform;
     LeftEdge       = new LeftEdge(this);
     RightEdge      = new RightEdge(this);
     UpEdge         = new UpEdge(this);
     DownEdge       = new DownEdge(this);
 }
Beispiel #2
0
 public UGUIRect(Behaviour go) : base(go)
 {
     this.transform = go.GetComponent <RectTransform>();
     LeftEdge       = new LeftEdge(this);
     RightEdge      = new RightEdge(this);
     UpEdge         = new UpEdge(this);
     DownEdge       = new DownEdge(this);
     transform.GetWorldCorners(Corners);
 }
 internal RelativeLayoutResults(RectTransform transform, RelativeLayoutParams other)
 {
     Transform = transform ?? throw new ArgumentNullException(nameof(transform));
     if (other != null)
     {
         BottomEdge.CopyFrom(other.BottomEdge);
         TopEdge.CopyFrom(other.TopEdge);
         RightEdge.CopyFrom(other.RightEdge);
         LeftEdge.CopyFrom(other.LeftEdge);
         Insets       = other.Insets ?? ZERO;
         OverrideSize = other.OverrideSize;
     }
     else
     {
         Insets = ZERO;
     }
     BottomParams   = LeftParams = TopParams = RightParams = null;
     PreferredWidth = PreferredHeight = 0.0f;
     UseSizeDeltaX  = UseSizeDeltaY = false;
 }
 /*_________________________________________________________Обработка_событий_______________________________________________________*/
 #region Event handles
 private void JuliaEditor_Load(object sender, EventArgs e)
 {
     LeftEdgeEdit.Text         = LeftEdge.ToString();
     RightEdgeEdit.Text        = RightEdge.ToString();
     TopEdgeEdit.Text          = TopEdge.ToString();
     BottomEdgeEdit.Text       = BottomEdge.ToString();
     RealPartEdit.Text         = RealPart.ToString();
     ImaginePartEdit.Text      = ImaginePart.ToString();
     LeftEdgeEdit.KeyPress    += FormEventHandlers.OnlyNumeric;
     RightEdgeEdit.KeyPress   += FormEventHandlers.OnlyNumeric;
     TopEdgeEdit.KeyPress     += FormEventHandlers.OnlyNumeric;
     BottomEdgeEdit.KeyPress  += FormEventHandlers.OnlyNumeric;
     RealPartEdit.KeyPress    += FormEventHandlers.OnlyNumeric;
     ImaginePartEdit.KeyPress += FormEventHandlers.OnlyNumeric;
     EditDescriptor.SetToolTip(LeftEdgeLabel, FractalGlobalDescriptions.LeftEdgeOf2DFractal);
     EditDescriptor.SetToolTip(LeftEdgeEdit, "Здесь необходимо вводить левую границу двухмерного фрактала джулии (десятиричное представления числа).\n" + FractalGlobalDescriptions.LeftEdgeOf2DFractal);
     EditDescriptor.SetToolTip(RightEdgeLabel, FractalGlobalDescriptions.RightEdgeOf2DFractal);
     EditDescriptor.SetToolTip(RightEdgeEdit, "Здесь необходимо вводить правую границу двухмерного фрактала джулии (десятиричной представления числа, в качестве разделителей на дроную часть используйте \",\" или \".\").\n" + FractalGlobalDescriptions.RightEdgeOf2DFractal);
     GlobalTemplates.SetTemplate(MainPanelOfJuliaEditor, "Шрифт окна для ввода фрактала джулии");
 }
Beispiel #5
0
        private bool internalCancelOrder(int id, RightEdge.Common.BrokerOrder order)
        {
            Monitor.Exit(_lockObject);
            try
            {
                client.CancelOrder(id);
            }
            finally
            {
                Monitor.Enter(_lockObject);
            }

            if (unSubmittedOrders.ContainsKey(order.OrderId))
            {
                //	Apparently IB will not send us a cancellation confirmation in this case
                unSubmittedOrders.Remove(order.OrderId);
                order.OrderState = BrokerOrderState.Cancelled;

                openOrders.Remove(order.OrderId);

                OrderUpdatedDelegate tmp = OrderUpdated;
                if (tmp != null)
                {
                    tmp(order, null, "System Cancelled");
                }
            }
            return true;
        }
Beispiel #6
0
        public bool SubmitOrder(RightEdge.Common.BrokerOrder order, out string orderId)
        {
            Krs.Ats.IBNet.Order apiOrder = new Krs.Ats.IBNet.Order();
            Contract contract;
            int intOrderId;

            lock (_lockObject)
            {
                // Before we submit the order, we need to make sure the price is trimmed
                // to something that IB will accept.  In other words, if a price is submitted
                // for 40.1032988923, this will be get rejected.

                order.LimitPrice = RoundPrice(order.OrderSymbol, order.LimitPrice);
                order.StopPrice = RoundPrice(order.OrderSymbol, order.StopPrice);

                contract = TWSAssetArgs.Create(order.OrderSymbol).ToContract();

                if (order.TransactionType == TransactionType.Buy ||
                    order.TransactionType == TransactionType.Cover)
                {
                    apiOrder.Action = ActionSide.Buy;
                }
                else if (order.TransactionType == TransactionType.Sell)
                {
                    apiOrder.Action = ActionSide.Sell;
                }
                else if (order.TransactionType == TransactionType.Short)
                {
                    //	SShort is apparently only used as part of a combo leg, and you get an "Invalid side" error if you try to use it otherwise
                    //apiOrder.Action = ActionSide.SShort;
                    apiOrder.Action = ActionSide.Sell;
                }
                else
                {
                    throw new RightEdgeError("Cannot submit order with transaction type " + order.TransactionType.ToString());
                }

                double limitPrice = 0.0;
                double auxPrice = 0.0;

                switch (order.OrderType)
                {
                    case RightEdge.Common.OrderType.Limit:
                        apiOrder.OrderType = Krs.Ats.IBNet.OrderType.Limit;
                        limitPrice = order.LimitPrice;
                        break;

                    case RightEdge.Common.OrderType.LimitOnClose:
                        apiOrder.OrderType = Krs.Ats.IBNet.OrderType.LimitOnClose;
                        limitPrice = order.LimitPrice;
                        break;

                    case RightEdge.Common.OrderType.Market:
                    case RightEdge.Common.OrderType.MarketOnOpen:
                        apiOrder.OrderType = Krs.Ats.IBNet.OrderType.Market;
                        break;

                    case RightEdge.Common.OrderType.MarketOnClose:
                        apiOrder.OrderType = Krs.Ats.IBNet.OrderType.MarketOnClose;
                        break;

                    case RightEdge.Common.OrderType.PeggedToMarket:
                        apiOrder.OrderType = Krs.Ats.IBNet.OrderType.PeggedToMarket;
                        break;

                    case RightEdge.Common.OrderType.Stop:
                        apiOrder.OrderType = Krs.Ats.IBNet.OrderType.Stop;
                        auxPrice = order.StopPrice;
                        break;

                    case RightEdge.Common.OrderType.StopLimit:
                        apiOrder.OrderType = Krs.Ats.IBNet.OrderType.StopLimit;
                        auxPrice = order.StopPrice;
                        limitPrice = order.LimitPrice;
                        break;

                    //	TODO: investigate and add support for trailing stop
                    case RightEdge.Common.OrderType.TrailingStop:
                        if (order.TrailingStopType != TargetPriceType.RelativePrice)
                        {
                            lastError = order.TrailingStopType.ToString() + " trailing stops not supported by IB.";
                            orderId = null;
                            return false;
                        }
                        apiOrder.OrderType = Krs.Ats.IBNet.OrderType.TrailingStop;
                        auxPrice = order.TrailingStop;
                        break;
                    default:
                        lastError = "Order type not supported by IB service: " + order.OrderType.ToString();
                        orderId = null;
                        return false;
                }

                if (double.IsNaN(limitPrice))
                {
                    throw new RightEdgeError("Limit price for order cannot be NaN");
                }
                if (double.IsNaN(auxPrice))
                {
                    throw new RightEdgeError("Stop price for order cannot be NaN");
                }

                apiOrder.LimitPrice = (Decimal)limitPrice;
                apiOrder.AuxPrice = (Decimal)auxPrice;

                if (order.GoodTillCanceled)
                {
                    //DateTime gtcDate = GetAccountTime("SubmitOrder").AddMonths(12);
                    //apiOrder.GoodTillDate = gtcDate.ToString("yyyyMMdd");
                    //apiOrder.GoodTillDate = "";
                    apiOrder.GoodTillDate = "GTC";
                    apiOrder.Tif = TimeInForce.GoodTillCancel;
                }

                apiOrder.TotalQuantity = (int)order.Shares;
                apiOrder.FAGroup = accountCode;
                apiOrder.FAMethod = _FAMethod;
                apiOrder.FAPercentage = _FAPercentage;
                apiOrder.FAProfile = _FAProfile;
                //	TODOSOON: Verify that RTH still works after upgrading Krs library
                //if (_useRTH)
                //{
                //    apiOrder.IgnoreRth = true;
                //    apiOrder.RthOnly = true;
                //}
                apiOrder.OutsideRth = !_useRTH;

                orderId = nextOrderId.ToString();
                order.OrderId = orderId;
                openOrders.Add(orderId, order);

                unSubmittedOrders[order.OrderId] = true;

                intOrderId = nextOrderId;

                nextOrderId++;
            }

            client.PlaceOrder(intOrderId, contract, apiOrder);

            Trace.WriteLine("IB Sent: " + order.ToString());

            return true;
        }
Beispiel #7
0
    void Update()
    {
        TitleBar.sizeDelta    = TitleBar.sizeDelta.YChangedTo(DefaultTitleBarHeight);
        BackgroundImage.color = DefaultBackgroundColor;

        TitleText.text = FrontPage.Title;

        if (!Application.isPlaying)
        {
            return;
        }

        if (WindowContainer == null)
        {
            The.WindowContainer.AddWindow(this);
        }

        if (!IsOpen)
        {
            gameObject.SetActive(false);
            return;
        }
        else
        {
            foreach (Window subwindow in Subwindows)
            {
                subwindow.IsOpen = true;
            }
        }

        if (IsSubwindow)
        {
            IsMaximized = false;
            IsMinimized = ParentWindow.IsMinimized;
        }

        if (InputUtility.IsMouseLeftPressed && IsTouched)
        {
            MoveToFront();
        }

        if (!IsGrabbed)
        {
            resize_grab_type = ResizeGrabType.None;
            if (!IsMaximized && IsTouched)
            {
                if (LeftEdge.IsPointedAt())
                {
                    resize_grab_type = ResizeGrabType.Left;
                }
                else if (BottomLeftCorner.IsPointedAt())
                {
                    resize_grab_type = ResizeGrabType.BottomLeft;
                }
                else if (BottomEdge.IsPointedAt())
                {
                    resize_grab_type = ResizeGrabType.Bottom;
                }
                else if (BottomRightCorner.IsPointedAt())
                {
                    resize_grab_type = ResizeGrabType.BottomRight;
                }
                else if (RightEdge.IsPointedAt())
                {
                    resize_grab_type = ResizeGrabType.Right;
                }
            }
        }
        switch (resize_grab_type)
        {
        case ResizeGrabType.Left:
            The.Cursor.ChangeCursorImage(The.Cursor.LeftHorizontalResizeImage);
            break;

        case ResizeGrabType.Right:
            The.Cursor.ChangeCursorImage(The.Cursor.RightHorizontalResizeImage);
            break;

        case ResizeGrabType.BottomLeft:
            The.Cursor.ChangeCursorImage(The.Cursor.PositiveDiagonalResizeImage);
            break;

        case ResizeGrabType.BottomRight:
            The.Cursor.ChangeCursorImage(The.Cursor.NegativeDiagonalResizeImage);
            break;

        case ResizeGrabType.Bottom:
            The.Cursor.ChangeCursorImage(The.Cursor.VerticalResizeImage);
            break;
        }

        if (InputUtility.WasMouseLeftPressed && IsTouched &&
            (resize_grab_type != ResizeGrabType.None || TitleBar.IsPointedAt()))
        {
            IsGrabbed = true;

            grab_offset = PixelPosition - The.Cursor.PixelPointedAt;
        }
        if (IsGrabbed && InputUtility.WasMouseLeftReleased)
        {
            IsGrabbed = false;
        }

        if (IsGrabbed)
        {
            if (resize_grab_type == ResizeGrabType.None)
            {
                Vector2Int new_position = The.Cursor.PixelPointedAt + grab_offset;
                if (new_position != PixelPosition)
                {
                    IsMaximized = false;
                }

                natural_position = new_position;
            }
            else
            {
                Vector2Int new_position = natural_position,
                           new_size     = natural_size;

                int top_edge_height = natural_position.y + natural_size.y;

                Vector2Int displaced_position = The.Cursor.PixelPointedAt;
                Vector2Int displacement       = displaced_position - natural_position;

                if ((resize_grab_type == ResizeGrabType.Left ||
                     resize_grab_type == ResizeGrabType.BottomLeft) &&
                    displaced_position.x <= (natural_position.x + natural_size.x - MinimumSize.x))
                {
                    new_position.x = displaced_position.x;
                    new_size.x    += -displacement.x;
                }
                else if (resize_grab_type == ResizeGrabType.Right ||
                         resize_grab_type == ResizeGrabType.BottomRight)
                {
                    new_size.x = displaced_position.x - natural_position.x + 1;
                }

                if (resize_grab_type == ResizeGrabType.BottomLeft ||
                    resize_grab_type == ResizeGrabType.Bottom ||
                    resize_grab_type == ResizeGrabType.BottomRight)
                {
                    new_size.y = (natural_position.y + natural_size.y) - displaced_position.y + 1;
                }

                natural_position = new_position;
                natural_size     = new_size;

                natural_size.x = Mathf.Max(natural_size.x, MinimumSize.x);
                natural_size.y = Mathf.Max(natural_size.y, MinimumSize.y);

                natural_position.y += top_edge_height - (natural_position.y + natural_size.y);
            }
        }

        if (IsMaximized)
        {
            RectTransform.sizeDelta =
                new Vector2(The.Style.MonitorResolution.x,
                            The.Style.MonitorResolution.y - The.Taskbar.Height);

            RectTransform.anchoredPosition = new Vector2(0, The.Taskbar.Height);
        }
        else
        {
            RectTransform.sizeDelta =
                new Vector2(natural_size.x,
                            natural_size.y);

            RectTransform.anchoredPosition = new Vector2(natural_position.x,
                                                         natural_position.y);
        }

        if (IsMinimized)
        {
            CanvasGroup.alpha = 0;
        }
        else
        {
            CanvasGroup.alpha = 1;
        }
    }