예제 #1
0
        private ResponseViewModel[] SearchInternal(object source)
        {
            var result = (IEnumerable <ResponseViewModel>)source;

            if (SearchFromSelectedParts)
            {
                result = result.Where(r => Parts.Any(p => p == r.PartNumber));
            }
            if (SearchFromSelectedPeople)
            {
                result = result.Where(r => People.Any(p => p == r.Tag));
            }
            if (SearchFromSelectedDate && (StartDate != null || EndDate != null))
            {
                var start = StartDate ?? DateTime.MinValue;
                var end   = EndDate == null?DateTime.MaxValue:EndDate.Value.Date.Add(new TimeSpan(23, 59, 59));
                result = result.Where(r => r.Date >= start && r.Date <= end);
            }
            var buffer = new StringBuilder(1000);

            return(result.Where(r =>
            {
                CharWidthNormalizer.NormalizeFast(r.Text, buffer);
                return Condition.IsMatch(CharWidthNormalizer.Normalize(buffer.ToString()));
            }).ToArray());
        }
예제 #2
0
    public static void ReplaceBlipContent(this WordprocessingDocument doc, Blip blip, Bitmap bitmap, string newImagePartId, ImagePartType imagePartType = ImagePartType.Png)
    {
        if (doc.MainDocumentPart !.Parts.Any(p => p.RelationshipId == blip.Embed))
        {
            doc.MainDocumentPart.DeletePart(blip.Embed !);
        }
        ImagePart img = CreateImagePart(doc, bitmap, newImagePartId, imagePartType);

        blip.Embed = doc.MainDocumentPart.GetIdOfPart(img);
    }
예제 #3
0
 public OpenWordRunText(params string[] lines)
 {
     foreach (string l in lines)
     {
         Parts.Add(new Text(l));
         Parts.Add(new Break());
     }
     if (Parts.Any())
     {
         Parts.Remove(Parts.Last());
     }
 }
예제 #4
0
        // Saves current Computer to human-readable text file, showing price info
        public void SaveToReceipt(string dir)
        {
            using (StreamWriter sw = new StreamWriter(dir))
            {
                for (int i = 0; i < 100; i++)
                {
                    sw.Write("-");
                }
                sw.WriteLine();
                sw.WriteLine($"{"Type",-20} | {"Manufacturer",-20} | {"Name",-20} | {"Model",-20} | {"Price",-20:C}");
                for (int i = 0; i < 100; i++)
                {
                    sw.Write("-");
                }
                sw.WriteLine();

                //foreach (var part in Parts) sw.WriteLine(part.ToStringInFile());
                foreach (var part in this)
                {
                    sw.WriteLine(part.ToStringInFile());
                }

                for (int i = 0; i < 100; i++)
                {
                    sw.Write("-");
                }
                sw.WriteLine();

                //sw.WriteLine($"{DateTime.Today.ToLongDateString(),50} Total: {Price:C}");
                //for (int i = 0; i < 100; i++) sw.Write("-");

                if (Parts.Any(x => x.IsDiscounted))
                {
                    sw.WriteLine($"{DateTime.Now,50} Total (PROMO PRICE): {Price:C}");
                    for (int i = 0; i < 100; i++)
                    {
                        sw.Write("-");
                    }
                }
                else
                {
                    sw.WriteLine($"{DateTime.Now,50} Total: {Price:C}");
                    for (int i = 0; i < 100; i++)
                    {
                        sw.Write("-");
                    }
                }
            }
        }
예제 #5
0
        protected override void EnsureValidState()
        {
            if (Parts == null)
            {
                throw new Exception("Model Invalid. Parts can not be null.");
            }

            foreach (var part in Parts)
            {
                if (Parts.Any(x => (x.Scheduled.Overlap(part.Scheduled) && x != part)))
                {
                    throw new Exception("Model Invalid. Parts overlap");
                }
            }
        }
예제 #6
0
        internal void UpdateHasTranslation(bool slideHasTranslation)
        {
            bool newHasTranslation;

            if (slideHasTranslation)
            {
                newHasTranslation = true;
            }
            else
            {
                newHasTranslation = Parts.Any(part => part.Slides.Any(slide => slide.HasTranslation));
            }

            if (newHasTranslation != hasTranslation)
            {
                OnPropertyChanging("HasTranslation");
                hasTranslation = newHasTranslation;
                OnPropertyChanged("HasTranslation");
            }
        }
