Exemple #1
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (AppUtil.IsInDesignMode)
            {
                return("0");
            }

            try
            {
                NatureRequirement natureRequirement = values[0] as NatureRequirement;

                if (natureRequirement == null)
                {
                    return("nature_nil");
                }

                int grade = 1;
                int.TryParse(values[1].ToString(), out grade);

                if (grade < 0)
                {
                    return("grade<0");
                }
                else if (grade == 0)
                {
                    return("0");
                }

                EAddition addType = (EAddition)values[2];

                int sum = 0;

                for (int i = 1; i <= grade; i++)
                {
                    int index = i - 1;
                    if (index >= natureRequirement.Count)
                    {
                        break;
                    }

                    NatureList natureList = natureRequirement[index];
                    foreach (NatureEnumWrap wrap in natureList)
                    {
                        NatureEntry entry = ModelManager.Instance.NatureXlsData[wrap.Value];
                        Addition    add   = entry.Additions[addType];
                        sum += add.Value;
                    }
                }

                return(sum.ToString());
            }
            catch (Exception e)
            {
                LogManager.Instance.Error(e.Message);
                LogManager.Instance.Error(e.Source);
                LogManager.Instance.Error(e.StackTrace);
                return("100");
            }
        }
Exemple #2
0
        private void onBtn_DeleteGrade(object sender, RoutedEventArgs e)
        {
            NatureList natureList = dgGrade.SelectedItem as NatureList;

            if (natureList == null)
            {
                return;
            }

            NatureRequirement x = dgGrade.ItemsSource as NatureRequirement;

            x.Remove(natureList);
        }
Exemple #3
0
        public override void Load()
        {
            base.Load();

            NatureRequirePresets = new List <NatureRequirePreset>();
            DataView view = DataTable.AsDataView();

            // TODO thy ID排序不应造成变化,但row次序不同 why?
            // view.Sort = "ID";
            foreach (DataRowView rowView in view)
            {
                string category = rowView["Category"].ToString();
                int    grade    = int.Parse(rowView["Grade"].ToString());
                int    index    = grade - 1;

                NatureList natureList = new NatureList();
                for (int i = 1; i <= 8; i++)
                {
                    ENature nature;
                    if (!Enum.TryParse <ENature>(rowView["Nature" + i].ToString(), out nature))
                    {
                        break;
                    }
                    natureList[i - 1] = new NatureEnumWrap(nature);
                }

                NatureRequirePreset preset = GetNatureRequire(category);
                if (preset == null)
                {
                    preset          = new NatureRequirePreset();
                    preset.Category = category;
                    NatureRequirePresets.Add(preset);
                }

                preset.Requirement.Add(natureList);
            }
        }