コード例 #1
0
ファイル: MainForm.cs プロジェクト: lx128/ForSchool
        private void DessineSalle(string cur_salle)
        {
            FonctionCLR myfunc = new FonctionCLR();
            FonctionFichierBinaireCLR binfile = new FonctionFichierBinaireCLR("Plan.csv");

            char[] str = new char[16];
            int    comp, posx, posy;
            string nposte, line, sposx, sposy;

            CacheTousPostes();
            currentsalle = cur_salle;
            nbposteaff   = 0;

            this.label1.Text = "Carte de la salle " + cur_salle;
            while (!binfile.EndOfStream)
            {
                line = binfile.LireLigne();
                line = line.ToLower();

                if (line.Length == 0)              //Ligne vide ignoré
                {
                }
                else if ((line[0] == ';' & line[1] == ';'))
                {
                    //vide, donc ligne ignoré
                }
                else if ((line[0] == '/' & line[1] == '/') | line[0] == ':')
                {
                    //Contient commentaire ou étage, donc ligne ignoré
                }
                else                //suite traitement
                {
                    //Section poste
                    comp = line.IndexOf('-');
                    line.CopyTo(0, str, 0, comp);
                    nposte = new string(str, 0, comp);                  //La seule solution pour convertir char* en string
                    nposte = nposte.ToUpper();

                    //Bonne salle
                    if (nposte == cur_salle)
                    {
                        myfunc.element(line, 0, out nposte, ';');

                        //PosX
                        myfunc.element(line, 1, out sposx, ';');
                        posx = int.Parse(sposx);
                        comp = comp + 3;

                        //PosY
                        myfunc.element(line, 2, out sposy, ';');
                        posy = int.Parse(sposy);

                        AjoutePoste(nposte, posx, posy);
                    }
                }
            }
            binfile.Ferme();
        }
コード例 #2
0
/*		void ImageBoxClick(object sender, EventArgs e)
 *              {
 *                      if (poste_courant != ((PictureBox)sender).Text)
 *                      {
 *                              Process myProc;
 *                              myProc = Process.Start("vncviewer.exe", "-connect " + ((PictureBox)sender).Text + " -password -viewonly");
 *                              //			myProc.WaitForExit();
 *                      }
 *              }*/
        //Affiche classes dans 2e menu
        void ComboBox1DropdownClosed(object sender, EventArgs e)
        {
            bool   rec = false;
            int    comp;
            string line, nposte;

            comboBox2.Items.Clear();
            if (comboBox1.SelectedItem == null)
            {
                return;
            }

            binfile = new FonctionFichierBinaireCLR("Plan.csv");

            binfile.Seek0();
            while (!binfile.EndOfStream)
            {
                line = binfile.LireLigne();

                if (line.Length != 0)              //Ligne vide ignoré
                {
                    if (line[0] == '/' & line[1] == '/')
                    {
                        //Contient commentaire, donc ligne ignoré
                    }
                    else if (line[0] == ':' & line[1] != ':')              //étage
                    {
                        nposte = line.Substring(1);
                        if (nposte == comboBox1.SelectedItem.ToString())
                        {
                            rec = true;
                        }
                        else
                        {
                            rec = false;
                        }
                    }
                    else if (line[0] == ':' & line[1] == ':' & rec == true)           //salle
                    {
                        comp = line.IndexOf(';');
                        if (comp == -1)                     //pas trouvé donc pas d'alias
                        {
                            comp = line.Length;
                        }
                        nposte = line.Substring(2, comp - 2);
                        comboBox2.Items.Add(nposte);
                    }
                }
            }
            binfile.Ferme();
        }
