Ejemplo n.º 1
0
        public override bool Deserialize(string Serialized)
        {
            if (!(RectangleConverter.ConvertFromInvariantString(Serialized) is Rectangle rect))
            {
                return(false);
            }

            _regionProvider.SelectedRegion = rect;

            OnSelect();

            return(true);
        }
Ejemplo n.º 2
0
            private static FloatWindowStruct[] LoadFloatWindows(XmlTextReader xmlIn)
            {
                EnumConverter      dockAlignmentConverter = new EnumConverter(typeof(DockAlignment));
                RectangleConverter rectConverter          = new RectangleConverter();
                int countOfFloatWindows = Convert.ToInt32(xmlIn.GetAttribute("Count"), CultureInfo.InvariantCulture);

                FloatWindowStruct[] floatWindows = new FloatWindowStruct[countOfFloatWindows];
                MoveToNextElement(xmlIn);
                for (int i = 0; i < countOfFloatWindows; i++)
                {
                    int id = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture);
                    if (xmlIn.Name != "FloatWindow" || id != i)
                    {
                        throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat);
                    }

                    var convertFromInvariantString = rectConverter.ConvertFromInvariantString(xmlIn.GetAttribute("Bounds"));
                    if (convertFromInvariantString != null)
                    {
                        floatWindows[i].Bounds = (Rectangle)convertFromInvariantString;
                    }
                    floatWindows[i].ZOrderIndex = Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"), CultureInfo.InvariantCulture);
                    MoveToNextElement(xmlIn);
                    if (xmlIn.Name != "DockList" && xmlIn.Name != "NestedPanes")
                    {
                        throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat);
                    }
                    int countOfNestedPanes = Convert.ToInt32(xmlIn.GetAttribute("Count"), CultureInfo.InvariantCulture);
                    floatWindows[i].NestedPanes = new NestedPane[countOfNestedPanes];
                    MoveToNextElement(xmlIn);
                    for (int j = 0; j < countOfNestedPanes; j++)
                    {
                        int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"), CultureInfo.InvariantCulture);
                        if (xmlIn.Name != "Pane" || id2 != j)
                        {
                            throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat);
                        }
                        floatWindows[i].NestedPanes[j].IndexPane     = Convert.ToInt32(xmlIn.GetAttribute("RefID"), CultureInfo.InvariantCulture);
                        floatWindows[i].NestedPanes[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"), CultureInfo.InvariantCulture);
                        var convertFrom = dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment"));
                        if (convertFrom != null)
                        {
                            floatWindows[i].NestedPanes[j].Alignment = (DockAlignment)convertFrom;
                        }
                        floatWindows[i].NestedPanes[j].Proportion = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), CultureInfo.InvariantCulture);
                        MoveToNextElement(xmlIn);
                    }
                }

                return(floatWindows);
            }
Ejemplo n.º 3
0
        public override bool ParseCli(string Arg)
        {
            if (!Regex.IsMatch(Arg, @"^\d+,\d+,\d+,\d+$"))
            {
                return(false);
            }

            var rectConverter = new RectangleConverter();

            if (!(rectConverter.ConvertFromInvariantString(Arg) is Rectangle rect))
            {
                return(false);
            }

            _regionProvider.SelectedRegion = rect.Even();

            return(true);
        }
Ejemplo n.º 4
0
        void RestoreVideoSource()
        {
            IScreen GetMatchingScreen()
            {
                return(ScreenItem.Enumerate()
                       .Select(M => M.Screen)
                       .FirstOrDefault(M => M.DeviceName == _settings.Video.Source));
            }

            switch (_settings.Video.SourceKind)
            {
            case VideoSourceKindEnum.Region:
                if (RectangleConverter.ConvertFromInvariantString(_settings.Video.Source) is Rectangle rect)
                {
                    _regionProvider.SelectedRegion = rect;

                    _videoViewModel.SelectedVideoSourceKind = _regionSourceProvider;
                }
                break;

            case VideoSourceKindEnum.NoVideo:
                var source = _noVideoSourceProvider.Sources.FirstOrDefault(M => M.Name == _settings.Video.Source);

                if (source != null)
                {
                    _noVideoSourceProvider.SelectedSource   = source;
                    _videoViewModel.SelectedVideoSourceKind = _noVideoSourceProvider;
                }
                break;

            case VideoSourceKindEnum.Window:
                var window = Window.EnumerateVisible().FirstOrDefault(M => M.Title == _settings.Video.Source);

                if (window != null)
                {
                    _windowSourceProvider.Set(window.Handle);
                    _videoViewModel.RestoreSourceKind(_windowSourceProvider);
                }
                break;

            case VideoSourceKindEnum.Screen:
            {
                var screen = GetMatchingScreen();

                if (screen != null)
                {
                    _screenSourceProvider.Set(screen);
                    _videoViewModel.RestoreSourceKind(_screenSourceProvider);
                }

                break;
            }

            case VideoSourceKindEnum.DeskDupl:
            {
                var screen = GetMatchingScreen();

                if (screen != null)
                {
                    _deskDuplSourceProvider.Set(screen);
                    _videoViewModel.RestoreSourceKind(_deskDuplSourceProvider);
                }

                break;
            }
            }
        }
