public void InitWindow(WindowMain parent)
 {
     this.ParentWindow         = parent;
     this.ConnectionProxys     = parent.TCPConnections;
     this.ConnectionMessages   = parent.ConnectionMessages;
     lbConnections.DataContext = ConnectionProxys;
     lbMessages.DataContext    = ConnectionMessages;
 }
        public static void loadApplicationSettingsFromDisk(ApplicationOptionsClient applicationOptions, WindowMain connectionHolder)
        {
            if (!File.Exists(APP_SETTINGS_FILE_NAME))
            {
                return;
            }

            XmlTextReader textReader = null;

            try
            {
                textReader = new XmlTextReader(APP_SETTINGS_FILE_NAME);
                textReader.Read(); // read declaration

                // read root node
                do
                {
                    textReader.Read();
                }while (textReader.NodeType == XmlNodeType.Whitespace);

                if (textReader.NodeType != XmlNodeType.Element || textReader.Name != XML_TAG_ROOT)
                {
                    throw new Exception("Error processing xml metadata file. The file might be corrupted.");
                }

                while (textReader.Read())
                {
                    if (textReader.NodeType == XmlNodeType.Element)
                    {
                        switch (textReader.Name)
                        {
                        case XML_TAG_LANGUAGE:
                            string lang_id = textReader.GetAttribute(XML_ATTR_LANGUAGE_ID);
                            Localization.LanguageSelector.Global.ChangeLanguage(Localization.LanguageInfo.getLanguageInfo(lang_id));
                            break;

                        case XML_TAG_IsPredictorComparison:
                            applicationOptions.IsPredictorCompareMode = bool.Parse(textReader.GetAttribute(XML_ATTR_VALUE));
                            break;

                        case XML_TAG_TRACE_PATH_MAIN:
                            applicationOptions.TracePathMain = textReader.GetAttribute(XML_ATTR_VALUE);
                            break;

                        case XML_TAG_SHOW_AM:
                            applicationOptions.ShowAM = bool.Parse(textReader.GetAttribute(XML_ATTR_VALUE));
                            break;

                        case XML_TAG_SHOW_GM:
                            applicationOptions.ShowGM = bool.Parse(textReader.GetAttribute(XML_ATTR_VALUE));
                            break;

                        case XML_TAG_SHOW_HM:
                            applicationOptions.ShowHM = bool.Parse(textReader.GetAttribute(XML_ATTR_VALUE));
                            break;

                        case XML_TAG_SHOW_LINE:
                            applicationOptions.ShowLine = bool.Parse(textReader.GetAttribute(XML_ATTR_VALUE));
                            break;

                        case XML_TAG_CONNECTIONS:
                            break;

                        case XML_TAG_CONNECTION:
                            string host = textReader.GetAttribute(XML_ATTR_CONNECTION_HOSTNAME);
                            string port = textReader.GetAttribute(XML_ATTR_CONNECTION_PORT);

                            TCPSimulatorProxy newproxy = new TCPSimulatorProxy(host, int.Parse(port));
                            newproxy.messagePosted       += new EventHandler <StringEventArgs>(connectionHolder.TCPProxy_MessagePosted);
                            newproxy.taskRequestReceived += new EventHandler(connectionHolder.proxyTaskRequestReceived);
                            newproxy.resultsReceived     += new statisticsResultReceivedEventHandler(connectionHolder.proxyResultsReceived);
                            connectionHolder.TCPConnections.Add(newproxy);
                            break;

                        default:
                            throw new Exception(string.Format("Unrecognised tag '{}' found in xml representation of the acquisition metadata. The file may be corrupt.", textReader.Name));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ErrorNotifier.showError(e.Message);
            }
            finally
            {
                if (textReader != null)
                {
                    textReader.Close();
                }
            }
        }