コード例 #3
0
        //Affiche la mosaique de la salle sélectionné
        void ComboBox2DropdownClosed(object sender, EventArgs e)
        {
            bool   rec;
            int    comp = 0, comp2;
            string nposte, line;

//			SuspendLayout();

            if (comboBox2.SelectedItem == null | (string)comboBox2.SelectedItem == salle_courante)
            {
                return;
            }
            if (nb_poste != 0)
            {
                Déconnexion();
            }
            salle_courante   = comboBox2.SelectedItem.ToString();
            this.label1.Text = salle_courante;
            liste_poste      = new string[POSTESMAX, 4];

            //Recherche des postes de cette classe
            binfile = new FonctionFichierBinaireCLR("Plan.csv");
            binfile.Seek0();
            nb_poste = 0;
            rec      = false;
            while (!binfile.EndOfStream)
            {
                line = binfile.LireLigne();

                if (line.Length < 2)
                {
                    //Ligne vide ou contenant 1 caractère
                }
                else if ((line[0] == '/' & line[1] == '/') | (line[0] == ':' & line[1] != ':'))
                {
                    //Contient commentaire ou étage, donc ligne ignoré
                }
                else if (line[0] == ':' & line[1] == ':')          //salle
                {
                    nposte = line.Substring(2);

                    //Bonne salle
                    if (nposte == salle_courante)
                    {
                        rec = true;
                    }
                    else                    //Mauvaise salle
                    {
                        rec = false;
                    }
                }
                else if (line.Length >= 0 & rec & nb_poste < POSTESMAX)            //suite traitement
                {
                    //Section poste
                    comp   = 0;
                    comp2  = line.IndexOf(';');
                    nposte = line.Substring(comp, comp2 - comp);
                    liste_poste.SetValue(nposte.ToUpper(), nb_poste, 0);

                    comp   = comp2 + 1;
                    comp2  = line.IndexOf(';', comp);
                    nposte = line.Substring(comp, comp2 - comp);
                    liste_poste.SetValue(nposte.ToUpper(), nb_poste, 1);

                    comp   = comp2 + 1;
                    comp2  = line.Length;
                    nposte = line.Substring(comp, comp2 - comp);
                    liste_poste.SetValue(nposte.ToUpper(), nb_poste, 2);

                    liste_poste.SetValue("0", nb_poste, 3);
                    nb_poste++;
                }
                else if (line.Length >= 0 & rec & nb_poste == POSTESMAX)            //suite traitement
                {
                    MessageBox.Show("Il est, pour le moment, impossible d'afficher plus de " + POSTESMAX.ToString() + " postes par page avec ce logiciel\n\nSeul les 20 premiers seront visibles\n");
                    break;
                }
            }

            //préparation de la mosaique
            mode = "Mosaique";
            Connexion();
            binfile.Ferme();
//			ResumeLayout(false);
//			PerformLayout();
        }
コード例 #4
0
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //

            int    comp;
            string nposte, nsalle, line, test;

            poste_courant = System.Environment.MachineName.ToUpper();
            test          = System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\ntuser.log";
//simulation
//poste_courant="B01-01";

