Example #1
0
        public void LoadFrom(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            bool changed = false;
            var  order   = section.GetValue("Order", RevisionQueryOrder.DateOrder);

            if (_order != order)
            {
                _order  = order;
                changed = true;
            }
            var maxCount = section.GetValue("MaxCount", 0);

            if (_maxCount != maxCount)
            {
                _maxCount = maxCount;
                changed   = true;
            }
            var skip = section.GetValue("Skip", 0);

            if (_skip != skip)
            {
                _skip   = skip;
                changed = true;
            }
            if (changed)
            {
                Changed.Raise(this);
            }
        }
Example #2
0
        public void LoadFrom(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            var name  = section.GetValue <string>("Name", null);
            var size  = section.GetValue <float>("Size", 0);
            var style = section.GetValue <FontStyle>("Name", FontStyle.Regular);

            Assert.IsNeitherNullNorWhitespace(name);
            Assert.BoundedDoubleInc(0, size, 100);

            if (_font.Name != name || _font.Size != size || _font.Style != style)
            {
                Font font = null;
                try
                {
                    font = new Font(name, size, style, GraphicsUnit.Point);
                }
                catch (Exception exc)
                {
                    if (exc.IsCritical())
                    {
                        throw;
                    }
                }
                if (font != null)
                {
                    _font = font;
                }
                Changed.Raise(this);
            }
        }
Example #3
0
        public RepositoryLink(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            _path        = section.GetValue("Path", string.Empty);
            _type        = section.GetValue("Type", string.Empty);
            _description = section.GetValue("Description", string.Empty);
        }
Example #4
0
        public RepositoryLink(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            _path = section.GetValue("Path", string.Empty);
            _type = section.GetValue("Type", string.Empty);
            _description = section.GetValue("Description", string.Empty);
        }
Example #5
0
 protected override void LoadMoreFrom(Section section)
 {
     base.LoadMoreFrom(section);
     AlignToGraph       = section.GetValue("AlignToGraph", AlignToGraph);
     ShowLocalBranches  = section.GetValue("ShowLocalBranches", ShowLocalBranches);
     ShowRemoteBranches = section.GetValue("ShowRemoteBranches", ShowRemoteBranches);
     ShowTags           = section.GetValue("ShowTags", ShowTags);
     ShowStash          = section.GetValue("ShowStash", ShowStash);
 }
Example #6
0
        public void LoadFrom(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            IsVisible = section.GetValue("Visible", _isVisible);
            if (_sizeMode != ColumnSizeMode.Fill)
            {
                Width = section.GetValue("Width", _width);
            }
            LoadMoreFrom(section);
        }
Example #7
0
        /// <summary>Load parameters from the specified <paramref name="section"/>.</summary>
        /// <param name="section">Section to look for parameters.</param>
        public void LoadFrom(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            ManualGitExePath           = section.GetValue("Path", string.Empty);
            AutodetectGitExePath       = section.GetValue("Autodetect", true);
            LogCalls                   = section.GetValue("LogCLICalls", false);
            EnableAnsiCodepageFallback = section.GetValue("EnableAnsiCodepageFallback", false);

            GitProcess.GitExePath = GitExecutablePath;
        }
Example #8
0
            public HostEntry(Section section)
                : this()
            {
                Verify.Argument.IsNotNull(section, nameof(section));

                _isRoot         = section.GetValue <bool>("IsRoot");
                _isDocumentWell = section.GetValue <bool>("IsDocumentHost");
                var tools = section.GetSection("Views");

                foreach (var t in tools.Sections)
                {
                    _views.Add(new ViewEntry(t));
                }
            }
Example #9
0
        public void LoadFrom(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            IsEnabled = section.GetValue("Enabled", _defaultEnabled);
            LoadMoreFrom(section);
        }
Example #10
0
        public SelectableFont(string id, string name, Section section)
        {
            Verify.Argument.IsNeitherNullNorWhitespace(name, "name");
            Verify.Argument.IsNotNull(section, "section");

            var fontName = section.GetValue <string>("Name", null);
            var size     = section.GetValue <float>("Size", 0);
            var style    = section.GetValue <FontStyle>("Style", FontStyle.Regular);

            Verify.Argument.IsTrue(fontName != null, "section", "Section does not contain a valid font name.");
            Verify.Argument.IsTrue(size > 0, "section", "Section contains invalid font size.");

            _font = new Font(fontName, size, style, GraphicsUnit.Point);
            _id   = id;
            _name = name;
        }
Example #11
0
        public SelectableFont(string id, string name, Section section)
        {
            Verify.Argument.IsNeitherNullNorWhitespace(name, "name");
            Verify.Argument.IsNotNull(section, "section");

            var fontName	= section.GetValue<string>("Name", null);
            var size		= section.GetValue<float>("Size", 0);
            var style		= section.GetValue<FontStyle>("Style", FontStyle.Regular);

            Verify.Argument.IsTrue(fontName != null, "section", "Section does not contain a valid font name.");
            Verify.Argument.IsTrue(size > 0, "section", "Section contains invalid font size.");

            _font	= new Font(fontName, size, style, GraphicsUnit.Point);
            _id		= id;
            _name	= name;
        }
Example #12
0
            public FloatEntry(Section section)
            {
                Verify.Argument.IsNotNull(section, nameof(section));

                _bounds = section.GetValue <Rectangle>("Bounds");
                _root   = ToLayout(section.GetSection("Root"));
            }
        /// <summary>
        ///   Reads a value from field-behind (name convention based on property). If the field is null
        ///   the value is read from the configuration section and. If the configuration section also
        ///   doesn't supported the value the method returns the <paramref name="useDefault"/> value.
        /// </summary>
        protected T GetFromFieldThenSection <T>(T useDefault = default, ValueParser <T> parser = null, [CallerMemberName] string propertyName = null)
        {
            if (tryGetFieldValue(out var fieldValue))
            {
                return(fieldValue);
            }

            if (parser is null)
            {
                // automatically support boolean values
                if (typeof(T) == typeof(bool))
                {
                    return(Section[propertyName].TryParseConfiguredBool(out var boolValue)
                        ? (T)Convert.ChangeType(boolValue, typeof(T))
                        : useDefault);
                }

                if (typeof(T) == typeof(TimeSpan))
                {
                    return(Section[propertyName].TryParseConfiguredTimeSpan(out var timeSpanValue)
                        ? (T)Convert.ChangeType(timeSpanValue, typeof(T))
                        : useDefault);
                }

                return(Section.GetValue(propertyName, useDefault));
            }

            var stringValue = Section[propertyName];

            if (stringValue is { })
            /// <summary>Loads color table from configuration.</summary>
            /// <param name="section">Configuration section to load colors from.</param>
            /// <exception cref="ArgumentNullException"><paramref name="section"/> == <c>null</c>.</exception>
            public CustomColorTable(Section section)
            {
                Verify.Argument.IsNotNull(section, "section");

                Background    = section.GetValue <Color>("Background");
                ArrowNormal   = section.GetValue <Color>("ArrowNormal");
                ArrowHover    = section.GetValue <Color>("ArrowHover");
                ArrowPressed  = section.GetValue <Color>("ArrowPressed");
                ArrowDisabled = section.GetValue <Color>("ArrowDisabled");
                ThumbNormal   = section.GetValue <Color>("ThumbNormal");
                ThumbHover    = section.GetValue <Color>("ThumbHover");
                ThumbPressed  = section.GetValue <Color>("ThumbPressed");
                ThumbDisabled = section.GetValue <Color>("ThumbDisabled");
            }
Example #15
0
        public T GetValue <T>
        (
            [NotNull] string sectionName,
            [NotNull] string keyName,
            [CanBeNull] T defaultValue
        )
        {
            Section section = GetSection(sectionName);
            T       result  = section == null
                ? defaultValue
                : section.GetValue(keyName, defaultValue);

            return(result);
        }
Example #16
0
        private static RepositoryGroup TryLoadGroupFrom(Section section)
        {
            Assert.IsNotNull(section);

            var name = section.GetValue <string>("Name", string.Empty);

            if (string.IsNullOrWhiteSpace(name))
            {
                return(null);
            }
            var group = new RepositoryGroup(name.Trim());

            LoadGroupContent(group, section);
            return(group);
        }
Example #17
0
        private static ILayoutBase ToLayout(Section section)
        {
            Verify.Argument.IsNotNull(section, nameof(section));

            switch (section.GetValue <string>("Type"))
            {
            case "Split":
                return(new SplitEntry(section));

            case "Host":
                return(new HostEntry(section));

            default:
                throw new ArgumentException("section");
            }
        }
Example #18
0
        protected override void LoadMoreViewFrom(Section section)
        {
            base.LoadMoreViewFrom(section);

            _toolbar.TreeModeButton.Checked = _treeMode = section.GetValue <bool>("TreeMode", true);
            var stagedListSection = section.TryGetSection("StagedList");

            if (stagedListSection != null)
            {
                _lstStaged.LoadViewFrom(stagedListSection);
            }
            var unstagedListSection = section.TryGetSection("UnstagedList");

            if (unstagedListSection != null)
            {
                _lstUnstaged.LoadViewFrom(unstagedListSection);
            }
        }
Example #19
0
            public SplitEntry(Section section)
                : this()
            {
                Verify.Argument.IsNotNull(section, nameof(section));

                _orientation = section.GetValue <Orientation>("Orientation");
                var splitters = section.GetSection("Splitters");

                foreach (var s in splitters.Parameters)
                {
                    _splitters.Add((double)s.Value);
                }
                var cells = section.GetSection("Cells");

                foreach (var c in cells.Sections)
                {
                    _cells.Add(ToLayout(c));
                }
            }
Example #20
0
 public static void LoadFrom(Section section)
 {
     if (section.ParameterCount != 0)
     {
         _loadCounter = section.ParameterCount;
         _evtDictionariesReady.Reset();
         foreach (var p in section.Parameters)
         {
             if (section.GetValue(p.Name, false))
             {
                 LoadLocaleAsync(p.Name);
             }
             else
             {
                 if (Interlocked.Decrement(ref _loadCounter) == 0)
                 {
                     _evtDictionariesReady.Set();
                 }
             }
         }
     }
 }
Example #21
0
            public ViewEntry(Section section)
            {
                Verify.Argument.IsNotNull(section, nameof(section));

                _guid = section.GetValue <Guid>("Guid");
            }
Example #22
0
        private static ILayoutBase ToLayout(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            switch(section.GetValue<string>("Type"))
            {
                case "Split":
                    return new SplitEntry(section);
                case "Host":
                    return new HostEntry(section);
                default:
                    throw new ArgumentException("section");
            }
        }
Example #23
0
 protected override void LoadMoreFrom(Section section)
 {
     base.LoadMoreFrom(section);
     Abbreviate = section.GetValue("Abbreviate", Abbreviate);
 }
Example #24
0
 protected override void LoadMoreFrom(Section section)
 {
     base.LoadMoreFrom(section);
     DateFormat = section.GetValue("DateFormat", DateFormat);
 }
Example #25
0
        public void LoadFrom(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            bool changed = false;
            var order = section.GetValue("Order", RevisionQueryOrder.DateOrder);
            if(_order != order)
            {
                _order = order;
                changed = true;
            }
            var maxCount = section.GetValue("MaxCount", 0);
            if(_maxCount != maxCount)
            {
                _maxCount = maxCount;
                changed = true;
            }
            var skip = section.GetValue("Skip", 0);
            if(_skip != skip)
            {
                _skip = skip;
                changed = true;
            }
            if(changed) Changed.Raise(this);
        }
Example #26
0
        protected override void LoadMoreViewFrom(Section section)
        {
            base.LoadMoreViewFrom(section);

            _toolbar.TreeModeButton.Checked = _treeMode = section.GetValue<bool>("TreeMode", true);
            var stagedListSection = section.TryGetSection("StagedList");
            if(stagedListSection != null)
            {
                _lstStaged.LoadViewFrom(stagedListSection);
            }
            var unstagedListSection = section.TryGetSection("UnstagedList");
            if(unstagedListSection != null)
            {
                _lstUnstaged.LoadViewFrom(unstagedListSection);
            }
        }
Example #27
0
        public void LoadFrom(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            var name	= section.GetValue<string>("Name", null);
            var size	= section.GetValue<float>("Size", 0);
            var style	= section.GetValue<FontStyle>("Name", FontStyle.Regular);

            Assert.IsNeitherNullNorWhitespace(name);
            Assert.BoundedDoubleInc(0, size, 100);

            if(_font.Name != name || _font.Size != size || _font.Style != style)
            {
                Font font = null;
                try
                {
                    font = new Font(name, size, style, GraphicsUnit.Point);
                }
                catch(Exception exc)
                {
                    if(exc.IsCritical())
                    {
                        throw;
                    }
                }
                if(font != null)
                {
                    _font = font;
                }
                Changed.Raise(this);
            }
        }
Example #28
0
            public SplitEntry(Section section)
                : this()
            {
                Verify.Argument.IsNotNull(section, "section");

                _orientation = section.GetValue<Orientation>("Orientation");
                var splitters = section.GetSection("Splitters");
                foreach(var s in splitters.Parameters)
                {
                    _splitters.Add((double)s.Value);
                }
                var cells = section.GetSection("Cells");
                foreach(var c in cells.Sections)
                {
                    _cells.Add(ToLayout(c));
                }
            }
Example #29
0
        public bool LoadFor(IWorkingEnvironment environment, Section section)
        {
            Verify.Argument.IsNotNull(environment, nameof(environment));

            if (section != null)
            {
                var providerName = section.GetValue <string>("AccessorProvider", string.Empty);
                if (!string.IsNullOrWhiteSpace(providerName))
                {
                    ActiveGitAccessorProvider = GitAccessorProviders.FirstOrDefault(
                        prov => prov.Name == providerName);
                }
                if (ActiveGitAccessorProvider == null)
                {
                    ActiveGitAccessorProvider = GitAccessorProviders.First();
                }
                var gitAccessorSection = section.TryGetSection(ActiveGitAccessorProvider.Name);
                if (gitAccessorSection != null)
                {
                    GitAccessor.LoadFrom(gitAccessorSection);
                }
            }
            else
            {
                ActiveGitAccessorProvider = GitAccessorProviders.First();
            }
            Version gitVersion;

            try
            {
                gitVersion = _gitAccessor.GitVersion;
            }
            catch (Exception exc) when(!exc.IsCritical())
            {
                gitVersion = null;
            }
            if (gitVersion == null || gitVersion < MinimumRequiredGitVersion)
            {
                using (var dlg = new VersionCheckDialog(environment, this, MinimumRequiredGitVersion, gitVersion))
                {
                    dlg.Run(environment.MainForm);
                    gitVersion = dlg.InstalledVersion;
                    if (gitVersion == null || gitVersion < _minVersion)
                    {
                        return(false);
                    }
                }
            }
            GlobalOptions.RegisterPropertyPageFactory(
                new PropertyPageFactory(
                    GitOptionsPage.Guid,
                    Resources.StrGit,
                    null,
                    PropertyPageFactory.RootGroupGuid,
                    env => new GitOptionsPage(env)));
            GlobalOptions.RegisterPropertyPageFactory(
                new PropertyPageFactory(
                    ConfigurationPage.Guid,
                    Resources.StrConfig,
                    null,
                    GitOptionsPage.Guid,
                    env => new ConfigurationPage(env)));
            _environment   = environment;
            _configSection = section;
            return(true);
        }
Example #30
0
 protected override void LoadMoreFrom(Section section)
 {
     base.LoadMoreFrom(section);
     AlignToGraph = section.GetValue("AlignToGraph", AlignToGraph);
     ShowLocalBranches = section.GetValue("ShowLocalBranches", ShowLocalBranches);
     ShowRemoteBranches = section.GetValue("ShowRemoteBranches", ShowRemoteBranches);
     ShowTags = section.GetValue("ShowTags", ShowTags);
     ShowStash = section.GetValue("ShowStash", ShowStash);
 }
Example #31
0
            public ViewEntry(Section section)
            {
                Verify.Argument.IsNotNull(section, "section");

                _guid = section.GetValue<Guid>("Guid");
            }
Example #32
0
        public void LoadFrom(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            IsVisible = section.GetValue("Visible", _isVisible);
            if(_sizeMode != ColumnSizeMode.Fill)
            {
                Width = section.GetValue("Width", _width);
            }
            LoadMoreFrom(section);
        }
Example #33
0
 protected override void LoadMoreFrom(Section section)
 {
     base.LoadMoreFrom(section);
     Abbreviate = section.GetValue("Abbreviate", Abbreviate);
 }
Example #34
0
 protected override void LoadMoreFrom(Section section)
 {
     base.LoadMoreFrom(section);
     DateFormat = section.GetValue("DateFormat", DateFormat);
 }
Example #35
0
 protected override void LoadMoreFrom(Section section)
 {
     base.LoadMoreFrom(section);
     ShowColors = section.GetValue("ShowColors", ShowColors);
 }
Example #36
0
            public HostEntry(Section section)
                : this()
            {
                Verify.Argument.IsNotNull(section, "section");

                _isRoot = section.GetValue<bool>("IsRoot");
                _isDocumentWell = section.GetValue<bool>("IsDocumentHost");
                var tools = section.GetSection("Views");
                foreach(var t in tools.Sections)
                {
                    _views.Add(new ViewEntry(t));
                }
            }
Example #37
0
        public bool LoadFor(IWorkingEnvironment environment, Section section)
        {
            Verify.Argument.IsNotNull(environment, "environment");

            if(section != null)
            {
                var providerName = section.GetValue<string>("AccessorProvider", string.Empty);
                if(!string.IsNullOrWhiteSpace(providerName))
                {
                    ActiveGitAccessorProvider = GitAccessorProviders.FirstOrDefault(
                        prov => prov.Name == providerName);
                }
                if(ActiveGitAccessorProvider == null)
                {
                    ActiveGitAccessorProvider = GitAccessorProviders.First();
                }
                var gitAccessorSection = section.TryGetSection(ActiveGitAccessorProvider.Name);
                if(gitAccessorSection != null)
                {
                    GitAccessor.LoadFrom(gitAccessorSection);
                }
            }
            else
            {
                ActiveGitAccessorProvider = GitAccessorProviders.First();
            }
            Version gitVersion;
            try
            {
                gitVersion = _gitAccessor.GitVersion;
            }
            catch(Exception exc)
            {
                if(exc.IsCritical())
                {
                    throw;
                }
                gitVersion = null;
            }
            if(gitVersion == null || gitVersion < MinimumRequiredGitVersion)
            {
                using(var dlg = new VersionCheckDialog(environment, this, MinimumRequiredGitVersion, gitVersion))
                {
                    dlg.Run(environment.MainForm);
                    gitVersion = dlg.InstalledVersion;
                    if(gitVersion == null || gitVersion < _minVersion)
                    {
                        return false;
                    }
                }
            }
            GlobalOptions.RegisterPropertyPageFactory(
                new PropertyPageFactory(
                    GitOptionsPage.Guid,
                    Resources.StrGit,
                    null,
                    PropertyPageFactory.RootGroupGuid,
                    env => new GitOptionsPage(env)));
            GlobalOptions.RegisterPropertyPageFactory(
                new PropertyPageFactory(
                    ConfigurationPage.Guid,
                    Resources.StrConfig,
                    null,
                    GitOptionsPage.Guid,
                    env => new ConfigurationPage(env)));
            _environment = environment;
            _configSection = section;
            return true;
        }
Example #38
0
        private static RepositoryGroup TryLoadGroupFrom(Section section)
        {
            Assert.IsNotNull(section);

            var name = section.GetValue<string>("Name", string.Empty);
            if(string.IsNullOrWhiteSpace(name))
            {
                return null;
            }
            var group = new RepositoryGroup(name.Trim());
            LoadGroupContent(group, section);
            return group;
        }
Example #39
0
 protected override void LoadMoreFrom(Section section)
 {
     base.LoadMoreFrom(section);
     ShowEmail = section.GetValue("ShowEmail", ShowEmail);
 }
Example #40
0
            public FloatEntry(Section section)
            {
                Verify.Argument.IsNotNull(section, "section");

                _bounds = section.GetValue<Rectangle>("Bounds");
                _root = ToLayout(section.GetSection("Root"));
            }
Example #41
0
            /// <summary>Loads color table from configuration.</summary>
            /// <param name="section">Configuration section to load colors from.</param>
            /// <exception cref="ArgumentNullException"><paramref name="section"/> == <c>null</c>.</exception>
            public CustomColorTable(Section section)
            {
                Verify.Argument.IsNotNull(section, "section");

                Background		= section.GetValue<Color>("Background");
                ArrowNormal		= section.GetValue<Color>("ArrowNormal");
                ArrowHover		= section.GetValue<Color>("ArrowHover");
                ArrowPressed	= section.GetValue<Color>("ArrowPressed");
                ArrowDisabled	= section.GetValue<Color>("ArrowDisabled");
                ThumbNormal		= section.GetValue<Color>("ThumbNormal");
                ThumbHover		= section.GetValue<Color>("ThumbHover");
                ThumbPressed	= section.GetValue<Color>("ThumbPressed");
                ThumbDisabled	= section.GetValue<Color>("ThumbDisabled");
            }
Example #42
0
 protected override void LoadMoreFrom(Section section)
 {
     base.LoadMoreFrom(section);
     ShowColors = section.GetValue("ShowColors", ShowColors);
 }