コード例 #1
0
 public StatusBar(AppWindow owner)
 {
     this.BackColor = owner.DarkColor;
     this.Dock      = DockStyle.Bottom;
     this.ForeColor = owner.LightColor;
     this.Height    = sz;
 }
コード例 #2
0
        public LeftPanelButton(AppWindow owner)
        {
            this.owner = owner;

            this.Font = new Font(this.Font.FontFamily, 15.0f);
            this.FlatAppearance.BorderSize = 0;
            this.FlatStyle         = FlatStyle.Flat;
            this.Height            = 40;
            this.Width             = 280;
            this.TextImageRelation = TextImageRelation.ImageBeforeText;

            this.Click += delegate
            {
                foreach (Control control in this.Parent.Controls)
                {
                    if (control is LeftPanelButton && this != control)
                    {
                        ((LeftPanelButton)control).Unhighlight();
                    }
                }
                this.Highlight();
            };

            this.Unhighlight();
        }
コード例 #3
0
            public Frame(AppWindow owner)
            {
                this.BackColor = owner.DarkColor;

                this.MouseDown += delegate(object sender, MouseEventArgs e)
                {
                    initialPoint = e.Location;
                };
            }
コード例 #4
0
            public LeftFrame(AppWindow owner)
                : base(owner)
            {
                this.Dock  = DockStyle.Left;
                this.Width = thickness;

                this.MouseMove += delegate(object sender, MouseEventArgs e)
                {
                    if (!owner.Maximized && !owner.IsFixed)
                    {
                        if (e.Button == System.Windows.Forms.MouseButtons.Left)
                        {
                            finalPoint = e.Location;

                            int deltaX = (finalPoint.X - initialPoint.X);
                            int deltaY = (finalPoint.Y - initialPoint.Y);

                            if (this.Cursor == Cursors.SizeWE)
                            {
                                owner.Location = new Point(owner.Location.X + deltaX, owner.Location.Y);
                                owner.Width   -= deltaX;
                            }
                            else if (this.Cursor == Cursors.SizeNWSE)
                            {
                                owner.Location = new Point(owner.Location.X + deltaX, owner.Location.Y + deltaY);
                                owner.Size     = new Size(owner.Width - deltaX, owner.Height - deltaY);
                            }
                            else if (this.Cursor == Cursors.SizeNESW)
                            {
                                deltaY         = -deltaX;//a hack to solve a problem I cant figure out
                                owner.Location = new Point(owner.Location.X + deltaX, owner.Location.Y);
                                owner.Size     = new Size(owner.Width - deltaX, owner.Height + deltaY);
                            }
                        }
                        else
                        {
                            if (e.Y <= cornerThickness)
                            {
                                this.Cursor = Cursors.SizeNWSE;
                            }
                            else if ((this.Height - e.Y) <= cornerThickness)
                            {
                                this.Cursor = Cursors.SizeNESW;
                            }
                            else
                            {
                                this.Cursor = Cursors.SizeWE;
                            }
                        }
                    }
                };
            }
コード例 #5
0
        public LoginForm(AppWindow owner)
        {
            InitializeComponent();

            this.Dock      = DockStyle.Fill;
            this.BackColor = owner.LightColor;

            owner.LeftPanel.Enabled = false;

            txtUsername = new HintedTextBox("username")
            {
                BorderStyle = System.Windows.Forms.BorderStyle.None,
                Font        = new System.Drawing.Font(this.Font.FontFamily, 11.0F),
                Width       = 300
            };
            UnderlineFor lblLine1 = new UnderlineFor(txtUsername, owner.DarkColor, SystemColors.GrayText)
            {
                BackColor = owner.DarkColor,
            };

            this.Controls.Add(txtUsername);
            this.Controls.Add(lblLine1);

            txtPassword = new HintedTextBox("password")
            {
                BorderStyle = txtUsername.BorderStyle,
                Font        = txtUsername.Font,
                //IsPasswordBox = true,
                Width = txtUsername.Width
            };
            UnderlineFor lblLine2 = new UnderlineFor(txtPassword, owner.DarkColor, SystemColors.GrayText)
            {
                BackColor = SystemColors.GrayText,
            };

            this.Controls.Add(txtPassword);
            this.Controls.Add(lblLine2);
            txtPassword.KeyDown += delegate { txtPassword.PasswordChar = '*'; };

            btnLogin = new Button()
            {
                BackColor = owner.DarkColor,
                ForeColor = owner.LightColor,
                FlatStyle = FlatStyle.Flat,
                Font      = new Font(this.Font.FontFamily, 16.0f, FontStyle.Bold),
                Size      = new Size(txtUsername.Width, 50),
                Text      = "Login"
            };
            this.Controls.Add(btnLogin);
            btnLogin.Click += delegate
            {
                if (txtUsername.Text == "admin" && txtPassword.Text == "admin")
                {
                    owner.LeftPanel.Enabled = true;
                    owner.Body.Controls.Remove(this);
                }
                else
                {
                    MessageBox.Show("Invalid username and password");
                }
            };

            this.SizeChanged += delegate
            {
                txtPassword.Location = new Point((this.Width - txtPassword.Width) / 2, (this.Height - txtPassword.Height) / 2);
                lblLine2.Location    = new Point(txtPassword.Location.X, txtPassword.Bottom);
                txtUsername.Location = new Point(txtPassword.Left, txtPassword.Top - (txtUsername.Height + 20));
                lblLine1.Location    = new Point(txtUsername.Location.X, txtUsername.Bottom);
                btnLogin.Location    = new Point(txtPassword.Location.X, txtPassword.Bottom + 20);
            };
        }
