Exemplo n.º 1
0
 public void AddLine(AverageLine line)
 {
     if (line != null && !Lines.Any(l => l.ID.Equals(line.ID)))
     {
         Lines.Add(line);
     }
 }
Exemplo n.º 2
0
        public override void Render(IRenderContext rc)
        {
            if (rc == null)
            {
                throw new ArgumentNullException(nameof(rc));
            }

            if (!Lines.Any() || Lines.All(a => !a.Any()))
            {
                return;
            }

            VerifyAxes();

            OxyRect clippingRect = GetClippingRect();

            rc.SetClip(clippingRect);

            // Transform all points to screen coordinates
            foreach (IEnumerable <DataPoint> line in Lines)
            {
                int n0   = line.Count();
                var pts0 = new ScreenPoint[n0];
                TransformToScreenCoordinates(n0, pts0, line);

                rc.DrawLine(pts0, Color, StrokeThickness, Dashes?.ToArray() ?? LineStyle.GetDashArray());
            }

            rc.ResetClip();
        }
Exemplo n.º 3
0
 public void Remove(int index)
 {
     //Check Lines has a item and index is valid or not.
     if (Lines.Any() && index <= Lines.Count)
     {
         Lines.RemoveAt(index);
     }
 }
Exemplo n.º 4
0
 public void QtyAdd(int index)
 {
     //Increase quantity.
     if (Lines.Any() && index <= Lines.Count)
     {
         Lines[index].Quantity++;
     }
 }
Exemplo n.º 5
0
        public CoverageDetails CalculateMethodCoverage(Lines lines)
        {
            var details = new CoverageDetails();

            details.Covered = lines.Any(l => l.Value > 0) ? 1 : 0;
            details.Total   = 1;
            return(details);
        }
Exemplo n.º 6
0
 public void Purchase()
 {
     if (Lines.Any(x => x.Product.Type == ProductType.BookClubMembership))
     {
         var orderedMembershipDomainEvent = new OrderedMembershipDomainEvent(this, CustomerId);
         this.AddDomainEvent(orderedMembershipDomainEvent);
     }
 }
Exemplo n.º 7
0
        public double CalculateMethodCoverage(Lines lines)
        {
            if (lines.Any(l => l.Value.Hits > 0))
            {
                return(1);
            }

            return(0);
        }
Exemplo n.º 8
0
        public void AddLine(Product product, int amount)
        {
            var nextLineId = Lines != null && Lines.Any() ? Lines.Max(x => x.LineNumber) + 1 : 1;

            if (Lines == null)
            {
                Lines = new HashSet <OrderLine>();
            }
            Lines.Add(new OrderLine(Id, nextLineId, product.Id, product.Name, product.Price, amount));
        }
Exemplo n.º 9
0
    /// <summary>
    /// Returns a string that represents the current object.
    /// </summary>
    /// <returns>The formatted description of a fixture.</returns>
    public override string ToString()
    {
        var lines = new List <string>();

        if (Lines.Any())
        {
            lines.Add(JoinLines());
        }
        lines.AddRange(Items.Select(item => item.JoinLines("  ")));
        return(string.Join(Environment.NewLine, lines));
    }
Exemplo n.º 10
0
        public Matrix(params Vector[] Lines)
        {
            _dimension = Lines.First().Dimensions;
            if (Lines.Any(r => r.Dimensions != Dimensions))
            {
                throw new Exception("Es wird versucht, eine Matrix aus einer MEnge von Vektroren zu erstellen, wobei dies unterschiedlich lange Dimensionen haben");
            }

            // Vektoren im Lines- Array kopieren ins _line- Array
            _lines = Lines.Select(r => new Vector(r)).ToArray();
        }
Exemplo n.º 11
0
        public decimal GetTotal()
        {
            if (!Lines.Any())
            {
                return(0);
            }
            var totalLines = Lines.Sum(x => x.Product.Price * x.Quantity);

            ShippingCost = totalLines > 100 ? 0 : 10;
            return(totalLines + ShippingCost);
        }
Exemplo n.º 12
0
 public void SelectLastLine()
 {
     if (Lines.Any())
     {
         var line = Lines.Count() - 1;
         var s1   = GetFirstCharIndexOfCurrentLine();
         var s2   = line < Lines.Count() - 1 ?
                    GetFirstCharIndexFromLine(line + 1) - 1 :
                    Text.Length;
         Select(s1, s2 - s1);
     }
 }
