Ejemplo n.º 1
0
 // Constructor
 public MainPage()
 {
     InitializeComponent();
     m_viewmodel = new ViewModelMandi();
     m_viewmodel.RefreshUIAction += CreateUI;
     m_viewmodel.LoadData();
 }
Ejemplo n.º 2
0
 // Constructor
 public MainPage()
 {
     InitializeComponent();
     m_viewmodel = new ViewModelMandi();
     m_viewmodel.RefreshUIAction += CreateUI;
     m_viewmodel.LoadData();
 }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            IDictionary<string, string> parameters = this.NavigationContext.QueryString;
            if (parameters.ContainsKey("commodityType"))
            {
                m_viewmodel = (Application.Current as App).SharedMandiInfo;
                var commodityType = m_viewmodel.CommodityTypeList.First(comotype => comotype.TypeName == parameters["commodityType"]);

                int nMaxCount = commodityType.CommoditySubTypeList.Count;
                nMaxCount = nMaxCount > 16 ? 16 : nMaxCount;
                var nCalculatedCount = nMaxCount / 2;
                var nCheck = nMaxCount % 2;

                ContentPanel.RowDefinitions.Clear();
                for (int i = 0; i < (nCalculatedCount + nCheck); i++)
                {
                    ContentPanel.RowDefinitions.Add(new RowDefinition());
                }

                int nColumnCounter = 0;
                int nRowCounter = 0;
                ContentPanel.Children.Clear();
                foreach (var commoditySubType in commodityType.CommoditySubTypeList)
                {
                    Button button = new Button();
                    button.MinHeight = 70;
                    button.MaxHeight = 140;
                    button.DataContext = commoditySubType;
                    button.Click += new RoutedEventHandler(button_Click);
                    button.Content = commoditySubType.SubTypeName;
                    ContentPanel.Children.Add(button);
                    Grid.SetColumn(button, nColumnCounter);
                    Grid.SetRow(button, nRowCounter);

                    if (nRowCounter % 2 == 0)
                        button.Background = new SolidColorBrush(Colors.Green);
                    else
                        button.Background = new SolidColorBrush(Colors.Orange);

                    if (nColumnCounter == 1)
                    {
                        nRowCounter = nRowCounter + 1;
                        nColumnCounter = 0;
                    }
                    else
                        nColumnCounter += 1;
                    if (nRowCounter == 8)
                        break;
                }
            }
            txtDataUpdateTime.Text = m_viewmodel.UpdatedDate + " " + m_viewmodel.UpdatedTime;
            base.OnNavigatedTo(e);
        }
 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
     IDictionary<string, string> parameters = this.NavigationContext.QueryString;
     if (parameters.ContainsKey("commodityType"))
     {
         m_viewmodel = (Application.Current as App).SharedMandiInfo;
         var commodityType = m_viewmodel.CommodityTypeList.First(comotype => comotype.TypeName == parameters["commodityType"]);
         var commoditySubType = commodityType.CommoditySubTypeList.First(comoSubType => comoSubType.SubTypeName == parameters["commoditySubType"]);
         lstCommodity.ItemsSource = commoditySubType.CommodityList;
     }
     txtDataUpdateTime.Text = m_viewmodel.UpdatedDate + " " + m_viewmodel.UpdatedTime;
 }