コード例 #6
0
        public ReportForm(AppWindow owner)
        {
            InitializeComponent();

            this.Dock      = DockStyle.Fill;
            this.BackColor = owner.LightColor;

            this.AutoScroll = true;

            this.Load += delegate
            {
                IdpDb db      = new IdpDb();
                var   persons = db.GetPersons();

                ChartArea caGender = new ChartArea()
                {
                    Name = "caGender"
                };
                Legend leGender = new Legend()
                {
                    BackColor = Color.Green,
                    ForeColor = Color.Black,
                    Name      = "leGender",
                    Title     = "Gender"
                };
                Chart chGender = new Chart()
                {
                    BackColor = Color.LightYellow,
                    Name      = "chGender",
                    Location  = new Point(100, 100),
                    Size      = new Size(400, 400),
                };
                Series serGender = new Series()
                {
                    Name              = "serGender",
                    Color             = Color.Green,
                    IsVisibleInLegend = true,
                    IsXValueIndexed   = true,
                    ChartType         = SeriesChartType.Pie
                };
                double females = persons.Count(p => p.Gender.ToLower() == "female");
                double males   = persons.Count(p => p.Gender.ToLower() == "male");
                serGender.Points.Add(females);
                serGender.Points.Add(males);
                serGender.Points[0].AxisLabel  = females + " (" + (females / (females + males)) * 100 + "%)";
                serGender.Points[0].LegendText = "Female";
                serGender.Points[1].AxisLabel  = males + " (" + (males / (females + males)) * 100 + "%)";
                serGender.Points[1].LegendText = "Male";

                chGender.ChartAreas.Add(caGender);
                chGender.ChartAreas[0].BackColor = Color.Transparent;
                chGender.Legends.Add(leGender);
                chGender.Series.Clear();
                chGender.Palette = ChartColorPalette.Fire;
                chGender.Titles.Add("Gender Distribution");
                chGender.Series.Add(serGender);
                chGender.Invalidate();
                this.Controls.Add(chGender);

                ChartArea caMarital = new ChartArea()
                {
                    Name = "caMarital"
                };
                Legend leMarital = new Legend()
                {
                    BackColor = Color.Blue,
                    ForeColor = Color.White,
                    Name      = "leMarital",
                    Title     = "Marital Status"
                };
                Chart chMarital = new Chart()
                {
                    BackColor = Color.LightBlue,
                    Name      = "chMarital",
                    Location  = new Point(chGender.Right + 100, chGender.Top),
                    Size      = chGender.Size,
                };
                Series serMarital = new Series()
                {
                    Name              = "serMarital",
                    Color             = Color.Green,
                    IsVisibleInLegend = true,
                    IsXValueIndexed   = true,
                    ChartType         = SeriesChartType.Pie
                };
                double single       = persons.Count(p => p.MaritalStatus.ToLower() == "single");
                double married      = persons.Count(p => p.MaritalStatus.ToLower() == "married");
                double widowed      = persons.Count(p => p.MaritalStatus.ToLower() == "widowed");
                double separated    = persons.Count(p => p.MaritalStatus.ToLower() == "separated");
                double others       = persons.Count(p => p.MaritalStatus.ToLower() == "others");
                double totalMarital = single + married + widowed + separated + others;
                serMarital.Points.Add(single);
                serMarital.Points.Add(married);
                serMarital.Points.Add(widowed);
                serMarital.Points.Add(separated);
                serMarital.Points.Add(others);
                serMarital.Points[0].AxisLabel  = single + " (" + (single / totalMarital) * 100 + "%)";
                serMarital.Points[0].LegendText = "Single";
                serMarital.Points[1].AxisLabel  = married + " (" + (married / totalMarital) * 100 + "%)";
                serMarital.Points[1].LegendText = "Married";
                serMarital.Points[2].AxisLabel  = widowed + " (" + (widowed / totalMarital) * 100 + "%)";
                serMarital.Points[2].LegendText = "Widowed";
                serMarital.Points[3].AxisLabel  = separated + " (" + (separated / totalMarital) * 100 + "%)";
                serMarital.Points[3].LegendText = "Separated";
                serMarital.Points[4].AxisLabel  = others + " (" + (others / totalMarital) * 100 + "%)";
                serMarital.Points[4].LegendText = "Others";

                chMarital.ChartAreas.Add(caMarital);
                chMarital.ChartAreas[0].BackColor = Color.Transparent;
                chMarital.Legends.Add(leMarital);
                chMarital.Series.Clear();
                //chMarital.Palette = ChartColorPalette.Berry;
                chMarital.Titles.Add("Marital Status Distribution");
                chMarital.Series.Add(serMarital);
                chMarital.Invalidate();
                this.Controls.Add(chMarital);

                ChartArea caAge = new ChartArea()
                {
                    Name = "caAge"
                };
                Legend legAge = new Legend()
                {
                    BackColor = Color.Green,
                    ForeColor = Color.Black,
                    Name      = "legAge",
                    Title     = "Age Group"
                };
                Chart chAge = new Chart()
                {
                    BackColor = Color.LightGreen,
                    Name      = "chAge",
                    Location  = new Point(chGender.Left, chGender.Bottom + 100),
                    Size      = new Size(900, chGender.Height),
                };
                Series serAge = new Series()
                {
                    Name              = "serAge",
                    Color             = Color.Green,
                    IsVisibleInLegend = false,
                    IsXValueIndexed   = true,
                    ChartType         = SeriesChartType.Column
                };
                double zeroTo4       = persons.Count(p => age(p) >= 0 && age(p) < 5);
                double fiveTo12      = persons.Count(p => age(p) >= 5 && age(p) < 13);
                double thirteenTo19  = persons.Count(p => age(p) >= 13 && age(p) < 20);
                double twentyTo35    = persons.Count(p => age(p) >= 20 && age(p) < 36);
                double thirtysixTo70 = persons.Count(p => age(p) >= 36 && age(p) < 71);
                double above70       = persons.Count(p => age(p) >= 71);
                double totalAge      = zeroTo4 + fiveTo12 + thirteenTo19 + twentyTo35 + thirtysixTo70 + above70;
                serAge.Points.Add(zeroTo4);
                serAge.Points.Add(fiveTo12);
                serAge.Points.Add(thirteenTo19);
                serAge.Points.Add(twentyTo35);
                serAge.Points.Add(thirtysixTo70);
                serAge.Points.Add(above70);
                serAge.Points[0].AxisLabel  = "0-4";
                serAge.Points[0].LegendText = "0-4";
                serAge.Points[0].Label      = zeroTo4 + " (" + (zeroTo4 / totalAge) * 100 + "%)";
                serAge.Points[1].AxisLabel  = "5-12";
                serAge.Points[1].LegendText = "5-12";
                serAge.Points[1].Label      = fiveTo12 + " (" + (fiveTo12 / totalAge) * 100 + "%)";
                serAge.Points[2].AxisLabel  = "13-19";
                serAge.Points[2].LegendText = "13-19";
                serAge.Points[2].Label      = thirteenTo19 + " (" + (thirteenTo19 / totalAge) * 100 + "%)";
                serAge.Points[3].AxisLabel  = "20-35";
                serAge.Points[3].LegendText = "20-35";
                serAge.Points[3].Label      = twentyTo35 + " (" + (twentyTo35 / totalAge) * 100 + "%)";
                serAge.Points[4].AxisLabel  = "36-70";
                serAge.Points[4].LegendText = "36-70";
                serAge.Points[4].Label      = thirtysixTo70 + " (" + (thirtysixTo70 / totalAge) * 100 + "%)";
                serAge.Points[5].AxisLabel  = "70-~";
                serAge.Points[5].LegendText = "70-~";
                serAge.Points[5].Label      = above70 + " (" + (above70 / totalAge) * 100 + "%)";

                chAge.ChartAreas.Add(caAge);
                chAge.ChartAreas[0].BackColor = Color.Transparent;
                chAge.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
                chAge.ChartAreas[0].AxisY.MajorGrid.Enabled = true;
                chAge.Legends.Add(legAge);
                chAge.Series.Clear();
                chAge.Palette = ChartColorPalette.Excel;
                chAge.Titles.Add("Age Distribution");
                chAge.Series.Add(serAge);
                chAge.Invalidate();
                this.Controls.Add(chAge);
            };

            //ChartArea chartArea1 =
            //    new System.Windows.Forms.DataVisualization.Charting.ChartArea();
            //System.Windows.Forms.DataVisualization.Charting.Legend legend1 =
            //    new System.Windows.Forms.DataVisualization.Charting.Legend();
            //System.Windows.Forms.DataVisualization.Charting.Chart chart1 =
            //    new System.Windows.Forms.DataVisualization.Charting.Chart();
            //chartArea1.Name = "ChartArea1";
            //chart1.ChartAreas.Add(chartArea1);
            //chart1.Dock = System.Windows.Forms.DockStyle.Fill;
            //legend1.Name = "Legend1";
            //chart1.Legends.Add(legend1);
            //chart1.Location = new System.Drawing.Point(0, 50);
            //chart1.Name = "chart1";
            //// this.chart1.Size = new System.Drawing.Size(284, 212);
            //chart1.TabIndex = 0;
            //chart1.Text = "chart1";
            ////this.Controls.Add(chart1);
            //chart1.Series.Clear();
            //var series1 = new System.Windows.Forms.DataVisualization.Charting.Series
            //{
            //    Name = "Series1",
            //    Color = System.Drawing.Color.Green,
            //    IsVisibleInLegend = false,
            //    IsXValueIndexed = true,
            //    ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line
            //};

            //chart1.Series.Add(series1);

            //for (int i = 0; i < 100; i++)
            //{
            //    series1.Points.AddXY(i, f(i));
            //}
            //chart1.Invalidate();
            //===========================
            ////chart1.Series.Add(new System.Windows.Forms.DataVisualization.Charting.Series("frank", 12));
            //var series = new System.Windows.Forms.DataVisualization.Charting.Series();
            //series.Name = "male";
            //chart1.Series.Add("Male");
            //chart1.Series.Add("Female");
            //Random rdn = new Random();
            //for (int i = 0; i < 50; i++)
            //{
            //    chart1.Series["Male"].Points.AddXY
            //                    (rdn.Next(0, 10), rdn.Next(0, 10));
            //    chart1.Series["Female"].Points.AddXY
            //                    (rdn.Next(0, 10), rdn.Next(0, 10));
            //}
            //chart1.Series["Male"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            //chart1.Series["Male"].Color = Color.Red;

            //chart1.Series["Female"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            //chart1.Series["Female"].Color = Color.Blue;
        }