Ejemplo n.º 5
0
        public static void LoadFromXml(DockContainer dockPanel, Stream stream, DeserializeDockContent deserializeContent, bool closeStream)
        {
            if (dockPanel.Contents.Count != 0)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPanel.LoadFromXml.AlreadyInitialized"));
            }

            EnumConverter      dockStateConverter     = new EnumConverter(typeof(DockState));
            EnumConverter      dockAlignmentConverter = new EnumConverter(typeof(DockAlignment));
            RectangleConverter rectConverter          = new RectangleConverter();

            XmlTextReader xmlIn = new XmlTextReader(stream);

            xmlIn.WhitespaceHandling = WhitespaceHandling.None;
            xmlIn.MoveToContent();

            while (!xmlIn.Name.Equals("DockPanel"))
            {
                if (!MoveToNextElement(xmlIn))
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
            }

            string formatVersion = xmlIn.GetAttribute("FormatVersion");

            if (!IsFormatVersionValid(formatVersion))
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidFormatVersion"));
            }

            DockPanelStruct dockPanelStruct = new DockPanelStruct();

            dockPanelStruct.DockLeftPortion         = Convert.ToDouble(xmlIn.GetAttribute("DockLeftPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockRightPortion        = Convert.ToDouble(xmlIn.GetAttribute("DockRightPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockTopPortion          = Convert.ToDouble(xmlIn.GetAttribute("DockTopPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockBottomPortion       = Convert.ToDouble(xmlIn.GetAttribute("DockBottomPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.IndexActiveDocumentPane = Convert.ToInt32(xmlIn.GetAttribute("ActiveDocumentPane"));
            dockPanelStruct.IndexActivePane         = Convert.ToInt32(xmlIn.GetAttribute("ActivePane"));

            // Load Contents
            MoveToNextElement(xmlIn);
            if (xmlIn.Name != "Contents")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfContents = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            ContentStruct[] contents = new ContentStruct[countOfContents];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfContents; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "Content" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                contents[i].PersistString   = xmlIn.GetAttribute("PersistString");
                contents[i].AutoHidePortion = Convert.ToDouble(xmlIn.GetAttribute("AutoHidePortion"), CultureInfo.InvariantCulture);
                contents[i].IsHidden        = Convert.ToBoolean(xmlIn.GetAttribute("IsHidden"));
                contents[i].IsFloat         = Convert.ToBoolean(xmlIn.GetAttribute("IsFloat"));
                MoveToNextElement(xmlIn);
            }

            // Load Panes
            if (xmlIn.Name != "Panes")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfPanes = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            PaneStruct[] panes = new PaneStruct[countOfPanes];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfPanes; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "Pane" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                panes[i].DockState          = (DockState)dockStateConverter.ConvertFrom(xmlIn.GetAttribute("DockState"));
                panes[i].IndexActiveContent = Convert.ToInt32(xmlIn.GetAttribute("ActiveContent"));
                panes[i].ZOrderIndex        = -1;

                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "Contents")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfPaneContents = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                panes[i].IndexContents = new int[countOfPaneContents];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfPaneContents; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Content" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }

                    panes[i].IndexContents[j] = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    MoveToNextElement(xmlIn);
                }
            }

            // Load DockWindows
            if (xmlIn.Name != "DockWindows")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfDockWindows = dockPanel.DockWindows.Count;

            DockWindowStruct[] dockWindows = new DockWindowStruct[countOfDockWindows];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfDockWindows; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "DockWindow" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                dockWindows[i].DockState   = (DockState)dockStateConverter.ConvertFrom(xmlIn.GetAttribute("DockState"));
                dockWindows[i].ZOrderIndex = Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"));
                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "DockList")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfDockList = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                dockWindows[i].DockList = new DockListItem[countOfDockList];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfDockList; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Pane" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }
                    dockWindows[i].DockList[j].IndexPane     = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    dockWindows[i].DockList[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"));
                    dockWindows[i].DockList[j].Alignment     = (DockAlignment)dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment"));
                    dockWindows[i].DockList[j].Proportion    = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), CultureInfo.InvariantCulture);
                    MoveToNextElement(xmlIn);
                }
            }

            // Load FloatWindows
            if (xmlIn.Name != "FloatWindows")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfFloatWindows = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            FloatWindowStruct[] floatWindows = new FloatWindowStruct[countOfFloatWindows];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfFloatWindows; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "FloatWindow" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                floatWindows[i].Bounds         = (Rectangle)rectConverter.ConvertFromInvariantString(xmlIn.GetAttribute("Bounds"));
                floatWindows[i].AllowRedocking = Convert.ToBoolean(xmlIn.GetAttribute("AllowRedocking"));
                floatWindows[i].ZOrderIndex    = Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"));
                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "DockList")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfDockList = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                floatWindows[i].DockList = new DockListItem[countOfDockList];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfDockList; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Pane" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }
                    floatWindows[i].DockList[j].IndexPane     = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    floatWindows[i].DockList[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"));
                    floatWindows[i].DockList[j].Alignment     = (DockAlignment)dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment"));
                    floatWindows[i].DockList[j].Proportion    = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), CultureInfo.InvariantCulture);
                    MoveToNextElement(xmlIn);
                }
            }

            if (closeStream)
            {
                xmlIn.Close();
            }

            dockPanel.DockLeftPortion   = dockPanelStruct.DockLeftPortion;
            dockPanel.DockRightPortion  = dockPanelStruct.DockRightPortion;
            dockPanel.DockTopPortion    = dockPanelStruct.DockTopPortion;
            dockPanel.DockBottomPortion = dockPanelStruct.DockBottomPortion;

            // Set DockWindow ZOrders
            int prevMaxDockWindowZOrder = int.MaxValue;

            for (int i = 0; i < dockWindows.Length; i++)
            {
                int maxDockWindowZOrder = -1;
                int index = -1;
                for (int j = 0; j < dockWindows.Length; j++)
                {
                    if (dockWindows[j].ZOrderIndex > maxDockWindowZOrder && dockWindows[j].ZOrderIndex < prevMaxDockWindowZOrder)
                    {
                        maxDockWindowZOrder = dockWindows[j].ZOrderIndex;
                        index = j;
                    }
                }

                dockPanel.DockWindows[dockWindows[index].DockState].BringToFront();
                prevMaxDockWindowZOrder = maxDockWindowZOrder;
            }

            // Create Contents
            for (int i = 0; i < contents.Length; i++)
            {
                IDockableWindow content = deserializeContent(contents[i].PersistString);
                if (content == null)
                {
                    content = new DummyContent();
                }
                content.DockHandler.DockPanel       = dockPanel;
                content.DockHandler.AutoHidePortion = contents[i].AutoHidePortion;
                content.DockHandler.IsHidden        = true;
                content.DockHandler.IsFloat         = contents[i].IsFloat;
            }

            // Create panes
            for (int i = 0; i < panes.Length; i++)
            {
                DockPane pane = null;
                for (int j = 0; j < panes[i].IndexContents.Length; j++)
                {
                    IDockableWindow content = dockPanel.Contents[panes[i].IndexContents[j]];
                    if (j == 0)
                    {
                        pane = dockPanel.DockPaneFactory.CreateDockPane(content, panes[i].DockState, false);
                    }
                    else if (panes[i].DockState == DockState.Float)
                    {
                        content.DockHandler.FloatPane = pane;
                    }
                    else
                    {
                        content.DockHandler.PanelPane = pane;
                    }
                }
            }

            // Assign Panes to DockWindows
            for (int i = 0; i < dockWindows.Length; i++)
            {
                for (int j = 0; j < dockWindows[i].DockList.Length; j++)
                {
                    DockWindow    dw            = dockPanel.DockWindows[dockWindows[i].DockState];
                    int           indexPane     = dockWindows[i].DockList[j].IndexPane;
                    DockPane      pane          = dockPanel.Panes[indexPane];
                    int           indexPrevPane = dockWindows[i].DockList[j].IndexPrevPane;
                    DockPane      prevPane      = (indexPrevPane == -1) ? dw.DockList.GetDefaultPrevPane(pane) : dockPanel.Panes[indexPrevPane];
                    DockAlignment alignment     = dockWindows[i].DockList[j].Alignment;
                    double        proportion    = dockWindows[i].DockList[j].Proportion;
                    pane.AddToDockList(dw, prevPane, alignment, proportion);
                    if (panes[indexPane].DockState == dw.DockState)
                    {
                        panes[indexPane].ZOrderIndex = dockWindows[i].ZOrderIndex;
                    }
                }
            }

            // Create float windows
            for (int i = 0; i < floatWindows.Length; i++)
            {
                FloatWindow fw = null;
                for (int j = 0; j < floatWindows[i].DockList.Length; j++)
                {
                    int      indexPane = floatWindows[i].DockList[j].IndexPane;
                    DockPane pane      = dockPanel.Panes[indexPane];
                    if (j == 0)
                    {
                        fw = dockPanel.FloatWindowFactory.CreateFloatWindow(dockPanel, pane, floatWindows[i].Bounds);
                    }
                    else
                    {
                        int           indexPrevPane = floatWindows[i].DockList[j].IndexPrevPane;
                        DockPane      prevPane      = indexPrevPane == -1 ? null : dockPanel.Panes[indexPrevPane];
                        DockAlignment alignment     = floatWindows[i].DockList[j].Alignment;
                        double        proportion    = floatWindows[i].DockList[j].Proportion;
                        pane.AddToDockList(fw, prevPane, alignment, proportion);
                        if (panes[indexPane].DockState == fw.DockState)
                        {
                            panes[indexPane].ZOrderIndex = floatWindows[i].ZOrderIndex;
                        }
                    }
                }
            }

            // sort IDockContent by its Pane's ZOrder
            int[] sortedContents = null;
            if (contents.Length > 0)
            {
                sortedContents = new int[contents.Length];
                for (int i = 0; i < contents.Length; i++)
                {
                    sortedContents[i] = i;
                }

                int lastDocument = contents.Length;
                for (int i = 0; i < contents.Length - 1; i++)
                {
                    for (int j = i + 1; j < contents.Length; j++)
                    {
                        DockPane pane1        = dockPanel.Contents[sortedContents[i]].DockHandler.Pane;
                        int      ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex;
                        DockPane pane2        = dockPanel.Contents[sortedContents[j]].DockHandler.Pane;
                        int      ZOrderIndex2 = pane2 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane2)].ZOrderIndex;
                        if (ZOrderIndex1 > ZOrderIndex2)
                        {
                            int temp = sortedContents[i];
                            sortedContents[i] = sortedContents[j];
                            sortedContents[j] = temp;
                        }
                    }
                }
            }

            // show non-document IDockContent first to avoid screen flickers
            for (int i = 0; i < contents.Length; i++)
            {
                IDockableWindow content = dockPanel.Contents[sortedContents[i]];
                if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState != DockState.Document)
                {
                    content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden;
                }
            }

            // after all non-document IDockContent, show document IDockContent
            for (int i = 0; i < contents.Length; i++)
            {
                IDockableWindow content = dockPanel.Contents[sortedContents[i]];
                if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState == DockState.Document)
                {
                    content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden;
                }
            }

            for (int i = 0; i < panes.Length; i++)
            {
                dockPanel.Panes[i].ActiveContent = panes[i].IndexActiveContent == -1 ? null : dockPanel.Contents[panes[i].IndexActiveContent];
            }

            if (dockPanelStruct.IndexActiveDocumentPane != -1)
            {
                dockPanel.Panes[dockPanelStruct.IndexActiveDocumentPane].Activate();
            }

            if (dockPanelStruct.IndexActivePane != -1)
            {
                dockPanel.Panes[dockPanelStruct.IndexActivePane].Activate();
            }

            for (int i = dockPanel.Contents.Count - 1; i >= 0; i--)
            {
                if (dockPanel.Contents[i] is DummyContent)
                {
                    dockPanel.Contents[i].DockHandler.Form.Close();
                }
            }
        }