예제 #7
0
        /// <summary>
        /// Determines whether or not the media item contains the specified search in any of it's properties
        /// </summary>
        /// <param name="searchText">Search text to look for</param>
        /// <returns>True if the media item contains the specified search in any of it's properties, false if not</returns>
        public Boolean ContainsSearchText(String searchText)
        {
            if (String.IsNullOrEmpty(searchText))
            {
                return(true);
            }

            searchText = searchText.ToLower();

            if (Name.ToLower().Contains(searchText))
            {
                return(true);
            }

            if (Genre.ToLower().Contains(searchText))
            {
                return(true);
            }

            if (MediaItemContainsSearchText(searchText))
            {
                return(true);
            }

            if (Parts.Any(p => p.Location.ToLower().Contains(searchText)))
            {
                return(true);
            }

            if (Tags.Any(p => p.ToLower().Contains(searchText)))
            {
                return(true);
            }

            return(false);
        }
예제 #8
0
        public IEnumerable <FluentRouteSetter> GetFluentRouteSetters()
        {
            var setters = new List <FluentRouteSetter>();

            if (!Parts.Any())
            {
                return(setters);
            }

            var alwaysGenerate = new[] { "index" };
            var parts          = Parts
                                 .Where(p => !p.Required || alwaysGenerate.Contains(p.Name))
                                 .Where(p => !string.IsNullOrEmpty(p.Name))
                                 .ToList();
            var returnType = CsharpNames.GenericOrNonGenericDescriptorName;

            foreach (var part in parts)
            {
                var p         = part;
                var paramName = p.Name.ToPascalCase();
                if (paramName.Length > 1)
                {
                    paramName = paramName.Substring(0, 1).ToLowerInvariant() + paramName.Substring(1);
                }
                else
                {
                    paramName = paramName.ToLowerInvariant();
                }

                var routeValue  = "v";
                var routeSetter = p.Required ? "Required" : "Optional";

                var code =
                    $"public {returnType} {p.InterfaceName}({p.HighLevelTypeName} {paramName}) => Assign({paramName}, (a,v)=>a.RouteValues.{routeSetter}(\"{p.Name}\", {routeValue}));";
                var xmlDoc = $"///<summary>{p.Description}</summary>";
                setters.Add(new FluentRouteSetter {
                    Code = code, XmlDoc = xmlDoc
                });
                if (paramName == "index")
                {
                    code   = $"public {returnType} {p.InterfaceName}<TOther>() where TOther : class ";
                    code  += $"=> Assign(typeof(TOther), (a,v)=>a.RouteValues.{routeSetter}(\"{p.Name}\", ({p.HighLevelTypeName})v));";
                    xmlDoc = $"///<summary>a shortcut into calling {p.InterfaceName}(typeof(TOther))</summary>";
                    setters.Add(new FluentRouteSetter {
                        Code = code, XmlDoc = xmlDoc
                    });
                }
                if (paramName == "index" && p.Type == "list")
                {
                    code   = $"public {returnType} AllIndices() => Index(Indices.All);";
                    xmlDoc = $"///<summary>A shortcut into calling Index(Indices.All)</summary>";
                    setters.Add(new FluentRouteSetter {
                        Code = code, XmlDoc = xmlDoc
                    });
                }
                if (paramName == "fields" && p.Type == "list")
                {
                    code   = $"public {returnType} Fields<T>(params Expression<Func<T, object>>[] fields) ";
                    code  += $"=> Assign(fields, (a,v)=>a.RouteValues.{routeSetter}(\"fields\", (Fields)v));";
                    xmlDoc = $"///<summary>{p.Description}</summary>";
                    setters.Add(new FluentRouteSetter {
                        Code = code, XmlDoc = xmlDoc
                    });
                }
            }
            return(setters);
        }
예제 #9
0
 public override bool IsOneOf(params Terrain[] options) => Parts.Any(part => part.IsOneOf(options));
예제 #10
0
 public override bool Is(Terrain terrain) => Parts.Any(part => part.Is(terrain));
예제 #11
0
 public bool ContainsContent(IPartEntity content) =>
 As.Expression(() => Parts.Any(p => p.Content.Is(content)));
예제 #12
0
 /// <summary>
 /// Determines whether the specified <paramref name="layer"/> is currently enabled.
 /// </summary>
 /// <param name="layer">The layer.</param>
 public bool IsLayerEnabled(string layer)
 {
     return(Parts.Any(p => p.IsLayerEnabled(layer)));
 }
예제 #13
0
 public bool KeyExists(string key)
 {
     return(Parts.Any(p => p.IndexOf(key) != -1));
 }
예제 #14
0
파일: Set.cs 프로젝트: uotools/JustUO
 public bool HasPartTypeOf(Type type)
 {
     return(Parts.Any(part => part.Valid && part.IsTypeOf(type)));
 }
예제 #15
0
 public int GetNewPartId() => Parts.Any() ? Parts.Max(part => part.ID) + 1 : 0;