Example #1
0
 private void hinzufügenToolStripMenuItem_Click_1(object sender, EventArgs e)
 {
     saved = false;
     if (table_lines >= table.RowCount)
     {
         return;
     }
     for (int i = 0; i < 4; i++)
     {
         TextBox textBox = new TextBox();// { Name = Convert.ToString(textboxname + i) };
         textBox.Name = "textBox" + Convert.ToString(textboxname + i);
         Console.WriteLine(textBox.Name);
         textBox.Dock      = DockStyle.Fill;
         textBox.KeyDown  += TextBoxesKeyPressed;
         textBox.KeyPress += TextBoxesKeyPressEvent;
         //textBox.Text = textBox.Name;
         TableLayoutControlCollection controls = table.Controls;
         try
         {
             controls.Add(textBox);
         }
         catch (System.ArgumentException)
         {
         }
     }
     textboxname += 4;
     table_lines += 1;
 }
Example #2
0
        public void TableLayoutControlCollection_Add_NullContainer_ThrowsNullReferenceExceptio()
        {
            var collection = new TableLayoutControlCollection(null);
            var control    = new Control();

            Assert.Throws <NullReferenceException>(() => collection.Add(control, -2, 2));
        }
        public void TableLayoutControlCollection_Add_NullControl_ThrowsArgumentNullException()
        {
            var container  = new TableLayoutPanel();
            var collection = new TableLayoutControlCollection(container);

            Assert.Throws <ArgumentNullException>("control", () => collection.Add(null, 1, 2));
            Assert.Empty(collection);
        }
Example #4
0
        public void TableLayoutControlCollection_Add_NullControl_ThrowsNullReferenceException()
        {
            var container  = new TableLayoutPanel();
            var collection = new TableLayoutControlCollection(container);

            Assert.Throws <NullReferenceException>(() => collection.Add(null, 1, 2));
            Assert.Empty(collection);
        }
        public void TableLayoutControlCollection_Add_NegativeRow_ThrowsArgumentOutOfRangeException()
        {
            var container  = new TableLayoutPanel();
            var collection = new TableLayoutControlCollection(container);
            var control    = new Control();

            Assert.Throws <ArgumentOutOfRangeException>("row", () => collection.Add(control, 1, -2));
            Assert.Equal(control, Assert.Single(collection));
            Assert.Equal(1, container.GetColumn(control));
            Assert.Equal(-1, container.GetRow(control));
        }
        public void TableLayoutControlCollection_Add_ValidControl_Success(int column, int row)
        {
            var container  = new TableLayoutPanel();
            var collection = new TableLayoutControlCollection(container);
            var control    = new Control();

            collection.Add(control, column, row);
            Assert.Equal(control, Assert.Single(collection));
            Assert.Equal(column, container.GetColumn(control));
            Assert.Equal(row, container.GetRow(control));
        }
Example #7
0
        public void TableLayoutControlCollection_Add_NegativeColumn_ThrowsArgumentOutOfRangeException()
        {
            using var container = new TableLayoutPanel();
            var collection = new TableLayoutControlCollection(container);

            using var child = new Control();
            Assert.Throws <ArgumentOutOfRangeException>("column", () => collection.Add(child, -2, 2));
            Assert.Equal(child, Assert.Single(collection));
            Assert.Equal(-1, container.GetColumn(child));
            Assert.Equal(-1, container.GetRow(child));
        }
Example #8
0
 public void Add(Control control)
 {
     _control.Add(control);
 }