コード例 #7
0
        public VerificationForm(AppWindow owner)
        {
            InitializeComponent();

            this.Dock      = DockStyle.Fill;
            this.BackColor = owner.LightColor;

            verificationControl = new DPFP.Gui.Verification.VerificationControl()
            {
                Size = new Size(100, 100)
            };
            verificationControl.ReaderSerialNumber = serial;
            verificationControl.OnComplete        += VerificationControl_OnComplete;
            this.Controls.Add(verificationControl);

            picBox = new PictureBox()
            {
                Size = new Size(300, 300)
            };
            this.Controls.Add(picBox);

            btnCard = new Button()
            {
                BackColor = owner.DarkColor,
                ForeColor = owner.LightColor,
                Font      = new Font(this.Font.FontFamily, 16.0f, FontStyle.Bold),
                Size      = new Size(picBox.Width, 50),
                Text      = "Show Card",
                Visible   = false,
            };
            this.Controls.Add(btnCard);
            btnCard.Click += delegate
            {
                if (FoundPerson != null)
                {
                    IdCardWindow idCardWin = new TestForm1.IdCardWindow(FoundPerson);
                    idCardWin.ShowDialog();
                }
            };

            lblName = new Label()
            {
                AutoSize  = false,
                Font      = new Font(this.Font.FontFamily, 16.0f, FontStyle.Regular),
                TextAlign = ContentAlignment.MiddleLeft,
                Width     = 500
            };
            this.Controls.Add(lblName);

            lblAge = new Label()
            {
                AutoSize  = lblName.AutoSize,
                Font      = lblName.Font,
                TextAlign = lblName.TextAlign,
                Width     = lblName.Width
            };
            this.Controls.Add(lblAge);

            lblGender = new Label()
            {
                AutoSize  = lblName.AutoSize,
                Font      = lblName.Font,
                TextAlign = lblName.TextAlign,
                Width     = lblName.Width
            };
            this.Controls.Add(lblGender);

            lblMaritalStatus = new Label()
            {
                AutoSize  = lblName.AutoSize,
                Font      = lblName.Font,
                TextAlign = lblName.TextAlign,
                Width     = lblName.Width
            };
            this.Controls.Add(lblMaritalStatus);

            lblState = new Label()
            {
                AutoSize  = lblName.AutoSize,
                Font      = lblName.Font,
                TextAlign = lblName.TextAlign,
                Width     = lblName.Width
            };
            this.Controls.Add(lblState);

            lblLGA = new Label()
            {
                AutoSize  = lblName.AutoSize,
                Font      = lblName.Font,
                TextAlign = lblName.TextAlign,
                Width     = lblName.Width
            };
            this.Controls.Add(lblLGA);

            this.SizeChanged += delegate
            {
                verificationControl.Location = new Point((this.Width - verificationControl.Width) / 2, 20);
                picBox.Location           = new Point(verificationControl.Left - picBox.Width, verificationControl.Bottom + 20);
                btnCard.Location          = new Point(picBox.Left, picBox.Bottom + 20);
                lblName.Location          = new Point(picBox.Right + 50, picBox.Top);
                lblAge.Location           = new Point(lblName.Left, lblName.Bottom + 20);
                lblGender.Location        = new Point(lblName.Left, lblAge.Bottom + 20);
                lblMaritalStatus.Location = new Point(lblName.Left, lblGender.Bottom + 20);
                lblState.Location         = new Point(lblName.Left, lblMaritalStatus.Bottom + 20);
                lblLGA.Location           = new Point(lblName.Left, lblState.Bottom + 20);
            };
        }
