public AssetRowControl(AbstractAsset asset, AssetType assetType, bool isEven, string openDialogFilter)
        {
            InitializeComponent();

            OpenDialogFilter = openDialogFilter;

            Asset              = asset;
            AssetType          = assetType;
            TextBlockTags.Text = string.Join(_tagSeparator, asset.Tags);

            Color colorEditEven = EditorUtils.FromRgbTuple(assetType.GetColor()) * 0.25f;
            Color colorEditOdd  = colorEditEven * 0.5f;
            Color colorInfoEven = colorEditOdd;
            Color colorInfoOdd  = colorEditOdd * 0.5f;

            _brushInfoEven = new SolidColorBrush(colorInfoEven);
            _brushInfoOdd  = new SolidColorBrush(colorInfoOdd);
            _brushEditEven = new SolidColorBrush(colorEditEven);
            _brushEditOdd  = new SolidColorBrush(colorEditOdd);

            UpdateGui();

            Panel.SetZIndex(RectangleInfo, -1);
            Grid.SetColumnSpan(RectangleInfo, 3);
            Grid.SetRowSpan(RectangleInfo, 2);

            Panel.SetZIndex(RectangleEdit, -1);
            Grid.SetColumn(RectangleEdit, 3);
            Grid.SetColumnSpan(RectangleEdit, 4);
            Grid.SetRowSpan(RectangleEdit, 2);

            UpdateBackgroundRectangleColors(isEven);

            Data.Children.Add(RectangleInfo);
            Data.Children.Add(RectangleEdit);

            TextBlockAssetName.Text = Asset.AssetName;

            if (Asset is ShaderAsset shaderAsset)
            {
                _shaderAsset = shaderAsset;
                BrowseButtonFragmentShader.Visibility        = Visibility.Visible;
                RemovePathButtonFragmentShader.Visibility    = Visibility.Visible;
                TextBlockEditorPathFragmentShader.Visibility = Visibility.Visible;
                RowDefinitionFragmentShader.Height           = new GridLength(24);
                Grid.SetRowSpan(TextBlockTags, 2);
            }

            if (Asset is AudioAsset audioAsset)
            {
                _audioAsset = audioAsset;
                ColumnDefinitionLoudness.Width = new GridLength(96);
                TextBoxLoudness.Visibility     = Visibility.Visible;
            }
        }
Exemplo n.º 2
0
        public BinaryPathControl(string header, BinaryFileType binaryFileType, AssetType assetTypeForColor)
        {
            InitializeComponent();

            BinaryFileType = binaryFileType;

            Header.Content = header;

            Progress = new ProgressWrapper(
                new Progress <string>(value => App.Instance.Dispatcher.Invoke(() => ProgressDescription.Text = value)),
                new Progress <float>(value => App.Instance.Dispatcher.Invoke(() => ProgressBar.Value         = value)));

            ProgressBar.Foreground = new SolidColorBrush(EditorUtils.FromRgbTuple(assetTypeForColor.GetColor()) * 0.25f);

            _binaryPath = Path.Combine(UserHandler.Instance.Settings.DevilDaggersRootFolder, binaryFileType.GetSubfolderName(), binaryFileType.ToString().ToLower(CultureInfo.InvariantCulture));
            UpdateGui();
        }
        public AssetTabControl(BinaryFileType binaryFileType, AssetType assetType, string openDialogFilter, string assetTypeJsonFileName)
        {
            InitializeComponent();

            AssetType = assetType;

            List <AbstractAsset> assets = AssetHandler.Instance.GetAssets(binaryFileType, assetTypeJsonFileName).ToList();

            int i = 0;

            foreach (AbstractAsset asset in assets)
            {
                AssetRowControl rowHandler = new AssetRowControl(asset, assetType, i++ % 2 == 0, openDialogFilter);
                RowControls.Add(rowHandler);
            }

            AllFilters   = RowControls.Select(a => a.Asset).SelectMany(a => a.Tags ?? new List <string>()).Where(t => !string.IsNullOrEmpty(t)).Distinct().OrderBy(s => s);
            FiltersCount = AllFilters.Count();

            FilterHighlightColor = EditorUtils.FromRgbTuple(assetType.GetColor()) * 0.25f;

            Previewer = assetType switch
            {
                AssetType.Audio => new AudioPreviewerControl(),
                AssetType.Model => new ModelPreviewerControl(),
                AssetType.ModelBinding => new ModelBindingPreviewerControl(),
                AssetType.Particle => new ParticlePreviewerControl(),
                AssetType.Shader => new ShaderPreviewerControl(),
                AssetType.Texture => new TexturePreviewerControl(),
                _ => throw new NotSupportedException($"Previewer control for type {assetType} is not supported."),
            };

            MainGrid.Children.Add(Previewer);

            if (assetType == AssetType.Audio)
            {
                StackPanelLoudness.Visibility  = Visibility.Visible;
                ColumnDefinitionLoudness.Width = new GridLength(96);
            }
        }