Ejemplo n.º 1
0
 protected virtual void CreateDataTable()
 {
     this.Table = new List <Dictionary <string, object> >();
     for (int i = 0; i < products.Count; i++)
     {
         Dictionary <string, object> dataRow = new Dictionary <string, object>();
         foreach (FieldDescription description in FieldDescriptions)
         {
             if (!string.IsNullOrEmpty(description.PropertyName))
             {
                 dataRow[description.ColumnName] = GetProductPropertyValue(i, description.PropertyName);
             }
         }
         dataRow["Country"]        = GetRandomCountry();
         dataRow["Units On Order"] = random.Next(100);
         dataRow["Notes"]          = "Notes: " + Environment.NewLine + "notes for Product #" + (i + 1);
         dataRow["Date"]           = DateTime.Today.AddYears(-5).AddDays(-random.Next(1000));
         dataRow["Pallete Size"]   = palleteSizes[random.Next(palleteSizes.Length)];
         dataRow["Countries"]      = GetRandomCountry();
         double selectionStart = random.Next(50);
         dataRow["Range"]      = new TrackBarEditRange(selectionStart, selectionStart + random.Next(50));
         dataRow["Color"]      = GenerateRandomColor();
         dataRow["Brush"]      = new LinearGradientBrush(GenerateRandomColor(), GenerateRandomColor(), random.Next(180));
         dataRow["Orders"]     = CreateOrdersList();;
         dataRow["Password"]   = GenerateRandomPassword();
         dataRow["Discount"]   = GenerateRandomDiscount();
         dataRow["Picture"]    = GetPhoto(i);
         dataRow["Font"]       = GetFont(i);
         dataRow["Data"]       = i + 3 + i * i;
         dataRow["Categories"] = GenerateRandomCategories(i);
         Table.Add(dataRow);
     }
 }
        void UpdateFilter(double minMagnitude, double maxMagnitude)
        {
            if (Data != null)
            {
                Data.Filter = (item) => {
                    EarthquakeViewModel earthquake = (EarthquakeViewModel)item;
                    return(GetMagnitudeFilter(earthquake, minMagnitude, maxMagnitude) && GetYearFilter(earthquake, lbYearsFilter.SelectedItems));
                }
            }
            ;
        }

        bool GetMagnitudeFilter(EarthquakeViewModel earthquake, double min, double max)
        {
            return(earthquake.Magnitude >= min && earthquake.Magnitude <= max);
        }

        bool GetYearFilter(EarthquakeViewModel earthquake, IList <object> selectedYears)
        {
            foreach (ListBoxEditItem item in selectedYears)
            {
                int year = Convert.ToInt32(item.Tag);
                if (earthquake.Year == year)
                {
                    return(true);
                }
            }
            return(false);
        }

        void lbYearsFilter_EditValueChanged(object sender, EditValueChangedEventArgs e)
        {
            Update();
        }

        void tbMagnitudeFilter_EditValueChanged(object sender, EditValueChangedEventArgs e)
        {
            Update();
        }

        void Update()
        {
            TrackBarEditRange range = (TrackBarEditRange)tbMagnitudeFilter.EditValue;

            UpdateFilter(range.SelectionStart, range.SelectionEnd);
        }
    }
Ejemplo n.º 3
0
        void Update()
        {
            TrackBarEditRange range = (TrackBarEditRange)tbMagnitudeFilter.EditValue;

            UpdateFilter(range.SelectionStart, range.SelectionEnd);
        }