コード例 #8
0
        public LeftPanel(AppWindow owner)
        {
            this.BackColor = owner.DarkColor;
            this.Dock      = DockStyle.Left;
            this.Width     = 300;

            Label lblLogo = new Label()
            {
                AutoSize = false,
                Dock     = DockStyle.Top,
                Height   = 150
            };

            lblLogo.BackgroundImage       = Properties.Resources.LogoWhite;
            lblLogo.BackgroundImageLayout = ImageLayout.Zoom;
            this.Controls.Add(lblLogo);

            Label lblName = new Label()
            {
                AutoSize  = false,
                Font      = new Font(this.Font.FontFamily, 13.0f, FontStyle.Bold),
                ForeColor = owner.LightColor,
                Location  = new Point(0, lblLogo.Bottom + 10),
                Size      = new Size(300, 30),
                Text      = owner.Text,
                TextAlign = ContentAlignment.MiddleCenter
            };

            this.Controls.Add(lblName);

            //registration
            LeftPanelButton btnReg = new LeftPanelButton(owner)
            {
                Text = "Enroll"
            };

            btnReg.Location = new Point(this.Width - btnReg.Width, lblName.Bottom + 10);
            btnReg.Click   += delegate
            {
                if (regForm == null)
                {
                    regForm = new RegistrationForm(owner);
                }
                owner.Body.Controls.Clear();
                owner.Body.Controls.Add(regForm);
                owner.Text = btnReg.Text + " - IDPs Biometric Enumeration";
            };
            this.Controls.Add(btnReg);
            //verification
            LeftPanelButton btnVeri = new LeftPanelButton(owner)
            {
                Text = "Verify"
            };

            btnVeri.Location = new Point(btnReg.Left, btnReg.Bottom + 10);
            btnVeri.Click   += delegate
            {
                if (veriForm == null)
                {
                    veriForm = new VerificationForm(owner);
                }
                owner.Body.Controls.Clear();
                owner.Body.Controls.Add(veriForm);
                owner.Text = btnVeri.Text + " - IDPs Biometric Enumeration";
            };
            this.Controls.Add(btnVeri);
            //report
            LeftPanelButton btnRep = new LeftPanelButton(owner)
            {
                Text = "Analitics"
            };

            btnRep.Location = new Point(btnVeri.Left, btnVeri.Bottom + 10);
            btnRep.Click   += delegate
            {
                owner.Body.Controls.Clear();
                owner.Body.Controls.Add(new ReportForm(owner)); //returns a new report form every time
                owner.Text = btnRep.Text + " - IDPs Biometric Enumeration";
            };
            this.Controls.Add(btnRep);
            //sync

            owner.RegisterToMoveWindow(this);
            owner.RegisterToMoveWindow(lblLogo);
            owner.RegisterToMoveWindow(lblName);
        }
