Exemplo n.º 1
0
 public static void ShowAllNotes()
 {
     Menu.ShowAllState();
     for (int i = 0; i < notes.Count; i++)
     {
         var table = new ConsoleTables.ConsoleTable("Id", $"{notes[i].id}");
         table.AddRow("Last name", notes[i].LastName)
         .AddRow("First name", notes[i].FirstName)
         .AddRow("Middle name", notes[i].MiddleName)
         .AddRow("Number", notes[i].Number)
         .AddRow("Country", notes[i].Country)
         .AddRow("Birth Date", notes[i].Birthday)
         .AddRow("Organization", notes[i].Organization)
         .AddRow("Job", notes[i].Job);
         try
         {
             foreach (KeyValuePair <string, string> entry in notes[i].additionalNotes)
             {
                 table.AddRow(entry.Key, entry.Value);
             }
         }
         catch (Exception)
         {
         }
         finally { table.Write(); }
     }
 }
Exemplo n.º 2
0
        public static void ReadNote(Note note)
        {
            Menu.ReadState();
            var table = new ConsoleTables.ConsoleTable("1", "Last name", note.LastName);

            table.AddRow("2", "First Name", note.FirstName)
            .AddRow("3", "Middle Name", note.MiddleName)
            .AddRow("4", "Number", note.Number)
            .AddRow("5", "Country", note.Country)
            .AddRow("6", "Birth Date", note.Birthday)
            .AddRow("7", "Organization", note.Organization)
            .AddRow("8", "Job", note.Job);
            int i = 9;

            try
            {
                foreach (KeyValuePair <string, string> entry in note.additionalNotes)
                {
                    table.AddRow(i, entry.Key, entry.Value);
                    i++;
                }
            }
            catch (NullReferenceException)
            {
            }
            finally { table.Write(); }
        }
Exemplo n.º 3
0
        public static void Find(out int results)
        {
            Console.Write("Enter Last name keyword: ");
            string keyword = Console.ReadLine();

            results = 0;
            for (int i = 0; i < notes.Count; i++)
            {
                if (notes[i].LastName.ToLower().Contains(keyword))
                {
                    results++;
                    var table = new ConsoleTables.ConsoleTable("Id", $"{notes[i].id}");
                    table.AddRow("Lastname", notes[i].LastName)
                    .AddRow("FirstName", notes[i].FirstName)
                    .AddRow("Number", notes[i].Number);
                    table.Write();
                }
            }
            if (results == 0)
            {
                Console.WriteLine("Sorry, nothing found...");
            }
            else
            {
                Console.WriteLine("Notes: " + results);
            }
        }
 /// <summary>
 /// Displays _availableLanguages dictionary in table format
 /// </summary>
 public void DisplayAvaiableLanguages()
 {
     ConsoleTables.ConsoleTable ct = new ConsoleTables.ConsoleTable("Language code", "Language name");
     foreach (var item in _availableLanguages)
     {
         ct.AddRow(item.Key, item.Value);
     }
     ct.Write(ConsoleTables.Format.Alternative);
 }
Exemplo n.º 5
0
        public static void WriteTable(IEnumerable <string> headers, IEnumerable <IEnumerable <string> > values)
        {
            var table = new ConsoleTables.ConsoleTable(headers.ToArray());

            foreach (var row in values)
            {
                table.AddRow(row.ToArray());
            }

            Log.Information(Environment.NewLine + table.ToString());
        }
Exemplo n.º 6
0
        private static void GetAllSpacesFunction()
        {
            var table = new ConsoleTables.ConsoleTable("Space", "Space 1", "Space 2", "Space 3");

            for (int i = 1; i < 50; i++)
            {
                table.AddRow(i, string.Join(", ", GetNextSpaces(i)));
            }

            table.Write();
        }
Exemplo n.º 7
0
        static void Refresh()
        {
            var objResult = Client.GetActive();

            DataRefresh = DateTime.Now;

            var Calls = objResult.Where(a => FilterZones.Contains(a.ZoneAsNumeric())).ToArray();

            Console.Clear();

            string strHeader = @"These are the Calls for Service in Bay Lake, Florida [Zone 60 + 61]";

            Console.WriteLine(strHeader);
            Console.WriteLine();

            var objTable = new ConsoleTables.ConsoleTable(
                @"Incident (ID/PK)",
                @"Dispatch Entry",
                @"Description",
                @"Location",
                @"Active Time"
                );

            foreach (var objCall in Calls)
            {
                var    tsActive  = objCall.TimeActive();
                string strActive = "N/A";

                if (tsActive.TotalMinutes <= 3)
                {
                    strActive = string.Format("{0:0.0} seconds", tsActive.TotalSeconds);
                }
                else if (tsActive.TotalMinutes <= 60)
                {
                    strActive = string.Format("{0:0.0} minutes", tsActive.TotalMinutes);
                }
                else
                {
                    strActive = string.Format("{0:0.0} hours", tsActive.TotalHours);
                }

                objTable.AddRow(objCall.ID,
                                objCall.EntryAsTimestamp(),
                                objCall.Description,
                                objCall.Location,
                                strActive);
            }

            objTable.Write();

            Console.WriteLine();
            Console.WriteLine(string.Format("Last Data Refresh: {0}", DataRefresh));
        }
