public void AddElement(OATeMedia item)
        {
            if (item.UI_Element != null)
            {
                LayoutRoot.Children.Add((Border)item.UI_Element);
                return;
            }
            Border mediaElem = new Border();

            Grid.SetRow(mediaElem, 1);
            mediaElem.Opacity    = 0;
            mediaElem.Visibility = System.Windows.Visibility.Hidden;
            BitmapImage source = new BitmapImage(new Uri(item.MediaUri, UriKind.RelativeOrAbsolute));
            ImageBrush  brush  = new ImageBrush(source);

            brush.Stretch        = Stretch.Uniform;
            mediaElem.Background = brush;
            mediaElem.Name       = "MediaElement_" + LayoutRoot.Children.Count + 1;
            if (!System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory() + "/" + item.MediaUri))
            {
                throw new Exception("Not existing media: " + item.MediaUri.ToString());
            }
            LayoutRoot.Children.Add(mediaElem);
            item.UI_Element = mediaElem;
        }
        private void CreateOATeSettings()
        {
            _Console = new Console();
            _Console.Show();

            _ListOATeSettings = new List <OATeSettings>();
            foreach (var item in Directory.EnumerateDirectories(Directory.GetCurrentDirectory()))
            {
                foreach (var settings in Directory.GetFiles(item, "OATeSettings.xml"))
                {
                    OATeSettings newsett = new OATeSettings();
                    if (OATeSettings.TryLoadSettingsNoUi(settings, out newsett))
                    {
                        _ListOATeSettings.Add(newsett);
                    }
                }
            }

            if (!OATeSettings.TryLoadSettingsNoUi("OATeSettings.xml", out _OATeSettings))
            {
                this._OATeSettings            = new OATeSettings();
                _OATeSettings.Barra           = "Sole/spettro.png";
                _OATeSettings.Puntatore       = "Sole/Puntatore.png";
                this._OATeSettings.MediaFiles = new System.Collections.Generic.List <OATeMedia>();
                OATeMedia media1 = new OATeMedia();
                media1.FromValue = 0;
                media1.ToValue   = 0.1;
                media1.MediaUri  = "Sole/Video/Ic_flat_2d.mpg";
                _OATeSettings.MediaFiles.Add(media1);
                media1           = new OATeMedia();
                media1.FromValue = 0.1;
                media1.ToValue   = 0.2;
                media1.MediaUri  = "Sole/Video/latest_1024_0094.mp4";
                _OATeSettings.MediaFiles.Add(media1);
                media1           = new OATeMedia();
                media1.FromValue = 0.2;
                media1.ToValue   = 0.3;
                media1.MediaUri  = "Sole/Video/latest_1024_0131.mp4";
                _OATeSettings.MediaFiles.Add(media1);
                media1           = new OATeMedia();
                media1.FromValue = 0.3;
                media1.ToValue   = 0.4;
                media1.MediaUri  = "Sole/Video/latest_1024_0193.mp4";
                _OATeSettings.MediaFiles.Add(media1);
                media1           = new OATeMedia();
                media1.FromValue = 0.4;
                media1.ToValue   = 0.5;
                media1.MediaUri  = "Sole/Video/latest_1024_0211.mp4";
                _OATeSettings.MediaFiles.Add(media1);
                media1           = new OATeMedia();
                media1.FromValue = 0.5;
                media1.ToValue   = 0.6;
                media1.MediaUri  = "Sole/Video/latest_1024_0304.mp4";
                _OATeSettings.MediaFiles.Add(media1);
                media1           = new OATeMedia();
                media1.FromValue = 0.6;
                media1.ToValue   = 0.7;
                media1.MediaUri  = "Sole/Video/latest_1024_0335.mp4";
                _OATeSettings.MediaFiles.Add(media1);
                media1           = new OATeMedia();
                media1.FromValue = 0.8;
                media1.ToValue   = 0.9;
                media1.MediaUri  = "Sole/Video/latest_1024_1600.mp4";
                _OATeSettings.MediaFiles.Add(media1);
                media1           = new OATeMedia();
                media1.FromValue = 0.9;
                media1.ToValue   = 1;
                media1.MediaUri  = "Sole/Video/latest_1024_1700.mp4";
                _OATeSettings.MediaFiles.Add(media1);
                OATeSettings.SaveSettings("OATeSettings.xml", _OATeSettings);
            }
            _ListOATeSettings.Add(_OATeSettings);

            CameraViewer = new TwoCamerasTest.MainForm();
            CameraViewer.Show();
            CameraViewer.Hide();

            _MediaViewer        = new MediaViewer(_OATeSettings);
            _MediaViewer.Width  = SystemParameters.PrimaryScreenWidth;
            _MediaViewer.Height = SystemParameters.PrimaryScreenHeight - this.Height;
            _MediaViewer.Left   = 0;
            _MediaViewer.Top    = 0;
            _MediaViewer.Show();

            ImageSource source = new BitmapImage(new Uri(_OATeSettings.Barra, UriKind.RelativeOrAbsolute));

            border_barra.Background = new ImageBrush(source);
            foreach (var item in _OATeSettings.MediaFiles)
            {
                _MediaViewer.AddElement(item);
            }

            UserStateVisualizer._OATeSettings = this._OATeSettings;
            UserStateVisualizer.ValueReached += UserStateVisualizer_ValueReached;
            UserStateVisualizer.ValueReached += _MediaViewer.UserStateVisualizer_ValueReached;
        }