예제 #1
0
        public void Dispose()
        {
            foreach (Image shadowImage in ShadowImages.Values)
            {
                shadowImage.Dispose();
            }

            ShadowImages.Clear();
            CurrentState.ComparisonRenamed -= state_ComparisonRenamed;
            InternalComponent.Dispose();

            foreach (SplitComponent splitComponent in SplitComponents)
            {
                splitComponent.Dispose();
            }

            SplitComponents.Clear();
            Settings.SplitLayoutChanged -= Settings_SplitLayoutChanged;
            Settings.Dispose();
        }
        private void Prepare(LiveSplitState state)
        {
            if (state != OldState)
            {
                state.OnScrollDown        += state_OnScrollDown;
                state.OnScrollUp          += state_OnScrollUp;
                state.OnStart             += state_OnStart;
                state.OnReset             += state_OnReset;
                state.OnSplit             += state_OnSplit;
                state.OnSkipSplit         += state_OnSkipSplit;
                state.OnUndoSplit         += state_OnUndoSplit;
                state.ComparisonRenamed   += state_ComparisonRenamed;
                state.RunManuallyModified += state_RunManuallyModified;
                OldState = state;
            }

            if (Settings.VisualSplitCount != visualSplitCount ||
                Settings.ShowColumnLabels != PreviousShowLabels ||
                (Settings.ShowColumnLabels && state.Layout.Mode != OldLayoutMode))
            {
                PreviousShowLabels = Settings.ShowColumnLabels;
                OldLayoutMode      = state.Layout.Mode;
                visualSplitCount   = Settings.VisualSplitCount;
                RebuildVisualSplits();
            }

            if (OldShadowsColor != state.LayoutSettings.ShadowsColor)
            {
                ShadowImages.Clear();
            }

            foreach (var split in state.Run)
            {
                if (split.Icon != null && (!ShadowImages.ContainsKey(split.Icon) || OldShadowsColor != state.LayoutSettings.ShadowsColor))
                {
                    ShadowImages.Add(split.Icon, IconShadow.Generate(split.Icon, state.LayoutSettings.ShadowsColor));
                }
            }

            var iconsNotBlank = state.Run.Where(x => x.Icon != null).Count() > 0;

            foreach (var split in SplitComponents)
            {
                var hideIconSectionSplit = !Settings.ShowIconSectionSplit && split.Split != null && state.Run.IndexOf(split.Split) == lastSplitOfSection;
                var shouldIndent         = split.Split == null || split.Split.Icon != null || Settings.IndentBlankIcons;

                if (split.Header)
                {
                    split.DisplayIcon = Settings.ShowSectionIcon && shouldIndent && iconsNotBlank;
                }
                else
                {
                    split.DisplayIcon = Settings.DisplayIcons && !hideIconSectionSplit && iconsNotBlank && shouldIndent;
                }

                if (split.Split != null && split.Split.Icon != null)
                {
                    split.ShadowImage = ShadowImages[split.Split.Icon];
                }
                else
                {
                    split.ShadowImage = null;
                }
            }
            OldShadowsColor = state.LayoutSettings.ShadowsColor;

            foreach (var component in Components)
            {
                if (component is SeparatorComponent)
                {
                    var separator = (SeparatorComponent)component;
                    var index     = Components.IndexOf(separator);
                    if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused)
                    {
                        if (((SplitComponent)Components[index + 1]).Split == state.CurrentSplit)
                        {
                            separator.LockToBottom = true;
                        }
                        else if (Components[index - 1] is SplitComponent && ((SplitComponent)Components[index - 1]).Split == state.CurrentSplit)
                        {
                            separator.LockToBottom = false;
                        }
                    }
                }
                else if (component is ThinSeparatorComponent)
                {
                    var separator = (ThinSeparatorComponent)component;
                    var index     = Components.IndexOf(separator);
                    if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused)
                    {
                        if (((SplitComponent)Components[index + 1]).Split == state.CurrentSplit)
                        {
                            separator.LockToBottom = true;
                        }
                        else if (Components[index - 1] is SplitComponent && ((SplitComponent)Components[index - 1]).Split == state.CurrentSplit)
                        {
                            separator.LockToBottom = false;
                        }
                    }
                }
            }
        }
