示例#1
0
 void UpdateStatistics(ShopInfoViewModel info)
 {
     foreach (ProductGroupViewModel productGroupInfo in ActualStatistics)
     {
         productGroupInfo.Value = info.GetSalesByProductGroup(productGroupInfo.Name);
     }
     SalesDescription = "Last Month Sales: " + info.Name;
     if (ChartControlService != null)
     {
         ChartControlService.UpdateData();
         ChartControlService.Animate();
     }
     GaugeVisibility = true;
 }
示例#2
0
        void LoadDataFromXML()
        {
            List <string> productGroupNames = new List <string>();
            XDocument     document          = DataLoader.LoadXmlFromResources("/Data/Sales.xml");

            if (document != null)
            {
                foreach (XElement element in document.Element("Sales").Elements())
                {
                    string shopName    = element.Element("ShopName").Value;
                    string shopAddress = element.Element("ShopAddr").Value;
                    string shopPhone   = element.Element("ShopPhone").Value;
                    string shopFax     = element.Element("ShopFax").Value;
                    var    sw          = new Stopwatch();
                    sw.Start();
                    ShopInfoViewModel info = ViewModelSource.Create(() => new ShopInfoViewModel(shopName, shopAddress, shopPhone, shopFax));
                    sw.Stop();
                    foreach (XElement statElement in element.Element("ShopStatistics").Elements())
                    {
                        string groupName = statElement.Element("ProductsGroupName").Value;
                        if (!productGroupNames.Contains(groupName))
                        {
                            productGroupNames.Add(groupName);
                        }
                        double sales = Convert.ToDouble(statElement.Element("ProductGroupSales").Value, CultureInfo.InvariantCulture);
                        info.AddProductGroup(groupName, sales);
                    }
                    GeoPoint geoPoint = new GeoPoint(Convert.ToDouble(element.Element("Latitude").Value, CultureInfo.InvariantCulture), Convert.ToDouble(element.Element("Longitude").Value, CultureInfo.InvariantCulture));
                    info.ShopLocation = geoPoint;
                    Shops.Add(info);
                }
            }
            foreach (string groupName in productGroupNames)
            {
                ActualStatistics.Add(ViewModelSource.Create(() => new ProductGroupViewModel(0.0, groupName)));
            }
            UpdateTotalStatistics();
        }