Ejemplo n.º 1
0
        public UserPreferencesView() : base(UITableViewStyle.Grouped, null)
        {
            bool filtered = PreferencesProvider.GetFilter() == 1 ? true : false;

            var filter = new CheckboxElement("Filter explicit jokes and photos", filtered);


            this.Pushing = true;

            Root = new RootElement("Settings")
            {
                new Section("")
                {
                    filter
                }
            };

            this.NavigationItem.SetRightBarButtonItem(
                new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, args) => {
                int success = PreferencesProvider.SetFilter(filter.Value);

                if (success > 0)
                {
                    new UIAlertView("Settings", "Your settings have been saved!", null, "ok", null).Show();
                }
                else
                {
                    new UIAlertView("Settings", "Uh oh something went wrong.  Please try again.", null, "ok", null).Show();
                }
            })

                , true);
        }
        protected override void Initialize()
        {
            base.Initialize();

            vsMonitorSelection = (IVsMonitorSelection)GetService(typeof(IVsMonitorSelection));
            dte = GetService(typeof(SDTE)) as DTE;

            if (provider == null)
            {
                var preferences = new PreferencesProvider("VisualStudio2010");
                provider = new CloudFoundryProvider(preferences);
            }

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                mcs.AddCommand(new MenuCommand(CloudFoundryExplorer,
                               new CommandID(GuidList.guidCloudFoundryCmdSet,
                               (int)PkgCmdIDList.cmdidCloudFoundryExplorer)));

                mcs.AddCommand(new MenuCommand(PushApplication,
                               new CommandID(GuidList.guidCloudFoundryCmdSet,
                               (int)PkgCmdIDList.cmdidPushCloudFoundryApplication)));

                mcs.AddCommand(new MenuCommand(UpdateApplication,
                               new CommandID(GuidList.guidCloudFoundryCmdSet,
                               (int)PkgCmdIDList.cmdidUpdateCloudFoundryApplication)));
            }
        }
Ejemplo n.º 3
0
        public void CanGetPreferencesConfiguration()
        {
            PreferencesProvider preferences = ProviderFactory.GetInstance <PreferencesFactory> (ProviderRepositoryFactory.Instance.Provider).GetDefaultProvider <PreferencesProvider> ();

            Assert.AreEqual(preferences.Name, "PreferencesTest");
            Assert.AreEqual(preferences.XmlFileName, "Preferences.xml");
        }
Ejemplo n.º 4
0
        IVehicle Build(Chassis chassis, VehicleType type, PreferencesProvider vehiclePreferences)
        {
            var vehicle     = Factory[type].Invoke(chassis);
            var preferences = new DefaultPreferencesConfig();

            return(vehiclePreferences(preferences).Apply(vehicle));
        }
Ejemplo n.º 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //determine explicit filter
            long filtered = PreferencesProvider.GetFilter();

            var vcRecentPhotos  = new UINavigationController();
            var vcPopularPhotos = new UINavigationController();

            if (filtered == 1)
            {
                vcRecentPhotos.PushViewController(new PhotosViewController(Enums.PhotoFilter.MostRecentNoExplicit), false);
                vcPopularPhotos.PushViewController(new PhotosViewController(Enums.PhotoFilter.MostPopularNoExplicit), false);
            }
            else
            {
                vcRecentPhotos.PushViewController(new PhotosViewController(Enums.PhotoFilter.MostRecent), false);
                vcPopularPhotos.PushViewController(new PhotosViewController(Enums.PhotoFilter.MostPopular), false);
            }



            var vcSearchPhotos = new PhotosSearchViewController();

            var vcs = new UIViewController[] { vcRecentPhotos, vcPopularPhotos, vcSearchPhotos };

            ViewControllers = vcs;

            vcRecentPhotos.TabBarItem  = new UITabBarItem(UITabBarSystemItem.MostRecent, 0);
            vcPopularPhotos.TabBarItem = new UITabBarItem(UITabBarSystemItem.TopRated, 0);
            vcSearchPhotos.TabBarItem  = new UITabBarItem(UITabBarSystemItem.Search, 0);

            this.Title = "Laftrip Photos";
        }
