Exemplo n.º 1
0
        public void Draw(Graphics g, Size imageSize, ProjectInstructions projectInstructions)
        {
            if (string.IsNullOrEmpty(Text) && !Cursor)
            {
                return;
            }

            var font = RenderingHelper.CreateFont(g, projectInstructions.FontFamily, projectInstructions.FontStyle,
                                                  projectInstructions.FontSize);

            var drawLocation = new PointF(0, 0);

            var text = string.Concat(Text, Cursor ? "_" : string.Empty);

            if (projectInstructions.DrawFromBottom)
            {
                var size = g.MeasureString(string.Concat(text, "EMPY LINES HAVE NO HEIGHT"), font);

                drawLocation = new PointF(0, imageSize.Height - size.Height);
            }

            if (projectInstructions.Outline)
            {
                using (var path = new GraphicsPath())
                {
                    path.AddString(text, font.FontFamily, (int)font.Style, font.Size, drawLocation,
                                   StringFormat.GenericDefault);

                    var p = new Pen(projectInstructions.OutlineColor, projectInstructions.OutlineWidth);
                    g.DrawPath(p, path);
                    g.FillPath(new SolidBrush(projectInstructions.FontColor), path);
                }
            }
            else
            {
                g.DrawString(text, font, new SolidBrush(projectInstructions.FontColor), drawLocation);
            }

            var pen       = new Pen(projectInstructions.BackgroundColor, projectInstructions.ScanlineWidth);
            var increment = projectInstructions.ScanlineGap + projectInstructions.ScanlineWidth;

            if (projectInstructions.HorizontalScanLines)
            {
                for (var lineY = 0; lineY < imageSize.Height; lineY += increment)
                {
                    g.DrawLine(pen, 0, lineY, imageSize.Width, lineY);
                }
            }
            if (projectInstructions.VericalScanLines)
            {
                for (var lineX = 0; lineX < imageSize.Width; lineX += increment)
                {
                    g.DrawLine(pen, lineX, 0, lineX, imageSize.Height);
                }
            }
        }
        private void UpdateProjectState(Project.Project project, string projectPath)
        {
            var viewModels = from item in project.ScriptedInstructions
                             select new ScriptedInstructionViewModel(this)
            {
                ScriptedInstruction = item
            };

            if (Script != null)
            {
                Script.CollectionChanged -= ScriptCollectionChanged;
            }

            Script = new ObservableCollection <ScriptedInstructionViewModel>(viewModels.ToList());
            Script.CollectionChanged    += ScriptCollectionChanged;
            projectInstructions          = project.ProjectInstructions;
            ProjectInstructionsViewModel = new ScriptedInstructionViewModel(this)
            {
                ScriptedInstruction = projectInstructions
            };
            outputFileName = project.OutputFileName;
            ProjectPath    = projectPath;
            HasChanges     = false;
        }
Exemplo n.º 3
0
 public RenderArgs(ScriptedInstruction[] script, ProjectInstructions projectInstructions)
 {
     this.script = script;
     this.projectInstructions = projectInstructions;
 }