Example #9
0
        private void Form2_Load(object sender, EventArgs e)
        {
            string json;

            using (StreamReader rd = new StreamReader(@"..\..\res\lang\lang.json"))
            {
                json = rd.ReadToEnd();
            }

            try
            {
                language = JsonConvert.DeserializeObject <lang>(json);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            panel4.BackColor = Color.FromArgb(30, Color.Black);

            Console.WriteLine("Test§: " + lines);
            //TableLayoutRowStyleCollection styles = tableLayoutPanel1.RowStyles;
            //foreach (RowStyle style in styles)
            //{
            //    // Set the row height to 20 pixels.
            //    style.SizeType = SizeType.Absolute;
            //    style.Height = 50;
            //}

            TableLayoutRowStyleCollection styles = tableLayoutPanel3.RowStyles;

            foreach (RowStyle style in styles)
            {
                // Set the row height to 20 pixels.
                style.SizeType = SizeType.Absolute;
                style.Height   = 70;
            }

            for (int i = 0; i < lines - 1; i++)
            {
                //tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
                //tableLayoutPanel1.RowCount++;

                Console.WriteLine(table[i][2] + " : " + lines);
                Label label = new Label();
                label.Name      = "next" + Convert.ToString(i);
                label.Dock      = DockStyle.Fill;
                label.TextAlign = ContentAlignment.MiddleCenter;
                label.Text      = $"Was: {table[prespoint + 1 + i][1]}\nWer: {table[prespoint + 1 + i][2]}\nUm: {table[prespoint + 1 + i][0]}\n({table[prespoint + 1 + i][3]})\n";
                if (fullscreen == true)
                {
                    label.Font = new Font("Arial", 22);
                }
                if (fullscreen == false)
                {
                    label.Font = new Font("Arial", 11);
                }
                Console.WriteLine(label.Text);
                TableLayoutControlCollection controls = tableLayoutPanel3.Controls;
                controls.Add(label);
                Console.WriteLine(table[i][2] + " : " + lines);

                /*Label label1 = new Label();
                 * label1.Name = "placeholder" + Convert.ToString(i);
                 * label1.Dock = DockStyle.Fill;
                 * controls.Add(label1);*/
            }
            label3.Text = table[prespoint][1];
            Int32.TryParse(string.Concat(table[prespoint + 1][0][0], table[prespoint + 1][0][1]), out tablehours);   //string1 + string2 - > int
            Int32.TryParse(string.Concat(table[prespoint + 1][0][3], table[prespoint + 1][0][4]), out tableminutes); // prespoin +1 weil wir uns auf die verbleibende zeit beziehen. also auf die startzeit des nächsten
            date = DateTime.Now;
            Console.WriteLine($"Test_Clock: {tablehours}");
            Console.WriteLine($"Test2_Clock: {date.Day.ToString()}");
            if (tablehours == 0) // wenn 0:00 dann Nächter Tag
            {
                date = date.AddDays(1);
            }
            Console.WriteLine($"Test3_Clock: {date.Day.ToString()}");
            startdate          = new DateTime(Convert.ToInt32(date.ToString("yyyy")), Convert.ToInt32(date.ToString("MM")), Convert.ToInt32(date.ToString("dd")), tablehours, tableminutes, Convert.ToInt32(date.ToString("ss")));
            date               = DateTime.Now;
            statsStart         = date; //Init Stats start time. Later for calculation of timespan for chart in Form 4
            timeSpan           = startdate - date;
            overtime_indikator = timeSpan.TotalSeconds * 0.1;
            Console.WriteLine(timeSpan.ToString(@"hh\:mm\:ss"));
            timer1.Enabled            = true;
            label4.Text               = table[prespoint][2];
            label5.Text               = table[prespoint][3];
            tableLayoutPanel3.Enabled = true;
            //panel1.Enabled = true;
        }
Example #10
0
        private void Form2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F11)
            {
                if (fullscreen)
                {
                    return;
                }
                this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                formState.Maximize(this);
                panel4.BackColor         = Color.FromArgb(5, Color.White);
                label7.BackColor         = Color.FromArgb(5, Color.White);
                panel4.Location          = new Point(this.Size.Width / 2 - panel4.Size.Width / 2, 57);
                panel4.Visible           = true;
                timer2.Enabled           = true;
                fullscreen               = true;
                tableLayoutPanel1.Height = this.Size.Height;
                tableLayoutPanel1.Width  = this.Size.Width;
                TableLayoutRowStyleCollection styles = tableLayoutPanel3.RowStyles;
                foreach (RowStyle style in styles)
                {
                    // Set the row height to 20 pixels.
                    style.SizeType = SizeType.Absolute;
                    style.Height   = 140;
                }
                for (int i = 0; i < tableLayoutPanel3.RowCount; i++)
                {
                    tableLayoutPanel3.Controls.RemoveByKey("next" + Convert.ToString(i));
                    tableLayoutPanel3.Controls.RemoveByKey("placeholder" + Convert.ToString(i));
                }
                for (int i = 1; i < lines; i++)
                {
                    //tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
                    //tableLayoutPanel1.RowCount++;

                    Console.WriteLine(table[prespoint + i][2] + " : " + lines);
                    Label label = new Label();
                    label.Name      = "next" + Convert.ToString(i - 1);
                    label.Dock      = DockStyle.Fill;
                    label.TextAlign = ContentAlignment.MiddleCenter;
                    if (table[prespoint + i][1] != null)
                    {
                        label.Text = $"Was: {table[prespoint + i][1]}\nWer: {table[prespoint + i][2]}\nUm: {table[prespoint + i][0]}\n({table[prespoint + i][3]})\n{label.Name}";
                    }
                    if (fullscreen == true)
                    {
                        label.Font = new Font("Arial", 22);
                    }
                    if (fullscreen == false)
                    {
                        label.Font = new Font("Arial", 11);
                    }
                    Console.WriteLine(label.Text);
                    TableLayoutControlCollection controls = tableLayoutPanel3.Controls;
                    controls.Add(label);
                    Console.WriteLine(table[prespoint + i][2] + " : " + lines);
                }
            }
            else if (e.KeyCode == Keys.Escape)
            {
                if (!fullscreen)
                {
                    return;
                }
                formState.Restore(this);
                this.WindowState = System.Windows.Forms.FormWindowState.Normal;
                fullscreen       = false;
                TableLayoutRowStyleCollection styles = tableLayoutPanel3.RowStyles;
                foreach (RowStyle style in styles)
                {
                    // Set the row height to 20 pixels.
                    style.SizeType = SizeType.Absolute;
                    style.Height   = 70;
                }
                for (int i = 0; i < tableLayoutPanel3.RowCount; i++)
                {
                    tableLayoutPanel3.Controls.RemoveByKey("next" + Convert.ToString(i));
                    tableLayoutPanel3.Controls.RemoveByKey("placeholder" + Convert.ToString(i));
                }
                for (int i = 1; i < lines; i++)
                {
                    //tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
                    //tableLayoutPanel1.RowCount++;

                    Console.WriteLine(table[prespoint + i][2] + " : " + lines);
                    Label label = new Label();
                    label.Name      = "next" + Convert.ToString(i - 1);
                    label.Dock      = DockStyle.Fill;
                    label.TextAlign = ContentAlignment.MiddleCenter;
                    if (table[prespoint + i][1] != null)
                    {
                        label.Text = $"Was: {table[prespoint + i][1]}\nWer: {table[prespoint + i][2]}\nUm: {table[prespoint + i][0]}\n({table[prespoint + i][3]})\n{label.Name}";
                    }
                    if (fullscreen == true)
                    {
                        label.Font = new Font("Arial", 22);
                    }
                    if (fullscreen == false)
                    {
                        label.Font = new Font("Arial", 11);
                    }
                    Console.WriteLine(label.Text);
                    TableLayoutControlCollection controls = tableLayoutPanel3.Controls;
                    controls.Add(label);
                    Console.WriteLine(table[prespoint + i][2] + " : " + lines);
                }
            }
            else if (e.KeyCode == Keys.Left)
            {
                if (prespoint != 0)
                {
                    prespoint--;
                }
                Reload();
                for (int i = 0; i <= lines; i++)
                {
                    //Control label = tableLayoutPanel1.Controls.Find("next" + i.ToString(), false).First() as Label;
                }
            }
            else if (e.KeyCode == Keys.Right)
            {
                //statsTimeSpan = statsStart - DateTime.Now;

                //stats.Add(table[prespoint][1], statsTimeSpan);



                if (table[prespoint + 1][1] != null)
                {
                    prespoint++;
                }

                timerCalc(DateTime.Now, false, 0, 0, 0, 0, timeSpan, DateTime.Now);

                Reload();
            }
        }
