Beispiel #1
0
        public void AddExplicit()
        {
            var coll = new SortableBindingList <int>();

            coll.Add(1);
            coll.Add(2);
            coll.Add(1);
            coll.Insert(0, 1);
            coll.ApplySort(ListSortDirection.Ascending);
            AssertConsistency(coll);
            AssertSorted(coll);

            // adding after sorted
            coll.Add(1);
            coll.Add(2);
            coll.Add(1);
            coll.Insert(0, 1);
            AssertConsistency(coll);

            // switching on sort on change sorts immediately
            coll.SortOnChange = true;
            AssertConsistency(coll);
            AssertSorted(coll);

            // adding when SortOnChange is true sorts on add
            coll.Add(0);
            AssertConsistency(coll);
            AssertSorted(coll);
        }
        void Instance_handleDtcMessageReceived(object sender, IncomingDtcMessageEventArgs e)
        {
            IncomingDeliveryOrderObject d;

            if (e.DtcMessage is IncomingDeliveryOrderObject)
            {
                d = (IncomingDeliveryOrderObject)e.DtcMessage;
            }
            else
            {
                return;
            }

            if (d.Receiver == Settings.Account.Padded() || d.Deliverer == Settings.Account.Padded())
            {
                try
                {
                    new Thread((ThreadStart) delegate()
                    {
                        this.BeginInvoke((ThreadStart) delegate()
                        {
                            Orders.Insert(0, d);
                            //Orders.Sort("DateAndTimeStamp", ListSortDirection.Descending);
                            dgvDeliveryOrders.Refresh();
                        });
                    }).Start();
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex, TraceEnum.LoggedError);
                }
            }
        }
        private void OnDragDrop(object sender, DragEventArgs drgevent)
        {
            //runs after a drag/drop operation for column/row has completed
            if (dataGridViewBurn.AllowDrop)
            {
                if (drgevent.Effect == DragDropEffects.Move)
                {
                    Point ClientPoint = dataGridViewBurn.PointToClient(new Point(drgevent.X, drgevent.Y));

                    DragDropTargetIndex = dataGridViewBurn.HitTest(ClientPoint.X, ClientPoint.Y).RowIndex;
                    if (DragDropTargetIndex > -1 && DragDropCurrentIndex < dataGridViewBurn.RowCount - 1)
                    {
                        DragDropCurrentIndex = -1;
                        TrackData track = bindingList[DragDropSourceIndex];
                        bindingList.RemoveAt(DragDropSourceIndex);

                        if (DragDropTargetIndex > DragDropSourceIndex)
                        {
                            DragDropTargetIndex--;
                        }

                        bindingList.Insert(DragDropTargetIndex, track);

                        dataGridViewBurn.ClearSelection();
                        dataGridViewBurn.Rows[DragDropTargetIndex].Selected = true;
                    }
                }
            }
            base.OnDragDrop(drgevent);
        }
Beispiel #4
0
 private void RefreshGuideChannels()
 {
     _guideChannels = new SortableBindingList <GuideChannel>(Proxies.GuideService.GetAllChannels(_channelGroupControl.ChannelType).Result);
     _guideChannels.Insert(0, new GuideChannel()
     {
         Name        = String.Empty,
         XmlTvId     = String.Empty,
         ChannelType = _channelGroupControl.ChannelType
     });
     _guideChannelColumn.DataPropertyName = "GuideChannelId";
     _guideChannelColumn.DisplayMember    = "Name";
     _guideChannelColumn.ValueMember      = "GuideChannelId";
     _guideChannelColumn.DataSource       = _guideChannels;
 }
        public void LoadSecurityData(OpenPositionItem monitorItem)
        {
            List <TemplateStock>            stocks    = _templateBLL.GetStocks(monitorItem.TemplateId);
            List <OpenPositionSecurityItem> secuItems = new List <OpenPositionSecurityItem>();

            foreach (var stock in stocks)
            {
                OpenPositionSecurityItem secuItem = new OpenPositionSecurityItem
                {
                    Selection     = true,
                    MonitorId     = monitorItem.MonitorId,
                    MonitorName   = monitorItem.MonitorName,
                    SecuCode      = stock.SecuCode,
                    SecuName      = stock.SecuName,
                    WeightAmount  = stock.Amount,
                    EntrustAmount = monitorItem.Copies * stock.Amount,
                    EDirection    = EntrustDirection.BuySpot,
                    SecuType      = SecurityType.Stock
                };

                _securityDataSource.Add(secuItem);
            }

            var templateItem = _templateBLL.GetTemplate(monitorItem.TemplateId);

            if (templateItem != null)
            {
                //Load the future
                OpenPositionSecurityItem futureItem = new OpenPositionSecurityItem
                {
                    Selection     = true,
                    MonitorId     = monitorItem.MonitorId,
                    MonitorName   = monitorItem.MonitorName,
                    SecuCode      = monitorItem.FuturesContract,
                    SecuName      = monitorItem.FuturesContract,
                    WeightAmount  = templateItem.FutureCopies,
                    EntrustAmount = monitorItem.Copies * templateItem.FutureCopies,
                    EDirection    = EntrustDirection.SellOpen,
                    SecuType      = SecurityType.Futures
                };

                int pos = _securityDataSource.Count - stocks.Count;
                _securityDataSource.Insert(pos, futureItem);
            }
        }
Beispiel #6
0
        public void AddInner()
        {
            var inner = new List <string>();
            var coll  = new SortableBindingList <string>(inner)
            {
                CheckConsistency = false
            };

            coll.Add("x");
            coll.Add("z");
            coll.Add("y");
            coll.ApplySort(ListSortDirection.Ascending);

            // causing inconsistency
            inner.Add("a");
            inner.RemoveAt(0); // making sure inner length does not change; otherwise, inconsistency is detected and fixed in Assert
            Throws <AssertionException>(() => AssertConsistency(coll));
            coll.CheckConsistency = true;

            // inconsistency detected and fixed on next insert
            coll.Insert(0, "b");
            AssertConsistency(coll);
        }
Beispiel #7
0
 private void RefreshGuideChannels()
 {
     _guideChannels = new SortableBindingList<GuideChannel>(Proxies.GuideService.GetAllChannels(_channelGroupControl.ChannelType).Result);
     _guideChannels.Insert(0, new GuideChannel()
     {
         Name = String.Empty,
         XmlTvId = String.Empty,
         ChannelType = _channelGroupControl.ChannelType
     });
     _guideChannelColumn.DataPropertyName = "GuideChannelId";
     _guideChannelColumn.DisplayMember = "Name";
     _guideChannelColumn.ValueMember = "GuideChannelId";
     _guideChannelColumn.DataSource = _guideChannels;
 }