Ejemplo n.º 6
0
        protected override void Initialize()
        {
            base.Initialize();

            vsMonitorSelection = (IVsMonitorSelection)GetService(typeof(IVsMonitorSelection));
            dte = GetService(typeof(SDTE)) as DTE;

            if (provider == null)
            {
                var preferences = new PreferencesProvider("VisualStudio2010");
                provider = new CloudFoundryProvider(preferences);
            }

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                mcs.AddCommand(new MenuCommand(CloudFoundryExplorer,
                                               new CommandID(GuidList.guidCloudFoundryCmdSet,
                                                             (int)PkgCmdIDList.cmdidCloudFoundryExplorer)));

                mcs.AddCommand(new MenuCommand(PushApplication,
                                               new CommandID(GuidList.guidCloudFoundryCmdSet,
                                                             (int)PkgCmdIDList.cmdidPushCloudFoundryApplication)));

                mcs.AddCommand(new MenuCommand(UpdateApplication,
                                               new CommandID(GuidList.guidCloudFoundryCmdSet,
                                                             (int)PkgCmdIDList.cmdidUpdateCloudFoundryApplication)));
            }
        }
        internal static PrefabStage.Mode GetPrefabStageModeFromModifierKeys()
        {
            // Update GetPrefabButtonContent if this logic changes
            var defaultPrefabMode     = PreferencesProvider.GetDefaultPrefabModeForHierarchy();
            var alternativePrefabMode = (defaultPrefabMode == PrefabStage.Mode.InContext) ? PrefabStage.Mode.InIsolation : PrefabStage.Mode.InContext;

            return(Event.current.alt ? alternativePrefabMode : defaultPrefabMode);
        }
Ejemplo n.º 8
0
        public void CanReadAddRemovePreferenceItem()
        {
            PreferencesProvider preferences = ProviderFactory.GetInstance <PreferencesFactory> (ProviderRepositoryFactory.Instance.Provider).GetDefaultProvider <PreferencesProvider> ();

            Assert.AreNotEqual(preferences.GetPreferences("appSetting").Count, 0);
            Assert.AreEqual(preferences.GetPreferences("appSetting").Count, 2);
            Assert.AreEqual(preferences.GetPreferences("appSetting") ["1"].ID, "1");
            Assert.AreEqual(preferences.GetPreferences("appSetting") ["1"].Description, "preference no 1");

            PreferenceItemCollection appSetting = preferences.GetPreferences("appSetting");
            PreferenceItem           newItem    = new PreferenceItem();

            newItem.ID          = "3";
            newItem.Description = "Percentage";
            newItem.Name        = "3";
            newItem.Value       = "3";

            appSetting.Add(newItem);

            preferences.SavePreferences(appSetting);

            var xmlDoc = new XmlDocument();

            xmlDoc.Load(preferences.XmlFileName);

            var dataTypeNode = xmlDoc.DocumentElement.SelectSingleNode(String.Format("preferenceCollection[@name='{0}']", appSetting.CollectionName));

            Assert.AreEqual(dataTypeNode.ChildNodes.Count, 3);
            Assert.AreEqual(dataTypeNode.ChildNodes [2].Attributes ["name"].Value, "3");

            appSetting = preferences.GetPreferences("appSetting");
            appSetting.Remove(appSetting ["3"]);
            preferences.SavePreferences(appSetting);

            xmlDoc = new XmlDocument();
            xmlDoc.Load(preferences.XmlFileName);

            dataTypeNode = xmlDoc.DocumentElement.SelectSingleNode(String.Format("preferenceCollection[@name='{0}']", appSetting.CollectionName));
            Assert.AreEqual(dataTypeNode.ChildNodes.Count, 2);
            Assert.AreNotEqual(dataTypeNode.ChildNodes [1].Attributes ["name"].Value, "3");
        }
        internal static GUIContent GetPrefabButtonContent(int instanceID)
        {
            GUIContent result;
            var        defaultPrefabMode = PreferencesProvider.GetDefaultPrefabModeForHierarchy();

            switch (defaultPrefabMode)
            {
            case PrefabStage.Mode.InContext:
                result = new GUIContent("", null, $"Open Prefab Asset in context.\nPress modifier key [Alt] to open in isolation.");
                break;

            case PrefabStage.Mode.InIsolation:
                result = new GUIContent("", null, "Open Prefab Asset in isolation.\nPress modifier key [Alt] to open in context.");
                break;

            default:
                result = new GUIContent("");
                Debug.LogError("Unhandled defaultPrefabMode enum");
                break;
            }
            return(result);
        }
