public ControlContainer(MMI.EBuLa.Tools.XMLLoader XMLConf)
        {
            InitializeComponent();

            m_XMLConf = XMLConf;

            try
            {
                //m_parent = gotParent;
                m_widget = new ET42XControl(XMLConf, ref net);
                P_Display.Controls.Add(m_widget);
                if (m_XMLConf.Inverse)
                {
                    m_widget.Inverse();
                }
                else
                {
                    /*m_widget.Inverse();
                    m_widget.Inverse();*/
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Fehler beim Erstellen des Widgets! ("+e.Message+")");
            }

            try
            {
                pB_EBuLa.Image = new Bitmap(BACKGROUND_IMAGE);
            }
            catch(Exception)
            {
                MessageBox.Show("Fehler! Das Hintergrundbild \""+BACKGROUND_IMAGE+"\" konnte nicht geladen werden!");
            }

            net = new Network(ref m_widget);

            if (t == null)
            {
                t = new Thread(new ThreadStart(net.Connect));
                t.IsBackground = true;
                t.Priority = m_XMLConf.thread_prio;
                t.Start();
                Thread.Sleep(1);
            }

            m_widget.m_net = net;
        }
        public ET42XControl(MMI.EBuLa.Tools.XMLLoader conf, ref Network net)
        {
            if (!conf.DoubleBuffer)
            {
                //This turns off internal double buffering of all custom GDI+ drawing
                this.SetStyle(ControlStyles.DoubleBuffer, true);
                this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
                this.SetStyle(ControlStyles.UserPaint, true);
                USE_DOUBLE_BUFFER = false;
            }
            else
                USE_DOUBLE_BUFFER = true;

            InitializeComponent();

            m_net = net;

            uhrAußen = new ISphere(508+60, 41+60, 57);
            uhrInnengr = new ISphere(508+60, 41+60, 45);
            uhrInnenkl = new ISphere(508+60, 41+60, 52);
            uhrsec = new ISphere(508+60, 41+60, 43);
            uhrmin = new ISphere(508+60, 41+60, 43);
            uhrstd = new ISphere(508+60, 41+60, 28);
            uhrrest = new ISphere(508+60, 41+60, 7);
            center = new Point(508+60, 41+60);

            m_conf = conf;

            // NOTBREMSE und E-BREMSE fehlen

            switch (m_conf.Sound)
            {
                case 1:
                    Sound = new APISound();
                    break;
                case 2:
                    Sound = new DxSound();
                    break;
                default:
                    Sound = new NullSound();
                    break;
            }

            localstate = new MMI.ET42X.ET42XState(ref conf, ref Sound);

            SetButtons();

            localstate.Energie = conf.Energie;

            vtime = DateTime.Now;

            zugkraft_thread = new Thread(new ThreadStart(MoveZugkraft));

            int interval = Convert.ToInt32(Math.Round((1d/(double)conf.FramesPerSecondLow)*1000d));
            timer1.Interval = interval;
            timer1.Enabled = true;

            Button_SW_Pressed(this, new EventArgs());

            /*if (localstate.ET42Xtype1 == ET42XTYPE.ET423)
                localstate.FISType = FIS_TYPE.FIS;*/

            timer2.Enabled = true;

            if (vtime.DayOfYear > 100 && vtime.DayOfYear < 300)
                localstate.Kuehlung = true;
            else
                localstate.Kuehlung = false;
        }
 public void Terminate()
 {
     m_widget.Dispose();
     m_widget = null;
     t.Abort();
     t = null;
     //net.Dispose();
     net = null;
     GC.Collect();
 }