private void ConnectorsGrid_DoubleClick(object sender, MouseButtonEventArgs e) { if (SelectedInfo == null) { return; } if (!CheckConnected(LocalizedStrings.Str1555)) { return; } var wnd = new MessageAdapterWindow { Adapter = SelectedInfo.Adapter }; if (!wnd.ShowModal(this)) { return; } SelectedInfo.Refresh(); ConnectorsChanged.SafeInvoke(); }
protected override bool OnAdding(ConnectorInfo item) { var mi = new MenuItem { Header = item.Name, ToolTip = item.Description }; mi.Click += (sender, args) => { // TODO var adapter = item.TransactionAdapterType.CreateInstanceArgs <IMessageAdapter>(new object[] { _parent.Adapter.TransactionIdGenerator }); var wnd = new MessageAdapterWindow { Adapter = adapter, }; if (!wnd.ShowModal(_parent)) { return; } var row = new ConnectorRow(item, wnd.Adapter); _parent.Adapter.InnerAdapters[wnd.Adapter] = 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)); }