예제 #3
0
        private void Prepare(LiveSplitState state)
        {
            if (state != OldState)
            {
                state.OnScrollDown += state_OnScrollDown;
                state.OnScrollUp   += state_OnScrollUp;
                state.OnStart      += state_OnStart;
                state.OnReset      += state_OnReset;
                state.OnSplit      += state_OnSplit;
                state.OnSkipSplit  += state_OnSkipSplit;
                state.OnUndoSplit  += state_OnUndoSplit;
                OldState            = state;
            }

            var previousSplitCount = visualSplitCount;

            visualSplitCount = Math.Min(state.Run.Count, Settings.VisualSplitCount);
            if (previousSplitCount != visualSplitCount ||
                (Settings.ShowBlankSplits && settingsSplitCount != Settings.VisualSplitCount) ||
                Settings.ShowColumnLabels != PreviousShowLabels ||
                (Settings.ShowColumnLabels && state.Layout.Mode != OldLayoutMode))
            {
                PreviousShowLabels = Settings.ShowColumnLabels;
                OldLayoutMode      = state.Layout.Mode;
                RebuildVisualSplits();
            }
            settingsSplitCount = Settings.VisualSplitCount;

            var skipCount = Math.Min(
                Math.Max(
                    0,
                    state.CurrentSplitIndex - (visualSplitCount - 2 - Settings.SplitPreviewCount + (Settings.AlwaysShowLastSplit ? 0 : 1))),
                state.Run.Count - visualSplitCount);

            ScrollOffset = Math.Min(Math.Max(ScrollOffset, -skipCount), state.Run.Count - skipCount - visualSplitCount);
            skipCount   += ScrollOffset;

            if (OldShadowsColor != state.LayoutSettings.ShadowsColor)
            {
                ShadowImages.Clear();
            }

            foreach (var split in state.Run)
            {
                if (split.Icon != null && (!ShadowImages.ContainsKey(split.Icon) || OldShadowsColor != state.LayoutSettings.ShadowsColor))
                {
                    ShadowImages.Add(split.Icon, IconShadow.Generate(split.Icon, state.LayoutSettings.ShadowsColor));
                }
            }

            var iconsNotBlank = state.Run.Where(x => x.Icon != null).Count() > 0;

            foreach (var split in SplitComponents)
            {
                split.DisplayIcon = iconsNotBlank && Settings.DisplayIcons;

                if (split.Split != null && split.Split.Icon != null)
                {
                    split.ShadowImage = ShadowImages[split.Split.Icon];
                }
                else
                {
                    split.ShadowImage = null;
                }
            }
            OldShadowsColor = state.LayoutSettings.ShadowsColor;

            foreach (var component in Components)
            {
                if (component is SeparatorComponent)
                {
                    var separator = (SeparatorComponent)component;
                    var index     = Components.IndexOf(separator);
                    if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused)
                    {
                        if (((SplitComponent)Components[index + 1]).Split == state.CurrentSplit)
                        {
                            separator.LockToBottom = true;
                        }
                        else if (Components[index - 1] is SplitComponent && ((SplitComponent)Components[index - 1]).Split == state.CurrentSplit)
                        {
                            separator.LockToBottom = false;
                        }
                    }
                    if (Settings.AlwaysShowLastSplit && Settings.SeparatorLastSplit && index == LastSplitSeparatorIndex)
                    {
                        if (skipCount >= state.Run.Count - visualSplitCount)
                        {
                            if (Settings.ShowThinSeparators)
                            {
                                separator.DisplayedSize = 1f;
                            }
                            else
                            {
                                separator.DisplayedSize = 0f;
                            }

                            separator.UseSeparatorColor = false;
                        }
                        else
                        {
                            separator.DisplayedSize     = 2f;
                            separator.UseSeparatorColor = true;
                        }
                    }
                }
                else if (component is ThinSeparatorComponent)
                {
                    var separator = (ThinSeparatorComponent)component;
                    var index     = Components.IndexOf(separator);
                    if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused)
                    {
                        if (((SplitComponent)Components[index + 1]).Split == state.CurrentSplit)
                        {
                            separator.LockToBottom = true;
                        }
                        else if (((SplitComponent)Components[index - 1]).Split == state.CurrentSplit)
                        {
                            separator.LockToBottom = false;
                        }
                    }
                }
            }
        }