Ejemplo n.º 6
0
        void RestoreRemembered()
        {
            // Restore Video Source
            if (!string.IsNullOrEmpty(Settings.Video.SourceKind))
            {
                var kind = VideoViewModel.AvailableVideoSourceKinds.FirstOrDefault(M => M.Name == Settings.Video.SourceKind);

                if (kind != null)
                {
                    VideoViewModel.SelectedVideoSourceKind = kind;

                    switch (kind)
                    {
                    case RegionSourceProvider _:
                        if (RectangleConverter.ConvertFromInvariantString(Settings.Video.Source) is Rectangle rect)
                        {
                            _regionProvider.SelectedRegion = rect;
                        }
                        break;

                    default:
                        var source = VideoViewModel.AvailableVideoSources
                                     .FirstOrDefault(S => S.ToString() == Settings.Video.Source);

                        if (source != null)
                        {
                            VideoViewModel.SelectedVideoSource = source;
                        }
                        break;
                    }
                }
            }

            // Restore Video Codec
            if (!string.IsNullOrEmpty(Settings.Video.WriterKind))
            {
                var kind = VideoViewModel.AvailableVideoWriterKinds.FirstOrDefault(W => W.Name == Settings.Video.WriterKind);

                if (kind != null)
                {
                    VideoViewModel.SelectedVideoWriterKind = kind;

                    var codec = VideoViewModel.AvailableVideoWriters.FirstOrDefault(C => C.ToString() == Settings.Video.Writer);

                    if (codec != null)
                    {
                        VideoViewModel.SelectedVideoWriter = codec;
                    }
                }
            }

            // Restore Microphones
            if (Settings.Audio.Microphones != null)
            {
                foreach (var source in AudioSource.AvailableRecordingSources)
                {
                    source.Active = Settings.Audio.Microphones.Contains(source.Name);
                }
            }

            // Restore Loopback Speakers
            if (Settings.Audio.Speakers != null)
            {
                foreach (var source in AudioSource.AvailableLoopbackSources)
                {
                    source.Active = Settings.Audio.Speakers.Contains(source.Name);
                }
            }

            // Restore ScreenShot Format
            if (!string.IsNullOrEmpty(Settings.ScreenShots.ImageFormat))
            {
                var format = ScreenShotImageFormats.FirstOrDefault(F => F.ToString() == Settings.ScreenShots.ImageFormat);

                if (format != null)
                {
                    SelectedScreenShotImageFormat = format;
                }
            }

            // Restore ScreenShot Target
            if (Settings.ScreenShots.SaveTargets != null)
            {
                foreach (var imageWriter in VideoViewModel.AvailableImageWriters)
                {
                    imageWriter.Active = Settings.ScreenShots.SaveTargets.Contains(imageWriter.Display);
                }

                // Activate First if none
                if (!VideoViewModel.AvailableImageWriters.Any(M => M.Active))
                {
                    VideoViewModel.AvailableImageWriters[0].Active = true;
                }
            }
        }
