begin process at 2012 02 04 07:43:01
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

.NET

 > SIMULATION DE CONSOLE POUR WINDOWS MOBILE

SIMULATION DE CONSOLE POUR WINDOWS MOBILE


 Information sur la source

Note :
Aucune note
Catégorie :.NET Source .NET ( DotNet ) Classé sous :Windows Mobile, console, chronomètre Niveau :Débutant Date de création :23/11/2009 Date de mise à jour :23/11/2009 17:05:38 Vu / téléchargé :4 164 / 168

Auteur : originalcompo

Ecrire un message privé
Site perso
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Pour faire court, lorsqu'on développe en .NET sous WM, on ne dispose pas des mêmes outils que sous windows: pas de console, pas de véritable chrono à se mettre sous la dent pour trouver les processus qui sont trop lents...
Bref, la classe que je vous propose bien que très simple permet de remplir quelques lacunes. Je l'ai faite (baclé ?) en 2h, avec moins 2 mois d' "expérience" en C#... et pourtant elle me rend de grands services !

C'est la 2ième fois que j'essais de poster ce code... comme je n'ai pas envie de re écrire ce que j'ai déjà fait 2 fois (sur mon site et ici), voici le lien direct sur mon site internet où j'explique pourquoi et comment se servir de la classe etc...

http://newprograms.free.fr/CSHARP/index.ph p