Ejemplo n.º 10
0
        public object Edit([Bind(Prefix = "")]Preference preference, string course,
		                   string prof, string CourseList)
        {
            ViewData["Title"] = "Edit Preference";
            ViewData["Message"] = "Edit a Preference";

            // redisplay form immediately if there are input format errors
            if (!ViewData.ModelState.IsValid)
                return View(preference);
            int profId;
            try {
                profId = Convert.ToInt32(prof);
                ViewData["id"] = prof;
            } catch (Exception) {  //not an integer
                return RedirectToAction("Index", "Professor");
            }
            int courseId;
            try {
                courseId = Convert.ToInt32(course);
            } catch (Exception) { //not an integer
                return this.RedirectToAction(c => c.Show(prof));
            }
            try {
                var prefProv = new PreferencesProvider();
                Preference pref = prefProv.GetPreferenceByProfIdAndCourseId(profId, courseId);
                if (pref != null) {
                    Course cour = (new CourseProvider()).GetCourseByID(Convert.ToInt32(CourseList));
                    pref.Id.Course = cour;
                    pref.Weight = preference.Weight;
                    prefProv.UpdatePreference(pref);
                    return View("Saved");
                }
                return this.RedirectToAction(c => c.Show(prof));
            } catch (RuleViolationException vex) {
                ViewData.ModelState.CopyValidationExceptions(vex);
                PrepareCoursesList(preference);
                return View("Edit", preference);
            } catch (Exception err) {
                ViewData.ModelState.CopyValidationExceptions(err, "preference");
                PrepareCoursesList(preference);
                return View("Edit", preference);
            }
        }
Ejemplo n.º 11
0
 public IVehicle BuildCar(Chassis chassis, PreferencesProvider vehiclePreferences) => Build(chassis, VehicleType.Car, vehiclePreferences);
Ejemplo n.º 12
0
 public IVehicle BuildBus(Chassis chassis, PreferencesProvider vehiclePreferences) => Build(chassis, VehicleType.Bus, vehiclePreferences);
Ejemplo n.º 13
0
 public App()
 {
     var preferencesProvider  = new PreferencesProvider("CloudFoundryExplorerApp");
     var cloudFoundryProvider = new CloudFoundryProvider(preferencesProvider);
 }
Ejemplo n.º 14
0
 public void Setup()
 {
     DatabaseSetUp();
     session = sessionManager.GetSession();
     provider = new PreferencesProvider(session);
 }
Ejemplo n.º 15
0
 public App()
 {
     var preferencesProvider = new PreferencesProvider("CloudFoundryExplorerApp");
     var cloudFoundryProvider = new CloudFoundryProvider(preferencesProvider);
 }
Ejemplo n.º 16
0
 public IVehicle BuildTruck(Chassis chassis, PreferencesProvider vehiclePreferences) => Build(chassis, VehicleType.Truck, vehiclePreferences);
Ejemplo n.º 17
0
        public ActionResult Delete(string prof, string course)
        {
            int profId, courseId;
            try {
                profId = Convert.ToInt32(prof);
                ViewData["id"] = prof;
            } catch (Exception)   //not an integer
            {
                return RedirectToAction("Index", "Professor");
            }
            try {
                courseId = Convert.ToInt32(course);
            } catch (Exception)   //not an integer
            {
                return this.RedirectToAction(c => c.Show(prof));
            }

            try {
                var prefProvider = new PreferencesProvider();
                Preference preference = prefProvider.GetPreferenceByProfIdAndCourseId(profId, courseId);
                if (preference != null) {
                    prefProvider.DeletePreference(preference);
                    return View("Deleted");
                }
                return this.RedirectToAction(c => c.Show(prof));
            } catch (Exception err) {
                if (err.InnerException != null &&
                    err.InnerException.Message.Contains(
                        "The DELETE statement conflicted with the REFERENCE constraint")) {
                            ViewData["ErrorMessage"] =
                                "Course could not be deleted.. there are assoiciated data.. cannot delete";
                        } else {
                            ViewData["ErrorMessage"] = "Preference Could not be deleted.. there is a problem";
                        }
                return View("NotDeleted");
            }
        }