Freitag, 30. Dezember 2011

Ein gutes Jahr 2012!

Ich wünsche allen Lesern einen guten Rutsch und ein frohes neues Jahr 2012.
In C# ausgedrückt:

Form1.Designer.cs:

namespace WindowsFormsApplication1
{
    partial class Form1
    {
        /// <summary>
       /// Erforderliche Designervariable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
       /// Verwendete Ressourcen bereinigen.
        /// </summary>
        /// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Vom Windows Form-Designer generierter Code

        /// <summary>
       /// Erforderliche Methode für die Designerunterstützung.
       /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            //
            // textBox1
            //
            this.textBox1.Location = new System.Drawing.Point(12, 12);
            this.textBox1.Multiline = true;
            this.textBox1.Name = "textBox1";
            this.textBox1.ReadOnly = true;
            this.textBox1.Size = new System.Drawing.Size(374, 328);
            this.textBox1.TabIndex = 0;
            //
            // timer1
            //
            this.timer1.Enabled = true;
            this.timer1.Interval = 300;
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            //
            // textBox2
            //
            this.textBox2.Location = new System.Drawing.Point(433, 346);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(12, 20);
            this.textBox2.TabIndex = 1;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(393, 349);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.textBox1);
            this.Name = "Form1";
            this.Text = "Grüße vom C# Blog";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.Timer timer1;
        private System.Windows.Forms.TextBox textBox2;
    }
}



Form1.cs:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        string[] images = new string[22];
        private void init()
        {
            images[0] = NewLine(23) + "".PadLeft(60, ' ') + "|";

            for (int j = 1; j < 14; j++)
            {
                images[j] = NewLine(23 - j) + "".PadLeft(60, ' ') + "|" + NewLine(1);
                images[j] += "".PadLeft(60, ' ') + "|";
            }

            images[14] = NewLine(9) + "".PadLeft(60, ' ') + ".";
            images[15] = NewLine(8) + "".PadLeft(58, ' ') + "....." + NewLine(1) + "".PadLeft(58, ' ') + "....." + NewLine(1) + "".PadLeft(58, ' ') + ".....";

            images[16] = Explode(7, 54, 7);
            images[17] = Explode(9, 52, 5);
            images[18] = Explode(11, 50, 3);
            images[19] = Explode(13, 48, 1);
            images[20] = Explode(7, 54, 7);
            images[21] = "Frohes Neues!";
        }

        private string Explode(int size, int left, int height)
        {
            string result = "";
            result += NewLine(height);
            result += "".PadLeft(left + 2 + (size - 5) + 1, ' ') + "|" + NewLine(1);

            for (int j = 5; j <= size; j++)
            {
                result += "".PadLeft(left + 2 + (size - 5) + 1 - (j - 4) - 1, ' ');
                for (int z = 0; z < 5  + (j - 5) * 2; z++)
                {
                    result += ".";
                }
                result += NewLine(1);
            }

            result += "".PadLeft(left, ' ') + "-";
            for (int j = 0; j <= 5 + (size - 5) * 2; j++)
            {
                result += ".";
            }
            result += "-";
            result += NewLine(1);

            for (int j = size; j >= 5; j--)
            {
                result += "".PadLeft(left + 2 + (size - 5) + 1 - (j - 4) - 1, ' ');
                for (int z = 0; z < 5 + (j - 5) * 2; z++)
                {
                    result += ".";
                }
                result += NewLine(1);
            }

            result += "".PadLeft(left + 2 + (size - 5) + 1, ' ') + "|" + NewLine(1);

            return result;
        }

        private string NewLine(int nr)
        {
            string result = "";
            for (int i = 0; i < nr; i++)
            {
                result += Environment.NewLine;
            }
            return result;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (i < images.Length)
            {
                textBox2.Focus();
                textBox1.Text = images[i];
                i++;
            }
        }

        int i = 0;
        private void Form1_Load(object sender, EventArgs e)
        {
            init();
        }
    }
}

(mein grafisches Vorstellungsvermögen ist nicht sehr gut)

Freitag, 16. Dezember 2011

Danke

Wie aufmerksame wie unaufmerksame Leser sicherlich schon bemerkt haben, erscheinen leider seit längerem keine Posts mehr von mir und auch die Antworten auf eure Kommentare dauern leider sehr lange, da ich ziemlich viel zu tun habe im Moment.

Ich versuche jedoch, wenigstens die Kommentare so gut ich kann zu beantworten und freue mich auch definitiv über jeden Eintrag und jedes Interesse an diesem Blog.

Dafür möchte ich mich hier herzlich bei allen Lesern bedanken, ich hoffe dieser Blog hilft ein wenig und bereitet ein bisschen Freude beim Lesen.