Example #11
0
        public void Reload()
        {
            timer1.Enabled = false;
            for (int i = 0; i < tableLayoutPanel3.RowCount; i++)
            {
                tableLayoutPanel3.Controls.RemoveByKey("next" + Convert.ToString(i));
                tableLayoutPanel3.Controls.RemoveByKey("placeholder" + Convert.ToString(i));
            }

            for (int i = 1; i < lines; i++)
            {
                //tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
                //tableLayoutPanel1.RowCount++;

                Console.WriteLine(table[prespoint + i][2] + " : " + lines);
                Label label = new Label();
                label.Name      = "next" + Convert.ToString(i - 1);
                label.Dock      = DockStyle.Fill;
                label.TextAlign = ContentAlignment.MiddleCenter;
                if (table[prespoint + i][1] != null)
                {
                    label.Text = $"Was: {table[prespoint + i][1]}\nWer: {table[prespoint + i][2]}\nUm: {table[prespoint + i][0]}\n({table[prespoint + i][3]})\n{label.Name}";
                }
                if (fullscreen == true)
                {
                    label.Font = new Font("Arial", 22);
                }
                if (fullscreen == false)
                {
                    label.Font = new Font("Arial", 11);
                }
                Console.WriteLine(label.Text);
                TableLayoutControlCollection controls = tableLayoutPanel3.Controls;
                controls.Add(label);
                Console.WriteLine(table[prespoint + i][2] + " : " + lines);

                /*Label label1 = new Label();
                 * label1.Name = "placeholder" + Convert.ToString(i - 1);
                 * label1.Dock = DockStyle.Fill;
                 * controls.Add(label1);*/
            }

            label3.Text = table[prespoint][1];
            try
            {
                Int32.TryParse(string.Concat(table[prespoint + 1][0][0], table[prespoint + 1][0][1]), out tablehours);//string1 + string2 - > int
                Int32.TryParse(string.Concat(table[prespoint + 1][0][3], table[prespoint + 1][0][4]), out tableminutes);
            }
            catch (NullReferenceException e)
            {
                //Wenn nichts wéiteres geplant ist!;
                label8.Text      = language.Deutsch.Form2.endOfTable;
                label8.Font      = new Font("Microsoft Sans Serif", this.Size.Width / 30, FontStyle.Bold);
                label4.Text      = table[prespoint][2];
                label8.ForeColor = Color.White;
                timer1.Enabled   = false;

                statsTimeSpan = statsStart - DateTime.Now;

                label5.Text = "Benötigte Zeit: " + statsTimeSpan.ToString(@"hh\:mm\:ss");
                return;
            }
            label5.Text = table[prespoint][3];
            date        = DateTime.Now;
            if (tablehours == 0)
            {
                date = date.AddDays(1);
            }
            startdate = new DateTime(Convert.ToInt32(date.ToString("yyyy")), Convert.ToInt32(date.ToString("MM")), Convert.ToInt32(date.ToString("dd")), tablehours, tableminutes, Convert.ToInt32(date.ToString("ss")));
            date      = DateTime.Now;
            if (hoch)
            {
                startdate.Add(timeSpan);
            }
            else
            {
                startdate.Subtract(timeSpan);
            }
            timeSpan           = startdate - date;
            overtime_indikator = timeSpan.TotalSeconds * 0.1;
            timer1.Enabled     = true;
            label4.Text        = table[prespoint][2];
            label5.Text        = table[prespoint][3];
            if (fullscreen == true)
            {
                label8.Font = new Font("Microsoft Sans Serif", this.Size.Width / 15);
            }
        }