Exemplo n.º 13
0
            public void AddLine(PdfTextInfo line)
            {
                if (Lines.Any())
                {
                    BoundingRectangle = BoundingRectangle.Union(line.BoundingRectangle);
                }
                else
                {
                    BoundingRectangle = line.BoundingRectangle;
                }

                Lines.Add(line);
            }
Exemplo n.º 14
0
    /// <summary>
    /// Joins lines of a description with <see cref="Environment.NewLine"/> and the specified indent.
    /// </summary>
    /// <param name="indent">The indent of a line.</param>
    /// <returns>
    /// The string representation of the lines of a description that is joined
    /// with <see cref="Environment.NewLine"/> and the specified indent.
    /// </returns>
    public string JoinLines(string indent = "")
    {
        if (!Lines.Any())
        {
            return(string.Empty);
        }

        var lineItems = new List <string> {
            $"{indent}{FirstLineIndent}{Lines.FirstOrDefault()}"
        };

        lineItems.AddRange(Lines.Skip(1).Select(line => $"{LineIndent}{line}"));
        return(string.Join($"{Environment.NewLine}{indent}", lineItems));
    }
Exemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dc"></param>
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);
            dc.DrawRectangle(Brushes.Transparent, new Pen(Brushes.Black, 1), Bounds);

            Pen p = new Pen((Brushes.Red), 1);

            if (Lines != null && Lines.Any())
            {
                foreach (var line in Lines)
                {
                    dc.DrawLine(p, line.P1, line.P2);
                }
            }
        }
Exemplo n.º 16
0
 public void Add(CartLine cartLine)
 {
     //Add item
     if (Lines.Any(x => x.Id == cartLine.Id))
     {
         //if item already added find the item find the index and incraese quantity.
         CartLine item  = Lines.First(x => x.Id == cartLine.Id);
         int      index = Lines.IndexOf(item);
         Lines[index].Quantity += cartLine.Quantity;
     }
     else
     {
         Lines.Add(cartLine);
     }
 }
Exemplo n.º 17
0
 public void QtySubtract(int index)
 {
     //Decrease quantity.
     if (Lines.Any() && index <= Lines.Count)
     {
         if (Lines[index].Quantity > 1)
         {
             Lines[index].Quantity--;
         }
         //if item quantity is 1 then remove the item.
         else
         {
             Lines.RemoveAt(index);
         }
     }
 }
Exemplo n.º 18
0
            // ReSharper disable once SuggestBaseTypeForParameter
            public ProjectFile(List <FileToWrite> files, bool updateProjectFile, VsTfsSourceControlProvider tfs)
            {
                if (updateProjectFile && files.Count > 0)
                {
                    ProjectFiles = new SortedDictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                    // ReSharper disable once AssignNullToNotNullAttribute
                    var file = GetProjectPath(new DirectoryInfo(files[0].Directory));
                    ProjectFound = file != null;
                    if (file == null)
                    {
                        return;
                    }
                    ProjectPath = file.FullName;
                    Lines       = File.ReadAllLines(ProjectPath).ToList();
                    ProjectDir  = Path.GetDirectoryName(ProjectPath);
                    if (!Lines.Any(l => l.Contains("<Compile Include=")))
                    {
                        ProjectFileIndexStart = Lines.FindLastIndex(l => l.Contains("</PropertyGroup>")) + 1;
                        Lines.Insert(ProjectFileIndexStart, "</ItemGroup>");
                        Lines.Insert(ProjectFileIndexStart, "<ItemGroup>");
                        ProjectFileIndexStart++;
                    }
                    else
                    {
                        ProjectFileIndexStart = Lines.FindIndex(l => l.Contains("<Compile Include="));
                    }
                    foreach (var line in Lines.Skip(ProjectFileIndexStart).TakeWhile(l => l.Contains("<Compile Include=")))
                    {
                        ProjectFiles.Add(line, line);
                    }
                    ProjectFileIndexEnd = ProjectFileIndexStart + ProjectFiles.Count;

                    // Determine Line Format, defaulting if none currently exist
                    var first = ProjectFiles.Keys.FirstOrDefault() ?? (ProjectPath.EndsWith("projitems")
                                    ? "    <Compile Include=\"$(MSBuildThisFileDirectory)\" />"
                                    : "    <Compile Include=\"\" />");

                    var startEndIndex = first.Contains("$(")
                        ? first.IndexOf(")", first.IndexOf("$(", StringComparison.Ordinal), StringComparison.Ordinal) + 1 // Path contains Ms Build Variable
                        : first.IndexOf("\"", StringComparison.Ordinal) + 1;
                    LineFormat = first.Substring(0, startEndIndex) + "{0}" + first.Substring(first.LastIndexOf("\"", StringComparison.Ordinal), first.Length - first.LastIndexOf("\"", StringComparison.Ordinal));
                }

                UpdateProjectFile = updateProjectFile;
                ProjectUpdated    = false;
                Tfs = tfs;
            }
