private async Task RefreshAllGrids()
        {
            Cursor = Cursors.Wait;
            try
            {
                if (this.CurrentTenantModel != null)
                {
                    ModelManager modelMgr = ModelManager.GetInstance();
                    this.Title = $"Azure Sphere Explorer - {CurrentTenantModel.Tenant}";
                    List <ProductModel> productModel = await modelMgr.GetProductModels(CurrentTenantModel, true);

                    List <DeviceGroupModel> deviceGroupModel = await modelMgr.GetDeviceGroupModels(CurrentTenantModel, true);

                    List <DeviceModel> deviceModels = await modelMgr.GetDeviceModels(CurrentTenantModel, true);

                    this.gridProducts.ItemsSource     = productModel;
                    this.gridDeviceGroups.ItemsSource = deviceGroupModel;
                    this.gridDevices.ItemsSource      = deviceModels;
                }
            }
            finally
            {
                Cursor = null;
            }
        }
        private async void NotificationChangeProduct(object sender, EventArgs e)
        {
            ModelManager modelMgr = ModelManager.GetInstance();

            Console.Write("called NotificationCreateProduct()");
            List <ProductModel> productModel = await modelMgr.GetProductModels(CurrentTenantModel, false);

            this.gridProducts.ItemsSource = productModel;
            this.gridProducts.Items.Refresh();
        }
Beispiel #3
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ModelManager modelManager = ModelManager.GetInstance();

            ProductModels = await modelManager.GetProductModels(CurrentTenantModel, true);

            // プロダクトのリストを作成
            foreach (ProductModel product in ProductModels)
            {
                ProductBox.Items.Add(product.Product);
            }
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ModelManager modelMgr = ModelManager.GetInstance();

            List <ProductModel> products = await modelMgr.GetProductModels(CurrTenant, false);

            this.DeviceGroups = await modelMgr.GetDeviceGroupModels(CurrTenant, false);

            this.Devices = await modelMgr.GetDeviceModels(CurrTenant, false);

            this.gridProducts.ItemsSource = products;

            if (CurrProduct != null)
            {
                int index = products.IndexOf(CurrProduct);
                this.gridProducts.SelectedIndex = index;

                ViewProduct(index);
                ViewDeviceGroups(CurrProduct);
            }

            if (CurrDeviceGroup != null)
            {
                foreach (ProductModel model in products)
                {
                    if (model.Product == this.CurrDeviceGroup.Product)
                    {
                        CurrProduct = model;
                        break;
                    }
                }

                int indexP = products.IndexOf(CurrProduct);
                this.gridProducts.SelectedIndex = indexP;

                ViewProduct(indexP);
                ViewDeviceGroups(CurrProduct);
                ViewDevices(CurrDeviceGroup);
            }
            modelMgr.NotificationChangeDevice      += NotificationChangeDevice;
            modelMgr.NotificationChangeDeviceGroup += NotificationChangeDeviceGroup;
        }
Beispiel #5
0
        private async void Create_Click(object sender, RoutedEventArgs e)
        {
            ModelManager modelManager = ModelManager.GetInstance();
            JObject      newObj       = new JObject();

            newObj.Add("CreateDefaultGroups", new JValue(DefaultGroupToggleBotton.IsChecked));
            newObj.Add("Description", new JValue(DescriptionBox.Text));
            newObj.Add("Name", new JValue(ProductNameBox.Text));

            List <ProductModel> products = await modelManager.GetProductModels(this.CurrentTenantModel, false);

            foreach (ProductModel model in products)
            {
                if (model.Product == ProductNameBox.Text)
                {
                    MessageBox.Show("Product is already exists",
                                    "Error", MessageBoxButtons.OK);
                    return;
                }
            }

            Cursor = System.Windows.Input.Cursors.Wait;
            this.CreateButton.IsEnabled = false;
            this.CloseButton.IsEnabled  = false;

            if (await modelManager.CreateProductGroup(CurrentTenantModel, newObj.ToString()))
            {
                MessageBox.Show("Create Product is success.",
                                "Ok", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("Create Product is failure.",
                                "Error", MessageBoxButtons.OK);
            }
            Cursor = null;
            this.CreateButton.IsEnabled = true;
            this.CloseButton.IsEnabled  = true;
        }