コード例 #1
0
        private void ConnectorsGrid_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (SelectedInfo == null)
            {
                return;
            }

            if (!CheckConnected(LocalizedStrings.Str1555))
            {
                return;
            }

            var wnd = new SessionHolderWindow
            {
                SessionHolder = SelectedInfo.SessionHolder
            };

            if (!wnd.ShowModal(this))
            {
                return;
            }

            SelectedInfo.Refresh();

            ConnectorsChanged.SafeInvoke();
        }
コード例 #2
0
            protected override bool OnAdding(ConnectorInfo item)
            {
                var mi = new MenuItem
                {
                    Header  = item.Name,
                    ToolTip = item.Description
                };

                mi.Click += (sender, args) =>
                {
                    var sessionHolder = item.SessionHolderType.CreateInstanceArgs <IMessageSessionHolder>(new object[] { _parent.SessionHolder.TransactionIdGenerator });

                    //sessionHolder.IsMarketDataEnabled = sessionHolder.MarketDataAdapterType != null;
                    //sessionHolder.IsTransactionEnabled = sessionHolder.TransactionAdapterType != null;

                    var wnd = new SessionHolderWindow
                    {
                        SessionHolder = sessionHolder,
                    };

                    if (!wnd.ShowModal(_parent))
                    {
                        return;
                    }

                    var row = new ConnectorRow(item, wnd.SessionHolder);

                    _parent.SessionHolder.InnerSessions.Add(wnd.SessionHolder, 0);

                    _parent._connectorRows.Add(row);
                    _parent.ConnectorsChanged.SafeInvoke();
                };

                _items.Add(item, mi);

                var separator = Items
                                .OfType <HeaderedSeparator>()
                                .FirstOrDefault(s => s.Header == item.Category);

                if (separator == null)
                {
                    var key = item.PreferLanguage == _language ? -1 : (int)item.PreferLanguage;

                    separator = new HeaderedSeparator
                    {
                        Header = item.Category,
                        Tag    = key
                    };

                    var prev = Items.OfType <HeaderedSeparator>().FirstOrDefault();
                    if (prev != null && key >= (int)prev.Tag)
                    {
                        var index = Items
                                    .OfType <Control>()
                                    .Select((i, idx) => new { Item = i, Index = idx })
                                    .FirstOrDefault(p => p.Item.Tag != null && (int)p.Item.Tag > key);

                        if (index == null)
                        {
                            Items.Add(separator);
                        }
                        else
                        {
                            Items.Insert(index.Index, separator);
                        }
                    }
                    else
                    {
                        Items.Insert(0, separator);
                    }
                }

                var categoryIndex = Items.IndexOf(separator);

                var categoryItems = Items
                                    .Cast <object>()
                                    .Skip(categoryIndex + 1)
                                    .TakeWhile(o => !(o is HeaderedSeparator))
                                    .ToArray();

                Items.Insert(categoryIndex + categoryItems.Length + 1, mi);

                return(base.OnAdding(item));
            }