//			this.SuspendLayout();
            //Fichier absent
            if (File.Exists(test) == false)
            {
                //exit
                MessageBox.Show("Vous n'êtes pas autorisé à utiliser ce logiciel\n\nMerci de contacter xxxxxxx si ce comportement est anormal\n", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Button1Click(null, null);
                System.Environment.Exit(0);
            }
            //Fichier absent
            if (File.Exists("Plan.csv") == false)
            {
                //exit
                MessageBox.Show("Plan.csv manquant", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                System.Environment.Exit(0);
            }

/*			if (File.Exists("vncviewer.exe")==false)
 *                      {
 *                              //exit
 *                              MessageBox.Show("vncviewer.exe manquant","Erreur",MessageBoxButtons.OK,MessageBoxIcon.Error);
 *                              System.Environment.Exit(0);
 *                      }*/
            binfile = new FonctionFichierBinaireCLR("Plan.csv");

            //Objet dans collection
            //InitCollections();

            //Détection de la licence windows.
            RegistryKey Nkey   = Registry.LocalMachine;
            RegistryKey valKey = Nkey.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion", false);

            line = valKey.GetValue("ProductId").ToString();
            valKey.Close();
            Nkey.Close();
            if (line != "55711-641-6046354-23889")
            {
                MessageBox.Show("Vous n'êtes pas autorisé à utiliser ce logiciel\n\nMerci de contacter xxxxx si ce comportement est anormal\n", "Alerte", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Button1Click(0, null);
                System.Environment.Exit(1);
            }

            button2.Visible = false;
            button3.Visible = false;
            button4.Visible = false;
            button6.Visible = false;
            button7.Visible = false;
            label3.Visible  = false;
            label4.Visible  = false;

            for (comp = 0; comp < POSTESMAX; comp++)
            {
                LabelArray[comp]           = new Label();
                LabelArray[comp].Font      = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
                LabelArray[comp].Location  = new Point(comp % 5 * this.Width / 5 + comp % 5, comp / 5 * this.Height / 5 + 30);
                LabelArray[comp].Name      = "label" + comp.ToString();
                LabelArray[comp].Size      = new Size(70, 15);
                LabelArray[comp].TabIndex  = comp * 4;
                LabelArray[comp].Text      = "label" + comp.ToString();
                LabelArray[comp].TextAlign = ContentAlignment.TopCenter;
                LabelArray[comp].Visible   = false;
//				LabelArray[comp].Enabled = true;
                this.Controls.Add(LabelArray[comp]);

                RDArray[comp]                  = new RemoteDesktop();
                RDArray[comp].GetPassword      = passw;
                RDArray[comp].AutoScroll       = false;
                RDArray[comp].Location         = new Point(comp % 5 * this.Width / 5 + comp % 5, comp / 5 * this.Height / 5 + 30);
                RDArray[comp].Name             = "remoteDesktop" + comp.ToString();
                RDArray[comp].TabIndex         = comp * 4 + 1;
                RDArray[comp].Visible          = false;
                RDArray[comp].Enabled          = true;
                RDArray[comp].ContextMenuStrip = contextMenuStrip;
                this.Controls.Add(RDArray[comp]);

                LabelArrayMap[comp]           = new Label();
                LabelArrayMap[comp].Font      = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
                LabelArrayMap[comp].Location  = new Point(0, 30);
                LabelArrayMap[comp].Visible   = false;
                LabelArrayMap[comp].TabIndex  = comp * 4 + 3;
                LabelArrayMap[comp].Size      = new Size(70, 15);
                LabelArrayMap[comp].TextAlign = ContentAlignment.TopCenter;
                this.Controls.Add(this.LabelArrayMap[comp]);

                PictureBoxArray[comp] = new PictureBox();
                PictureBoxArray[comp].ImageLocation = "computer.bmp";
                PictureBoxArray[comp].Location      = new Point(0, 30);
                PictureBoxArray[comp].Size          = new Size(70, 52);
                PictureBoxArray[comp].SizeMode      = PictureBoxSizeMode.StretchImage;
                PictureBoxArray[comp].Name          = "pictureBox" + comp.ToString();
                PictureBoxArray[comp].TabIndex      = comp * 4 + 2;
                PictureBoxArray[comp].TabStop       = false;
                PictureBoxArray[comp].Visible       = false;
                this.Controls.Add(this.PictureBoxArray[comp]);
            }
            mode = "";

            //Version prof
            nposte = "";
            nsalle = "";
            if (vprof == true)
            {
                redémarrerToolStripMenuItem.Visible  = false;
                redémarrerToolStripMenuItem1.Visible = false;
                comboBox1.Visible = false;
                comboBox2.Visible = false;
                label1.Text       = "";
                while (!binfile.EndOfStream)
                {
                    line = binfile.LireLigne();

                    if (line.Length < 2)
                    {
                        //Ligne vide ou trop courte ignoré
                    }
                    else if (line[0] == '/' & line[1] == '/')
                    {
                        //Contient commentaire, donc ligne ignoré
                    }
                    else if (line[0] == ':' & line[1] != ':')              //etage
                    {
                        //etage
                    }
                    else if (line[0] == ':' & line[1] == ':')              //salle
                    {
                        nsalle = line.Substring(2);
                    }
                    else if (line.Length > 0)                  //poste
                    {
                        comp   = line.IndexOf(';');
                        nposte = line.Substring(0, comp);
                        if (nposte == poste_courant & nsalle != null)
                        {
                            comboBox2.Items.Add(nsalle);
                            comboBox2.SelectedItem = nsalle;
                            label2.Text            = "                VNC MANAGER 3.1\n\nCette version apporte de nouvelles fonctions.\n\n" +
                                                     "-prise de photo\n-prise de controle du poste\n\nHave fun !";
                            break;
                        }
                    }
                }
                if (binfile.EndOfStream)
                {
                    MessageBox.Show("Numéro de poste introuvable.\nLa salle ne contient peut être qu'un seul poste\n\nMerci de contacter xxxx si ce comportement est anormal", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    System.Environment.Exit(1);
                }
            }
            //Version Admin
            else
            {
                comp            = 0;
                label2.Visible  = false;
                button5.Visible = false;
                //MessageBox.Show(comp0.ToString());
                binfile.Seek0();
                while (!binfile.EndOfStream)
                {
                    line = binfile.LireLigne();

                    if (line.Length != 0)                    //Ligne vide ignoré
                    {
                        if (line[0] == ':' & line[1] != ':') //étage
                        {
                            nsalle = line.Substring(1);
                            comboBox1.Items.Add(nsalle);
                        }
                    }
                }
            }
//			this.ResumeLayout(false);
            binfile.Ferme();
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: lx128/ForSchool
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //

            char[] str = new char[16];
            int    comp = 0, comp0 = 0;
            string nsalle = "", line, étage;

            ceposte = System.Environment.MachineName.ToUpper();
//nsalle="B208";
//ceposte="B01-01";

            //Fichier absent
            if (System.IO.File.Exists("Plan.csv") == false)
            {
                //exit
                MessageBox.Show("Plan.csv manquant", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                System.Environment.Exit(0);
            }
            if (System.IO.File.Exists("vncviewer.exe") == false)
            {
                //exit
                MessageBox.Show("vncviewer.exe manquant", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                System.Environment.Exit(0);
            }
            binfile = new FonctionFichierBinaireCLR("Plan.csv");

            //Objet dans collection
            InitCollections();

            //Détection de la licence windows.
            RegistryKey Nkey   = Registry.LocalMachine;
            RegistryKey valKey = Nkey.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion", false);

            line = valKey.GetValue("ProductId").ToString();
            valKey.Close();
            Nkey.Close();
            if (line == "55711-641-6046354-23889")
            {
                MessageBox.Show("Vous n'êtes pas autorisé à utiliser ce logiciel\n\nMerci de contacter xxxx si ce comportement est anormal\n\nID du poste " + line, "Alerte", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                AProposToolStripMenuItemClick(0, null);
                System.Environment.Exit(1);
            }

//Version prof
            if (vprof == true)
            {
                //this.Etage1ToolStripMenuItem.Visible=false;
                //this.Etage2ToolStripMenuItem.Visible=false;
                //this.RdcToolStripMenuItem.Visible=false;

                comp = ceposte.IndexOf('-');
                if (comp != -1)
                {
                    ceposte.CopyTo(0, str, 0, comp);
                    nsalle = new string(str, 0, comp);                  //La seule solution pour convertir char* en string
                    nsalle = nsalle.ToUpper();
                    DessineSalle(nsalle);
                }
                else
                {
                    //this.label1.Text = "Numéro de poste non conforme.";
                    MessageBox.Show("Numéro de poste non conforme.\n\nMerci de contacter xxxx si ce comportement est anormal", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    System.Environment.Exit(1);
                }
                if (nbposteaff < 2)
                {
                    MessageBox.Show("Cette salle ne contient qu'un seul poste ou n'est pas prévu.\n\nMerci de contacter xxxx si ce comportement est anormal", "Alerte", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    System.Environment.Exit(1);
                }
                this.Show();
                MessageBox.Show("La mosaique est enfin disponible dans le menu en haut à gauche.", "Aide", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
//Version Admin
            else
            {
                comp0 = 0;
                while (!binfile.EndOfStream)
                {
                    line = binfile.LireLigne();

                    if (line.Length != 0)                  //Ligne vide ignoré
                    {
                        if (line[0] == '/' & line[1] == '/')
                        {
                            //Contient commentaire, donc ligne ignoré
                        }
                        else if (line[0] == ':' && line[1] != ':')                  //étage
                        {
                            line.CopyTo(1, str, 0, line.Length - 1);
                            nsalle = new string(str, 0, line.Length - 1);                        //La seule solution pour convertir char* en string
                            étage  = nsalle;
                        }
                        else if (line[0] == ':' && line[1] == ':')                  //Salle
                        {
//								nsalle.CopyTo(0,str,0,comp);
//								nsalle = new string(str,0,comp);//La seule solution pour convertir char* en string
                            comp0 += 1;

                            /*if(Array.BinarySearch(établissement, nsalle)==0)
                             * {
                             *      //établissement.SetValue(étage, nsalle);
                             * }*/
                        }
                    }
                }
//MessageBox.Show(comp0.ToString());
                établissement = new string[comp0, 2];
                binfile.Seek0();
                while (!binfile.EndOfStream)
                {
                    line = binfile.LireLigne();

                    if (line.Length != 0)                  //Ligne vide ignoré
                    {
                        if (line[0] == '/' & line[1] == '/')
                        {
                            //Contient commentaire, donc ligne ignoré
                        }
                        else if (line[0] == ':' & line[1] != ':')                  //étage
                        {
                            line.CopyTo(1, str, 0, line.Length - 1);
                            nsalle = new string(str, 0, line.Length - 1);                        //La seule solution pour convertir char* en string
                            comboBox1.Items.Add(nsalle);

/*							switch (line)
 *                                                      {
 *                                                              case ":RDC;X;Y"://RDC
 *                                                                              etage=0;
 *                                                              break;
 *                                                              case ":PREMIER;;"://egal à premier
 *                                                                              etage=1;
 *                                                              break;
 *                                                              case ":DEUXIEME;;"://egal à deuxieme
 *                                                                              etage=2;
 *                                                              break;
 *                                                      }*/
                        }

/*						else if (line[0]==':'&line[1]==':')//salle
 *                                              {
 *                                                      //Section poste
 *                                                      comp = line.IndexOf('-');
 *      //System.Windows.Forms.MessageBox.Show(comp.ToString());
 *                                                      line.CopyTo(0,str,0,comp);
 *                                                      nsalle = new string(str,0,comp);//La seule solution pour convertir char* en string
 *                                                      nsalle = nsalle.ToUpper();
 *
 *                                                      //changement du menu
 *                                                      if (nsalle!=nsallesave)//pour eviter de recommencer la même chose
 *                                                      {
 *                                                              if(etage==0)
 *                                                              {
 *                                                                      MyTSM3[comp0].Text=nsalle;
 *                                                                      MyTSM3[comp0].Visible=true;
 *                                                                      MyTSM3[comp0].Click += new System.EventHandler(MyTSM1Click);
 *                                                                      comp0++;
 *                                                              }
 *                                                              else if(etage==1)
 *                                                              {
 *                                                                      MyTSM1[comp1].Text=nsalle;
 *                                                                      MyTSM1[comp1].Visible=true;
 *                                                                      MyTSM1[comp1].Click += new System.EventHandler(MyTSM1Click);
 *                                                                      comp1++;
 *                                                              }
 *                                                              else if(etage==2)
 *                                                              {
 *                                                                      MyTSM2[comp2].Text=nsalle;
 *                                                                      MyTSM2[comp2].Visible=true;
 *                                                                      MyTSM2[comp2].Click += new System.EventHandler(MyTSM1Click);
 *                                                                      comp2++;
 *                                                              }
 *                                                      }
 *                                                      nsallesave=nsalle.ToString();
 *                                              }*/
                    }
                }
            }
            this.Resize += new EventHandler(MainForm_Resize);
            FormClosing += MainForm_Resize;

            SuspendLayout();
            for (comp = 0; comp < NBELEMENT; comp++)
            {
                LabelArray[comp]           = new Label();
                LabelArray[comp].Font      = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                LabelArray[comp].Location  = new System.Drawing.Point(comp % 5 * this.Width / 5 + comp % 5, comp / 5 * this.Height / 5);
                LabelArray[comp].Name      = "label" + comp.ToString();
                LabelArray[comp].Size      = new System.Drawing.Size(70, 15);
                LabelArray[comp].TabIndex  = LabelArray[comp].TabIndex;
                LabelArray[comp].Text      = "label" + comp.ToString();
                LabelArray[comp].TextAlign = System.Drawing.ContentAlignment.TopLeft;
                LabelArray[comp].Visible   = false;
                LabelArray[comp].Enabled   = false;
                Controls.Add(LabelArray[comp]);

                MyRDArray[comp]             = new RemoteDesktop();
                MyRDArray[comp].GetPassword = passw;
                MyRDArray[comp].AutoScroll  = false;
                MyRDArray[comp].Location    = new System.Drawing.Point(comp % 5 * this.Width / 5 + comp % 5, comp / 5 * this.Height / 5 + 24);
                MyRDArray[comp].Name        = "remoteDesktop" + comp.ToString();
                MyRDArray[comp].TabIndex    = 0;
                MyRDArray[comp].Visible     = false;
                MyRDArray[comp].Enabled     = false;
                this.Controls.Add(MyRDArray[comp]);
            }

            ResumeLayout(false);
            PerformLayout();

            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
        }