コード例 #9
0
 public Container(AppWindow owner)
 {
     this.BackColor = owner.LightColor;
     this.Dock      = DockStyle.Fill;
 }
コード例 #10
0
        public TitleBar(AppWindow owner)
        {
            this.owner = owner;

            this.BackColor = owner.LightColor;//this.BackColor = owner.DarkColor;
            this.Dock      = DockStyle.Top;
            this.ForeColor = owner.DarkColor;
            this.Height    = sz;

            ToolTip tooltip = new ToolTip();

            //customControls
            customControls = new List <Control>();

            //btnMinimize
            btnMinimize = new Label()
            {
                BackgroundImage       = Properties.Resources.Minimize,
                BackgroundImageLayout = ImageLayout.Stretch,
                Size = new Size(smSz, smSz)
            };
            btnMinimize.MouseEnter += delegate { btnMinimize.BackgroundImage = Properties.Resources.Minimize2; };
            btnMinimize.MouseLeave += delegate { btnMinimize.BackgroundImage = Properties.Resources.Minimize; };
            btnMinimize.Click      += delegate { owner.WindowState = FormWindowState.Minimized; };

            if (owner.Maximized)
            {
                MaximizeImageNormal = Properties.Resources.Restore;
                MaximizeImageFocus  = Properties.Resources.Restore2;
            }
            else
            {
                MaximizeImageNormal = Properties.Resources.Maximize;
                MaximizeImageFocus  = Properties.Resources.Maximize2;
            }
            //btnMaximize
            btnMaximize = new Label()
            {
                BackgroundImage       = MaximizeImageNormal,
                BackgroundImageLayout = ImageLayout.Stretch,
                Size = new Size(smSz, smSz)
            };
            btnMaximize.MouseEnter += delegate { btnMaximize.BackgroundImage = MaximizeImageFocus; };
            btnMaximize.MouseLeave += delegate { btnMaximize.BackgroundImage = MaximizeImageNormal; };
            btnMaximize.Click      += delegate { owner.Maximized = !owner.Maximized; };

            //btnClose
            btnClose = new Label()
            {
                BackgroundImage       = Properties.Resources.Close,
                BackgroundImageLayout = ImageLayout.Stretch,
                Size = new Size(smSz, smSz)
            };
            btnClose.MouseEnter += delegate { btnClose.BackgroundImage = Properties.Resources.Close2; };
            btnClose.MouseLeave += delegate { btnClose.BackgroundImage = Properties.Resources.Close; };
            btnClose.Click      += delegate { owner.Close(); };

            //dynamicPanel
            dynamicPanel = new Panel()
            {
                Height = 30,
                Width  = 0
            };
            this.Controls.Add(dynamicPanel);

            //btnIconBox
            btnIconBox = new Label()
            {
                BackgroundImage       = Properties.Resources.IconImage,
                BackgroundImageLayout = ImageLayout.Stretch,
                Location = new Point(offset, offset),
                Size     = new Size(smSz, smSz)
            };
            owner.RegisterToMoveWindow(btnIconBox);
            this.Controls.Add(btnIconBox);

            //lblAppName
            lblAppName = new Label()
            {
                AutoEllipsis = true,
                Font         = new System.Drawing.Font(this.Font.FontFamily, 11.0F),
                Height       = smSz,
                Text         = owner.Text,
                TextAlign    = ContentAlignment.BottomLeft
            };
            lblAppName.Location = new Point(btnIconBox.Location.X + btnIconBox.Width + offset, offset);
            this.Controls.Add(lblAppName);
            owner.RegisterToMoveWindow(lblAppName);
            owner.SizeChanged += delegate { lblAppName.Width = owner.Width / 2; };
            owner.TextChanged += delegate { lblAppName.Text = owner.Text; };

            owner.MaximizedChanged += owner_MaximizedChanged;

            this.SizeChanged += TitleBar_SizeChanged;

            RefreshTitleBar(true, true, true);
        }
コード例 #11
0
            public CameraControl(AppWindow owner)
            {
                picBox = new PictureBox()
                {
                    BorderStyle = BorderStyle.Fixed3D,
                    Location    = new Point(2, 2)
                };
                this.Controls.Add(picBox);

                camerasList = new ComboBox()
                {
                    Text = "Select camera",
                    //DropDownStyle = ComboBoxStyle.DropDownList,
                };
                camerasList.DropDown += delegate
                {
                    cameras = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                    camerasList.Items.Clear();
                    foreach (FilterInfo cam in cameras)
                    {
                        camerasList.Items.Add(cam.Name);
                    }
                };
                camerasList.SelectedIndexChanged += delegate
                {
                    if (device != null && device.IsRunning)
                    {
                        device.Stop();
                    }

                    device           = new VideoCaptureDevice(cameras[camerasList.SelectedIndex].MonikerString);
                    device.NewFrame += (sender, eventargs) =>
                    {
                        currentBitmap = (Bitmap)eventargs.Frame.Clone();
                        //picBox.Image = bitmap;
                        picBox.Image = new Bitmap(currentBitmap, picBox.Size);
                    };
                    device.Start();
                };
                this.Controls.Add(camerasList);

                btnCaptureRestart = new Button()
                {
                    BackColor = owner.DarkColor,
                    ForeColor = owner.LightColor,
                    Text      = "Capture"
                };
                this.Controls.Add(btnCaptureRestart);
                btnCaptureRestart.Click += delegate
                {
                    if (capture)
                    {
                        if (device != null && device.IsRunning)
                        {
                            device.Stop();
                            CapturedBitmap         = new Bitmap(currentBitmap, picBox.Size);
                            btnCaptureRestart.Text = "Again";
                            capture = !capture;
                        }
                    }
                    else
                    {
                        if (device != null && !device.IsRunning)
                        {
                            device.Start();
                            btnCaptureRestart.Text = "Capture";
                            capture = !capture;
                        }
                    }
                };

                this.SizeChanged += delegate
                {
                    picBox.Width               = this.Width - 4;
                    picBox.Height              = this.Height - 30;
                    camerasList.Width          = this.Width / 2;
                    camerasList.Location       = new Point(2, picBox.Bottom + 2);
                    btnCaptureRestart.Width    = this.Width / 4;
                    btnCaptureRestart.Location = new Point(this.Width - (btnCaptureRestart.Width + 2), camerasList.Top);
                };

                this.Disposed += delegate
                {
                    if (device != null && device.IsRunning)
                    {
                        device.Stop();
                    }
                };
            }
コード例 #12
0
        public RegistrationForm(AppWindow owner)
        {
            InitializeComponent();

            PopulateStatesAndLGAs();

            this.Dock      = DockStyle.Fill;
            this.BackColor = owner.LightColor;

            txtFirstname = new HintedTextBox("first name")
            {
                BorderStyle = System.Windows.Forms.BorderStyle.None,
                Font        = new System.Drawing.Font(this.Font.FontFamily, 16.0F),
                Width       = 300
            };
            txtFirstname.Location = new Point(100, 20);
            UnderlineFor lblLine1 = new UnderlineFor(txtFirstname, owner.DarkColor, SystemColors.GrayText)
            {
                BackColor = owner.DarkColor,
            };

            lblLine1.Location = new Point(txtFirstname.Location.X, txtFirstname.Bottom);
            this.Controls.Add(txtFirstname);
            this.Controls.Add(lblLine1);

            txtLastName = new HintedTextBox("last name")
            {
                BorderStyle = txtFirstname.BorderStyle,
                Font        = txtFirstname.Font,
                Width       = txtFirstname.Width
            };
            txtLastName.Location = new Point(txtFirstname.Left, txtFirstname.Bottom + 20);
            UnderlineFor lblLine2 = new UnderlineFor(txtLastName, owner.DarkColor, SystemColors.GrayText)
            {
                BackColor = SystemColors.GrayText,
            };

            lblLine2.Location = new Point(txtLastName.Location.X, txtLastName.Bottom);
            this.Controls.Add(txtLastName);
            this.Controls.Add(lblLine2);

            txtOtherNames = new HintedTextBox("other names")
            {
                BorderStyle = txtFirstname.BorderStyle,
                Font        = txtFirstname.Font,
                Width       = txtFirstname.Width
            };
            txtOtherNames.Location = new Point(txtLastName.Left, txtLastName.Bottom + 20);
            UnderlineFor lblLine3 = new UnderlineFor(txtOtherNames, owner.DarkColor, SystemColors.GrayText)
            {
                BackColor = SystemColors.GrayText,
            };

            lblLine3.Location = new Point(txtOtherNames.Location.X, txtOtherNames.Bottom);
            this.Controls.Add(txtOtherNames);
            this.Controls.Add(lblLine3);

            btnDob = new RadioButton()
            {
                Checked  = true,
                Font     = txtFirstname.Font,
                Height   = 30,
                Location = new Point(txtOtherNames.Location.X, txtOtherNames.Bottom + 20),
                Text     = "I know my date of birth",
                Width    = txtFirstname.Width,
            };
            btnDob.CheckedChanged += delegate
            {
                datePicker.Enabled = btnDob.Checked;
            };
            this.Controls.Add(btnDob);

            datePicker = new DateTimePicker()
            {
                Enabled  = btnDob.Checked,
                Font     = txtFirstname.Font,
                Location = new Point(btnDob.Left + 20, btnDob.Bottom + 5),
                Width    = btnDob.Width - 20
            };
            this.Controls.Add(datePicker);

            btnYoB = new RadioButton()
            {
                Checked  = false,
                Font     = btnDob.Font,
                Height   = btnDob.Height,
                Location = new Point(btnDob.Left, datePicker.Bottom + 20),
                Text     = "I may know my age",
                Width    = btnDob.Width
            };
            btnYoB.CheckedChanged += delegate
            {
                txtAge.Enabled = btnYoB.Checked;
            };
            this.Controls.Add(btnYoB);

            txtAge = new NumericUpDown()//HintedTextBox("estimated age")
            {
                BorderStyle = txtFirstname.BorderStyle,
                Enabled     = btnYoB.Checked,
                Font        = txtFirstname.Font,
                Maximum     = 200,
                Minimum     = 0,
                Width       = datePicker.Width
            };
            txtAge.Location = new Point(btnYoB.Left + 20, btnYoB.Bottom + 5);
            //UnderlineFor lblLine4 = new UnderlineFor(txtAge, owner.DarkColor, SystemColors.GrayText)
            //{
            //    BackColor = SystemColors.GrayText,
            //};
            //lblLine4.Location = new Point(txtAge.Location.X, txtAge.Bottom);
            this.Controls.Add(txtAge);
            //this.Controls.Add(lblLine4);

            genderList = new ComboBox()
            {
                //DropDownStyle = ComboBoxStyle.DropDownList,
                Font     = txtFirstname.Font,
                Location = new Point(txtFirstname.Left, txtAge.Bottom + 20),
                Text     = "select gender",
                Width    = txtFirstname.Width,
            };
            genderList.Items.Add("Male");
            genderList.Items.Add("Female");
            this.Controls.Add(genderList);

            maritalStatusList = new ComboBox()
            {
                //DropDownStyle = ComboBoxStyle.DropDownList,
                Font     = txtFirstname.Font,
                Location = new Point(txtFirstname.Left, genderList.Bottom + 20),
                Text     = "select marital status",
                Width    = txtFirstname.Width,
            };
            maritalStatusList.Items.Add("Single");
            maritalStatusList.Items.Add("Married");
            maritalStatusList.Items.Add("Widowed");
            maritalStatusList.Items.Add("Separated");
            maritalStatusList.Items.Add("Others");
            this.Controls.Add(maritalStatusList);

            statesList = new ComboBox()
            {
                //DropDownStyle = ComboBoxStyle.DropDownList,
                Font     = txtFirstname.Font,
                Location = new Point(txtFirstname.Left, maritalStatusList.Bottom + 20),
                Text     = "select state",
                Width    = txtFirstname.Width,
            };
            statesList.AutoCompleteCustomSource.AddRange(statesAndLGAs.Keys.ToArray());
            statesList.AutoCompleteMode   = AutoCompleteMode.Suggest;
            statesList.AutoCompleteSource = AutoCompleteSource.CustomSource;
            statesList.Items.AddRange(statesAndLGAs.Keys.ToArray());
            statesList.SelectedIndexChanged += delegate
            {
                lgaList.Items.Clear();
                if (statesList.SelectedItem != null)
                {
                    var key = statesList.SelectedItem.ToString();
                    if (statesAndLGAs.ContainsKey(key))
                    {
                        lgaList.Items.AddRange(statesAndLGAs[key]);
                    }
                }
            };
            this.Controls.Add(statesList);

            lgaList = new ComboBox()
            {
                //DropDownStyle = ComboBoxStyle.DropDownList,
                Font     = txtFirstname.Font,
                Location = new Point(txtFirstname.Left, statesList.Bottom + 20),
                Text     = "select LGA",
                Width    = txtFirstname.Width,
            };
            this.Controls.Add(lgaList);

            camControl          = new TestForm1.RegistrationForm.CameraControl(owner);
            camControl.Location = new Point(txtFirstname.Right + 50, txtFirstname.Top);
            camControl.Size     = new Size(txtFirstname.Width, txtFirstname.Width);
            this.Controls.Add(camControl);

            RecreateEnrollmentControl();

            btnSave = new Button()
            {
                BackColor = owner.DarkColor,
                ForeColor = owner.LightColor,
                Font      = new Font(this.Font.FontFamily, 16.0f, FontStyle.Bold),
                Size      = new Size(100, 50),
                Text      = "Save"
            };
            this.Controls.Add(btnSave);
            btnSave.Click += BtnSave_Click;

            this.SizeChanged += delegate
            {
                btnSave.Location = new Point((this.Width - btnSave.Width) / 2, this.Height - (btnSave.Height + 2));
            };
        }