Exemple #1
0
        public RenameLikeCommand(DuplPairViewModel result, string newPath, PositionInDuplPair place)
        {
            _newPath = newPath;
            _result  = result;
            _place   = place;

            //_oldPath = oldPath;
            if (place == PositionInDuplPair.First)
            {
                _oldPath = result.FirstFile.Path;
            }
            else if (place == PositionInDuplPair.Second)
            {
                _oldPath = result.SecondFile.Path;
            }
            else
            {
                throw new ArgumentException("Неизвестно значение PositionInDuplPair " + place);
            }
        }
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values[2] != DependencyProperty.UnsetValue && values[3] != DependencyProperty.UnsetValue)
            {
                DuplPairViewModel  result   = values[0] as DuplPairViewModel;
                PositionInDuplPair position = (PositionInDuplPair)values[1];
                Color       goodColor       = (Color)values[2];
                Color       badColor        = (Color)values[3];
                MaxProperty property        = (MaxProperty)parameter;
                if (result != null && position != null && goodColor != null && badColor != null && property != null)
                {
                    switch (property)
                    {
                    case MaxProperty.FileSize:
                        if (result.FirstFile.FileSize == result.SecondFile.FileSize)
                        {
                            return(new SolidColorBrush());
                        }
                        if (result.FirstFile.FileSize < result.SecondFile.FileSize)
                        {
                            return(position == PositionInDuplPair.First ? new SolidColorBrush(badColor) : new SolidColorBrush(goodColor));
                        }
                        else
                        {
                            return(position == PositionInDuplPair.Second ? new SolidColorBrush(badColor) : new SolidColorBrush(goodColor));
                        }

                    //чем выше JpegQuality тем лучше изображение
                    case MaxProperty.JpegQuality:
                        if (result.FirstFile.JpegQuality == result.SecondFile.JpegQuality)
                        {
                            return(new SolidColorBrush());
                        }
                        if (result.FirstFile.JpegQuality < result.SecondFile.JpegQuality)
                        {
                            return(position == PositionInDuplPair.First ? new SolidColorBrush(badColor) : new SolidColorBrush(goodColor));
                        }
                        else
                        {
                            return(position == PositionInDuplPair.Second ? new SolidColorBrush(badColor) : new SolidColorBrush(goodColor));
                        }

                    case MaxProperty.Sharpness:
                        if (result.FirstFile.Sharpness == result.SecondFile.Sharpness)
                        {
                            return(new SolidColorBrush());
                        }
                        if (result.FirstFile.Sharpness < result.SecondFile.Sharpness)
                        {
                            return(position == PositionInDuplPair.First ? new SolidColorBrush(badColor) : new SolidColorBrush(goodColor));
                        }
                        else
                        {
                            return(position == PositionInDuplPair.Second ? new SolidColorBrush(badColor) : new SolidColorBrush(goodColor));
                        }

                    case MaxProperty.Resolution:
                        if (result.FirstFile.Width * result.FirstFile.Height == result.SecondFile.Width * result.SecondFile.Height)
                        {
                            return(new SolidColorBrush());
                        }
                        if (result.FirstFile.Width * result.FirstFile.Height < result.SecondFile.Width * result.SecondFile.Height)
                        {
                            return(position == PositionInDuplPair.First ? new SolidColorBrush(badColor) : new SolidColorBrush(goodColor));
                        }
                        else
                        {
                            return(position == PositionInDuplPair.Second ? new SolidColorBrush(badColor) : new SolidColorBrush(goodColor));
                        }

                    case MaxProperty.UtilityIndex:
                        if (result.FirstFile.UtilityIndex == result.SecondFile.UtilityIndex)
                        {
                            return(new SolidColorBrush());
                        }
                        if (result.FirstFile.UtilityIndex < result.SecondFile.UtilityIndex)
                        {
                            return(position == PositionInDuplPair.First ? new SolidColorBrush(badColor) : new SolidColorBrush(goodColor));
                        }
                        else
                        {
                            return(position == PositionInDuplPair.Second ? new SolidColorBrush(badColor) : new SolidColorBrush(goodColor));
                        }
                    }
                }
            }
            return(new SolidColorBrush());
        }