/// <summary> /// Creates graph view model /// </summary> /// <param name="creationInfo"><see cref="HudToolCreationInfo"/></param> /// <returns>Graph view model</returns> private HudBaseToolViewModel CreateGraphTool(HudToolCreationInfo creationInfo) { Check.Require(creationInfo.Layout != null, "Layout isn't defined. Graph has not been created."); var statInfo = creationInfo.Source as StatInfo; HudLayoutGraphTool layoutTool = null; if (statInfo != null) { statInfo.IsSelected = false; var initialStat = statInfo.Stat == Stat.PlayerInfoIcon ? StatsProvider.GetStat(Stat.NetWon) : statInfo.Clone(); layoutTool = new HudLayoutGraphTool { BaseStat = statInfo.Clone(), Stats = new ReactiveList <StatInfo> { initialStat } }; } else { var parentTool = creationInfo.Source as HudBaseToolViewModel; if (parentTool == null) { return(null); } layoutTool = new HudLayoutGraphTool { ParentId = parentTool.Tool.Id }; } var toolViewModel = layoutTool.CreateViewModel(creationInfo.HudElement); toolViewModel.Position = creationInfo.Position; creationInfo.Layout.LayoutTools.Add(layoutTool); return(toolViewModel); }