Beispiel #1
0
        internal override RawCommand getRawCommand(DotMatrix dotMatrix, DisplayModel displayModel, Controller controller)
        {
            // Choose font and text alignment

            Fonts fontToUse = (fontSet?font:controller.DefaultTextFont);

            TextAlignments textAlignmentToUse;

            if (textAlignmentSet)
            {
                textAlignmentToUse = textAlignment;
            }
            else
            {
                if (this.HorPosition == HorPositions.Right)
                {
                    textAlignmentToUse = TextAlignments.Right;
                }
                else if (this.HorPosition == HorPositions.Center)
                {
                    textAlignmentToUse = TextAlignments.Center;
                }
                else
                {
                    textAlignmentToUse = TextAlignments.Left;
                }
            }

            // Get content
            int[,] content = TextToContent.getContent(textLines, fontToUse, fixedWidth, bold, textColor, backColor, charSpacing, lineSpacing, textAlignmentToUse);

            // Create raw command with this content
            return(base.getRawCommand(dotMatrix, displayModel, controller, content));
        }
Beispiel #2
0
 private void setEditorDisplayContent()
 {
     // Draw content
     if (contentInEditor != ContentsInEditor.Text)
     {
         // Other content than text
         for (int y = 0; y < editor_heightInDots; y++)
         {
             for (int x = 0; x < editor_widthInDots; x++)
             {
                 if (contentInEditor == ContentsInEditor.Empty)
                 {
                     displayDots[y, x].setNewStateInstantly(0);
                 }
                 else if (contentInEditor == ContentsInEditor.Filled)
                 {
                     displayDots[y, x].setNewStateInstantly(((x + y) % (getStateCount() - 1)) + 1);
                 }
                 else if (contentInEditor == ContentsInEditor.Borders)
                 {
                     displayDots[y, x].setNewStateInstantly((x == 0 || y == 0 || x == editor_widthInDots - 1 || y == editor_heightInDots - 1) ? 1 : 0);
                 }
                 else
                 {
                     displayDots[y, x].setNewStateInstantly((x == 0 || y == 0 || x == editor_widthInDots - 1 || y == editor_heightInDots - 1 ||
                                                             (y == 1 && (x + 1) % 5 == 0) || (x == 1 && (y + 1) % 5 == 0) ||
                                                             (y == 2 && (x + 1) % 10 == 0) || (x == 2 && (y + 1) % 10 == 0)) ? 1 : 0);
                 }
             }
         }
     }
     else
     {
         // Text
         int[,] textContent = TextToContent.getContent(textInEditorText, textInEditorFont, true, false, 1);
         int height = textContent.GetLength(0);
         int width  = textContent.GetLength(1);
         int startY = editor_heightInDots / 2 - height / 2;
         int startX = editor_widthInDots / 2 - width / 2;
         for (int y = 0; y < editor_heightInDots; y++)
         {
             for (int x = 0; x < editor_widthInDots; x++)
             {
                 if (x >= startX && x < startX + width && y >= startY && y < startY + height)
                 {
                     displayDots[y, x].setNewStateInstantly(textContent[y - startY, x - startX]);
                 }
                 else
                 {
                     displayDots[y, x].setNewStateInstantly(0);
                 }
             }
         }
     }
     // Clear border dots
     if (displayBorderDots != null)
     {
         foreach (DisplayDot displayBorderDot in displayBorderDots)
         {
             displayBorderDot.setNewStateInstantly(0);
         }
     }
     // Broken dots for example
     setBrokenDots(editor_widthInDots, editor_heightInDots, true);
 }