Source

  • using System;
  • using System.Linq;
  • using System.Collections.Generic;
  • using System.Text;
  • using System.Drawing; // Point
  • using System.Runtime.InteropServices; // DllImport
  • using System.Windows.Forms; // Form
  • using System.IO; // StreamWriter
  • namespace OCagenda
  • {
  • class ClassDebugForWM
  • {
  • [DllImport("coredll.dll")]
  • public static extern int GetTickCount();
  • List<long> lstart = new List<long>();
  • Panel pchrono = new Panel();
  • TextBox lchrono = new TextBox();
  • int unite;
  • string ini = "";
  • public void init(Color c, string repini)
  • {
  • ini = repini;
  • lchrono.Parent = pchrono;
  • pchrono.Location = new Point(50, 100);
  • pchrono.BackColor = c;
  • lchrono.Multiline = true;
  • lchrono.BackColor = Color.White;
  • lchrono.Font = new Font("Arial", 7, FontStyle.Regular);
  • lchrono.WordWrap = false;
  • lchrono.ScrollBars = ScrollBars.Both;
  • unite = lchrono.Height;
  • pchrono.ClientSize = new Size(122, unite * 7 + 2);
  • lchrono.Location = new Point(1, 1 + unite);
  • lchrono.Size = new Size(120, unite * 6);
  • pchrono.MouseMove += new MouseEventHandler(TitreFenetre_MouseMove);
  • pchrono.MouseDown += new MouseEventHandler(TitreFenetre_MouseDown);
  • pchrono.MouseUp += new MouseEventHandler(TitreFenetre_MouseUp);
  • FenetreUtile = Screen.PrimaryScreen.WorkingArea;
  • //
  • Button b3 = new Button();
  • b3.Location = new Point(1, 1);
  • b3.Size = new Size(unite, unite);
  • b3.Font = lchrono.Font;
  • b3.Text = "-";
  • b3.Parent = pchrono;
  • b3.Click += delegate(Object sender, EventArgs e)
  • {
  • if (b3.Text == "-")
  • {
  • pchrono.ClientSize = new Size(122, unite * 1 + 2);
  • lchrono.Height = unite * 0;
  • b3.Text = "+";
  • }
  • else
  • {
  • pchrono.ClientSize = new Size(122, unite * 7 + 2);
  • lchrono.Height = unite * 6;
  • b3.Text = "-";
  • }
  • };
  • //
  • Button b1 = new Button();
  • b1.Location = new Point(1 +unite, 1);
  • b1.Size = new Size(unite, unite);
  • b1.Font = lchrono.Font;
  • b1.Text = "0";
  • b1.Parent = pchrono;
  • b1.Click += delegate(Object sender, EventArgs e)
  • {
  • lchrono.Text = "";
  • };
  • //
  • Button b2 = new Button();
  • b2.Location = new Point(1 + unite * 2, 1);
  • b2.Size = new Size(unite, unite);
  • b2.Font = lchrono.Font;
  • b2.Text = "10";
  • b2.Parent = pchrono;
  • b2.Click += delegate(Object sender, EventArgs e)
  • {
  • string[] st = lchrono.Text.Split('\r');
  • if (st.Length > 10)
  • {
  • lchrono.Text = st[0];
  • for (int i = 1; i < 10; i++)
  • lchrono.Text += "\r\n" + st[i].Substring(1, st[i].Length-1);
  • }
  • };
  • //
  • Button b4 = new Button();
  • b4.Location = new Point(1 + unite * 3, 1);
  • b4.Size = new Size(unite, unite);
  • b4.Font = lchrono.Font;
  • b4.Text = "s";
  • b4.Parent = pchrono;
  • b4.Click += delegate(Object sender, EventArgs e)
  • {
  • WriteIni();
  • };
  • }
  • // --------------------------------------------------------------------------------------------------
  • public void WriteIni()
  • {
  • try
  • {
  • using (StreamWriter sw = File.CreateText(ini + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"))
  • {
  • string[] st = lchrono.Text.Split('\r');
  • if (st.Length > 1)
  • {
  • sw.WriteLine(st[0]);
  • for (int i = 1; i < st.Length; i++)
  • sw.WriteLine(st[i].Substring(1, st[i].Length - 1));
  • }
  • sw.Close();
  • }
  • }
  • catch
  • {
  • // si l'écriture dans le mobile échoue, je ne fais rien !!!!
  • }
  • }
  • // --------------------------------------------------------------------------------------------------
  • Point MousePositionInCaption;
  • private void TitreFenetre_MouseDown(object sender, MouseEventArgs e)
  • {
  • MousePositionInCaption.X = e.X;
  • MousePositionInCaption.Y = e.Y;
  • }
  • Rectangle FenetreUtile;
  • Boolean NouveauTraitement = true;
  • Point NouvellePositionForm = new Point();
  • Point AnciennePosition = new Point();
  • //static Point this_Location = new Point();
  • private void TitreFenetre_MouseMove(object sender, MouseEventArgs e)
  • {
  • if (NouveauTraitement)
  • {
  • NouveauTraitement = false;
  • // e.X, e.Y = position de la souris dans le controle
  • NouvellePositionForm.X = pchrono.Location.X + (e.X - MousePositionInCaption.X);
  • NouvellePositionForm.Y = pchrono.Location.Y + (e.Y - MousePositionInCaption.Y);
  • if (!AnciennePosition.Equals(NouvellePositionForm))
  • {
  • AnciennePosition.X = NouvellePositionForm.X;
  • AnciennePosition.Y = NouvellePositionForm.Y;
  • }
  • NouveauTraitement = true;
  • }
  • }
  • private void TitreFenetre_MouseUp(object sender, MouseEventArgs e)
  • {
  • pchrono.Top = Math.Min(Math.Max(0, NouvellePositionForm.Y), Screen.PrimaryScreen.WorkingArea.Height -24 - pchrono.Height);
  • pchrono.Left = Math.Min(Math.Max(0, NouvellePositionForm.X), Screen.PrimaryScreen.WorkingArea.Width - pchrono.Width);
  • }
  • // --------------------------------------------------------------------------------------------------
  • public void show(string t, Boolean Clear)
  • {
  • if (Clear || (lchrono.Text == ""))
  • lchrono.Text = t;
  • else
  • lchrono.Text = t + "\r\n" + lchrono.Text;
  • }
  • // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • public void show(Form f, string t, Boolean Clear)
  • {
  • show(t, Clear);
  • pchrono.Parent = f;
  • pchrono.Visible = true;
  • pchrono.BringToFront();
  • }
  • // --------------------------------------------------------------------------------------------------
  • public void start()
  • {
  • lstart.Add(GetTickCount());
  • }
  • // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  • public void end(Form f, string s, Boolean Clear)
  • {
  • long lduree = GetTickCount() - lstart[lstart.Count - 1];
  • string t = lstart.Count.ToString() + " ; " +lduree.ToString() + (s != "" ? " ; " + s : "");
  • show(f, t, Clear);
  • lstart.RemoveAt(lstart.Count - 1);
  • }
  • // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • public void end(string s, Boolean Clear)
  • {
  • long lduree = GetTickCount() - lstart[lstart.Count - 1];
  • string t = lstart.Count.ToString() + " ; " + lduree.ToString() + (s != "" ? " ; " + s : "");
  • show(t, Clear);
  • lstart.RemoveAt(lstart.Count - 1);
  • }
  • // --------------------------------------------------------------------------------------------------
  • }
  • }
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Drawing;                   // Point
using System.Runtime.InteropServices;   // DllImport
using System.Windows.Forms;             // Form
using System.IO;                        // StreamWriter

namespace OCagenda
{
    class ClassDebugForWM
    {
        [DllImport("coredll.dll")]
        public static extern int GetTickCount();

        List<long> lstart = new List<long>();

        Panel pchrono = new Panel();
        TextBox lchrono = new TextBox();
        int unite;
        string ini = "";

        public void init(Color c, string repini)
        {
            ini = repini;
            lchrono.Parent = pchrono;
            pchrono.Location = new Point(50, 100);
            pchrono.BackColor = c;
            lchrono.Multiline = true;
            lchrono.BackColor = Color.White;
            lchrono.Font = new Font("Arial", 7, FontStyle.Regular);
            lchrono.WordWrap = false;
            lchrono.ScrollBars = ScrollBars.Both;
            unite = lchrono.Height;
            pchrono.ClientSize = new Size(122, unite * 7 + 2);
            lchrono.Location = new Point(1, 1 + unite);
            lchrono.Size = new Size(120, unite * 6);
            pchrono.MouseMove += new MouseEventHandler(TitreFenetre_MouseMove);
            pchrono.MouseDown += new MouseEventHandler(TitreFenetre_MouseDown);
            pchrono.MouseUp += new MouseEventHandler(TitreFenetre_MouseUp);
            FenetreUtile = Screen.PrimaryScreen.WorkingArea;
            //
            Button b3 = new Button();
            b3.Location = new Point(1, 1);
            b3.Size = new Size(unite, unite);
            b3.Font = lchrono.Font;
            b3.Text = "-";
            b3.Parent = pchrono;
            b3.Click += delegate(Object sender, EventArgs e)
            {
                if (b3.Text == "-")
                {
                    pchrono.ClientSize = new Size(122, unite * 1 + 2);
                    lchrono.Height = unite * 0;
                    b3.Text = "+";
                }
                else 
                {
                    pchrono.ClientSize = new Size(122, unite * 7 + 2);
                    lchrono.Height = unite * 6;
                    b3.Text = "-";
                }
            };
            //
            Button b1 = new Button();
            b1.Location = new Point(1 +unite, 1);
            b1.Size = new Size(unite, unite);
            b1.Font = lchrono.Font;
            b1.Text = "0";
            b1.Parent = pchrono;
            b1.Click += delegate(Object sender, EventArgs e)
            {
                lchrono.Text = "";
            };
            //
            Button b2 = new Button();
            b2.Location = new Point(1 + unite * 2, 1);
            b2.Size = new Size(unite, unite);
            b2.Font = lchrono.Font;
            b2.Text = "10";
            b2.Parent = pchrono;
            b2.Click += delegate(Object sender, EventArgs e)
            {
                string[] st = lchrono.Text.Split('\r');

                if (st.Length > 10)
                {
                    lchrono.Text = st[0];

                    for (int i = 1; i < 10; i++)
                        lchrono.Text += "\r\n" + st[i].Substring(1, st[i].Length-1);
                }
            };
            //
            Button b4 = new Button();
            b4.Location = new Point(1 + unite * 3, 1);
            b4.Size = new Size(unite, unite);
            b4.Font = lchrono.Font;
            b4.Text = "s";
            b4.Parent = pchrono;
            b4.Click += delegate(Object sender, EventArgs e)
            {
                WriteIni();
            };
        }

        // --------------------------------------------------------------------------------------------------
        
        public void WriteIni()
        {
            try
            {
                using (StreamWriter sw = File.CreateText(ini + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"))
                {
                    string[] st = lchrono.Text.Split('\r');

                    if (st.Length > 1)
                    {
                        sw.WriteLine(st[0]);

                        for (int i = 1; i < st.Length; i++)
                            sw.WriteLine(st[i].Substring(1, st[i].Length - 1));
                    }
                    sw.Close();
                }
            }
            catch
            {
                // si l'écriture dans le mobile échoue, je ne fais rien !!!!
            }
        }
        
        // --------------------------------------------------------------------------------------------------

        Point MousePositionInCaption;

        private void TitreFenetre_MouseDown(object sender, MouseEventArgs e)
        {
            MousePositionInCaption.X = e.X;
            MousePositionInCaption.Y = e.Y;
        }

        Rectangle FenetreUtile;
        Boolean NouveauTraitement = true;
        Point NouvellePositionForm = new Point();
        Point AnciennePosition = new Point();
        //static Point this_Location = new Point();

        private void TitreFenetre_MouseMove(object sender, MouseEventArgs e)
        {
            if (NouveauTraitement)
            {
                NouveauTraitement = false;
                // e.X, e.Y = position de la souris dans le controle
                NouvellePositionForm.X = pchrono.Location.X + (e.X - MousePositionInCaption.X);
                NouvellePositionForm.Y = pchrono.Location.Y + (e.Y - MousePositionInCaption.Y);

                if (!AnciennePosition.Equals(NouvellePositionForm))
                {
                    AnciennePosition.X = NouvellePositionForm.X;
                    AnciennePosition.Y = NouvellePositionForm.Y;
                }

                NouveauTraitement = true;
            }
        }

        private void TitreFenetre_MouseUp(object sender, MouseEventArgs e)
        {
            pchrono.Top = Math.Min(Math.Max(0, NouvellePositionForm.Y), Screen.PrimaryScreen.WorkingArea.Height -24 - pchrono.Height);
            pchrono.Left = Math.Min(Math.Max(0, NouvellePositionForm.X), Screen.PrimaryScreen.WorkingArea.Width - pchrono.Width);
        }

        // --------------------------------------------------------------------------------------------------

        public void show(string t, Boolean Clear)
        {
            if (Clear || (lchrono.Text == ""))
                lchrono.Text = t;
            else
                lchrono.Text = t + "\r\n" + lchrono.Text;
        }

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        public void show(Form f, string t, Boolean Clear)
        {
            show(t, Clear);
            pchrono.Parent = f;
            pchrono.Visible = true;
            pchrono.BringToFront();
        }

        // --------------------------------------------------------------------------------------------------
        
        public void start()
        {
            lstart.Add(GetTickCount());
        }

        // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
        
        public void end(Form f, string s, Boolean Clear)
        {
            long lduree = GetTickCount() - lstart[lstart.Count - 1];
            string t = lstart.Count.ToString() + " ; " +lduree.ToString() + (s != "" ? " ; " + s : "");
            show(f, t, Clear);
            lstart.RemoveAt(lstart.Count - 1);
        }

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        public void end(string s, Boolean Clear)
        {
            long lduree = GetTickCount() - lstart[lstart.Count - 1];
            string t = lstart.Count.ToString() + " ; " + lduree.ToString() + (s != "" ? " ; " + s : "");
            show(t, Clear);
            lstart.RemoveAt(lstart.Count - 1);
        }

        // --------------------------------------------------------------------------------------------------
    }
}

 Conclusion

http://newprograms.free.fr/CSHARP/index.php

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

23 novembre 2009 17:05:38 :
rajout d'une image

 Sources de la même categorie

Source avec Zip Source avec une capture Source .NET (Dotnet) ORIONBANQUE par toutphp
Source avec Zip Source avec une capture Source .NET (Dotnet) ORIONAPPLICATION par toutphp
Source avec Zip SOCKET CONNEXION CLIENT & SERVEUR par ziedto83
Source avec Zip Source .NET (Dotnet) FFMPEG.NET : WRAPPER .NET DE FFMPEG par MasterShadows
Source avec Zip Source .NET (Dotnet) ATTACHER, CRÉER ET SAUVEGARDER UNE BASE DE DONNÉES SQL SERVE... par Alvepinai

 Sources en rapport avec celle ci

Source avec Zip Source .NET (Dotnet) CLONE/FORK DES FLUX DE LA CONSOLE : PERMETTRE LA REDIRECTION... par ShareVB
Source avec Zip Source avec une capture (CONSOLE) TROUVER LA CLEF D'UN CODE INSEE EN DONNANT SES 13 ... par Maxime95k
Source .NET (Dotnet) GREP POUR WINDOWS par Warny
Source avec Zip Source .NET (Dotnet) LOG DES CONSOLE WRITELINE par jb_exe
Source avec Zip Source avec une capture Source .NET (Dotnet) CHRONOMÈTRE EN WPF par poiuytrez3

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

PB avec les application console [ par Mike ] Salut, j'ai un probleme avec les application en mode consol ( style fenetre DOS ), lorsque je lance un de ces programmes, il s'arrete automatiquement Pb avec mon programme - help... [ par adrien78 ] Voici les sources de mon programme il bug :// project created on 09/11/2002 at 10:51// By Adrien HADJ SALAH// http://www.informatick.com// Pour me rem problemes de compilation [ par clebard ] bonjour à tous,newbie j'avais à plusieurs reprises déposé des appels au secours car mon CSC.exe n'était pas reconnu dans la console DOS.J'ai (enfin et faire un GUI [ par raver2046 ] Bon voila, sa fais un moment que je me creuse la tête pour essayer de faire une GUI ( comprenez par la une appli WIN32 avec des fenêtres et tout) qui exporter les donnés d'une base dans un fichier.TXT [ par kmbmaster ] salut , en faite voila je suis débutant en c# dailleurs meme en programmation donc je voulais vous demander SVP si possible un peu daide .voila le Soucis avec un switch [ par zigzou ] Voila je viens de commencer le C#, et je viens de tombé sur un problème... :(En effet je demande au user de rentré un nombre je fais mes cas et en fai Problème de console au chargement de la form [ par Jujufouq ] Bonjour à tous!Je ne sais pas si ce problème a déjà été posté, mais j'ai ce problème. Voici mon code :using System;using System.Windows.Forms;class fr Enlever la console de son programme .net windows [ par ricklekebekoi ] J'ai mon programme , tout fonctionne, mais jai toujours la *** de console derriere .. comment je peut l'enlever ? [C#] System.Information & mode console [ par scoubidou944 ] using System.Windows.Forms;string szComputerName = System.Windows.Forms.ComputerName;Vala, ca marche nickel, le pb, c'est qu'en mode console, 'using S Application graphique avec Console [ par oberown ] Comment faire une application graphique (une windows form) et qui en même temps utilise une console.Par exemple qd on utilise une fonction qu'on puiss


Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 4,415 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales