示例#1
0
        public static void AddWeightedItem(WeightedItem item)
        {
            try
            {
                WeightedItems.Add(item);

                if (_weightsMenu != null)
                {
                    _weightsMenu.AddItem(
                        new MenuItem(_weightsMenu.Name + "." + item.Name, item.DisplayName).SetValue(
                            new Slider(item.Weight, MinWeight, MaxWeight)));
                    _weightsMenu.Item(_weightsMenu.Name + "." + item.Name).ValueChanged +=
                        delegate(object sender, OnValueChangeEventArgs args)
                    {
                        item.Weight    = args.GetNewValue <Slider>().Value;
                        _averageWeight = (float)WeightedItems.Average(w => w.Weight);
                    };
                    item.Weight = _menu.Item(_weightsMenu.Name + "." + item.Name).GetValue <Slider>().Value;
                }

                _averageWeight = (float)WeightedItems.Average(w => w.Weight);
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
示例#2
0
        public static void AddWeightedItem(WeightedItem item)
        {
            try
            {
                WeightedItems.Add(item);

                if (_weightsMenu != null)
                {
                    _weightsMenu.AddItem(
                        new MenuItem(_weightsMenu.Name + "." + item.Name, item.DisplayName).SetValue(
                            new Slider(item.Weight, MinWeight, MaxWeight)));
                    _weightsMenu.Item(_weightsMenu.Name + "." + item.Name).ValueChanged +=
                        delegate(object sender, OnValueChangeEventArgs args)
                        {
                            item.Weight = args.GetNewValue<Slider>().Value;
                            _averageWeight = (float) WeightedItems.Average(w => w.Weight);
                        };
                    item.Weight = _menu.Item(_weightsMenu.Name + "." + item.Name).GetValue<Slider>().Value;
                }

                _averageWeight = (float) WeightedItems.Average(w => w.Weight);
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }