private void RaiseEditShaderGroup(ShaderGroup group) { ShaderGroupNotification notification = new ShaderGroupNotification(); notification.ShaderGroup = group.Copy(); notification.Title = "Edit Shader"; notification.Content = true; bool selectionNeedsUpdate = false; int selectedIndex = ShaderGroupsView.CurrentPosition; List <Shader> openItems = ShaderGroupsView.Cast <Shader>().ToList(); int originalCount = group.Shaders.Count; int startIndex = 0; if (openItems[selectedIndex].Group == group) { selectionNeedsUpdate = true; startIndex = openItems.IndexOf(group.Shaders[0]); } ShaderGroupRequest.Raise(notification, (returned) => { if (returned.Confirmed) { int flattenedIndex = ShadersFlattened.IndexOf(group.Shaders[0]); int index = _shaderStorage.ShaderGroups.IndexOf(group); _shaderStorage.ShaderGroups.Remove(group); _shaderStorage.ShaderGroups.Insert(index, notification.ShaderGroup); group.AnnotationShaderGroups.Clear(); group.IsBuilded = false; group.Shaders.ToList().ForEach((s) => ShadersFlattened.Remove(s)); for (int i = 0; i < notification.ShaderGroup.Shaders.Count; ++i) { ShadersFlattened.Insert(flattenedIndex + i, notification.ShaderGroup.Shaders[i]); } if (selectionNeedsUpdate) { selectedIndex = Math.Min(openItems.Count - 1, selectedIndex); if (startIndex + notification.ShaderGroup.Shaders.Count <= selectedIndex) { selectedIndex = startIndex + notification.ShaderGroup.Shaders.Count - 1; } ShaderGroupsView.MoveCurrentToPosition(selectedIndex); } } }); }
private void RaiseNewShaderGroup() { ShaderGroupNotification notification = new ShaderGroupNotification(); notification.Title = "New Shader"; notification.Content = null; ShaderGroupRequest.Raise(notification, (returned) => { if (returned.Confirmed) { notification.ShaderGroup.IsOpen = true; _shaderStorage.ShaderGroups.Add(notification.ShaderGroup); ShadersFlattened.AddRange(notification.ShaderGroup.Shaders); notification.ShaderGroup.Save(Workspace); Workspace.Save(); } }); }