Affichage drawtext

goffle Messages postés 78 Date d'inscription mercredi 11 mai 2005 Statut Membre Dernière intervention 3 juillet 2012 - 21 mai 2009 à 22:00
goffle Messages postés 78 Date d'inscription mercredi 11 mai 2005 Statut Membre Dernière intervention 3 juillet 2012 - 22 mai 2009 à 11:03
Bonjour,

Je découvre le Csharp actuellement.
Je doit afficher un message à l'aide de drawtext sur l'émulateur microsoft avec microsoft visual studio 2008.

J'ai écrit un bout de code mais il doit me manquer quelques choses. Il ne fonctionne pas :

J'ai juste un écran blanc ...

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;

using FusionWare.SPOT.Hardware;

namespace MFWindowApplication22
{
    /// <summary>Core apllication object for the application</summary>
    public class App : FusionWare.SPOT.Application
    {
        #region Application Entry Point
        /// <summary>Main entry point for the application</summary>
        public static void Main()
        {
            // Init and run the application main window
            App theApp = new App();
            theApp.Run(theApp.MainWindow);
        }
        #endregion

        #region Constructor
        /// <summary>Constructor for the application object</summary>
        /// <remarks>
        /// Creates a new Full Screen BouncyViewWindow as the
        /// main window for the application.
        /// </remarks>
        App()
            : base(App.ButtonDefs)
        {
            this.MainWindow = new MainViewWindow();
            this.MainWindow.Height = SystemMetrics.ScreenHeight;
            this.MainWindow.Width = SystemMetrics.ScreenWidth;
        }
        #endregion

        #region Button Definitions
        /// <summary>Button Definitions for this application</summary>
        /// <remarks>
        /// For Demo purposes defines all the directions and select button.
        /// Currently the only one actually used in this application is the select button.
        /// </remarks>
        static ButtonDefinition[] ButtonDefs = {
                // TODO: Add button definitions here for this application
                // new ButtonDefinition(Button.Up, true, Pins.SW5),
                // new ButtonDefinition(Button.Left, true, Pins.SW6),
                // new ButtonDefinition(Button.Select, false, Pins.SW7),
                // new ButtonDefinition(Button.Right, true, Pins.SW8),
                // new ButtonDefinition(Button.Down, true, Pins.SW9)
        };
        #endregion
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Hardware;
using DeviceSolutions.SPOT.Hardware;

namespace MFWindowApplication22
{
    /// <summary>Main Window For the application</summary>
    /// <remarks>
    /// Creates a Text region child element
    /// </remarks>
    public class MainViewWindow : Window
    {
        static InterruptPort SW1;
        private Font SmallFont;
        static int var = 0;
        /// <summary> Constructor for the window</summary>
        public MainViewWindow()
        {
             this.SmallFont = Resources.GetFont(Resources.FontResources.small);
             SW1 = new InterruptPort(Tahoe.Pins.SW1, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
             SW1.OnInterrupt += new NativeEventHandler(SW1_OnInterrupt);
             this.Child = new view(this.SmallFont,var);
        }

        void SW1_OnInterrupt(uint data1, uint data2, TimeSpan time)
        {
            var++;
        }
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Hardware;
using DeviceSolutions.SPOT.Hardware;

namespace MFWindowApplication22
{
    class view : UIElement
    {
        private Bitmap bm;
        private Font myfont;
        private int var;
        public view(Font textFont,int nb){
                   bm = new Bitmap(240, 320);
                   myfont = textFont;
                   var = nb;
                   drawText(bm);
                               }
        public void drawText(Bitmap bm)
        {
            bm.Clear();
            bm.DrawText("HELLO. Variale n° :" + var, myfont, Color.Black, 1, 1);
            bm.DrawLine(Color.Black, 2, 1, 1, 100, 100);
 
        }
    }
}

1 réponse

goffle Messages postés 78 Date d'inscription mercredi 11 mai 2005 Statut Membre Dernière intervention 3 juillet 2012
22 mai 2009 à 11:03
je crois qu'il faut utiliser un truc comme :

   base.OnRender(dc);
mais je ne comprend pas comment cça fonctionne

help plz
0
Rejoignez-nous