private void DrawGraphManagementWizard(Rect obj) { var listRect = obj.RightHalf().PadSides(2); var controlRect = obj.LeftHalf().BottomHalf().PadSides(2); var actionRect = obj.LeftHalf().TopHalf().PadSides(2); var actions = new List <ActionItem>(); Signal <IQueryGraphsActions>(_ => _.QueryGraphsAction(actions)); DrawGraphsList(listRect, Repository.AllOf <IGraphData>() .OrderBy(_ => WorkspaceService.CurrentWorkspace != null && !WorkspaceService.CurrentWorkspace.Graphs.Contains(_)) .ThenBy(_ => _.Name) .ToList()); Signal <IDrawActionsPanel>(_ => _.DrawActionsPanel(PlatformDrawer, actionRect, actions, (i, m) => { SelectedAction = i; })); if (SelectedAction != null) { Signal <IDrawActionDialog>(_ => _.DrawActionDialog(PlatformDrawer, controlRect, SelectedAction, () => { SelectedAction = null; })); } var closeButtonBounds = new Rect().WithSize(80, 30).InnerAlignWithBottomRight(listRect.PadSides(15)); PlatformDrawer.DoButton(closeButtonBounds, "Close", ElementDesignerStyles.ButtonStyle, () => EnableGraphManagementhWizard = false); }
private void DrawPackageList(Rect projectListBounds) { var buttonBounds = new Rect(projectListBounds) { height = 20, }; foreach (var package in KoinoniaSystem.InstalledPackagesDescriptors) { var bounds = buttonBounds; PlatformDrawer.DoButton(buttonBounds, string.Format("{0}", package.Title), ElementDesignerStyles.ButtonStyle, x => SelectPackage(package.Id), x => OpenPackageControlPanelWindow(new Rect(x.x, x.y, bounds.width, bounds.height), package)); buttonBounds = new Rect(buttonBounds) { y = buttonBounds.yMax }; } }
public void DrawGraphsList(Rect bounds, List <IGraphData> items) { PlatformDrawer.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13); var scrollBounds = bounds.Translate(15, 0).Pad(0, 0, 15, 0); bounds = bounds.PadSides(15); var headerRect = bounds.WithHeight(40); PlatformDrawer.DrawLabel(headerRect, string.Format("{0} Graphs", WorkspaceService.CurrentWorkspace.Title), CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter); var unpaddedItemRect = bounds.Below(headerRect).WithHeight(50); var databasesListItems = items.ToArray(); var position = scrollBounds.Below(headerRect).Clip(scrollBounds).Pad(0, 0, 0, 55); var usedRect = position.Pad(0, 0, 15, 0).WithHeight((unpaddedItemRect.height + 1) * databasesListItems.Length); _scrollPos = GUI.BeginScrollView(position, _scrollPos, usedRect); foreach (var db in databasesListItems) { var db1 = db; var isGraphInWorkspace = WorkspaceService.CurrentWorkspace != null && WorkspaceService.CurrentWorkspace.Graphs.Contains(db1); var cColor = GUI.color; var mColor = new Color(cColor.r, cColor.g, cColor.b, 0.3f); if (!isGraphInWorkspace) { GUI.color = mColor; } PlatformDrawer.DrawStretchBox(unpaddedItemRect, CachedStyles.WizardListItemBoxStyle, 2); if (isGraphInWorkspace) { PlatformDrawer.DoButton(unpaddedItemRect.TopHalf(), "", CachedStyles.ClearItemStyle, () => { Execute(new LambdaCommand("Open Graph", () => { WorkspaceService.CurrentWorkspace.AddGraph(db1); WorkspaceService.CurrentWorkspace.CurrentGraphId = db1.Identifier; EnableGraphManagementhWizard = false; })); }); } var itemRect = unpaddedItemRect.PadSides(15); var titleRect = itemRect.WithHeight(40); PlatformDrawer.DrawLabel(titleRect, db.Title, CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopLeft); var infoRect = itemRect.Below(titleRect).WithHeight(38); //(PlatformDrawer as UnityDrawer).DrawInfo(infoRect, string.Format("Namespace: {0}\nPath: {1}", db.GraphConfiguration.Namespace ?? "-", db.GraphConfiguration.FullPath)); var openButton = new Rect().WithSize(80, 25).InnerAlignWithBottomRight(itemRect).AlignHorisonallyByCenter(itemRect); var configButton = openButton.LeftOf(openButton).Translate(-2, 0); var exportButton = openButton.LeftOf(configButton).Translate(-2, 0); var deleteButton = openButton.LeftOf(exportButton).Translate(-2, 0); GUI.color = cColor; PlatformDrawer.DoButton(openButton, isGraphInWorkspace ? "Open" : "Import", ElementDesignerStyles.DarkButtonStyle, () => { /* OPEN DATABASE */ Execute(new LambdaCommand("Open Graph", () => { WorkspaceService.CurrentWorkspace.AddGraph(db1); WorkspaceService.CurrentWorkspace.CurrentGraphId = db1.Identifier; EnableGraphManagementhWizard = false; })); //DatabaseListWindow.Init(new Vector2(Screen.currentResolution.width / 2 - 200, Screen.currentResolution.height/2- 300)); }); //PlatformDrawer.DoButton(configButton, "Config", ElementDesignerStyles.ButtonStyle, () => { /* CONFIG DATABASE */ }); //PlatformDrawer.DoButton(deleteButton, "Delete", ElementDesignerStyles.ButtonStyle, () => { /* SHOW DATABASE IN EXPLORER */ }); //PlatformDrawer.DoButton(exportButton, "Export", ElementDesignerStyles.ButtonStyle, () => { /* SHOW DATABASE IN EXPLORER */ }); unpaddedItemRect = unpaddedItemRect.Below(unpaddedItemRect).Translate(0, 1); } GUI.EndScrollView(true); }
public void DrawTreeView(Rect bounds, TreeViewModel viewModel, Action <Vector2, IItem> itemClicked, Action <Vector2, IItem> itemRightClicked = null) { var boundY = bounds.height; if (Event.current != null && Event.current.isKey && Event.current.rawType == EventType.KeyUp) { switch (Event.current.keyCode) { case KeyCode.UpArrow: viewModel.MoveUp(); break; case KeyCode.DownArrow: viewModel.MoveDown(); break; case KeyCode.RightArrow: { var selectedContainer = viewModel.SelectedData as ITreeItem; if (selectedContainer != null) { selectedContainer.Expanded = true; viewModel.IsDirty = true; } } break; case KeyCode.LeftArrow: { var selectedContainer = viewModel.SelectedData as ITreeItem; if (selectedContainer != null) { selectedContainer.Expanded = false; viewModel.IsDirty = true; } } break; case KeyCode.Return: if (viewModel != null) { viewModel.InvokeSubmit(); } break; default: break; } } // PlatformDrawer.DrawLabel(new Rect().WithSize(100,100).InnerAlignWithBottomRight(bounds),"Total height: {0}, Total Items: {1}"); var dirty = false; var position = bounds; var usedRect = position.WithWidth(Math.Max(bounds.width, PlatformDrawer.CalculateTextSize(viewModel.LargestString, CachedStyles.ListItemTitleStyle).x + 5 * viewModel.MaxIdentLevel)).Pad(0, 0, 15, 0).WithHeight(ItemHeight * viewModel.TreeData.Count(s => s.Visible)); PlatformDrawer.DrawStretchBox(position.PadSides(-1), CachedStyles.WizardListItemBoxStyle, 10); viewModel.Scroll = GUI.BeginScrollView(position, viewModel.Scroll, usedRect); var itemTemplateRect = bounds.WithHeight(ItemHeight); bool hasItems = false; foreach (var treeViewItem in viewModel.TreeData) { if (!treeViewItem.Visible) { continue; } hasItems = true; var data = treeViewItem.Data; var treeData = data as ITreeItem; var itemRect = itemTemplateRect.Pad(5 * treeViewItem.Indent, 0, 5 * treeViewItem.Indent, 0); var localItemY = itemRect.Translate(0, -position.yMin).y; if (localItemY > (viewModel.Scroll.y + position.height)) { break; } var imageRect = new Rect().WithSize(12, 12) .Align(itemRect) .AlignHorisonallyByCenter(itemRect) .Translate(5, 0); var labelRect = itemRect.WithWidth( PlatformDrawer.CalculateTextSize(treeViewItem.Data.Title, CachedStyles.BreadcrumbTitleStyle).x) .Translate(25, 0); if (treeViewItem == viewModel.ScrollTarget) { viewModel.Scroll = new Vector2(0, localItemY - ItemHeight * 5); viewModel.ScrollToItem(null); } if (treeViewItem.Selected) { PlatformDrawer.DrawStretchBox(itemRect, CachedStyles.WizardSubBoxStyle, 14); } PlatformDrawer.DrawLabel(labelRect, treeViewItem.Data.Title, CachedStyles.ListItemTitleStyle); PlatformDrawer.DrawImage(imageRect, treeViewItem.Icon, true); if (treeViewItem.ColorMark.HasValue) { var colorMarkRect = new Rect().WithSize(8, 8).InnerAlignWithCenterRight(itemRect).Translate(-24, 0); PlatformDrawer.DrawRect(colorMarkRect, treeViewItem.ColorMark.Value); } if (viewModel.ShowToggle) { EditorGUI.BeginChangeCheck(); var toggleRect = new Rect().WithSize(16, 16).InnerAlignWithUpperRight(itemRect).Translate(-50, 0); GUI.enabled = viewModel.AllowManualToggle; var toggle = GUI.Toggle(toggleRect, treeViewItem.IsChecked, ""); GUI.enabled = true; if (treeViewItem.IsChecked != toggle) { viewModel.ToggleItem(treeViewItem, toggle); return; } } var item1 = treeViewItem; PlatformDrawer.DoButton(itemRect.Translate(25, 0), "", CachedStyles.ClearItemStyle, m => { viewModel.SelectedIndex = item1.Index; //TODO PUBLISH EVENT if (itemClicked != null) { itemClicked(m, item1.Data); } }, m => { if (itemRightClicked != null) { itemRightClicked(m, item1.Data); } }); if (treeData != null) { PlatformDrawer.DoButton(imageRect, "", CachedStyles.ClearItemStyle, () => { treeData.Expanded = !treeData.Expanded; dirty = true; }); } if (treeViewItem.Highlighted) { PlatformDrawer.DrawLine(new[] { new Vector3(labelRect.x, itemRect.yMax - 1, 0), new Vector3(labelRect.x + 75, itemRect.yMax - 1, 0) }, Color.cyan); } itemTemplateRect = itemTemplateRect.Below(itemTemplateRect); } GUI.EndScrollView(); if (!hasItems) { var textRect = bounds; var cacheColor = GUI.color; GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.4f); PlatformDrawer.DrawLabel(textRect, "No Items Found", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.MiddleCenter); GUI.color = cacheColor; return; } if (dirty) { viewModel.IsDirty = true; } }
public void DrawActionsExplorer(Rect obj) { if (ActionsViewModel.IsDirty) { ActionsViewModel.Refresh(); } var mainContentBounds = obj.Pad(0, 0, 0, 30); var listRect = mainContentBounds.LeftHalf(); var actionCode = mainContentBounds.RightHalf().BottomHalf(); Signal <IDrawTreeView>(_ => _.DrawTreeView(listRect.PadSides(15), ActionsViewModel, (m, i) => { })); //var selectedAction = ActionsViewModel.SelectedData as ActionNode; var item = ActionsViewModel.SelectedData; if (item != null) { PlatformDrawer.DrawStretchBox(actionCode, CachedStyles.WizardSubBoxStyle, 15); PlatformDrawer.DrawLabel(actionCode.PadSides(15), string.Format("Title: {0}\nType: {1}\n", item.Title, item.GetType().Name) , CachedStyles.BreadcrumbTitleStyle, DrawingAlignment.TopLeft); } var updateButton = new Rect().WithSize(80, 24).InnerAlignWithBottomLeft(obj); PlatformDrawer.DoButton(updateButton, "Update", ElementDesignerStyles.ButtonStyle, () => { EditorApplication.delayCall += () => { ActionsViewModel = null; DataItems = null; }; }); PlatformDrawer.DrawTextbox("12345", new Rect().WithSize(120, 24).Align(updateButton).RightOf(updateButton), _searchCriterial, GUI.skin.textField, (a, b) => { if (_searchCriterial == a) { return; } _searchCriterial = a; if (!string.IsNullOrEmpty(_searchCriterial)) { ActionsViewModel.Predicate = i => { if (string.IsNullOrEmpty(i.Title)) { return(false); } if ( CultureInfo.CurrentCulture.CompareInfo.IndexOf(i.Title, _searchCriterial, CompareOptions.IgnoreCase) != -1) { return(true); } if (!string.IsNullOrEmpty(i.SearchTag) && CultureInfo.CurrentCulture.CompareInfo.IndexOf(i.SearchTag, _searchCriterial, CompareOptions.IgnoreCase) != -1) { return(true); } return(false); }; } else { ActionsViewModel.Predicate = null; } ActionsViewModel.IsDirty = true; }); }