Exemplo n.º 8
0
 public static void ShowSimplifiedNotes()
 {
     Menu.ShowSimpleState();
     for (int i = 0; i < notes.Count; i++)
     {
         var table = new ConsoleTables.ConsoleTable("Id", $"{notes[i].id}");
         table.AddRow("Lastname", notes[i].LastName)
         .AddRow("FirstName", notes[i].FirstName)
         .AddRow("Number", notes[i].Number);
         table.Write();
     }
 }
Exemplo n.º 9
0
        public static void Print_AppInfo()
        {
            var table = new ConsoleTables.ConsoleTable(new ConsoleTables.ConsoleTableOptions()
            {
                EnableCount     = false,
                NumberAlignment = ConsoleTables.Alignment.Left
            });

            //Print out Application information
            table.Columns.Add("App name");
            table.Columns.Add("Data Collector");
            table.AddRow("Version", "0.1");
            table.AddRow("Author", "Alireza Keshavarz");
            table.AddRow("Date", "05/10/2019");
            table.Write(ConsoleTables.Format.Alternative);

            table.Rows.Clear(); table.Columns.Clear();

            //Print out Platforms Status
            table.Columns.Add("Platform");
            table.Columns.Add("Ready?");
            table.AddRow("Instagram", "Yes");
            table.AddRow("Twitter", "No");
            table.AddRow("Telegram", "No");
            Colorful.StyleSheet styleSheet = new Colorful.StyleSheet(System.Drawing.Color.White);
            styleSheet.AddStyle("Yes[a-z]*", System.Drawing.Color.Green);
            styleSheet.AddStyle("No[a-z]*", System.Drawing.Color.Red);
            Colorful.Console.WriteLineStyled(table.ToMarkDownString(), styleSheet);
        }
Exemplo n.º 10
0
        public static void Print_Table_With_TF_Style(System.Collections.Generic.List <string[]> rows)
        {
            Console.WriteLine();

            var table = new ConsoleTables.ConsoleTable();

            table.Options.EnableCount = false;

            table.AddColumn(rows[0]);
            for (int i = 1; i < rows.Count; i++)
            {
                table.AddRow(rows[i]);
            }

            Colorful.StyleSheet _Temp1 = new Colorful.StyleSheet(System.Drawing.Color.White);
            _Temp1.AddStyle("True[a-z]*", System.Drawing.Color.Green);
            _Temp1.AddStyle("False[a-z]*", System.Drawing.Color.Red);
            Colorful.Console.WriteLineStyled(table.ToMarkDownString(), _Temp1);
        }
Exemplo n.º 11
0
        static async Task <int> ShowUnitTable(IKTRulesContext db, Model unit)
        {
            Console.WriteLine($"\n== {unit.NameEn} ==");
            var table = new ConsoleTables.ConsoleTable("Name", "M", "WS", "BS", "S", "T", "W", "A", "Ld", "Sv", "Max");

            foreach (var profile in unit.ModelProfiles)
            {
                table.AddRow(
                    profile.NameEn,
                    profile.Movement.ToString() + '"',
                    profile.WeaponSkill.ToString() + '+',
                    profile.BallisticSkill.ToString() + '+',
                    profile.Strength,
                    profile.Toughness,
                    profile.Wounds,
                    profile.Attacks,
                    profile.Leadership,
                    profile.Save.ToString() + '+',
                    profile.MaximumNumber > 0 ? profile.MaximumNumber.ToString() : "-"
                    );
            }
            table.Configure(o => o.EnableCount = false);
            table.Write();

            var weapons = unit.ModelWeapons.Select(w => w.Weapon.NameEn);

            Console.WriteLine($"This model is armed with: {string.Join(", ", weapons)}");

            /* WARGEAR OPTIONS */

            if (unit.WarGearOptions.Count > 0 || unit.ModelProfiles.Any(mp => mp.WarGearOptions.Count > 0))
            {
                Console.WriteLine("\n=== Wargear Options ===");
                foreach (var option in unit.WarGearOptions)
                {
                    PrintWarGearOption(db, option);
                }
                foreach (var modelProfile in unit.ModelProfiles)
                {
                    if (modelProfile.WarGearOptions.Count == 0)
                    {
                        continue;
                    }

                    Console.WriteLine($" - {modelProfile.NameEn}");
                    foreach (var option in modelProfile.WarGearOptions)
                    {
                        PrintWarGearOption(db, option);
                    }
                }
            }

            /* ABILITIES */

            Console.WriteLine("\n=== Abilities ===");

            // faction abilities
            foreach (var ability in db.Factions.Where(f => f.Id == unit.FactionId).Include(f => f.Abilities).First().Abilities)
            {
                Console.WriteLine($"*{ability.NameEn}*: {ability.DescriptionEn}");
            }

            // model abilities
            foreach (var ability in unit.Abilities)
            {
                Console.WriteLine($"*{ability.NameEn}*: {ability.DescriptionEn}");
            }

            // model profile abilities
            foreach (var modelProfile in unit.ModelProfiles)
            {
                if (modelProfile.Abilities.Count == 0)
                {
                    continue;
                }

                Console.WriteLine($" - {modelProfile.NameEn}");
                foreach (var ability in modelProfile.Abilities)
                {
                    Console.WriteLine($"*{ability.NameEn}*: {ability.DescriptionEn}");
                }
            }

            /* PSYKER */

            var psykers = unit.ModelProfiles.Where(mp => mp.NumberOfKnownPsychics > 0 || mp.NumberOfPsychicsManifestationPerRound > 0 || mp.NumberOfPsychicsDenialPerRound > 0);

            if (psykers.Count() > 0)
            {
                Console.WriteLine("\n=== Psyker ===");
                foreach (var mp in psykers)
                {
                    Console.WriteLine($"{mp.NameEn}: Cast {mp.NumberOfPsychicsManifestationPerRound}, Deny {mp.NumberOfPsychicsDenialPerRound}, Know {mp.NumberOfKnownPsychics}");
                    foreach (var psychic in mp.Psychics)
                    {
                        Console.WriteLine($" - {psychic.NameEn}");
                    }
                    // TODO: psybolt? Or like, does everyone know that?
                }
            }

            /* SPECIALISTS */

            Console.WriteLine("\n=== Specialists ===");
            foreach (var mp in unit.ModelProfiles)
            {
                Console.WriteLine($"{mp.NameEn}: {string.Join(", ", mp.Specialists.Select(s => s.Specialist.NameEn))}");
            }

            /* KEYWORDS */

            Console.WriteLine("\n=== Keywords ===");
            Console.WriteLine(unit.KeywordsEn);

            return(0);
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
#if !TEST
            if (args.Length == 0)
            {
                Console.WriteLine("[Error] path not selected");
                Environment.Exit(-1);
                return;
            }
            var path = args[0];
#else
            var path = "./Test.cs";
#endif

            var file = new FileInfo(path);
            if (!file.Exists)
            {
                Console.WriteLine("[Error] file not found");
                Environment.Exit(-1);
                return;
            }

            var list = new Queue <EnumVariable>();
start:

            using (var r = new StreamReader(file.OpenRead()))
            {
                var codePage = r.ReadToEnd();
                var temper   = new Temper();
                var types    = temper.Temp(codePage).ToArray();

                if (types.Length < 2)
                {
                    Console.WriteLine("[Error] not enough types in this file.");
                    Environment.Exit(-1);
                    return;
                }
                Console.CursorVisible = false;

                foreach (var t in types)
                {
                    var e = Enumeration.Create(t);
                    Console.WriteLine($"[Select] type: { t }, {(e.HasFlags ? "multi-selectable" : "non-flags")}");
                    if (e.HasFlags)
                    {
                        Console.WriteLine($"[Info] press '{selectedChar}' to select and unselect item");
                    }
                    var procedure = e.HasFlags ? new Action <Type, Enumeration, Action <EnumVariable> >(HasFlags) : NonFlags;

                    procedure(t, e, list.Enqueue);
                }
            }

            Console.CursorVisible = true;

            if (list.Count < 2)
            {
                Console.WriteLine("[Warning] not enough selected types for generate flags.");
                goto restart;
            }


            var table = new ConsoleTables.ConsoleTable("type", "variable name", "value", "has flags");
            foreach (var item in list)
            {
                table.AddRow(item.Field.Info.EnumType, item.Name, item.Field.Value, item.Field.Info.HasFlags);
            }
            table.Write(ConsoleTables.Format.Alternative);

            Console.WriteLine();
            var enc = Flags.Encode(list);


            var code = enc.GenerateDecodeStub(YesOrNoQuestion.Builder
                                              .Title("Choose")
                                              .Question("need debug?")
                                              .Build()
                                              .Ask());

            YesOrNoQuestion.Builder
            .Title("Choose")
            .Question("copy code?")
            .Positive(() => TextCopy.Clipboard.SetText(code))
            .Negative(() =>
            {
                Console.WriteLine();
                Console.WriteLine("===========================================");
                Console.BackgroundColor = ConsoleColor.DarkBlue;
                Console.WriteLine(code);
                Console.ResetColor();
                Console.WriteLine("===========================================");
                Console.WriteLine();
            })
            .Build()
            .Ask();


restart:
            if (YesOrNoQuestion.Builder
                .Title("Choose")
                .Question("rebuild?")
                .Positive(new Action(Console.Clear) + list.Clear)
                .Build()
                .Ask())
            {
                goto start;
            }
        }