From c3088bb36a9820871c9dc666f2180f7a4af001bb Mon Sep 17 00:00:00 2001 From: Wafa Sadri Date: Tue, 13 May 2014 18:48:51 +0200 Subject: [PATCH 1/3] Komplettumbau und Splashscreen sollte jetzt funktionieren (Muss noch getestet werden) --- src/Backend.cs | 6 ++- src/Gui/ChatOutputBox.cs | 11 +++++- src/Gui/ChatPanel.cs | 14 ++++--- src/Gui/Gui.cs | 18 ++++++--- src/Gui/IBackend.cs | 2 + src/Gui/MapPanel.cs | 79 +++++++++++++++++++------------------ src/Gui/OnlinePlayerList.cs | 12 ++++-- src/Gui/Program.cs | 9 ++++- src/Gui/Splashscreen.cs | 21 +++++++++- src/Music.cs | 8 +++- 10 files changed, 121 insertions(+), 59 deletions(-) diff --git a/src/Backend.cs b/src/Backend.cs index dcc8655..67b1330 100644 --- a/src/Backend.cs +++ b/src/Backend.cs @@ -24,7 +24,7 @@ namespace WorldOfPeacecraft Dragons = new Dictionary (); Players = new Dictionary (); ChatMessages = new LinkedList (); - Client = new TcpClient ("localhost", 9999); + Client = new TcpClient (); Buffer receiverBuffer = new Buffer(10000); SenderBuffer = new Buffer(100); Parse = new Parser (this, receiverBuffer); @@ -182,6 +182,10 @@ namespace WorldOfPeacecraft Send.Stop (); Client.Close (); } + + public void Connect(){ + Client.Connect ("localhost", 9999); + } } } diff --git a/src/Gui/ChatOutputBox.cs b/src/Gui/ChatOutputBox.cs index be05f88..1ba0f52 100644 --- a/src/Gui/ChatOutputBox.cs +++ b/src/Gui/ChatOutputBox.cs @@ -10,12 +10,11 @@ namespace WorldOfPeacecraft private Font MessageFont; private Font SenderFont; private Font IregularSenderFont; + private Music m = new Music(); public ChatOutputBox (IBackend backend) { Backend = backend; - this.ReadOnly = true; - this.Multiline = true; MessageFont = this.SelectionFont; SenderFont = new Font (MessageFont, FontStyle.Bold); IregularSenderFont = new Font (MessageFont, FontStyle.Bold | FontStyle.Italic); @@ -43,10 +42,18 @@ namespace WorldOfPeacecraft this.AppendText (": "); this.SelectionFont = MessageFont; this.AppendText (message.GetMessage ()); + if (message.GetMessage().Contains("nyancat")) { + m.Playmusic ("poptart"); + } } } this.ResumeLayout (); } + + public void InitializeComponents(){ + this.ReadOnly = true; + this.Multiline = true; + } } } diff --git a/src/Gui/ChatPanel.cs b/src/Gui/ChatPanel.cs index ed09603..aa21096 100644 --- a/src/Gui/ChatPanel.cs +++ b/src/Gui/ChatPanel.cs @@ -15,9 +15,6 @@ namespace WorldOfPeacecraft ChatInput = new ChatInputBox (); ChatInput.ChatMessageSubmitted += OnChatMessageSent; ChatOutput = new ChatOutputBox (backend); - - this.Controls.Add (ChatInput); - this.Controls.Add (ChatOutput); } protected override void OnLayout (LayoutEventArgs levent) @@ -36,8 +33,9 @@ namespace WorldOfPeacecraft { if (message.StartsWith ("/")) { string command = message.Substring (1); - Backend.SendCommand(command); - } else { + Backend.SendCommand (command); + } + else { Backend.SendChatMessage(message); } // TODO Move focus to board? @@ -47,5 +45,11 @@ namespace WorldOfPeacecraft { ChatOutput.UpdateData (); } + + public void InitializeComponents(){ + ChatOutput.InitializeComponents (); + this.Controls.Add (ChatInput); + this.Controls.Add (ChatOutput); + } } } diff --git a/src/Gui/Gui.cs b/src/Gui/Gui.cs index a9b08fe..dec1d70 100644 --- a/src/Gui/Gui.cs +++ b/src/Gui/Gui.cs @@ -6,7 +6,7 @@ using System.Runtime.InteropServices; namespace WorldOfPeacecraft { - class Gui : Form, IGui + public class Gui : Form, IGui { private const int ChatWidth = 300; private const int OnlinePlayerWidth = 150; @@ -20,7 +20,7 @@ namespace WorldOfPeacecraft public Gui () { - //AllocConsole(); + } public void SetBackend (IBackend backend) @@ -42,9 +42,9 @@ namespace WorldOfPeacecraft public void InitializeComponents () { - ChatPanel = new ChatPanel (Backend); - MapPanel = new MapPanel (Backend); - OnlinePlayerList = new OnlinePlayerList (Backend); + MapPanel.InitializeComponents (); + ChatPanel.InitializeComponents (); + OnlinePlayerList.InitializeComponents (); this.SuspendLayout(); this.Size = new Size(OnlinePlayerWidth + 400 + ChatWidth, 400); OnlinePlayerList.Location = new Point(0,0); @@ -91,6 +91,14 @@ namespace WorldOfPeacecraft })); } + public void LoadResources(){ + ChatPanel = new ChatPanel (Backend); + MapPanel = new MapPanel (Backend); + OnlinePlayerList = new OnlinePlayerList (Backend); + MapPanel.LoadResources (); + OnlinePlayerList.LoadResources (); + } + [DllImport("kernel32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool AllocConsole(); diff --git a/src/Gui/IBackend.cs b/src/Gui/IBackend.cs index 96d82d0..806f0c6 100644 --- a/src/Gui/IBackend.cs +++ b/src/Gui/IBackend.cs @@ -25,5 +25,7 @@ namespace WorldOfPeacecraft void StartThreads(); void Stop(); + + void Connect(); } } diff --git a/src/Gui/MapPanel.cs b/src/Gui/MapPanel.cs index 88f5471..9b4bc5d 100644 --- a/src/Gui/MapPanel.cs +++ b/src/Gui/MapPanel.cs @@ -50,43 +50,7 @@ namespace WorldOfPeacecraft public MapPanel (IBackend backend) { - SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); Backend = backend; - this.PreviewKeyDown += board_KeyPress; - Dragon1 = Image.FromFile (ImagesFolder + "dragon1.png"); - Dragon2 = Image.FromFile (ImagesFolder + "dragon2.png"); - Dragon3 = Image.FromFile (ImagesFolder + "dragon3.png"); - Forest = Image.FromFile (ImagesFolder + "forest.png"); - ForestStag = Image.FromFile (ImagesFolder + "stag.png"); - ForestLeft = Image.FromFile (ImagesFolder + "forest_left.png"); - ForestRight = Image.FromFile (ImagesFolder + "forest_right.png"); - ForestTop = Image.FromFile (ImagesFolder + "forest_top.png"); - ForestBottom = Image.FromFile (ImagesFolder + "forest_bottom.png"); - Knight = Image.FromFile (ImagesFolder + "knight.png"); - Walkable = Image.FromFile (ImagesFolder + "walkable.jpg"); - Water = Image.FromFile (ImagesFolder + "water.jpg"); - Flowers = Image.FromFile(ImagesFolder + "flowers.png"); - BeachBottom = Image.FromFile (ImagesFolder + "beach.png"); - BeachLeft = RotateFlipImage (BeachBottom, RotateFlipType.Rotate90FlipNone); - BeachTop = RotateFlipImage (BeachBottom, RotateFlipType.Rotate180FlipNone); - BeachRight = RotateFlipImage (BeachBottom, RotateFlipType.Rotate270FlipNone); - BeachBottomRight = Image.FromFile (ImagesFolder + "beachcorner.png"); - BeachBottomLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate90FlipNone); - BeachTopLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate180FlipNone); - BeachTopRight = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate270FlipNone); - WallBase = Image.FromFile(ImagesFolder + "wall_base.png"); - WallEdgeBotLeft = Image.FromFile (ImagesFolder + "wall_edge_botleft.png"); - WallEdgeBotRight = Image.FromFile (ImagesFolder + "wall_edge_botright.png"); - WallEdgeTopLeft = Image.FromFile (ImagesFolder + "wall_edge_topleft.png"); - WallEdgeTopRight = Image.FromFile (ImagesFolder + "wall_edge_topright.png"); - WallCornerBotLeft = Image.FromFile (ImagesFolder + "wall_corner_botleft.png"); - WallCornerBotRight = Image.FromFile (ImagesFolder + "wall_corner_botright.png"); - WallCornerTopLeft = Image.FromFile (ImagesFolder + "wall_corner_topleft.png"); - WallCornerTopRight = Image.FromFile (ImagesFolder + "wall_corner_topright.png"); - WallInnerBotLeft = Image.FromFile (ImagesFolder + "wall_inner_botleft.png"); - WallInnerBotRight = Image.FromFile (ImagesFolder + "wall_inner_botright.png"); - WallInnerTopLeft = Image.FromFile (ImagesFolder + "wall_inner_topleft.png"); - WallInnerTopRight = Image.FromFile (ImagesFolder + "wall_inner_topright.png"); } private Image RotateFlipImage(Image image, RotateFlipType type) @@ -377,10 +341,47 @@ namespace WorldOfPeacecraft int y = posy + (TileSize - image.Height) / 2; g.DrawImage(image, x, y, image.Width, image.Height); } + + public void LoadResources (){ + Dragon1 = Image.FromFile (ImagesFolder + "dragon1.png"); + Dragon2 = Image.FromFile (ImagesFolder + "dragon2.png"); + Dragon3 = Image.FromFile (ImagesFolder + "dragon3.png"); + Forest = Image.FromFile (ImagesFolder + "forest.png"); + ForestStag = Image.FromFile (ImagesFolder + "stag.png"); + ForestLeft = Image.FromFile (ImagesFolder + "forest_left.png"); + ForestRight = Image.FromFile (ImagesFolder + "forest_right.png"); + ForestTop = Image.FromFile (ImagesFolder + "forest_top.png"); + ForestBottom = Image.FromFile (ImagesFolder + "forest_bottom.png"); + Knight = Image.FromFile (ImagesFolder + "knight.png"); + Walkable = Image.FromFile (ImagesFolder + "walkable.jpg"); + Water = Image.FromFile (ImagesFolder + "water.jpg"); + Flowers = Image.FromFile(ImagesFolder + "flowers.png"); + BeachBottom = Image.FromFile (ImagesFolder + "beach.png"); + BeachLeft = RotateFlipImage (BeachBottom, RotateFlipType.Rotate90FlipNone); + BeachTop = RotateFlipImage (BeachBottom, RotateFlipType.Rotate180FlipNone); + BeachRight = RotateFlipImage (BeachBottom, RotateFlipType.Rotate270FlipNone); + BeachBottomRight = Image.FromFile (ImagesFolder + "beachcorner.png"); + BeachBottomLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate90FlipNone); + BeachTopLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate180FlipNone); + BeachTopRight = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate270FlipNone); + WallBase = Image.FromFile(ImagesFolder + "wall_base.png"); + WallEdgeBotLeft = Image.FromFile (ImagesFolder + "wall_edge_botleft.png"); + WallEdgeBotRight = Image.FromFile (ImagesFolder + "wall_edge_botright.png"); + WallEdgeTopLeft = Image.FromFile (ImagesFolder + "wall_edge_topleft.png"); + WallEdgeTopRight = Image.FromFile (ImagesFolder + "wall_edge_topright.png"); + WallCornerBotLeft = Image.FromFile (ImagesFolder + "wall_corner_botleft.png"); + WallCornerBotRight = Image.FromFile (ImagesFolder + "wall_corner_botright.png"); + WallCornerTopLeft = Image.FromFile (ImagesFolder + "wall_corner_topleft.png"); + WallCornerTopRight = Image.FromFile (ImagesFolder + "wall_corner_topright.png"); + WallInnerBotLeft = Image.FromFile (ImagesFolder + "wall_inner_botleft.png"); + WallInnerBotRight = Image.FromFile (ImagesFolder + "wall_inner_botright.png"); + WallInnerTopLeft = Image.FromFile (ImagesFolder + "wall_inner_topleft.png"); + WallInnerTopRight = Image.FromFile (ImagesFolder + "wall_inner_topright.png"); + } - public void PaintEntity (Graphics g, IPositionable entity, Color color) - { - + public void InitializeComponents(){ + SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); + this.PreviewKeyDown += board_KeyPress; } } } diff --git a/src/Gui/OnlinePlayerList.cs b/src/Gui/OnlinePlayerList.cs index dcc2bc6..50fa507 100644 --- a/src/Gui/OnlinePlayerList.cs +++ b/src/Gui/OnlinePlayerList.cs @@ -12,9 +12,6 @@ namespace WorldOfPeacecraft public OnlinePlayerList(IBackend backend) { this.Backend = backend; - SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); - Font = new Font(Font, FontStyle.Bold); - PlayerOnlineImage = Image.FromFile("textures/playerOnline.png"); } protected override void OnPaint (PaintEventArgs e) @@ -32,5 +29,14 @@ namespace WorldOfPeacecraft count++; } } + + public void LoadResources(){ + Font = new Font(Font, FontStyle.Bold); + PlayerOnlineImage = Image.FromFile("textures/playerOnline.png"); + } + + public void InitializeComponents(){ + SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); + } } } \ No newline at end of file diff --git a/src/Gui/Program.cs b/src/Gui/Program.cs index 014673c..34522c4 100644 --- a/src/Gui/Program.cs +++ b/src/Gui/Program.cs @@ -9,11 +9,16 @@ namespace WorldOfPeacecraft { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Gui gui = new Gui(); Backend backend = new Backend(gui); gui.SetBackend(backend); - Application.Run (gui); + SplashScreen splash = new SplashScreen (gui,backend); + splash.GuiHasLoaded += OnGuiLoaded; + Application.Run (splash); + } + private static void OnGuiLoaded(SplashScreen screen, Gui gui){ + screen.Hide (); + gui.Show (); } } } diff --git a/src/Gui/Splashscreen.cs b/src/Gui/Splashscreen.cs index 3d87009..b8fabc8 100644 --- a/src/Gui/Splashscreen.cs +++ b/src/Gui/Splashscreen.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; @@ -10,9 +11,19 @@ namespace WorldOfPeacecraft private string ImagesFolder = "textures/"; private Image Logo; private Music m = new Music(); + private Gui gui; + private IBackend backend; - public SplashScreen () + public delegate void GuiHasLoadedEventHandler (SplashScreen screen, Gui gui); + public event GuiHasLoadedEventHandler GuiHasLoaded; + + public SplashScreen (Gui gui, IBackend backend) { + this.gui = gui; + this.backend = backend; + Thread t = new Thread (ThreadEntry); + t.Start (); + this.SetClientSizeCore (450, 150); Logo = Image.FromFile (ImagesFolder + "splashscreen.png"); m.Playmusic ("splashscreen"); } @@ -23,6 +34,14 @@ namespace WorldOfPeacecraft g.InterpolationMode = InterpolationMode.Low; g.DrawImage (Logo, 0, 0, 450, 150); } + + private void ThreadEntry(){ + gui.LoadResources (); + backend.Connect (); + Thread.Sleep (1000); + if (GuiHasLoaded != null) + GuiHasLoaded (this,gui); + } } } diff --git a/src/Music.cs b/src/Music.cs index bc108d6..9675437 100644 --- a/src/Music.cs +++ b/src/Music.cs @@ -11,19 +11,25 @@ namespace WorldOfPeacecraft private SoundPlayer minigameplayer = new SoundPlayer(musicpath + "minigame.wav"); private SoundPlayer splashscreenplayer = new SoundPlayer (soundpath + "splashscreen.wav"); private SoundPlayer walkplayer = new SoundPlayer(soundpath + "step.wav"); + private SoundPlayer poptartplayer = new SoundPlayer(musicpath + "poptart.wav"); + public Music () { } + public void Playmusic (string sound){ if (sound == "overworld") overworldplayer.PlayLooping (); if (sound == "minigame") minigameplayer.PlayLooping (); if (sound == "splashscreen") - splashscreenplayer.PlaySync (); + splashscreenplayer.Play (); if (sound == "walk") walkplayer.Play (); + if (sound == "poptart") + poptartplayer.Play (); + //TODO: Monalisa } } } From f8c1993c9f8b1f7213492ce8513e161446203066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Tue, 13 May 2014 19:15:41 +0200 Subject: [PATCH 2/3] Die Potato (or music), locken beim Zeichnen, Threads von Parse, Receiver und Sender laufen nun im Hintergrund --- src/Gui/ChatOutputBox.cs | 4 ++-- src/Gui/Gui.cs | 11 +++++++++-- src/Gui/Program.cs | 6 ++++-- src/Gui/Splashscreen.cs | 4 ++-- src/Music.cs | 4 ++-- src/Parser.cs | 1 + src/Receiver.cs | 1 + src/Sender.cs | 1 + 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Gui/ChatOutputBox.cs b/src/Gui/ChatOutputBox.cs index 1ba0f52..cf1c4e2 100644 --- a/src/Gui/ChatOutputBox.cs +++ b/src/Gui/ChatOutputBox.cs @@ -10,7 +10,7 @@ namespace WorldOfPeacecraft private Font MessageFont; private Font SenderFont; private Font IregularSenderFont; - private Music m = new Music(); + //private Music m = new Music(); public ChatOutputBox (IBackend backend) { @@ -43,7 +43,7 @@ namespace WorldOfPeacecraft this.SelectionFont = MessageFont; this.AppendText (message.GetMessage ()); if (message.GetMessage().Contains("nyancat")) { - m.Playmusic ("poptart"); + //m.Playmusic ("poptart"); } } } diff --git a/src/Gui/Gui.cs b/src/Gui/Gui.cs index dec1d70..f2fb30c 100644 --- a/src/Gui/Gui.cs +++ b/src/Gui/Gui.cs @@ -16,7 +16,7 @@ namespace WorldOfPeacecraft private ChatPanel ChatPanel; private OnlinePlayerList OnlinePlayerList; - private Music m = new Music(); + //private Music m = new Music(); public Gui () { @@ -40,6 +40,13 @@ namespace WorldOfPeacecraft Backend.StartThreads (); } + protected override void OnPaint (PaintEventArgs e) + { + lock (Backend) { + base.OnPaint(e); + } + } + public void InitializeComponents () { MapPanel.InitializeComponents (); @@ -65,7 +72,7 @@ namespace WorldOfPeacecraft this.ResumeLayout(); - m.Playmusic ("overworld"); + //m.Playmusic ("overworld"); } protected override void OnClosing (System.ComponentModel.CancelEventArgs e) diff --git a/src/Gui/Program.cs b/src/Gui/Program.cs index 34522c4..25201c5 100644 --- a/src/Gui/Program.cs +++ b/src/Gui/Program.cs @@ -17,8 +17,10 @@ namespace WorldOfPeacecraft Application.Run (splash); } private static void OnGuiLoaded(SplashScreen screen, Gui gui){ - screen.Hide (); - gui.Show (); + screen.BeginInvoke(new MethodInvoker(delegate { + screen.Hide (); + gui.Show (); + })); } } } diff --git a/src/Gui/Splashscreen.cs b/src/Gui/Splashscreen.cs index b8fabc8..a8eb669 100644 --- a/src/Gui/Splashscreen.cs +++ b/src/Gui/Splashscreen.cs @@ -10,7 +10,7 @@ namespace WorldOfPeacecraft { private string ImagesFolder = "textures/"; private Image Logo; - private Music m = new Music(); + //private Music m = new Music(); private Gui gui; private IBackend backend; @@ -25,7 +25,7 @@ namespace WorldOfPeacecraft t.Start (); this.SetClientSizeCore (450, 150); Logo = Image.FromFile (ImagesFolder + "splashscreen.png"); - m.Playmusic ("splashscreen"); + //m.Playmusic ("splashscreen"); } protected override void OnPaint (PaintEventArgs e) diff --git a/src/Music.cs b/src/Music.cs index 9675437..4d685f4 100644 --- a/src/Music.cs +++ b/src/Music.cs @@ -3,7 +3,7 @@ using System.Media; namespace WorldOfPeacecraft { - public class Music + /*public class Music { private static string musicpath = "./music/"; private static string soundpath = "./sounds/"; @@ -31,6 +31,6 @@ namespace WorldOfPeacecraft poptartplayer.Play (); //TODO: Monalisa } - } + }*/ } diff --git a/src/Parser.cs b/src/Parser.cs index 7d3bed9..ceb433d 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -61,6 +61,7 @@ namespace WorldOfPeacecraft Message = new LinkedList (); LastLineRegex = new Regex ("^end:[0-9]+$"); ParserThread = new Thread (new ThreadStart (this.RunParser)); + ParserThread.IsBackground = true; } private void RunParser () diff --git a/src/Receiver.cs b/src/Receiver.cs index 3146961..a96d5a0 100644 --- a/src/Receiver.cs +++ b/src/Receiver.cs @@ -17,6 +17,7 @@ namespace WorldOfPeacecraft this.Client = client; this.ReceiverBuffer = buffer; ReceiverThread = new Thread(new ThreadStart(this.doReceive)); + ReceiverThread.IsBackground = true; } public string Receive () diff --git a/src/Sender.cs b/src/Sender.cs index eb16001..a739f1a 100644 --- a/src/Sender.cs +++ b/src/Sender.cs @@ -17,6 +17,7 @@ namespace WorldOfPeacecraft this.Client = client; this.Buffer = buffer; this.SenderThread = new Thread(new ThreadStart(this.threadStart)); + this.SenderThread.IsBackground = true; } public void Send (String message) From 3bdf126d12b0def9ce4f67580ed1b6cc93f5925b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Tue, 13 May 2014 19:31:25 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Die=20schei=C3=9Fe=20Terminiert=20\o/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Gui/Gui.cs | 2 ++ src/Gui/Splashscreen.cs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Gui/Gui.cs b/src/Gui/Gui.cs index f2fb30c..737e281 100644 --- a/src/Gui/Gui.cs +++ b/src/Gui/Gui.cs @@ -11,6 +11,7 @@ namespace WorldOfPeacecraft private const int ChatWidth = 300; private const int OnlinePlayerWidth = 150; private IBackend Backend; + public Form MainForm { get; set; } private MapPanel MapPanel; private ChatPanel ChatPanel; @@ -78,6 +79,7 @@ namespace WorldOfPeacecraft protected override void OnClosing (System.ComponentModel.CancelEventArgs e) { base.OnClosing (e); + MainForm.Close(); Backend.Stop (); } diff --git a/src/Gui/Splashscreen.cs b/src/Gui/Splashscreen.cs index a8eb669..c40e2b1 100644 --- a/src/Gui/Splashscreen.cs +++ b/src/Gui/Splashscreen.cs @@ -20,6 +20,7 @@ namespace WorldOfPeacecraft public SplashScreen (Gui gui, IBackend backend) { this.gui = gui; + gui.MainForm = this; this.backend = backend; Thread t = new Thread (ThreadEntry); t.Start ();