Exemplo n.º 19
0
        /// <summary>
        /// look for xstr in each file
        /// </summary>
        private void FetchXstr()
        {
            List <string> compatibleFiles = FilesList.Where(x => !x.Contains("-lcl.tbm") && !x.Contains("-tlc.tbm") && !x.Contains("strings.tbl")).ToList();

            foreach (string file in compatibleFiles)
            {
                FileInfo fileInfo    = new(file);
                string   fileContent = File.ReadAllText(file);

                IEnumerable <Match> combinedResults = Utils.GetAllXstrFromFile(fileInfo, fileContent);

                foreach (Match match in combinedResults)
                {
                    //match.Groups[0] => entire line
                    //match.Groups[1] => text
                    //match.Groups[2] => id

                    if (int.TryParse(match.Groups[2].Value, out int id))
                    {
                        string text = match.Groups[1].Value;

                        // if id not existing, add a new line
                        if (id >= 0 && !Lines.Any(x => x.Id == id))
                        {
                            Lines.Add(new Xstr(id, text, fileInfo));
                        }
                        // if id already existing but value is different, then put it in another list that will be treated separately
                        else if (ManageDuplicates && (id < 0 || Lines.First(x => x.Id == id).Text != text))
                        {
                            Duplicates.Add(new Xstr(id, text, fileInfo, match.Value));
                        }
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
            }

            int maxProgress = Lines.Count + (ManageDuplicates ? FilesList.Count + Duplicates.Count : 0);

            Parent.SetMaxProgress(maxProgress);
        }
Exemplo n.º 20
0
        public OrderLine CreateOrderLine(Product product, int quantity)
        {
            if (Lines.Any(ol => ol.ProductIdentifier == product.Identifier))
            {
                throw new InvalidOperationException($"An orderline with product {product.Identifier} already exists");
            }

            var orderLineIdentifier = OrderLineIdentifier.NextIdentifier(Lines.LastIdentifier);

            ApplyChange(
                new OrderLineCreated(
                    OrderIdentifier,
                    orderLineIdentifier,
                    product.Identifier,
                    product.ProductName,
                    quantity));

            return(Lines.Get(orderLineIdentifier));
        }
Exemplo n.º 21
0
        void SelectCurrentLine()
        {
            if (Lines == null || !Lines.Any())
            {
                return;
            }

            for (int i = 0; i < Lines.Count(); i++)
            {
                if (Lines.ElementAt(i).LineNumber == LineNumber)
                {
                    RTB.Document.Blocks.ElementAt(i).Background = _currentMatchedLineBackgroundBrush;
                    break;
                }
                else
                {
                    RTB.Document.Blocks.ElementAt(i).Background = null;
                }
            }
        }
        private void LoadLines(Lines lines)
        {
            lines.LineEntity.ForEach(e =>
            {
                if (Points.Any(p => p.Id == e.FirstEnd) && Points.Any(p => p.Id == e.SecondEnd))
                {
                    GridPoint first = Points.Single(p => p.Id == e.FirstEnd);
                    GridPoint last  = Points.Single(p => p.Id == e.SecondEnd);

                    if (!Lines.Any(l => (l.Points.First() == first && l.Points.Last() == last) || (l.Points.First() == last && l.Points.Last() == first)))
                    {
                        GridPoint breakPoint = new GridPoint()
                        {
                            X = last.X, Y = first.Y, Type = GridPointType.Intersection
                        };
                        Points.Add(breakPoint);

                        GridLine lineStart = new GridLine()
                        {
                            Id = e.Id,
                        };

                        lineStart.Points.Add(first);
                        lineStart.Points.Add(breakPoint);

                        Lines.Add(lineStart);

                        GridLine lineEnd = new GridLine()
                        {
                            Id = e.Id,
                        };

                        lineEnd.Points.Add(breakPoint);
                        lineEnd.Points.Add(last);

                        Lines.Add(lineEnd);
                    }
                }
            });
        }
Exemplo n.º 23
0
        /// <summary>
        /// Gets the raw value of the key.
        /// </summary>
        /// <returns>The value raw.</returns>
        /// <param name="sectionName">Section name.</param>
        /// <param name="keyName">Key name.</param>
        /// <param name="defaultValue">Default value returned if the key with the given name does not exist.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        internal virtual T GetRawValue <T>(string sectionName, string keyName, T defaultValue)
        {
            if (sectionName is null)
            {
                throw new ArgumentNullException(nameof(sectionName));
            }

            if (string.IsNullOrWhiteSpace(keyName))
            {
                throw new ArgumentException("Key name must be a non-empty string.", nameof(keyName));
            }

            var iniKey = new ConfigKeyValue <T>(keyName, Settings.KeyValueSeparator, defaultValue, -1);

            if (!sections.TryGetValue(sectionName, out var section))
            {
                section = new ConfigSection(sectionName, Lines.Any() ? Lines.Max(l => l.LineNumber) : 0);
                if (Sections.Any())
                {
                    Sections.Last().AddLine(new ConfigLine());
                }
                sections.Add(sectionName, section);
            }

            var key = (section ?? fileHeader?.Section).Keys.FirstOrDefault(k => Equals(keyName, k.Name));

            if (key != null)
            {
                return((T)key.ValueRaw);
            }

            if (section is null && Settings.MultiLineValues.HasFlag(MultiLineValues.AllowEmptyTopSection))
            {
                section = fileHeader.Section;
            }

            section?.AddLine(iniKey);
            return(defaultValue);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Sets the value.
        /// </summary>
        /// <param name="sectionName">Name of the section.</param>
        /// <param name="keyName">Name of the key.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        /// <exception cref="InvalidOperationException"></exception>
        public bool SetValue(string sectionName, string keyName, string value)
        {
            if (string.IsNullOrWhiteSpace(sectionName))
            {
                throw new ArgumentNullException(nameof(sectionName));
            }
            if (string.IsNullOrWhiteSpace(keyName))
            {
                throw new ArgumentNullException(nameof(keyName));
            }

            if (!sections.TryGetValue(sectionName, out var section))
            {
                var lineNumber = (null != Lines && Lines.Any()) ? Lines.Max(l => l.LineNumber) : -1;
                section        = new ConfigSection(sectionName, lineNumber);
                sections.Add(sectionName, section);
            }

            if (section == null)
            {
                Logger?.Warn($"Failed to create {sectionName} and store {keyName}={value} key");
                return(false);
            }

            var iniKey = section.Keys
                         .FirstOrDefault(k => Equals(keyName, k.Name));

            if (iniKey != null)
            {
                iniKey.ValueRaw = value;
            }
            else
            {
                iniKey = new ConfigKeyValue <string>(keyName, Settings.KeyValueSeparator, value, -1);
                section.AddLine((ConfigLine)iniKey);
            }
            return(true);
        }
Exemplo n.º 25
0
        private void EmulateKaraokeForSimultaneousLines()
        {
            for (int i = 0; i < Lines.Count; i++)
            {
                AssLine line = (AssLine)Lines[i];
                if (line.Position != null || !line.Sections.Any(s => s.StartOffset > TimeSpan.Zero))
                {
                    continue;
                }

                if (!Lines.Any(l => l.Start < line.End && l.End > line.Start && l.Position == null && l.AnchorPoint == line.AnchorPoint))
                {
                    continue;
                }

                foreach (AssSection section in line.Sections)
                {
                    section.StartOffset = TimeSpan.Zero;
                }

                Lines.RemoveAt(i);
                Lines.InsertRange(i, CreateEmulatedKaraokeLines(line));
            }
        }
Exemplo n.º 26
0
 /// <summary>
 /// Check if there is at least one complete line (=mill)
 /// </summary>
 public bool HasCompleteLine(int ownerId)
 {
     return Lines.Any(x => x.IsComplete(ownerId));
 }
Exemplo n.º 27
0
 public int GetWidth()
 {
     return(Lines.Any()
         ? Lines.Max(l => l.Length)
         : 0);
 }
Exemplo n.º 28
0
 public bool Contains(string host)
 {
     return(Lines.Any(x => x.Host == host));
 }