Esempio n. 1
0
        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="values">
        /// The values.
        /// </param>
        /// <param name="targetType">
        /// The target type.
        /// </param>
        /// <param name="parameter">
        /// The parameter.
        /// </param>
        /// <param name="culture">
        /// The culture.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter.ToString() == "навык")
            {
                Rangs        rang    = values[0] as Rangs;
                AbilitiModel ability = values[1] as AbilitiModel;
                if (ability == null)
                {
                    return(Brushes.White);
                }

                int   levelAbility = ability.LevelProperty;
                Rangs lastRang     = this.getLastRang(levelAbility, ability.Rangs);
                if (rang == lastRang)
                {
                    return(Brushes.Yellow);
                }
                else
                {
                    return(Brushes.White);
                }
            }

            if (parameter.ToString() == "характеристика")
            {
                Rangs          rang    = values[0] as Rangs;
                Characteristic charact = values[1] as Characteristic;
                if (charact == null)
                {
                    return(Brushes.White);
                }

                int levelCharact = charact.LevelProperty;

                Rangs lastRang =
                    charact.Rangs.Where(n => n.LevelRang <= levelCharact).OrderBy(n => n.LevelRang).LastOrDefault();
                if (rang == lastRang)
                {
                    return(Brushes.Yellow);
                }
                else
                {
                    return(Brushes.White);
                }
            }

            return(Brushes.White);
        }
        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="targetType">
        /// The target type.
        /// </param>
        /// <param name="parameter">
        /// The parameter.
        /// </param>
        /// <param name="culture">
        /// The culture.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == DependencyProperty.UnsetValue || value == null)
            {
                return(string.Empty);
            }

            Task task = value as Task;

            if (parameter == null)
            {
                string text = task.NameOfProperty;

                if (string.IsNullOrEmpty(task.SubTitle) == false)
                {
                    text += "(" + task.SubTitle + ")";
                }


                return(text);
            }
            else
            {
                Rangs lastRang = new Rangs();

                lastRang = getRang(task, lastRang);

                if (parameter.ToString() == "видимостьРанга")
                {
                    //if (StaticMetods.PersProperty.PersSettings.IsAlterProgRelays == true)
                    {
                    }
                    //else
                    {
                        if (lastRang == null)
                        {
                            return(Visibility.Collapsed);
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(lastRang.NameOfRang))
                            {
                                return(Visibility.Collapsed);
                            }
                            else
                            {
                                return(Visibility.Visible);
                            }
                        }
                    }
                }

                if (parameter.ToString() == "названиеРанга")
                {
                    return(string.Empty);
                }

                if (parameter.ToString() == "описаниеРанга")
                {
                    if (lastRang == null)
                    {
                        return(string.Empty);
                    }
                    else
                    {
                        return(lastRang.DeskriptionRangProperty);
                    }
                }
            }

            return(string.Empty);
        }
 /// <summary>
 /// The get rang.
 /// </summary>
 /// <param name="task">
 /// The task.
 /// </param>
 /// <param name="lastRang">
 /// The last rang.
 /// </param>
 /// <returns>
 /// The <see cref="Rangs"/>.
 /// </returns>
 private static Rangs getRang(Task task, Rangs lastRang)
 {
     return(lastRang);
 }