コード例 #1
0
ファイル: Document.cs プロジェクト: gregshevchenko3/Library
 public Document(string title, Ganres ganre, Langs lang, DateTime publish, string pathToFile, Font font = null, PageSettings pg_settings = null)
 {
     DocumentName    = title;
     Ganre           = ganre;
     Lang            = lang;
     DateOfPublished = publish;
     _pages          = new List <PageContent>();
     if (pg_settings != null)
     {
         DefaultPageSettings = pg_settings;
     }
     else
     {
         DefaultPageSettings.PaperSize    = PaperStandards.GetSizeByName("A5");
         DefaultPageSettings.Landscape    = false;
         DefaultPageSettings.Margins.Left = PrinterUnitConvert.Convert(200, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display);
         int short_margin = PrinterUnitConvert.Convert(100, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display);
         DefaultPageSettings.Margins.Top = DefaultPageSettings.Margins.Bottom = DefaultPageSettings.Margins.Right = short_margin;
     }
     if (font != null)
     {
         _font = font;
     }
     else
     {
         _font = new Font("Arial", 14);
     }
     _storageReader = new StorageReader(pathToFile);
     _storageReader.eventHandler += OnReadLine;
     _storageReader.read_line();
 }
コード例 #2
0
        static void Main(string[] args)
        {
            _keyPressed += Program.OnKeyPressed;
            //Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
            PageSettings pageSettings = new PageSettings();

            pageSettings.PaperSize    = PaperStandards.GetSizeByName("A4");
            pageSettings.Landscape    = false;
            pageSettings.Margins.Left = PrinterUnitConvert.Convert(200, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display);
            int short_margin = PrinterUnitConvert.Convert(100, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display);

            pageSettings.Margins.Top = pageSettings.Margins.Bottom = pageSettings.Margins.Right = short_margin;

            _bk = new Book("Якийсь там title", Ganres.DETECTIVE, Langs.ru_RU, DateTime.Now, @"book_01.txt", new Font("Arial", 14), pageSettings);
            _bk.StorageUpdatedEvent += page_count =>
            {
                if (_currentPage == -1)
                {
                    _currentPage = 0;
                    Console.Clear();
                    _bk.show(_currentPage);
                }
                _ReadPagesCount = page_count;
            };

            while (!_exit)
            {
                if (Console.KeyAvailable)
                {
                    _keyPressed(Console.ReadKey(true));
                }
            }
        }