Ejemplo n.º 7
0
        void RestoreRemembered()
        {
            // Restore Video Source
            if (!string.IsNullOrEmpty(Settings.Video.SourceKind))
            {
                var kind = VideoViewModel.AvailableVideoSourceKinds.FirstOrDefault(M => M.Name == Settings.Video.SourceKind);

                if (kind != null)
                {
                    VideoViewModel.SelectedVideoSourceKind = kind;

                    switch (kind)
                    {
                    case RegionSourceProvider _:
                        if (RectangleConverter.ConvertFromInvariantString(Settings.Video.Source) is Rectangle rect)
                        {
                            _regionProvider.SelectedRegion = rect;
                        }
                        break;

                    default:
                        var source = VideoViewModel.AvailableVideoSources
                                     .FirstOrDefault(S => S.ToString() == Settings.Video.Source);

                        if (source != null)
                        {
                            VideoViewModel.SelectedVideoSource = source;
                        }
                        break;
                    }
                }
            }

            // Restore Video Codec
            if (!string.IsNullOrEmpty(Settings.Video.WriterKind))
            {
                var kind = VideoViewModel.AvailableVideoWriterKinds.FirstOrDefault(W => W.Name == Settings.Video.WriterKind);

                if (kind != null)
                {
                    VideoViewModel.SelectedVideoWriterKind = kind;

                    var codec = VideoViewModel.AvailableVideoWriters.FirstOrDefault(C => C.ToString() == Settings.Video.Writer);

                    if (codec != null)
                    {
                        VideoViewModel.SelectedVideoWriter = codec;
                    }
                }
            }

            // Restore Microphone
            if (!string.IsNullOrEmpty(Settings.Audio.Microphone))
            {
                var source = AudioSource.AvailableRecordingSources.FirstOrDefault(C => C.ToString() == Settings.Audio.Microphone);

                if (source != null)
                {
                    AudioSource.SelectedRecordingSource = source;
                }
            }

            // Restore Loopback Speaker
            if (!string.IsNullOrEmpty(Settings.Audio.Speaker))
            {
                var source = AudioSource.AvailableLoopbackSources.FirstOrDefault(C => C.ToString() == Settings.Audio.Speaker);

                if (source != null)
                {
                    AudioSource.SelectedLoopbackSource = source;
                }
            }

            // Restore ScreenShot Format
            if (!string.IsNullOrEmpty(Settings.ScreenShots.ImageFormat))
            {
                var format = ScreenShotImageFormats.FirstOrDefault(F => F.ToString() == Settings.ScreenShots.ImageFormat);

                if (format != null)
                {
                    SelectedScreenShotImageFormat = format;
                }
            }

            // Restore ScreenShot Target
            if (!string.IsNullOrEmpty(Settings.ScreenShots.SaveTarget))
            {
                var saveTo = VideoViewModel.AvailableImageWriters.FirstOrDefault(S => S.ToString() == Settings.ScreenShots.SaveTarget);

                if (saveTo != null)
                {
                    VideoViewModel.SelectedImageWriter = saveTo;
                }
            }

            // Restore Webcam
            if (!string.IsNullOrEmpty(Settings.Video.Webcam))
            {
                var webcam = WebCamProvider.AvailableCams.FirstOrDefault(C => C.Name == Settings.Video.Webcam);

                if (webcam != null)
                {
                    WebCamProvider.SelectedCam = webcam;
                }
            }
        }