Example #12
0
        public void openFile()
        {
            openFileDialog1.Filter           = "Kirche files (*.kabp)|*.kabp|Text files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                file_name = openFileDialog1.FileName;
                try
                {
                    using (StreamReader rd = new StreamReader(openFileDialog1.FileName))
                    {
                        do
                        {
                            if (textboxname > 0)
                            {
                                textboxname -= 4;
                                table_lines -= 1;
                                saved        = false;
                            }
                            if (textboxname <= 0)
                            {
                                textboxname = 0;
                                table_lines = 0;
                                saved       = true;
                            }

                            for (int i = 0; i < 4; i++)
                            {
                                TextBox textBox = new TextBox();
                                textBox.Name = "textBox" + Convert.ToString(textboxname + i);
                                textBox.Dock = DockStyle.Fill;
                                //textBox.Text = "textBox" + Convert.ToString(textboxname + i);
                                textBox.KeyDown  -= TextBoxesKeyPressed;
                                textBox.KeyPress -= TextBoxesKeyPressEvent;
                                table.Controls.RemoveByKey("textBox" + Convert.ToString(textboxname + i));
                            }
                            toolStripProgressBar1.PerformStep();
                        } while (textboxname > 0);

                        using (StreamReader sr = new StreamReader(file_name))
                        {
                            int c = 0;
                            while (sr.ReadLine() != null)
                            {
                                c++;
                            }
                            toolStripProgressBar1.Maximum = c;
                            toolStripProgressBar1.Value   = 1;
                        }
                        do
                        {
                            String   line    = rd.ReadLine();
                            String[] erg     = new String[4];
                            int      point   = 0;
                            bool     nextcol = false;
                            Console.WriteLine(line);
                            for (int i = 0; i < line.Length; i++)
                            {
                                if (line[i] != '|')
                                {
                                    erg[point] += line[i];
                                }
                                else
                                {
                                    if (nextcol)
                                    {
                                        point  += 1;
                                        nextcol = false;
                                    }
                                    else
                                    {
                                        nextcol = true;
                                    }
                                }
                            }
                            for (int i = 0; i < 4; i++)
                            {
                                TextBox textBox = new TextBox();// { Name = Convert.ToString(textboxname + i) };
                                textBox.Name = "textBox" + Convert.ToString(textboxname + i);
                                Console.WriteLine(textBox.Name);
                                textBox.Dock      = DockStyle.Fill;
                                textBox.Text      = erg[i];
                                textBox.KeyDown  += TextBoxesKeyPressed;
                                textBox.KeyPress += TextBoxesKeyPressEvent;
                                TableLayoutControlCollection controls = table.Controls;
                                controls.Add(textBox);
                            }
                            textboxname += 4;
                            table_lines += 1;
                            toolStripProgressBar1.PerformStep();
                        } while (!rd.EndOfStream);
                    }
                }
                catch (IOException e)
                {
                    Console.WriteLine("The file could not be read!");
                    Console.WriteLine(e.Message);
                }
            }
        }