/// <summary> /// SpellTimerの描画をRefreshする /// </summary> public void RefreshSpellTimer() { if (this.IsDragging) { return; } // 表示するものがなければ何もしない if (this.SpellTimers == null) { this.HideOverlay(); return; } // 表示対象だけに絞る var spells = from x in this.SpellTimers where x.ProgressBarVisible select x; // タイムアップしたものを除外する if ((Settings.Default.TimeOfHideSpell > 0.0d) && !this.SpellPositionFixed) { spells = from x in spells where x.DontHide || (DateTime.Now - x.CompleteScheduledTime).TotalSeconds <= Settings.Default.TimeOfHideSpell select x; } if (!spells.Any()) { this.HideOverlay(); return; } // リキャストの近いもの順でソートする if (Settings.Default.AutoSortEnabled && !this.SpellPositionFixed) { // 昇順? if (!Settings.Default.AutoSortReverse) { spells = from x in spells orderby x.CompleteScheduledTime, x.DisplayNo select x; } else { spells = from x in spells orderby x.CompleteScheduledTime descending, x.DisplayNo select x; } } // Brushを生成する if (spells.Count() > 0) { var s = spells.FirstOrDefault(); if (s != null) { var c = s.BackgroundColor.FromHTMLWPF(); var backGroundColor = Color.FromArgb( (byte)s.BackgroundAlpha, c.R, c.G, c.B); this.BackgroundBrush = this.GetBrush(backGroundColor); } } // 背景色を設定する var nowbackground = this.BaseColorRectangle.Fill as SolidColorBrush; if (nowbackground == null || nowbackground.Color != this.BackgroundBrush.Color) { if (this.BackgroundBrush != null) { this.BaseColorRectangle.Fill = this.BackgroundBrush; } } // 水平レイアウト時のマージンを調整する var m = this.BaseGrid.Margin; m.Bottom = this.IsHorizontal ? 0 : 6; this.BaseGrid.Margin = m; // スペルタイマコントロールのリストを生成する var displayList = new List <SpellTimerControl>(); var timeupList = new List <SpellTimerControl>(); foreach (var spell in spells) { SpellTimerControl c; if (this.SpellTimerControls.ContainsKey(spell.ID)) { c = this.SpellTimerControls[spell.ID]; } else { c = new SpellTimerControl(); this.SpellTimerControls.Add(spell.ID, c); c.Visibility = Visibility.Collapsed; c.MouseDown += (s, e) => this.DragOn(e); c.MouseUp += (s, e) => this.DragOff(e); c.HorizontalAlignment = HorizontalAlignment.Left; c.VerticalAlignment = VerticalAlignment.Top; c.Margin = new Thickness(0, 0, 0, 0); this.BaseGrid.Children.Add(c); c.SetValue(Grid.ColumnProperty, 0); c.SetValue(Grid.RowProperty, 0); } c.SpellTitle = string.IsNullOrWhiteSpace(spell.SpellTitleReplaced) ? spell.SpellTitle : spell.SpellTitleReplaced; c.SpellIcon = spell.SpellIcon; c.SpellIconSize = spell.SpellIconSize; c.IsReverse = spell.IsReverse; c.HideSpellName = spell.HideSpellName; c.OverlapRecastTime = spell.OverlapRecastTime; c.ReduceIconBrightness = spell.ReduceIconBrightness; c.RecastTime = 0; c.Progress = 1.0d; c.BarWidth = spell.BarWidth; c.BarHeight = spell.BarHeight; c.FontInfo = spell.Font; c.FontColor = spell.FontColor; c.FontOutlineColor = spell.FontOutlineColor; c.BarColor = spell.BarColor; c.BarOutlineColor = spell.BarOutlineColor; // 一度もログにマッチしていない時はバーを初期化する if (spell.MatchDateTime == DateTime.MinValue && !spell.UpdateDone) { c.Progress = 1.0; c.RecastTime = 0; c.Update(); c.StartBarAnimation(); spell.UpdateDone = true; } else { c.RecastTime = (spell.CompleteScheduledTime - DateTime.Now).TotalSeconds; if (c.RecastTime < 0) { c.RecastTime = 0; } var totalRecastTime = (spell.CompleteScheduledTime - spell.MatchDateTime).TotalSeconds; c.Progress = totalRecastTime != 0 ? (totalRecastTime - c.RecastTime) / totalRecastTime : 1.0d; if (c.Progress > 1.0d) { c.Progress = 1.0d; } if (!spell.UpdateDone) { c.Update(); c.StartBarAnimation(); spell.UpdateDone = true; } } c.Refresh(); displayList.Add(c); if ((Settings.Default.TimeOfHideSpell > 0.0d) && this.SpellPositionFixed) { if (!spell.DontHide && (DateTime.Now - spell.CompleteScheduledTime).TotalSeconds > Settings.Default.TimeOfHideSpell) { timeupList.Add(c); } } } // 今回表示しないスペルを隠す foreach (var c in this.SpellTimerControls) { if (!spells.Any(x => x.ID == c.Key)) { c.Value.Visibility = Visibility.Collapsed; } } // 行・列の個数がスペル表示数より小さい場合に拡張する // また不要な行・列を削除する if (this.IsHorizontal) { if (this.BaseGrid.RowDefinitions.Count > 1) { this.BaseGrid.RowDefinitions.RemoveRange(1, this.BaseGrid.RowDefinitions.Count - 1); } for (int i = 0; i < (displayList.Count - this.BaseGrid.ColumnDefinitions.Count); i++) { var column = new ColumnDefinition(); column.Width = GridLength.Auto; this.BaseGrid.ColumnDefinitions.Add(column); } } else { if (this.BaseGrid.ColumnDefinitions.Count > 1) { this.BaseGrid.ColumnDefinitions.RemoveRange(1, this.BaseGrid.ColumnDefinitions.Count - 1); } for (int i = 0; i < (displayList.Count - this.BaseGrid.RowDefinitions.Count); i++) { var row = new RowDefinition(); row.Height = GridLength.Auto; this.BaseGrid.RowDefinitions.Add(row); } } // スペルの表示順とマージンを設定する var index = 0; foreach (var displaySpell in displayList) { var margin = displaySpell.Margin; if (index != 0) { margin.Left = this.IsHorizontal ? this.SpellMargin : 0; margin.Top = this.IsHorizontal ? 0 : this.SpellMargin; } else { margin.Left = 0; margin.Top = 0; } displaySpell.Margin = margin; displaySpell.VerticalAlignment = this.IsHorizontal ? VerticalAlignment.Bottom : VerticalAlignment.Top; displaySpell.SetValue(Grid.RowProperty, this.IsHorizontal ? 0 : index); displaySpell.SetValue(Grid.ColumnProperty, this.IsHorizontal ? index : 0); displaySpell.Visibility = Visibility.Visible; index++; } // タイムアップしたものは非表示とする foreach (var c in timeupList) { c.Visibility = Visibility.Hidden; } if (spells.Count() > 0) { this.ShowOverlay(); } }
/// <summary> /// SpellTimerの描画をRefreshする /// </summary> public void RefreshSpellTimer() { if (this.IsDragging) { return; } // 表示するものがなければ何もしない if (this.SpellTimers == null) { this.HideOverlay(); return; } // 表示対象だけに絞る var spells = from x in this.SpellTimers where x.ProgressBarVisible select x; // タイムアップしたものを除外する if ((Settings.Default.TimeOfHideSpell > 0.0d) && !this.SpellPositionFixed) { spells = from x in spells where x.DontHide || (DateTime.Now - x.CompleteScheduledTime).TotalSeconds <= Settings.Default.TimeOfHideSpell select x; } if (!spells.Any()) { this.HideOverlay(); return; } // リキャストの近いもの順でソートする if (Settings.Default.AutoSortEnabled && !this.SpellPositionFixed) { // 昇順? if (!Settings.Default.AutoSortReverse) { spells = from x in spells orderby x.CompleteScheduledTime, x.DisplayNo select x; } else { spells = from x in spells orderby x.CompleteScheduledTime descending, x.DisplayNo select x; } } // Brushを生成する if (spells.Count() > 0) { var s = spells.FirstOrDefault(); if (s != null) { var c = s.BackgroundColor.FromHTMLWPF(); var backGroundColor = Color.FromArgb( (byte)s.BackgroundAlpha, c.R, c.G, c.B); this.BackgroundBrush = this.GetBrush(backGroundColor); } } // 背景色を設定する var nowbackground = this.BaseColorRectangle.Fill as SolidColorBrush; if (nowbackground == null || nowbackground.Color != this.BackgroundBrush.Color) { if (this.BackgroundBrush != null) { this.BaseColorRectangle.Fill = this.BackgroundBrush; } } // 水平レイアウト時のマージンを調整する var m = this.BaseGrid.Margin; m.Bottom = this.IsHorizontal ? 0 : 6; this.BaseGrid.Margin = m; // スペルタイマコントロールのリストを生成する var displayList = new List<SpellTimerControl>(); var timeupList = new List<SpellTimerControl>(); foreach (var spell in spells) { SpellTimerControl c; if (this.SpellTimerControls.ContainsKey(spell.ID)) { c = this.SpellTimerControls[spell.ID]; } else { c = new SpellTimerControl(); this.SpellTimerControls.Add(spell.ID, c); c.Visibility = Visibility.Collapsed; c.MouseDown += (s, e) => this.DragOn(e); c.MouseUp += (s, e) => this.DragOff(e); c.HorizontalAlignment = HorizontalAlignment.Left; c.VerticalAlignment = VerticalAlignment.Top; c.Margin = new Thickness(0, 0, 0, 0); this.BaseGrid.Children.Add(c); c.SetValue(Grid.ColumnProperty, 0); c.SetValue(Grid.RowProperty, 0); } c.SpellTitle = string.IsNullOrWhiteSpace(spell.SpellTitleReplaced) ? spell.SpellTitle : spell.SpellTitleReplaced; c.SpellIcon = spell.SpellIcon; c.SpellIconSize = spell.SpellIconSize; c.IsReverse = spell.IsReverse; c.HideSpellName = spell.HideSpellName; c.OverlapRecastTime = spell.OverlapRecastTime; c.ReduceIconBrightness = spell.ReduceIconBrightness; c.RecastTime = 0; c.Progress = 1.0d; c.BarWidth = spell.BarWidth; c.BarHeight = spell.BarHeight; c.FontInfo = spell.Font; c.FontColor = spell.FontColor; c.FontOutlineColor = spell.FontOutlineColor; c.BarColor = spell.BarColor; c.BarOutlineColor = spell.BarOutlineColor; // 一度もログにマッチしていない時はバーを初期化する if (spell.MatchDateTime == DateTime.MinValue && !spell.UpdateDone) { c.Progress = 1.0; c.RecastTime = 0; c.Update(); c.StartBarAnimation(); spell.UpdateDone = true; } else { c.RecastTime = (spell.CompleteScheduledTime - DateTime.Now).TotalSeconds; if (c.RecastTime < 0) { c.RecastTime = 0; } var totalRecastTime = (spell.CompleteScheduledTime - spell.MatchDateTime).TotalSeconds; c.Progress = totalRecastTime != 0 ? (totalRecastTime - c.RecastTime) / totalRecastTime : 1.0d; if (c.Progress > 1.0d) { c.Progress = 1.0d; } if (!spell.UpdateDone) { c.Update(); c.StartBarAnimation(); spell.UpdateDone = true; } } c.Refresh(); displayList.Add(c); if ((Settings.Default.TimeOfHideSpell > 0.0d) && this.SpellPositionFixed) { if (!spell.DontHide && (DateTime.Now - spell.CompleteScheduledTime).TotalSeconds > Settings.Default.TimeOfHideSpell) { timeupList.Add(c); } } } // 今回表示しないスペルを隠す foreach (var c in this.SpellTimerControls) { if (!spells.Any(x => x.ID == c.Key)) { c.Value.Visibility = Visibility.Collapsed; } } // 行・列の個数がスペル表示数より小さい場合に拡張する // また不要な行・列を削除する if (this.IsHorizontal) { if (this.BaseGrid.RowDefinitions.Count > 1) { this.BaseGrid.RowDefinitions.RemoveRange(1, this.BaseGrid.RowDefinitions.Count - 1); } for (int i = 0; i < (displayList.Count - this.BaseGrid.ColumnDefinitions.Count); i++) { var column = new ColumnDefinition(); column.Width = GridLength.Auto; this.BaseGrid.ColumnDefinitions.Add(column); } } else { if (this.BaseGrid.ColumnDefinitions.Count > 1) { this.BaseGrid.ColumnDefinitions.RemoveRange(1, this.BaseGrid.ColumnDefinitions.Count - 1); } for (int i = 0; i < (displayList.Count - this.BaseGrid.RowDefinitions.Count); i++) { var row = new RowDefinition(); row.Height = GridLength.Auto; this.BaseGrid.RowDefinitions.Add(row); } } // スペルの表示順とマージンを設定する var index = 0; foreach (var displaySpell in displayList) { var margin = displaySpell.Margin; if (index != 0) { margin.Left = this.IsHorizontal ? this.SpellMargin : 0; margin.Top = this.IsHorizontal ? 0 : this.SpellMargin; } else { margin.Left = 0; margin.Top = 0; } displaySpell.Margin = margin; displaySpell.VerticalAlignment = this.IsHorizontal ? VerticalAlignment.Bottom : VerticalAlignment.Top; displaySpell.SetValue(Grid.RowProperty, this.IsHorizontal ? 0 : index); displaySpell.SetValue(Grid.ColumnProperty, this.IsHorizontal ? index : 0); displaySpell.Visibility = Visibility.Visible; index++; } // タイムアップしたものは非表示とする foreach (var c in timeupList) { c.Visibility = Visibility.Hidden; } if (spells.Count() > 0) { this.ShowOverlay(); } }
/// <summary> /// SpellTimerの描画をRefreshする /// </summary> public void RefreshSpellTimer() { if (this.IsDragging) { return; } // 表示するものがなければ何もしない if (this.SpellTimers == null) { this.HideOverlay(); return; } // 表示対象だけに絞る var spells = from x in this.SpellTimers where x.ProgressBarVisible select x; // タイムアップしたものを除外する if (Settings.Default.TimeOfHideSpell > 0.0d) { spells = from x in spells where x.DontHide || (DateTime.Now - x.CompleteScheduledTime).TotalSeconds <= Settings.Default.TimeOfHideSpell select x; } if (!spells.Any()) { this.HideOverlay(); return; } // リキャストの近いもの順でソートする if (Settings.Default.AutoSortEnabled) { // 昇順? if (!Settings.Default.AutoSortReverse) { spells = from x in spells orderby x.CompleteScheduledTime, x.DisplayNo select x; } else { spells = from x in spells orderby x.CompleteScheduledTime descending, x.DisplayNo select x; } } // Brushを生成する if (spells.Count() > 0) { var s = spells.FirstOrDefault(); if (s != null) { var c = s.BackgroundColor.FromHTMLWPF(); var backGroundColor = Color.FromArgb( (byte)s.BackgroundAlpha, c.R, c.G, c.B); this.BackgroundBrush = this.GetBrush(backGroundColor); } } // 背景色を設定する var nowbackground = this.BaseColorRectangle.Fill as SolidColorBrush; if (nowbackground == null || nowbackground.Color != this.BackgroundBrush.Color) { if (this.BackgroundBrush != null) { this.BaseColorRectangle.Fill = this.BackgroundBrush; } } // スペルタイマコントロールのリストを生成する var displayList = new List<SpellTimerControl>(); foreach (var spell in spells) { SpellTimerControl c; if (this.SpellTimerControls.ContainsKey(spell.ID)) { c = this.SpellTimerControls[spell.ID]; } else { c = new SpellTimerControl(); this.SpellTimerControls.Add(spell.ID, c); c.Visibility = Visibility.Collapsed; c.MouseDown += (s, e) => this.DragOn(e); c.MouseUp += (s, e) => this.DragOff(e); c.HorizontalAlignment = HorizontalAlignment.Left; c.VerticalAlignment = VerticalAlignment.Top; c.Margin = new Thickness(0, 0, 0, 0); this.BaseGrid.RowDefinitions.Add(new RowDefinition()); this.BaseGrid.Children.Add(c); c.SetValue(Grid.ColumnProperty, 0); c.SetValue(Grid.RowProperty, this.BaseGrid.Children.Count - 1); } c.SpellTitle = string.IsNullOrWhiteSpace(spell.SpellTitleReplaced) ? spell.SpellTitle : spell.SpellTitleReplaced; c.SpellIcon = spell.SpellIcon; c.SpellIconSize = spell.SpellIconSize; c.IsReverse = spell.IsReverse; c.HideSpellName = spell.HideSpellName; c.OverlapRecastTime = spell.OverlapRecastTime; c.RecastTime = 0; c.Progress = 1.0d; c.BarWidth = spell.BarWidth; c.BarHeight = spell.BarHeight; c.FontInfo = spell.Font; c.FontColor = spell.FontColor; c.FontOutlineColor = spell.FontOutlineColor; c.BarColor = spell.BarColor; c.BarOutlineColor = spell.BarOutlineColor; if (spell.MatchDateTime > DateTime.MinValue) { c.RecastTime = (spell.CompleteScheduledTime - DateTime.Now).TotalSeconds; if (c.RecastTime < 0) { c.RecastTime = 0; } var totalRecastTime = (spell.CompleteScheduledTime - spell.MatchDateTime).TotalSeconds; c.Progress = totalRecastTime != 0 ? (totalRecastTime - c.RecastTime) / totalRecastTime : 1.0d; if (c.Progress > 1.0d) { c.Progress = 1.0d; } } c.Refresh(); displayList.Add(c); } // 表示するスペル数と行数が同じ? if (displayList.Count == this.BaseGrid.RowDefinitions.Count) { // 空行を加える this.BaseGrid.RowDefinitions.Add(new RowDefinition()); } // 今回表示しないスペルを隠す // 非表示にして一番下の行に追いやる foreach (var c in this.SpellTimerControls) { if (!spells.Any(x => x.ID == c.Key)) { c.Value.Visibility = Visibility.Collapsed; c.Value.SetValue(Grid.RowProperty, this.BaseGrid.RowDefinitions.Count - 1); } } // スペルの表示順を設定する var index = 0; foreach (var displaySpell in displayList) { displaySpell.SetValue(Grid.RowProperty, index); displaySpell.Visibility = Visibility.Visible; index++; } if (spells.Count() > 0) { this.ShowOverlay(); } }
/// <summary> /// SpellTimerの描画をRefreshする /// </summary> public void RefreshSpellTimer() { if (this.IsDragging) { return; } // 表示するものがなければ何もしない if (this.SpellTimers == null) { this.HideOverlay(); return; } // 表示対象だけに絞る var spells = from x in this.SpellTimers where x.ProgressBarVisible select x; // タイムアップしたものを除外する if (Settings.Default.TimeOfHideSpell > 0.0d) { spells = from x in spells where x.DontHide || (DateTime.Now - x.MatchDateTime.AddSeconds(x.RecastTime)).TotalSeconds <= Settings.Default.TimeOfHideSpell select x; } if (!spells.Any()) { this.HideOverlay(); return; } // リキャストの近いもの順でソートする if (Settings.Default.AutoSortEnabled) { // 昇順? if (!Settings.Default.AutoSortReverse) { spells = from x in spells orderby x.MatchDateTime.AddSeconds(x.RecastTime), x.DisplayNo select x; } else { spells = from x in spells orderby x.MatchDateTime.AddSeconds(x.RecastTime) descending, x.DisplayNo select x; } } // Brushを生成する if (spells.Count() > 0) { var s = spells.FirstOrDefault(); if (s != null) { var c = s.BackgroundColor.FromHTMLWPF(); var backGroundColor = Color.FromArgb( (byte)s.BackgroundAlpha, c.R, c.G, c.B); this.BackgroundBrush = this.CreateBrush(this.BackgroundBrush, backGroundColor); } } Dispatcher.InvokeAsync(new Action(() => { // 背景色を設定する var nowbackground = this.BaseColorRectangle.Fill as SolidColorBrush; if (nowbackground == null || nowbackground.Color != this.BackgroundBrush.Color) { if (this.BackgroundBrush != null) { this.BaseColorRectangle.Fill = this.BackgroundBrush; } } // スペルタイマコントロールのリストを生成する var displayList = new List <SpellTimerControl>(); foreach (var spell in spells) { SpellTimerControl c; if (this.SpellTimerControls.ContainsKey(spell.ID)) { c = this.SpellTimerControls[spell.ID]; } else { c = new SpellTimerControl(); this.SpellTimerControls.Add(spell.ID, c); c.Visibility = Visibility.Collapsed; c.MouseDown += (s, e) => this.DragOn(e); c.MouseUp += (s, e) => this.DragOff(e); c.HorizontalAlignment = HorizontalAlignment.Left; c.VerticalAlignment = VerticalAlignment.Top; c.Margin = new Thickness(0, 0, 0, 0); this.BaseGrid.RowDefinitions.Add(new RowDefinition()); this.BaseGrid.Children.Add(c); c.SetValue(Grid.ColumnProperty, 0); c.SetValue(Grid.RowProperty, this.BaseGrid.Children.Count - 1); } c.SpellTitle = string.IsNullOrWhiteSpace(spell.SpellTitleReplaced) ? spell.SpellTitle : spell.SpellTitleReplaced; c.IsReverse = spell.IsReverse; c.RecastTime = 0; c.Progress = 1.0d; c.BarWidth = spell.BarWidth; c.BarHeight = spell.BarHeight; c.TextFontFamily = spell.FontFamily; c.TextFontSize = spell.FontSize; c.TextFontStyle = spell.FontStyle; c.FontColor = spell.FontColor; c.FontOutlineColor = spell.FontOutlineColor; c.BarColor = spell.BarColor; c.BarOutlineColor = spell.BarOutlineColor; if (spell.MatchDateTime > DateTime.MinValue) { var nextDateTime = spell.MatchDateTime.AddSeconds(spell.RecastTime); c.RecastTime = (nextDateTime - DateTime.Now).TotalSeconds; if (c.RecastTime < 0) { c.RecastTime = 0; } c.Progress = spell.RecastTime != 0 ? (spell.RecastTime - c.RecastTime) / spell.RecastTime : 1.0d; if (c.Progress > 1.0d) { c.Progress = 1.0d; } } c.Refresh(); displayList.Add(c); } // 表示するスペル数と行数が同じ? if (displayList.Count == this.BaseGrid.RowDefinitions.Count) { // 空行を加える this.BaseGrid.RowDefinitions.Add(new RowDefinition()); } // 今回表示しないスペルを隠す // 非表示にして一番下の行に追いやる foreach (var c in this.SpellTimerControls) { if (!spells.Any(x => x.ID == c.Key)) { c.Value.Visibility = Visibility.Collapsed; c.Value.SetValue(Grid.RowProperty, this.BaseGrid.RowDefinitions.Count - 1); } } // スペルの表示順を設定する var index = 0; foreach (var displaySpell in displayList) { displaySpell.SetValue(Grid.RowProperty, index); displaySpell.Visibility = Visibility.Visible; index++; } if (spells.Count() > 0) { this.ShowOverlay(); this.Topmost = false; this.Topmost = true; } })); }