Exemplo n.º 1
0
        private async void locationsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var view = new LocationsView(manager, await manager.List <Location>("Locations"));

            view.Anchor = Constants.FullScreenStyles;
            this.mainPanel.Controls.Clear();
            this.mainPanel.Controls.Add(view);
        }
Exemplo n.º 2
0
 private void NavigateToLocations()
 {
     MainView = new LocationsView();
 }
        private void CreateSampleWorker(object[] args)
        {
            SampleUtilities.RegisterToolboxWidget("Locations Widget", typeof(LocationsView), "Samples");
            SampleUtilities.RegisterTheme(SamplesThemeName, SamplesThemePath);
            SampleUtilities.RegisterTemplate(new Guid(SamplesTemplateId), SamplesTemplateName, SamplesTemplateName, SamplesTemplatePath, SamplesThemeName);

            // Create Locations public landing page
            var result = SampleUtilities.CreatePage(new Guid(LocationsPageID), "Locations", true);

            if (result)
            {
                SampleUtilities.SetTemplateToPage(new Guid(LocationsPageID), new Guid(SamplesTemplateId));
                var locationsView = new LocationsView();
                locationsView.ContentViewDisplayMode = ContentViewDisplayMode.Automatic;
                SampleUtilities.AddControlToPage(new Guid(LocationsPageID), locationsView, "Content", "Locations Widget");
            }

            #region Create Taxonomy

            // ensure Categories taxonomy exists
            var taxonomyMgr = TaxonomyManager.GetManager();
            var taxonomy    = taxonomyMgr.GetTaxonomies <HierarchicalTaxonomy>().FirstOrDefault(t => t.Name == "Categories");
            if (taxonomy == null)
            {
                taxonomy           = taxonomyMgr.CreateTaxonomy <HierarchicalTaxonomy>(new Guid(TaxonomyID));
                taxonomy.Name      = "Categories";
                taxonomy.Title     = "Categories";
                taxonomy.TaxonName = "Categories";
                taxonomyMgr.SaveChanges();
            }

            // Add continents as categories
            if (taxonomy.Taxa.Count == 0)
            {
                var taxon = taxonomyMgr.CreateTaxon <HierarchicalTaxon>();
                taxon.Title   = "Europe";
                taxon.Name    = "Europe";
                taxon.UrlName = "europe";
                taxonomy.Taxa.Add(taxon);

                taxon         = taxonomyMgr.CreateTaxon <HierarchicalTaxon>();
                taxon.Title   = "North America";
                taxon.Name    = "North America";
                taxon.UrlName = "north-america";
                taxonomy.Taxa.Add(taxon);

                taxon         = taxonomyMgr.CreateTaxon <HierarchicalTaxon>();
                taxon.Title   = "Australia";
                taxon.Name    = "Australia";
                taxon.UrlName = "australia";
                taxonomy.Taxa.Add(taxon);

                taxonomyMgr.SaveChanges();
            }

            #endregion

            #region Create Sample Data

            // init content manager
            var mgr = new LocationsManager();

            // create sample items if not exist
            if (mgr.GetLocations().Count() == 0)
            {
                // North American Offices
                CreateLocation(mgr, "Boston Office", "460 Totten Pond Rd, Suite 640", "Waltham", "MA", "02451", "USA", "North America");
                CreateLocation(mgr, "Houston Office", "10200 Grogans Mill Rd, Suite 130", "The Woodlands", "TX", "77380", "USA", "North America");
                CreateLocation(mgr, "Austin Office", "701 Brazos Street, Suite 320", "Austin", "TX", "78701", "USA", "North America");
                CreateLocation(mgr, "Canada Office", "460 Totten Pond Rd, Suite 640", "Waltham", "MA", "02451", "USA", "North America");

                // Europe Offices
                CreateLocation(mgr, "London Office", "15 Bedford Square", "London", "London", "WC1B 3JA", "UK", "Europe");
                CreateLocation(mgr, "Bulgaria Office", "33 Alexander Malinov Blvd.", "Sofia", "Sofia", "1729", "Bulgaria", "Europe");
                CreateLocation(mgr, "Germany Office", "Balanstrasse 73", "Munich", "Munich", "81541", "Germany", "Europe");

                // Australian Office
                CreateLocation(mgr, "Sydney Office", "81-91 Military Road", "Neutral Bay", "NSW", "2089", "Australia", "Australia");
            }

            // save locations
            mgr.SaveChanges();

            #endregion
        }