Esempio n. 1
0
        private void FxCreateModules(int lTotal)
        {
            PanModule.Controls.Clear();

            SplitContainer[]  ObjModule           = new SplitContainer[lTotal];
            FlowLayoutPanel[] ObjModuleText       = new FlowLayoutPanel[lTotal];
            PictureBox[]      ObjImage            = new PictureBox[lTotal];
            Label[]           ObjLabelName        = new Label[lTotal];
            Label[]           ObjLabelDescription = new Label[lTotal];

            for (int lCounter = 0; lCounter < lTotal; lCounter++)
            {
                ObjModule[lCounter] = new SplitContainer
                {
                    IsSplitterFixed  = true,
                    Width            = 300,
                    Height           = 80,
                    SplitterDistance = 80,
                    TabStop          = false
                };

                ObjImage[lCounter] = new PictureBox
                {
                    Dock     = DockStyle.Fill,
                    SizeMode = PictureBoxSizeMode.Zoom,
                    Cursor   = Cursors.Hand,
                    //Image = Properties.Resources.Administrator,
                    Tag = lCounter.ToString()
                };

                long lModuleId = 0;

                try
                {
                    lModuleId = long.Parse(ObjDtModule.Rows[lCounter][3].ToString());
                }
                catch
                {
                    lModuleId = 0;
                }

                if (lModuleId > 0)
                {
                    Bitmap ObjLogo = ClsFunctions.FxGetModuleLogo(lModuleId);

                    if (ObjImage != null)
                    {
                        ObjImage[lCounter].Image = ObjLogo;
                    }
                }

                ObjModuleText[lCounter] = new FlowLayoutPanel
                {
                    Dock          = DockStyle.Fill,
                    FlowDirection = FlowDirection.TopDown,
                    WrapContents  = false
                };

                ObjLabelName[lCounter] = new Label
                {
                    AutoSize  = true,
                    Cursor    = Cursors.Hand,
                    Font      = new Font("Microsoft Sans Serif", 9.75F, FontStyle.Bold),
                    ForeColor = Color.FromArgb(76, 106, 169),
                    Text      = ObjDtModule.Rows[lCounter][0].ToString(),
                    Tag       = lCounter.ToString()
                };

                ObjLabelDescription[lCounter] = new Label
                {
                    AutoSize = true,
                    Cursor   = Cursors.Hand,
                    Text     = ObjDtModule.Rows[lCounter][1].ToString(),
                    Tag      = lCounter.ToString()
                };

                ObjImage[lCounter].Click += new EventHandler(ObjImage_Click);

                ObjLabelName[lCounter].Click        += new EventHandler(ObjLabel_Click);
                ObjLabelDescription[lCounter].Click += new EventHandler(ObjLabel_Click);

                ObjModuleText[lCounter].Controls.Add(ObjLabelName[lCounter]);
                ObjModuleText[lCounter].Controls.Add(ObjLabelDescription[lCounter]);

                ObjModule[lCounter].Panel1.Controls.Add(ObjImage[lCounter]);
                ObjModule[lCounter].Panel2.Controls.Add(ObjModuleText[lCounter]);

                PanModule.Controls.Add(ObjModule[lCounter]);
            }
        }