public string?Validate()
 {
     if (string.IsNullOrWhiteSpace(Name))
     {
         return("Name must be set.");
     }
     if (string.IsNullOrWhiteSpace(Abbr))
     {
         return("Abbreviation must be set.");
     }
     if (ExpressionType == UExpressionType.Numerical)
     {
         if (Abbr.Trim().Length < 1 || Abbr.Trim().Length > 4)
         {
             return("Abbreviation must be between 1 and 4 characters long.");
         }
         if (Min >= Max)
         {
             return("Min must be smaller than max.");
         }
         if (DefaultValue < Min || DefaultValue > Max)
         {
             return("Default value must be between min and max.");
         }
     }
     else
     {
         var options = OptionValues.Split(',');
         if (options.Length < 2)
         {
             return("No options specified.");
         }
     }
     return(null);
 }
 public UExpressionDescriptor Build()
 {
     return(ExpressionType == UExpressionType.Numerical
     ? new UExpressionDescriptor(
                Name.Trim(), Abbr.Trim().ToLower(), Min, Max, DefaultValue, Flag)
     : new UExpressionDescriptor(
                Name.Trim(), Abbr.Trim().ToLower(), IsFlag, OptionValues.Split(',')));
 }
示例#3
0
        private void MakePuzzle()
        {
            // create a Puzzle instance from its UI representation
            CurrentPuzzle = Abbr[CurrentPuzzle.Abbreviation]();
            switch (CurrentPuzzle.DefinitionType)
            {
            case PuzzleDefinitionType.Values:
            case PuzzleDefinitionType.ValuesAndWritability:
                int?[,] grid     = new int?[GridSize.Height, GridSize.Width];
                bool[,] writable = CurrentPuzzle.DefinitionType == PuzzleDefinitionType.Values ? null : new bool[GridSize.Height, GridSize.Width];
                foreach (int y in Enumerable.Range(0, GridSize.Height))
                {
                    foreach (int x in Enumerable.Range(0, GridSize.Width))
                    {
                        grid[y, x] = CellsKnown[y, x].Checked ? (int?)CellsValues[y, x, 0].Value : null;
                        writable?.SetValue(CellsWritable[y, x].Checked, y, x);
                    }
                }
                if (CurrentPuzzle.DefinitionType == PuzzleDefinitionType.ValuesAndWritability)
                {
                    CurrentPuzzle.Initialize(grid, writable);
                }
                else
                {
                    CurrentPuzzle.Initialize(grid);
                }
                break;

            case PuzzleDefinitionType.Entries:
                CurrentPuzzle.Initialize(CollectEntries());
                break;

            default:
                throw new NotSupportedException();
            }
        }
        public string MakeSizeView(DocumentView document)
        {
            var  size    = document.Size;
            Abbr abbr    = Abbr.b;
            var  newsize = (double)size;

            if (document.IsFile == false)
            {
                return("-");
            }
            while (true)
            {
                if (Math.Round((double)newsize / 1024, 1) > 0.1)
                {
                    newsize = Math.Round((double)newsize / 1024, 1);
                    abbr++;
                }
                else
                {
                    break;
                }
            }
            return(newsize + " " + abbr.ToString());
        }
示例#5
0
 public Class1()
 {
     Abbr a = Abbr.Int32;
 }
示例#6
0
 public static Abbr <THelper> SetInitialism <THelper>(this Abbr <THelper> abbr, bool initialism = true)
     where THelper : BootstrapHelper <THelper>
 {
     return(abbr.ToggleCss(Css.Initialism, initialism));
 }