Ejemplo n.º 8
0
        static void HandleVideoSource(MainViewModel ViewModel, CommonCmdOptions CommonOptions)
        {
            // Desktop
            if (CommonOptions.Source == null || CommonOptions.Source == "desktop")
            {
                return;
            }

            var video = ViewModel.VideoViewModel;

            // Region
            if (Regex.IsMatch(CommonOptions.Source, @"^\d+,\d+,\d+,\d+$"))
            {
                var rectConverter = new RectangleConverter();

                if (rectConverter.ConvertFromInvariantString(CommonOptions.Source) is Rectangle rect)
                {
                    FakeRegionProvider.Instance.SelectedRegion = rect.Even();
                    video.SelectedVideoSourceKind = ServiceProvider.Get <RegionSourceProvider>();
                }
            }

            // Screen
            else if (Regex.IsMatch(CommonOptions.Source, @"^screen:\d+$"))
            {
                var index = int.Parse(CommonOptions.Source.Substring(7));

                if (index < ScreenItem.Count)
                {
                    var screenSourceProvider = ServiceProvider.Get <ScreenSourceProvider>();

                    screenSourceProvider.Set(index);

                    video.RestoreSourceKind(screenSourceProvider);
                }
            }

            // Window
            else if (Regex.IsMatch(CommonOptions.Source, @"^win:\d+$"))
            {
                var handle = new IntPtr(int.Parse(CommonOptions.Source.Substring(4)));

                var winProvider = ServiceProvider.Get <WindowSourceProvider>();

                winProvider.Set(handle);

                video.RestoreSourceKind(winProvider);
            }

            // Start command only
            else if (CommonOptions is StartCmdOptions)
            {
                // Desktop Duplication
                if (Regex.IsMatch(CommonOptions.Source, @"^deskdupl:\d+$"))
                {
                    var index = int.Parse(CommonOptions.Source.Substring(9));

                    if (index < ScreenItem.Count)
                    {
                        var deskDuplSourceProvider = ServiceProvider.Get <DeskDuplSourceProvider>();

                        deskDuplSourceProvider.Set(new ScreenWrapper(Screen.AllScreens[index]));

                        video.RestoreSourceKind(deskDuplSourceProvider);
                    }
                }

                // No Video for Start
                else if (CommonOptions.Source == "none")
                {
                    video.SelectedVideoSourceKind = ServiceProvider.Get <NoVideoSourceProvider>();
                }
            }
        }
Ejemplo n.º 9
0
        private bool ProcessSetValue(Type type, string name, string newvalue)
        {
            if (type == typeof(string))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { newvalue });
                return(true);
            }

            if (type == typeof(bool))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { bool.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(int))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { int.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(long))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { long.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(decimal))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { decimal.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(float))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { float.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(double))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { double.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(char))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { char.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Enum) || type.BaseType == typeof(Enum))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Enum.Parse(type, newvalue) });
                return(true);
            }

            if (type == typeof(Single))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Single.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Byte))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Byte.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(SByte))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { SByte.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Int16))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Int16.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Int32))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Int32.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Int64))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { Int64.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(UInt16))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { UInt16.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(UInt32))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { UInt32.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(UInt64))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { UInt64.Parse(newvalue) });
                return(true);
            }

            // 20080827 : DateTimeConvertor.ConvertToInvariantString(DateTime.MinValue) return empty string ""
            //            which cannot be parsed by following culture specific method.

            //if( type == typeof( DateTime ) )
            //{
            //    this.GetType().InvokeMember( name,
            //        /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
            //        BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField ,
            //        null, this, new object[]{ DateTime.Parse(newvalue) } );
            //    return true;
            //}

            if (type == typeof(TimeSpan))
            {
                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { TimeSpan.Parse(newvalue) });
                return(true);
            }

            if (type == typeof(Color))
            {
                ColorConverter cc = new ColorConverter();

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { cc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            if (type == typeof(Font))
            {
                FontConverter cc = new FontConverter();

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { cc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            if (type == typeof(Point))
            {
                PointConverter cc = new PointConverter();

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { cc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            if (type == typeof(Rectangle))
            {
                RectangleConverter cc = new RectangleConverter();

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { cc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            if (type == typeof(Size))
            {
                SizeConverter cc = new SizeConverter();

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { cc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            //if (type == typeof(Type))
            //{
            //    Type newType = null;
            //    if (newvalue != null && newvalue.Length > 0)
            //    {
            //        newType = Type.GetType(newvalue, true);
            //    }

            //    this.GetType().InvokeMember(name,
            //        /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
            //        BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
            //        null, this, new object[] { newType });
            //    return true;
            //}

            if (!XObjectHelper.IsXBaseType(type))
            {
                TypeConverter tc = TypeDescriptor.GetConverter(type);
                if (tc == null)
                {
                    return(true);
                }

                this.GetType().InvokeMember(name,
                                            /*BindingFlags.DeclaredOnly |*/ BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.SetField,
                                            null, this, new object[] { tc.ConvertFromInvariantString(newvalue) });
                return(true);
            }

            return(true);
        }
Ejemplo n.º 10
0
        private void SetProperty(PropertyInfo p, object val)
        {
            if (p == null)
            {
                return;
            }

            if (val == null)
            {
                this.GetType().InvokeMember(p.Name,
                                            BindingFlags.DeclaredOnly | BindingFlags.Public |
                                            BindingFlags.Instance | BindingFlags.SetProperty,
                                            null, this, new object[] { null });
            }
            else
            {
                string str = val.ToString();

                if (p.PropertyType == typeof(string))
                {
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { str });
                    return;
                }

                if (p.PropertyType == typeof(DateTime))
                {
                    DateTime v = DateTime.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(decimal))
                {
                    decimal v = decimal.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(int))
                {
                    int v = int.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(long))
                {
                    long v = long.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(float))
                {
                    float v = float.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(double))
                {
                    double v = double.Parse(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(Color))
                {
                    ColorConverter cc = new ColorConverter();
                    Color          v  = (Color)cc.ConvertFromInvariantString(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(Font))
                {
                    FontConverter cc = new FontConverter();
                    Font          v  = (Font)cc.ConvertFromInvariantString(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(Point))
                {
                    PointConverter cc = new PointConverter();
                    Point          v  = (Point)cc.ConvertFromInvariantString(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(Size))
                {
                    SizeConverter cc = new SizeConverter();
                    Size          v  = (Size)cc.ConvertFromInvariantString(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }

                if (p.PropertyType == typeof(Rectangle))
                {
                    RectangleConverter cc = new RectangleConverter();
                    Rectangle          v  = (Rectangle)cc.ConvertFromInvariantString(str);
                    this.GetType().InvokeMember(p.Name,
                                                BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                BindingFlags.Instance | BindingFlags.SetProperty,
                                                null, this, new object[] { v });
                    return;
                }
            }
        }
Ejemplo n.º 11
0
        public bool LoadFromFile()
        {
            string iniFileName = "";
            string stoneName;
            string backgroundName;
            string skinFolder = "";

            if (!File.Exists(skinFileName))
            {
                return(false);
            }
            else
            {
                iniFileName = skinFileName;
                skinFolder  = Path.GetDirectoryName(skinFileName);
            }


            MemIniFile ini = new MemIniFile(iniFileName);

            try
            {
                ini.Load();

                MenuSkin = ini.ReadString("Menu", "Theme", null);

                ColorConverter     cc = new ColorConverter();
                RectangleConverter rc = new RectangleConverter();
                fontName = ini.ReadString("Info", "FontName", "Tahoma");
                fontSize = ini.ReadInteger("Info", "FontSize", 14);
                try
                {
                    foreColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Info", "Color", "White"));
                }
                catch
                {
                    foreColor = Color.White;
                }

                try
                {
                    HintOutlineColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Hint", "OutlineColor", "Black"));
                }
                catch
                {
                    HintOutlineColor = Color.Black;
                }

                try
                {
                    HintBorderColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Hint", "BorderColor", "Gainsboro"));
                }
                catch
                {
                    HintBorderColor = Color.Gainsboro;
                }

                try
                {
                    HintBodyColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Hint", "BodyColor", "Black"));
                }
                catch
                {
                    HintBodyColor = Color.Black;
                }

                ButtonStoneSize  = ini.ReadInteger("Hint", "ButtonSize", 26);
                ButtonStoneSpace = ini.ReadInteger("Hint", "ButtonSpace", 4);

                try
                {
                    MenuBorderColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "BorderColor", "Gainsboro"));
                }
                catch
                {
                    MenuBorderColor = Color.Gainsboro;
                }

                try
                {
                    MenuOutlineColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "OutlineColor", "Black"));
                }
                catch
                {
                    MenuOutlineColor = Color.Black;
                }

                try
                {
                    MenuBodyColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "BodyColor", "Black"));
                }
                catch
                {
                    MenuBodyColor = Color.Black;
                }

                try
                {
                    MenuNormalTextColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "NormalTextColor", "White"));
                }
                catch
                {
                    MenuNormalTextColor = Color.White;
                }

                try
                {
                    MenuDisabledTextColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "DisabledTextColor", "Gray"));
                }
                catch
                {
                    MenuDisabledTextColor = Color.Gray;
                }

                try
                {
                    MenuSelectedTextColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "SelectedTextColor", "Black"));
                }
                catch
                {
                    MenuSelectedTextColor = Color.Black;
                }

                MenuFontSize = ini.ReadInteger("Menu", "FontSize", 12);

                MenuFontName = ini.ReadString("Menu", "FontName", "Tahoma");

                try
                {
                    MenuHighlightColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "HighlightColor", "Orange"));
                }
                catch
                {
                    MenuHighlightColor = Color.Orange;
                }


                ButtonStoneAbout = ini.ReadString("Hint", "ButtonStoneAbout", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStoneAbout))
                {
                    ButtonStoneAbout = Path.Combine(skinFolder, ButtonStoneAbout);
                }


                ButtonStoneSelect = ini.ReadString("Hint", "ButtonStoneSelect", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStoneSelect))
                {
                    ButtonStoneSelect = Path.Combine(skinFolder, ButtonStoneSelect);
                }


                ButtonStoneEdit = ini.ReadString("Hint", "ButtonStoneEdit", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStoneEdit))
                {
                    ButtonStoneEdit = Path.Combine(skinFolder, ButtonStoneEdit);
                }

                ButtonStoneDelete = ini.ReadString("Hint", "ButtonStoneDelete", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStoneDelete))
                {
                    ButtonStoneDelete = Path.Combine(skinFolder, ButtonStoneDelete);
                }


                ButtonBackNormal = ini.ReadString("ButtonBack", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonBackNormal))
                {
                    ButtonBackNormal = Path.Combine(skinFolder, ButtonBackNormal);
                }

                ButtonBackFocused = ini.ReadString("ButtonBack", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonBackFocused))
                {
                    ButtonBackFocused = Path.Combine(skinFolder, ButtonBackFocused);
                }

                ButtonBackPressed = ini.ReadString("ButtonBack", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonBackPressed))
                {
                    ButtonBackPressed = Path.Combine(skinFolder, ButtonBackPressed);
                }


                ButtonStartMenuNormal = ini.ReadString("ButtonStartMenu", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStartMenuNormal))
                {
                    ButtonStartMenuNormal = Path.Combine(skinFolder, ButtonStartMenuNormal);
                }

                ButtonStartMenuFocused = ini.ReadString("ButtonStartMenu", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStartMenuFocused))
                {
                    ButtonStartMenuFocused = Path.Combine(skinFolder, ButtonStartMenuFocused);
                }

                ButtonStartMenuPressed = ini.ReadString("ButtonStartMenu", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStartMenuPressed))
                {
                    ButtonStartMenuPressed = Path.Combine(skinFolder, ButtonStartMenuPressed);
                }

                ButtonForwardNormal = ini.ReadString("ButtonForward", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonForwardNormal))
                {
                    ButtonForwardNormal = Path.Combine(skinFolder, ButtonForwardNormal);
                }
                else
                {
                    ButtonForwardFocused = ini.ReadString("ButtonForward", "Focused", string.Empty);
                }
                if (!string.IsNullOrEmpty(ButtonForwardFocused))
                {
                    ButtonForwardFocused = Path.Combine(skinFolder, ButtonForwardFocused);
                }

                ButtonForwardPressed = ini.ReadString("ButtonForward", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonForwardPressed))
                {
                    ButtonForwardPressed = Path.Combine(skinFolder, ButtonForwardPressed);
                }

                ButtonPowerNormal = ini.ReadString("ButtonPower", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonPowerNormal))
                {
                    ButtonPowerNormal = Path.Combine(skinFolder, ButtonPowerNormal);
                }

                ButtonPowerFocused = ini.ReadString("ButtonPower", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonPowerFocused))
                {
                    ButtonPowerFocused = Path.Combine(skinFolder, ButtonPowerFocused);
                }

                ButtonPowerPressed = ini.ReadString("ButtonPower", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonPowerPressed))
                {
                    ButtonPowerPressed = Path.Combine(skinFolder, ButtonPowerPressed);
                }

                ButtonHomeNormal = ini.ReadString("ButtonHome", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonHomeNormal))
                {
                    ButtonHomeNormal = Path.Combine(skinFolder, ButtonHomeNormal);
                }

                ButtonHomeFocused = ini.ReadString("ButtonHome", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonHomeFocused))
                {
                    ButtonHomeFocused = Path.Combine(skinFolder, ButtonHomeFocused);
                }

                ButtonHomePressed = ini.ReadString("ButtonHome", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonHomePressed))
                {
                    ButtonHomePressed = Path.Combine(skinFolder, ButtonHomePressed);
                }

                ButtonLauncherNormal = ini.ReadString("ButtonLauncher", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonLauncherNormal))
                {
                    ButtonLauncherNormal = Path.Combine(skinFolder, ButtonLauncherNormal);
                }

                ButtonLauncherFocused = ini.ReadString("ButtonLauncher", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonLauncherFocused))
                {
                    ButtonLauncherFocused = Path.Combine(skinFolder, ButtonLauncherFocused);
                }

                ButtonLauncherPressed = ini.ReadString("ButtonLauncher", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonLauncherPressed))
                {
                    ButtonLauncherPressed = Path.Combine(skinFolder, ButtonLauncherPressed);
                }

                ButtonSettingsNormal = ini.ReadString("ButtonSettings", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonSettingsNormal))
                {
                    ButtonSettingsNormal = Path.Combine(skinFolder, ButtonSettingsNormal);
                }

                ButtonSettingsFocused = ini.ReadString("ButtonSettings", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonSettingsFocused))
                {
                    ButtonSettingsFocused = Path.Combine(skinFolder, ButtonSettingsFocused);
                }

                ButtonSettingsPressed = ini.ReadString("ButtonSettings", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonSettingsPressed))
                {
                    ButtonSettingsPressed = Path.Combine(skinFolder, ButtonSettingsPressed);
                }

                ManagerWidth  = ini.ReadInteger("Background", "ManagerWidth", GlobalSettings.WindowWidth);
                ManagerHeight = ini.ReadInteger("Background", "ManagerHeight", GlobalSettings.WindowHeight);
                Radius        = ini.ReadInteger("Background", "Radius", GlobalSettings.Radius);

                string sectionName = "Background";

                if (ini.SectionExists("Background"))
                {
                    sectionName = "Background";
                }
                else
                if (ini.SectionExists("Tile"))
                {
                    sectionName = "Tile";
                }
                else
                if (ini.SectionExists("BackgroundTop"))
                {
                    sectionName = "BackgroundTop";
                }
                else
                if (ini.SectionExists("BackgroundBottom"))
                {
                    sectionName = "BackgroundBottom";
                }

                if (ini.ValueExists(sectionName, "LeftMargin"))
                {
                    leftMargin = ini.ReadInteger(sectionName, "LeftMargin", 0);
                }
                else
                {
                    leftMargin = ini.ReadInteger(sectionName, "LeftWidth", 0);
                }

                textOffset = ini.ReadInteger("Background", "TextOffset", leftMargin);

                if (ini.ValueExists(sectionName, "RightMargin"))
                {
                    rightMargin = ini.ReadInteger(sectionName, "RightMargin", 0);
                }
                else
                {
                    rightMargin = ini.ReadInteger(sectionName, "RightWidth", 0);
                }

                if (ini.ValueExists(sectionName, "TopMargin"))
                {
                    topMargin = ini.ReadInteger(sectionName, "TopMargin", 0);
                }
                else
                {
                    topMargin = ini.ReadInteger(sectionName, "TopHeight", 0);
                }

                if (ini.ValueExists(sectionName, "BottomMargin"))
                {
                    bottomMargin = ini.ReadInteger(sectionName, "BottomMargin", 0);
                }
                else
                {
                    bottomMargin = ini.ReadInteger(sectionName, "BottomHeight", 0);
                }

                if (ini.ValueExists(sectionName, "Outside-LeftMargin"))
                {
                    outsideLeftMargin = ini.ReadInteger(sectionName, "Outside-LeftMargin", 0);
                }
                else
                {
                    outsideLeftMargin = ini.ReadInteger(sectionName, "OutsideBorderLeft", 0);
                }

                if (ini.ValueExists(sectionName, "Outside-TopMargin"))
                {
                    outsideTopMargin = ini.ReadInteger(sectionName, "Outside-TopMargin", 0);
                }
                else
                {
                    outsideTopMargin = ini.ReadInteger(sectionName, "OutsideBorderTop", 0);
                }

                if (ini.ValueExists(sectionName, "Outside-BottomMargin"))
                {
                    outsideBottomMargin = ini.ReadInteger(sectionName, "Outside-BottomMargin", 0);
                }
                else
                {
                    outsideBottomMargin = ini.ReadInteger(sectionName, "OutsideBorderBottom", 0);
                }

                if (ini.ValueExists(sectionName, "Outside-RightMargin"))
                {
                    outsideRightMargin = ini.ReadInteger(sectionName, "Outside-RightMargin", 0);
                }
                else
                {
                    outsideRightMargin = ini.ReadInteger(sectionName, "OutsideBorderRight", 0);
                }

                backgroundName = ini.ReadString(sectionName, "Image", string.Empty);

                ButtonSize = ini.ReadInteger("Background", "ButtonSize", 60);


                //read stone info
                indicatorRect   = (Rectangle)rc.ConvertFromInvariantString(ini.ReadString("Stone", "Indicator-Rect", "0, 0, 100, 100"));
                IndicatorLeft   = ini.ReadInteger("Stone", "Indicator-Left", 0);
                IndicatorBottom = ini.ReadInteger("Stone", "Indicator-Bottom", 0);

                indicatorImageName = ini.ReadString("Stone", "Indicator", string.Empty);
                if (!string.IsNullOrEmpty(indicatorImageName))
                {
                    indicatorImageName = Path.Combine(skinFolder, indicatorImageName);
                }


                if (ini.SectionExists("Stone"))
                {
                    stoneMarginTop    = ini.ReadInteger("Stone", "OutsideBorderTop", 0);
                    stoneMarginBottom = ini.ReadInteger("Stone", "OutsideBorderBottom", 0);
                    stoneMarginLeft   = ini.ReadInteger("Stone", "OutsideBorderLeft", 0);
                    stoneMarginRight  = ini.ReadInteger("Stone", "OutsideBorderRight", 0);
                    stoneBorder       = ini.ReadInteger("Stone", "Border", 0);
                    stoneName         = ini.ReadString("Stone", "Image", backgroundName);
                }
                else
                {
                    stoneMarginTop    = outsideTopMargin;
                    stoneMarginBottom = outsideBottomMargin;
                    stoneMarginLeft   = outsideLeftMargin;
                    stoneMarginRight  = outsideRightMargin;
                    stoneName         = backgroundName;
                    stoneBorder       = 0;
                }

                if (string.IsNullOrEmpty(backgroundName))
                {
                    return(false);
                }
                else
                {
                    if (background != null)
                    {
                        background.Dispose();
                        background = null;
                    }
                    try
                    {
                        background = FastBitmap.FromFile(Path.Combine(skinFolder, backgroundName));
                        if (background == null)
                        {
                            return(false);
                        }
                    }
                    catch
                    {
                        return(false);
                    }
                }

                if (string.IsNullOrEmpty(stoneName))
                {
                    return(false);
                }
                else
                {
                    if (stone != null)
                    {
                        stone.Dispose();
                        stone = null;
                    }
                    try
                    {
                        stone = FastBitmap.FromFile(Path.Combine(skinFolder, stoneName));
                        if (stone == null)
                        {
                            return(false);
                        }
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }
            finally
            {
                ini.Dispose();
            }
            return(true);
        }