public byte[] GenerateDocx(int themeId)
        {
            var theme      = _context.GetThemes().FirstOrDefault(t => t.Id == themeId);
            var supervisor = _context.Supervisors.FirstOrDefault(s => s.Id == theme.SupervisorId);
            var stProgram  = _context.StPrograms.FirstOrDefault(s => s.Id == theme.StProgramId);

            DirectoryInfo di       = new DirectoryInfo("..\\..\\..\\Data\\Word");
            DocX          template = DocX.Load(di.FullName + "\\PhD_temy_sablona.docx");

            byte[] ret          = null;
            string fileNamePath = di.FullName + "\\Result" + di.GetFiles().Length + ".docx";

            using (DocX newFile = DocX.Create(fileNamePath))
            {
                newFile.InsertDocument(template);
                newFile.ReplaceText("#=ThemeName=#", theme.Name);
                newFile.ReplaceText("#=Supervisor=#", supervisor.FullName);
                newFile.ReplaceText("#=StProgram=#", stProgram.Name);
                newFile.ReplaceText("#=FieldOfStudy=#", stProgram.FieldOfStudy);
                string resType = "";
                switch (theme.ResearchType)
                {
                case ResearchType.BasicResearch:
                    resType = "základný výskum";
                    break;

                case ResearchType.AppliedResearch:
                    resType = "aplikovaný výskum";
                    break;

                case ResearchType.AppliedResearchExpDevelopment:
                    resType = "aplikovaný výskum a experimentálny vývoj";
                    break;

                case null:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                newFile.ReplaceText("#=ResearchType=#", resType);
                newFile.ReplaceText("#=Description=#", theme.Description);
                ret = Encoding.ASCII.GetBytes(newFile.ToString());
                newFile.Save();
            }
            Process.Start(fileNamePath);
            return(ret);
        }
Example #2
0
        private static void Draw()
        {
            // draw fresh
            DrawFresh();

            // draw document
            for (int i = 0; i < CLI.Height; i++)
            {
                int pos = i + Scroll;
                if (pos < Lines.Count)
                {
                    TextGraphics.DrawString(StartX, StartY + i, Lines[pos], Color.Black, Color.White);
                }
            }

            // draw doc pos
            TextGraphics.DrawString(Shell.TitleBarTime.Length, 0, " | CUR: " + DocX.ToString() + "   LINE:" + DocY.ToString(), Shell.TitleColor, Shell.TitleBarColor);

            // return cursor position to document
            SendScreenPos();
        }