Ejemplo n.º 1
0
 public TrainingCostRow this[ListUpgrade type]
 {
     get
     {
         return(Rows.FirstOrDefault(r => r.ID_Unit == type));
     }
 }
Ejemplo n.º 2
0
        private void OneToGui(KomBankE komBank, string response)
        {
            if (string.IsNullOrEmpty(response))
            {
                var lastLine = Rows.LastOrDefault(r => r.Bank == komBank.GetAbbreviation());
                lastLine?.SetIfExpired();
                return;
            }

            var oneLine = JsonConvert.DeserializeObject <KomBankRatesLine>(response);
            var newLine = Mapper.Map <KomBankRateVm>(oneLine);

            var last = Rows.FirstOrDefault(r => r.Id == newLine.Id);

            if (last == null)
            {
                newLine.State = "Fresh";
                if (Rows.Any())
                {
                    Rows.Last().State = "";
                }
                Rows.Add(newLine);
            }
            else
            {
                last.SetIfExpired();
                last.LastCheck = newLine.LastCheck;
            }
        }
Ejemplo n.º 3
0
        internal void UpdateTableData(object msgUnit)
        {
            var targetOperation = ReadTargetOperation(msgUnit);

            if (targetOperation == "INSERT" || targetOperation == "Create")
            {
                AppendRow(msgUnit);
            }
            else
            {
                var beforeImage = GetBeforeAfterImage(msgUnit, true);
                var afterImage  = GetBeforeAfterImage(msgUnit, false);
                if (targetOperation == "DELETE")
                {
                    DeleteRow(beforeImage, afterImage);
                }
                else if (targetOperation == "DELETEALL")
                {
                    ClearRows();
                }
                else
                {
                    var payload        = beforeImage ?? afterImage;
                    var rowToBeUpdated = Rows.FirstOrDefault(r => r.Match(payload));
                    if (rowToBeUpdated != null)
                    {
                        rowToBeUpdated.Update(afterImage ?? beforeImage);
                    }
                    else if (targetOperation == "MERGE")
                    {
                        AppendRow(msgUnit, beforeImage, afterImage);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public SudokuCell GetCell(int columnNumber, int rowNumber)
        {
            var row  = Rows.FirstOrDefault(r => r.RowNumber == rowNumber);
            var cell = row.Cells.FirstOrDefault(c => c.ColumnNumber == columnNumber);

            return(cell);
        }
Ejemplo n.º 5
0
        public void Add(Memorial memorial)
        {
            var firstRow = Rows.FirstOrDefault();

            if (firstRow == null)
            {
                Rows.Add(new MemorialRow(_memorialVmFactory(memorial, () => Navigation), null));
                return;
            }
            var needAddRow = Rows.Last().Right != null;

            var prevRight = firstRow.Right;

            firstRow.ChangeItems(_memorialVmFactory(memorial, () => Navigation), firstRow.Left);

            for (var i = 1; i < Rows.Count; i++)
            {
                var row        = Rows[i];
                var prevRight1 = row.Right;
                row.ChangeItems(prevRight, row.Left);
                prevRight = prevRight1;
            }

            if (needAddRow)
            {
                Rows.Add(new MemorialRow(prevRight, null));
            }
        }
Ejemplo n.º 6
0
        //protected override void OnRefreshClicked() => Rows.SetItems(GetBillRows());
        protected override async Task OnRefreshClickedAsync()
        {
            IEnumerable <DailyBillsRow> rows = null;
            await Task.Run(() => rows = GetBillRows());

            UIThread.Run(() => Rows.SetItems(rows));
            FirstRow = Rows.FirstOrDefault();
        }
Ejemplo n.º 7
0
        public virtual void MergeWith(DataElement mergedElement)
        {
            int initialColumnsCount = Columns.Count;
            int initialRowsCount    = Rows.Count;

            for (int rowInd = 0; rowInd < mergedElement.Rows.Count; rowInd++)
            {
                if (string.IsNullOrEmpty(mergedElement.Rows[rowInd].Header) || !Rows.Any(r => r.Header.Equals(mergedElement.Rows[rowInd].Header, StringComparison.OrdinalIgnoreCase)))
                {
                    Row newRow = mergedElement.Rows[rowInd].Clone();
                    newRow.Data.InsertRange(0, Enumerable.Repeat <object>(null, initialColumnsCount));
                    Rows.Add(newRow);
                }
            }
            for (int colInd = 0; colInd < mergedElement.Columns.Count; colInd++)
            {
                if (string.IsNullOrEmpty(mergedElement.Columns[colInd].Header) || !Columns.Any(r => r.Header.Equals(mergedElement.Columns[colInd].Header, StringComparison.OrdinalIgnoreCase)))
                {
                    Column newColumn = mergedElement.Columns[colInd].Clone(false);
                    Columns.Add(newColumn);
                    foreach (Row row in Rows)
                    {
                        row.Data.Add(null);
                    }
                }
            }

            for (int rowInd = 0; rowInd < mergedElement.Rows.Count; rowInd++)
            {
                Row row = Rows.FirstOrDefault(r => !string.IsNullOrEmpty(r.Header) && r.Header.Equals(mergedElement.Rows[rowInd].Header, StringComparison.OrdinalIgnoreCase));
                if (row == null)
                {
                    row = Rows[initialRowsCount + rowInd];
                }
                for (int colInd = 0; colInd < mergedElement.Columns.Count; colInd++)
                {
                    if (mergedElement.Rows[rowInd].Data[colInd] != null)
                    {
                        int    dataIndex = initialColumnsCount + colInd;
                        Column column    = Columns.FirstOrDefault(r => !string.IsNullOrEmpty(r.Header) && r.Header.Equals(mergedElement.Columns[colInd].Header, StringComparison.OrdinalIgnoreCase));
                        if (column != null)
                        {
                            dataIndex = Columns.IndexOf(column);
                        }
                        if (row.Data[dataIndex] == null)
                        {
                            row.Data[dataIndex] = mergedElement.Rows[rowInd].Data[colInd];
                        }
                    }
                }
            }
            foreach (var item in Columns)
            {
                item.Data.Clear();
            }

            Normalize();
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 获取行
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 private GanttChartViewRow GetRow(Point e)
 {
     if (e.X < ((EndDate.Date - StartDate.Date).TotalDays + 1) * DateWidth + RowHeaderWidth - _HScrollBar.Value && e.Y > this.ColumnHeight && e.Y + _VScrollBar.Value < (Rows == null || !Rows.Any() ? 0 : Rows.Max(r => r.Bottom)) && Rows != null)
     {
         var y = e.Y + _VScrollBar.Value;
         return(Rows.FirstOrDefault(r => r.Top <= y && r.Bottom >= y));
     }
     return(null);
 }
Ejemplo n.º 9
0
        public void Handle(RetryMessage message)
        {
            var msg = Rows.FirstOrDefault(x => x.Id == message.Id);

            if (msg != null)
            {
                msg.Status = MessageStatus.RetryIssued;
            }
        }
Ejemplo n.º 10
0
        private void DeleteRow(Dictionary <string, CellValue> beforeImage, Dictionary <string, CellValue> afterImage)
        {
            var rowToBeDeleted = Rows.FirstOrDefault(r => r.Match(beforeImage ?? afterImage));

            if (rowToBeDeleted != null)
            {
                Rows.Remove(rowToBeDeleted);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Получить реальное полное минимальное значение по всему набору данных с учетом стеков и рядов
        /// </summary>
        /// <param name="scaleType"></param>
        /// <returns></returns>
        public decimal GetMin(ScaleType scaleType = ScaleType.First)
        {
            if (_isNormalizedRecord)
            {
                var seria = Rows.FirstOrDefault(_ => _.ScaleType == scaleType);
                return(null == seria ? 0 : seria.Items.Select(_ => _.Min).Min());
            }

            return(GetNormalizedRecord().GetMin(scaleType));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Finds the row corresponding to the y coordinate.
        /// Null if y is outside the table.
        /// </summary>
        /// <param name="y">The y.</param>
        /// <returns>The row or null if y is outside the table</returns>
        private Row FindRow(double y)
        {
            Row row = Rows.FirstOrDefault(_ => _.BeginY <= y && y <= _.EndY);

            if (row == null)
            {
                row = Rows.FirstOrDefault(_ => _.BeginY - ContentExtractor.Tolerance <= y && y <= _.EndY + ContentExtractor.Tolerance);
            }
            return(row);
        }
Ejemplo n.º 13
0
        public void Focus(StoredMessage msg)
        {
            if (msg == null)
            {
                FocusedRow = null;
                return;
            }

            FocusedRow = Rows.FirstOrDefault(row => row.MessageId == msg.MessageId && row.TimeSent == msg.TimeSent && row.Id == msg.Id);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Returns a cell at a given row, column.
        /// It creates a new cell if it does not exist.
        /// It will return the cell if it already exists
        /// </summary>
        /// <param name="rowNumber">Row Number</param>
        /// <param name="columnIndex">Column Index</param>
        /// <returns></returns>
        private Cell GetCell(int rowNumber, int columnIndex)
        {
            string reference = Utilities.BuildReference(rowNumber, columnIndex);
            var    row       = AllCells.FirstOrDefault(c => c.Key == rowNumber).Value;

            // Check if the cell already exists
            var cell = row == null ? null : row.FirstOrDefault(c => c.ColumnNumber == columnIndex);

            // Cell does not exist. Create one.
            if (cell == null)
            {
                cell = new Cell(reference)
                {
                    Stylesheet = _styleSheet
                };

                var currentRow = Rows.FirstOrDefault(r => r.Index == rowNumber);

                // If the row already exists, get the row. Else, create a new row
                List <Cell> thisRow = null;
                if (AllCells.ContainsKey(rowNumber))
                {
                    thisRow = AllCells[rowNumber];
                }
                else
                {
                    thisRow = new List <Cell>();
                    AllCells.Add(rowNumber, thisRow);
                }

                // Add cell to the current row.
                thisRow.Add(cell);

                // Add the current row to the list of rows if it does not exist in the list.
                if (currentRow == null)
                {
                    cell.Row = new Row(rowNumber);
                    Rows.Add(cell.Row);
                }
                else
                {
                    cell.Row = currentRow;
                }

                // Add the current column to the list of columns if it does not exist in the list.
                if (!Columns.ColumnsList.Any(c => c.Index == columnIndex))
                {
                    Columns.ColumnsList.Add(new Column {
                        Index = columnIndex
                    });
                }
            }

            return(cell);
        }
Ejemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="scaleType"></param>
        /// <returns></returns>
        public decimal GetMax(ScaleType scaleType = ScaleType.First)
        {
            if (_isNormalizedRecord)
            {
                var seria = Rows.FirstOrDefault(_ => _.ScaleType == scaleType);
                if (null == seria)
                {
                    return(0);
                }
                return(seria.Items.Select(_ => _.Max).Max());
            }

            return(GetNormalizedRecord().GetMax(scaleType));
        }
Ejemplo n.º 16
0
        public void UpdateMainHeaderRow(string[] tags)
        {
            MainHeaderRowCount = 0;

            if (Rows.Count != 0)
            {
                var searchRowsCount = Rows.Count < 50 ? Rows.Count : 50;

                var allTags = Tag.FromStrings(tags);
                var exTags  = allTags.Where(t => t.Direction == TagDirection.Exclude).ToArray();
                var inTags  = allTags.Where(t => t.Direction == TagDirection.Include).ToArray();

                Dictionary <int, double> weightDict = new Dictionary <int, double>();
                for (var i = searchRowsCount - 1; i >= 0; i--)
                {
                    if (!Rows[i].IsEmpty)
                    {
                        double weight      = 0.0;
                        var    uniqueCells = Rows[i].UniqueNotEmptyCells.Select(c => c.Value.Trim().ToLower()).ToArray();
                        weight = exTags.Any(t => uniqueCells.Any(c => c.Like(t.Value)))
                                ? 0
                                : uniqueCells.Count(c => inTags.Any(t => c.Like(t.Value))) + uniqueCells.Count(c => inTags.Where(t => t.IsStrong).Any(t => c.Like(t.Value))) * 5;
                        weightDict.Add(i, weight);
                    }
                }

                double maxWeight = weightDict.Select(kvp => kvp.Value).OrderByDescending(i => i).FirstOrDefault();
                if (maxWeight > 0)
                {
                    var headerRows      = weightDict.Where(kvp => kvp.Value == maxWeight).Select(kvp => kvp.Key).OrderBy(kvp => kvp);
                    int mainHeaderIndex = headerRows.FirstOrDefault();

                    int mainHeaderCnt = 1;
                    for (mainHeaderCnt = 1; mainHeaderCnt < headerRows.Count(); mainHeaderCnt++)
                    {
                        if (!headerRows.Contains(mainHeaderIndex + mainHeaderCnt))
                        {
                            break;
                        }
                    }

                    MainHeaderRowCount = mainHeaderCnt > 4 ? 1 : mainHeaderCnt;
                    MainHeader         = Rows.ElementAt(mainHeaderIndex);
                    return;
                }
            }
            MainHeader         = Rows.FirstOrDefault();
            MainHeaderRowCount = 1;
        }
Ejemplo n.º 17
0
        public Row Row(string rowHeader)
        {
            if (!HasRowHeaders)
            {
                throw new ArgumentException("DataElement " + Name + " doesn't have row headers");
            }

            var row = Rows.FirstOrDefault(r => r.Header.Equals(rowHeader, StringComparison.OrdinalIgnoreCase));

            if (row == null)
            {
                throw new IndexOutOfRangeException();
            }
            return(row);
        }
Ejemplo n.º 18
0
        public void Handle(SelectedMessageChanged message)
        {
            var msg = Selection.SelectedMessage;

            if (msg == null)
            {
                return;
            }

            var newFocusedRow = Rows.FirstOrDefault(row => row.MessageId == msg.MessageId &&
                                                    row.TimeSent == msg.TimeSent &&
                                                    row.Id == msg.Id);

            if (newFocusedRow != null)
            {
                Selection.SelectedMessage = newFocusedRow;
                NotifyPropertiesChanged();
            }
        }
Ejemplo n.º 19
0
        public Option <Result> GetWinner()
        {
            // check rows
            var winningRow = Rows.FirstOrDefault(r => FindWinner(r) != Position.Open);

            if (winningRow != null)
            {
                return(PositionOwnedBy(FindWinner(winningRow)));
            }

            // check columns
            var winningColumn = Columns.FirstOrDefault(c => FindWinner(c) != Position.Open);

            if (winningColumn != null)
            {
                return(PositionOwnedBy(FindWinner(winningColumn)));
            }

            return(Option <Result> .None());
        }
Ejemplo n.º 20
0
        void TryRebindMessageList(PagedResult <StoredMessage> pagedResult)
        {
            if (ShouldUpdateMessages(pagedResult))
            {
                var currentItem = FocusedRow;

                Rows.Clear();
                Rows.AddRange(pagedResult.Result);

                if (currentItem != null)
                {
                    FocusedRow = Rows.FirstOrDefault(item => item.Id == currentItem.Id);
                }
            }

            if (FocusedRow == null && Rows.Count > 0)
            {
                FocusedRow = Rows[0];
            }
        }
Ejemplo n.º 21
0
        private void RestoreNodes()
        {
            foreach (TreeNode node in s_ExpandedNodes)
            {
                TreeNode tn = Rows.FirstOrDefault(x =>
                                                  (x.Tag as MylistEntry).OriginalEntry.GetType() == (node.Tag as MylistEntry).OriginalEntry.GetType() &&
                                                  (x.Tag as MylistEntry).ID == (node.Tag as MylistEntry).ID);

                if (tn != null)
                {
                    SetIsExpanded(tn, true);
                }
            }

            if (s_SelectedNode != null &&
                (s_SelectedNode = Rows.FirstOrDefault(x =>
                                                      (x.Tag as MylistEntry).OriginalEntry.GetType() == (s_SelectedNode.Tag as MylistEntry).OriginalEntry.GetType() &&
                                                      (x.Tag as MylistEntry).ID == (s_SelectedNode.Tag as MylistEntry).ID)) != null)
            {
                ScrollIntoView(s_SelectedNode);
            }
        }
Ejemplo n.º 22
0
        ///// <summary>
        ///// 初始化DataTable 并且追加自有属性
        ///// </summary>
        ///// <param name="data"></param>
        ///// <param name="page"></param>
        ///// <param name="total"></param>
        ///// <param name="key"></param>
        ///// <param name="appendProperties"></param>
        //public EntityContainer(DataTable data, int page, int total,
        //    string key, Action<EntityPropertyContainer<T>> appendProperties) :
        //    this(data, page, total, key)
        //{
        //    Append(appendProperties);
        //    #region reg

        //    //var dataCollection = new EntityPropertyContainer<T>();
        //    //appendProperties.Invoke(dataCollection);
        //    //foreach (DataRow item in data.Rows)
        //    //{
        //    //    var item1 = item;
        //    //    IList<string> rowData =
        //    //        dataCollection.ProperyValue
        //    //        .Select(properyItem => properyItem(item1 as T).ToString()).ToList();
        //    //    // 创建DataList
        //    //    var row = _rows.FirstOrDefault(c => c.id == item[key].ToString());
        //    //    if (row != null){
        //    //        rowData.ForEach(c =>
        //    //        {
        //    //            row.cell.Add(c);
        //    //        });
        //    //    }
        //    //}
        //    //dataCollection.ProperyKey.ForEach(c =>
        //    //{
        //    //    _keys.Add(c);
        //    //});
        //    #endregion
        //}



        #endregion

        #region Append

        public EntityContainer <T> Append(Action <EntityPropertyContainer <T> > appendProperties)
        {
            var dataCollection = new EntityPropertyContainer <T>();

            appendProperties.Invoke(dataCollection);
            foreach (var item in _data)
            {
                var            item1   = item;
                IList <string> rowData =
                    dataCollection.ProperyValue
                    .Select(properyItem => (DoProperyItem(properyItem, item1) ?? "").ToString()).ToList();

                // 创建DataList
                var key = GetItemKey(item);
                var row = Rows.FirstOrDefault(c => c.Id == key);
                if (row != null)
                {
                    rowData.ForEach(c => row.Cell.Add(c));
                }
            }
            dataCollection.ProperyKey.ForEach(c => Keys.Add(c));
            return(this);
        }
Ejemplo n.º 23
0
        // runtime only
        public byte[] GetKey(string keyID, int level = 0)
        {
            // RFStatic.Log.Debug(this, "GetKey key {0} under user {1}", keyID, AccessingUsername);

            if (!IsOpen())
            {
                throw new RFSystemException(this, "Key Vault hasn't been opened yet.");
            }

            // prevent infinite recursion
            if (level == MAX_RECURSION)
            {
                return(null);
            }

            // do we have it secured by our password?
            var userRow = Rows.FirstOrDefault(r => r.Key.KeyID == keyID && r.Key.SecuredByUsername == AccessingUsername);

            if (userRow != null)
            {
                return(RIFF.Interfaces.Encryption.AES.AESUtils.SimpleDecryptWithPassword(userRow.CipherStream, AccessingPasswordHash, SALT_LENGTH));
            }

            // recursive try other keys we own
            foreach (var k in Rows.Where(r => r.Key.KeyID == keyID && r.Key.SecuredByKeyID != null))
            {
                var tryGetKey = GetKey(k.Key.SecuredByKeyID, level + 1);
                if (tryGetKey != null)
                {
                    return(RIFF.Interfaces.Encryption.AES.AESUtils.SimpleDecrypt(k.CipherStream, tryGetKey, SALT_LENGTH));
                }
            }

            // key not accessible to us
            return(null);
        }
Ejemplo n.º 24
0
        public void AddTilesToRow(int rowNumber, TileType tileType, int number, bool isFirstTakeFromCenterTable)
        {
            // Se è il mio turno
            if (IsMyTurn)
            {
                // Trovo la riga richiesta
                var rowToInsert = Rows.FirstOrDefault(q => q.Position.Equals(rowNumber));

                // Aggiungo le tile e calcolo le eccedenze
                var toFloor = rowToInsert.AddTiles(tileType, number);

                // Se è la prima presa, la tile primo giocatore va nel floor
                if (isFirstTakeFromCenterTable)
                {
                    FloorRow.Add(new Tile(TileType.Player1));
                }

                // Aggiungo le eccedenze al Floor
                FloorRow.AddRange(Enumerable.Range(0, toFloor).Select(q => new Tile(tileType)));

                // Segnalo che ho fatto
                IsMyTurn = false;
            }
        }
Ejemplo n.º 25
0
Archivo: Chart.cs Proyecto: TagruP/tpd
        private void doubleClickTimer_Tick(object sender, EventArgs e)
        {
            milliseconds += 100;

            //The timer has reached the double click time limit.
            if (milliseconds >= SystemInformation.DoubleClickTime)
            {
                doubleClickTimer.Stop();

                Row       clickedRow       = null;
                Row       relatedRow       = null;
                TimeBlock clickedTimeBlock = null;
                foreach (Row row in Rows.Where(p => p.IsVisible))
                {
                    if (row.Rect.Contains(doubleClickLocation))
                    {
                        clickedRow = row;
                        break;
                    }
                    else if (row.TimeBlocks.Find(p => p.Rect.Contains(doubleClickLocation)) != null)
                    {
                        relatedRow       = row;
                        clickedTimeBlock = row.TimeBlocks.Find(p => p.Rect.Contains(doubleClickLocation));
                        break;
                    }
                }

                Point eventGlobalLocation = new Point(doubleClickLocation.X + this.Left,
                                                      doubleClickLocation.Y + this.Top);

                if (isDoubleClick)
                {
                    if (clickedRow != null)
                    {
                        if (clickedRow.IconRect.Contains(doubleClickLocation))
                        {
                            RowIconDoubleClick?.Invoke(new RowClickedEventArgs()
                            {
                                ClickedRow = clickedRow, CursorLocation = eventGlobalLocation
                            });
                        }
                        else
                        {
                            RowDoubleClick?.Invoke(new RowClickedEventArgs()
                            {
                                ClickedRow = clickedRow, CursorLocation = eventGlobalLocation
                            });
                        }
                    }
                    else if (clickedTimeBlock != null && clickedTimeBlock.Clickable)
                    {
                        TimeBlockDoubleClick?.Invoke(new TimeBlockClickedEventArgs()
                        {
                            ClickedTimeBlock = clickedTimeBlock, RelatedRow = relatedRow, CursorLocation = eventGlobalLocation
                        });
                    }
                    else if (renderer.MainCanvas.Contains(doubleClickLocation))
                    {
                        Row horizontalRow = Rows.FirstOrDefault(p => p.Rect.Contains(1, doubleClickLocation.Y));

                        DateTime?clickedTime = null;
                        for (int i = 0; i < renderer.TimeXLocations.Count - 1; i++) //Loop to 1 less than the end so we don't get index exceptions
                        {
                            Tuple <DateTime, int, StringFormat> time = renderer.TimeXLocations[i];
                            Rectangle rowRect = horizontalRow.Rect;
                            rowRect.X     = time.Item2;
                            rowRect.Width = renderer.TimeXLocations[i + 1].Item2 - rowRect.X;

                            if (rowRect.Contains(doubleClickLocation))
                            {
                                clickedTime = time.Item1;
                                break;
                            }
                        }

                        MainCanvasDoubleClick?.Invoke(new CanvasClickedEventArgs()
                        {
                            RelatedRow = horizontalRow, ClickedLocation = clickedTime, CursorLocation = eventGlobalLocation
                        });
                    }
                }
                else
                {
                    if (clickedRow != null)
                    {
                        if (clickedRow.IconRect.Contains(doubleClickLocation))
                        {
                            RowIconSingleClick?.Invoke(new RowClickedEventArgs()
                            {
                                ClickedRow = clickedRow, CursorLocation = eventGlobalLocation
                            });
                        }
                        else
                        {
                            RowSingleClick?.Invoke(new RowClickedEventArgs()
                            {
                                ClickedRow = clickedRow, CursorLocation = eventGlobalLocation
                            });
                        }
                    }
                    else if (clickedTimeBlock != null && clickedTimeBlock.Clickable)
                    {
                        TimeBlockSingleClick?.Invoke(new TimeBlockClickedEventArgs()
                        {
                            ClickedTimeBlock = clickedTimeBlock, RelatedRow = relatedRow, CursorLocation = eventGlobalLocation
                        });
                    }
                    else if (renderer.MainCanvas.Contains(doubleClickLocation))
                    {
                        Row horizontalRow = Rows.FirstOrDefault(p => p.Rect.Contains(1, doubleClickLocation.Y));

                        DateTime?clickedTime = null;
                        for (int i = 0; i < renderer.TimeXLocations.Count - 1; i++) //Loop to 1 less than the end so we don't get index exceptions
                        {
                            Tuple <DateTime, int, StringFormat> time = renderer.TimeXLocations[i];
                            Rectangle rowRect = horizontalRow.Rect;
                            rowRect.X     = time.Item2;
                            rowRect.Width = renderer.TimeXLocations[i + 1].Item2 - rowRect.X;

                            if (rowRect.Contains(doubleClickLocation))
                            {
                                clickedTime = time.Item1;
                                break;
                            }
                        }

                        MainCanvasSingleClick?.Invoke(new CanvasClickedEventArgs()
                        {
                            RelatedRow = horizontalRow, ClickedLocation = clickedTime, CursorLocation = eventGlobalLocation
                        });
                    }
                }

                //Allow the MouseDown event handler to process clicks again.
                isFirstClick  = true;
                isDoubleClick = false;
                milliseconds  = 0;
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Adds a rate tier row to the ship rate table
        /// </summary>
        /// <param name="shipRateTier">
        /// The ship Rate Tier.
        /// </param>
        /// <remarks>
        /// Requires a call to Save() to persist
        /// </remarks>
        internal void AddRow(IShipRateTier shipRateTier)
        {
            if (!ValidateRateTier(ref shipRateTier))
            {
                return;
            }

            // TODO : Refactor this validation
            if (!Rows.Any())
            {
                shipRateTier.RangeLow = 0;
                _shipRateTiers.Add(shipRateTier);
            }
            else
            {
                // confirm there is not already a matching tier
                if (Rows.FirstOrDefault(x => x.RangeLow == shipRateTier.RangeLow && x.RangeHigh == shipRateTier.RangeHigh) != null)
                {
                    return;
                }

                // find the insertion point
                var index = Rows.IndexOf(Rows.Where(y => y.RangeHigh >= shipRateTier.RangeLow).OrderBy(z => z.RangeLow).FirstOrDefault());
                if (index < 0)
                {
                    shipRateTier.RangeLow = Rows.Last().RangeHigh;
                    AddRow(shipRateTier);
                    return;
                }

                // not found or at the end of the table
                if (index < 0 || index == Rows.IndexOf(Rows.Last()))
                {
                    if (shipRateTier.RangeLow >= Rows.Last().RangeLow&&
                        shipRateTier.RangeHigh < Rows.Last().RangeHigh)
                    {
                        shipRateTier.RangeLow = Rows.Last().RangeLow;
                        Rows.Last().RangeLow = shipRateTier.RangeHigh;
                    }

                    ////shipRateTier.RangeLow = Rows.Last().RangeHigh;
                    if (shipRateTier.RangeHigh <= shipRateTier.RangeLow)
                    {
                        return;
                    }
                    _shipRateTiers.Add(shipRateTier);
                }
                else
                {
                    // insert in the middle of the table
                    // verify that inserting this tier will not create a span encapsulating another tier
                    if (shipRateTier.RangeHigh >= _shipRateTiers[index + 1].RangeHigh)
                    {
                        return;
                    }
                    if (shipRateTier.RangeLow <= _shipRateTiers[index].RangeLow)
                    {
                        return;
                    }

                    // match the range low to range high in the following tier
                    _shipRateTiers[index + 1].RangeLow = shipRateTier.RangeHigh;

                    // verify that the high value at the current index is equal to the low value of the tier to be insert
                    _shipRateTiers[index].RangeHigh = shipRateTier.RangeLow;

                    _shipRateTiers.Insert(index + 1, shipRateTier);
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Gets the decimal rate associated with the range
        /// </summary>
        /// <param name="rangeValue">The value within a range used to determine which rate to return</param>
        /// <returns>A decimal rate or zero (0) if not found</returns>
        public decimal FindRate(decimal rangeValue)
        {
            var rateTier = Rows.FirstOrDefault(x => x.RangeLow < rangeValue && x.RangeHigh >= rangeValue);

            return(rateTier == null ? 0M : rateTier.Rate);
        }
Ejemplo n.º 28
0
 private ExcelRow GetRowAtPosition(float yPositionPoints)
 {
     return(Rows.FirstOrDefault(y => Math.Abs(y.YPosition - yPositionPoints) <= Tolerance));
 }
Ejemplo n.º 29
0
 public ISingleDataRow <T> FirstItem()
 {
     //if (!serie.Rows.Any()) return null;
     return(Rows.FirstOrDefault());
 }
Ejemplo n.º 30
0
 public T?First()
 {
     //if (!Rows.Any()) return null;
     return(Rows.FirstOrDefault()?.Value);
 }