Пример #1
0
        public void DrawActionDialog(IPlatformDrawer platform, Rect bounds, ActionItem item, Action cancel = null)
        {
            if (item == null) return;

            platform.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13);

            bounds = bounds.PadSides(15);

            var descriptionHeight = string.IsNullOrEmpty(item.Description) ? 50 : platform.CalculateTextHeight(item.Description, CachedStyles.BreadcrumbTitleStyle, bounds.width) + 60;

            var headerRect = bounds.WithHeight(40);
            var iconRect = bounds.WithSize(41, 41);
            
            var descriptionRect = headerRect.Below(headerRect).Translate(0,-22).WithHeight(descriptionHeight);
            var inspectorRect = bounds.Below(descriptionRect).Clip(bounds);
            var executeButtonRect = new Rect()
                .WithSize(100, 30)
                .InnerAlignWithBottomRight(bounds);

            if (!_inspectors.ContainsKey(item))
            {
                var uFrameMiniInspector = new uFrameMiniInspector(item.Command);
                _inspectors.Add(item, uFrameMiniInspector);
            }
            var inspector = _inspectors[item];
            var inspectorHeight = inspector.Height;


            _scrollPosition = GUI.BeginScrollView(bounds.AddHeight(-30).AddWidth(15), _scrollPosition,
                bounds.WithHeight(headerRect.height + iconRect.height + descriptionRect.height + inspectorHeight));

            platform.DrawLabel(headerRect, item.Title, CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.MiddleCenter);
            platform.DrawImage(iconRect, string.IsNullOrEmpty(item.Icon) ? "CreateEmptyDatabaseIcon" : item.Icon, true);
            platform.DrawLabel(descriptionRect, item.Description, CachedStyles.BreadcrumbTitleStyle, DrawingAlignment.MiddleLeft);

            inspector.Draw(descriptionRect.WithHeight(inspectorHeight).Pad(0,0,10,0).Below(descriptionRect));

            //Draw generic inspector


                GUI.EndScrollView();
            if ( cancel != null)
            {
                platform.DoButton(executeButtonRect.InnerAlignWithBottomLeft(bounds), "Cancel", ElementDesignerStyles.DarkButtonStyle, cancel);
            }

            platform.DoButton(executeButtonRect, string.IsNullOrEmpty(item.Verb) ? "Create" : item.Verb, ElementDesignerStyles.DarkButtonStyle, () =>
            {
                InvertApplication.Execute(item.Command);
            });
        }