Example #1
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            if (AcceptCancelDialog.Show(Common.Localize("DropAllDreams:Prompt")))
            {
                int count = 0;

                List <Sim> list = new List <Sim>(Sims3.Gameplay.Queries.GetObjects <Sim>());
                foreach (Sim sim in list)
                {
                    if (sim.Household == Household.ActiveHousehold)
                    {
                        continue;
                    }

                    if ((sim.DreamsAndPromisesManager != null) ||
                        (sim.OpportunityManager != null))
                    {
                        sim.NullSelectableSimManagers();

                        count++;
                    }
                }

                SimpleMessageDialog.Show(Name, Common.Localize("DropAllDreams:Result", false, new object[] { count }));
            }
            return(OptionResult.SuccessClose);
        }
Example #2
0
        protected override OptionResult Run(GameHitParameters <TTarget> parameters)
        {
            string text = StringInputDialog.Show(Name, GetPrompt(), this.DisplayValue);

            if (string.IsNullOrEmpty(text))
            {
                return(OptionResult.Failure);
            }

            uint value = 0;

            try
            {
                value = uint.Parse("FF" + text, System.Globalization.NumberStyles.HexNumber);
            }
            catch
            { }

            if (value == 0)
            {
                SimpleMessageDialog.Show(Name, Common.Localize("Hex:Error"));
                return(OptionResult.Failure);
            }

            Value = Validate(value);

            Tagger.InitTags(false);

            Common.Notify(ToString());
            return(OptionResult.SuccessRetain);
        }
Example #3
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(me, CASParts.sPrimary))
            {
                if (!builder.OutfitValid)
                {
                    return(true);
                }

                if (!ApplyAll)
                {
                    float oldValue = GetValue(builder.Builder);

                    string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me }), oldValue.ToString(), 256, StringInputDialog.Validation.None);
                    if (string.IsNullOrEmpty(text))
                    {
                        return(false);
                    }

                    mValue = 0;
                    if (!float.TryParse(text, out mValue))
                    {
                        SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                        return(false);
                    }
                }

                ApplyValue(builder.Builder, mValue);
            }

            new SavedOutfit.Cache(me).PropagateGenetics(me, CASParts.sPrimary);

            return(true);
        }
Example #4
0
        protected override OptionResult Run(Lot myLot, Household house)
        {
            try
            {
                string text = StringInputDialog.Show(Name, "Enter the ID for the lot:", "");
                if (string.IsNullOrEmpty(text))
                {
                    return(OptionResult.Failure);
                }

                ulong lotID = ulong.Parse(text);

                Lot lot = LotManager.GetLot(lotID);
                if (lot == null)
                {
                    SimpleMessageDialog.Show(Name, "No lot found");
                }
                else
                {
                    Focus.Perform(lot);

                    SimpleMessageDialog.Show(Name, lot.Name + " " + lot.Address);
                }
            }
            catch (Exception e)
            {
                Common.Exception(myLot, e);
            }
            return(OptionResult.SuccessClose);
        }
Example #5
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            if (parameters.mTarget != null)
            {
                DoorPortalComponentEx.DoorSettings settings = GoHere.Settings.GetDoorSettings(parameters.mTarget.ObjectId);

                string sCost = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":PromptCost"), settings.mDoorCost.ToString());
                if (string.IsNullOrEmpty(sCost))
                {
                    return(OptionResult.Failure);
                }

                int cost = 0;
                if (!int.TryParse(sCost, out cost))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(OptionResult.Failure);
                }

                if (cost < 0 || cost > int.MaxValue)
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:InvalidInput"));
                    return(OptionResult.Failure);
                }

                settings.mDoorCost = cost;
                GoHere.Settings.AddOrUpdateDoorSettings(parameters.mTarget.ObjectId, settings, false);

                Common.Notify(Common.Localize("Generic:Success"));

                return(OptionResult.SuccessClose);
            }

            return(OptionResult.Failure);
        }
Example #6
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            Sim sim = me.CreatedSim;

            if (sim == null)
            {
                return(false);
            }

            int value = me.TraitChipManager.NumTraitSlots;

            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me }), value.ToString(), 256, StringInputDialog.Validation.None);
                if (string.IsNullOrEmpty(text))
                {
                    return(false);
                }

                mCount = 0;
                if (!int.TryParse(text, out mCount) || (mCount < 0 || mCount > 7))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(false);
                }
            }

            me.TraitChipManager.UpgradeNumTraitChips(mCount);

            return(true);
        }
Example #7
0
 protected override bool Run()
 {
     base.StandardEntry();
     SimpleMessageDialog.Show("Test Dialog", "This is a test dialog.");
     base.StandardExit();
     return(true);
 }
Example #8
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me, 100 }), me.AlienDNAPercentage.ToString(), 256, StringInputDialog.Validation.None);
                if (string.IsNullOrEmpty(text))
                {
                    return(false);
                }

                mPercent = 0;
                if (!float.TryParse(text, out mPercent))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(false);
                }
            }

            me.mAlienDNAPercentage = mPercent;

            if (me.CreatedSim != null)
            {
                me.CreatedSim.Motives.RecreateMotives(me.CreatedSim);
            }
            return(true);
        }
Example #9
0
 private void ShowDialog(string messageType)
 {
     if (base.Actor.IsSelectable)
     {
         SimpleMessageDialog.Show(this.GetInteractionName(), LocalizeCallString("InviteOver", messageType, new object[0]), ModalDialog.PauseMode.PauseSimulator);
     }
 }
Example #10
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            CommonSelection <Item> .Results selection = new CommonSelection <Item>(Name, this.GetCareerOptions()).SelectMultiple();

            List <CareerLevelItem> mLevelOptions = new List <CareerLevelItem>();

            foreach (Item item in selection)
            {
                mLevelOptions.AddRange(GetLevelOptions(item.Value));
            }

            CommonSelection <CareerLevelItem> .Results levelSelection = new CommonSelection <CareerLevelItem>(Name, mLevelOptions).SelectMultiple();

            foreach (CareerLevelItem item in levelSelection)
            {
                mPicks.Add(item.Value);
            }

            if (mPicks.Count == 0)
            {
                SimpleMessageDialog.Show(Name, Common.Localize("Selection:Error"));
                return(OptionResult.Failure);
            }

            return(OptionResult.SuccessRetain);
        }
Example #11
0
            protected override bool Run(SimDescription a, SimDescription b)
            {
                Relationship relation = Relationship.Get(a, b, true);

                if (relation == null)
                {
                    return(false);
                }

                string text = StringInputDialog.Show("Change Long Term Relationship", "Enter the amount to change the existing long term relationship between\n" + a.FirstName + " " + a.LastName + "\nand\n" + b.FirstName + " " + b.LastName + "\n\nRange is -100 to 100", relation.LTR.Liking.ToString("F1"), 256, StringInputDialog.Validation.None);

                if ((text == null) || (text == ""))
                {
                    return(false);
                }

                float value = 0f;

                if (!float.TryParse(text, out value))
                {
                    SimpleMessageDialog.Show("Change Long Term Relationship", "Value '" + text + "' could not be converted to a number.");
                    return(false);
                }

                relation.LTR.SetLiking(value);
                return(true);
            }
Example #12
0
            public override bool Run()
            {
                try
                {
                    Sim sim = Target as Sim;
                    if (sim == null)
                    {
                        sim = Actor;
                    }

                    List <Opportunity> allOpportunities = GetAllOpportunities(sim);
                    if (allOpportunities.Count == 0)
                    {
                        SimpleMessageDialog.Show(Localize("Random:MenuName"), Localize("Choice:None"));
                        return(false);
                    }

                    Opportunity sel = RandomUtil.GetRandomObjectFromList(allOpportunities);
                    if (sel == null)
                    {
                        return(false);
                    }

                    sim.OpportunityManager.AddOpportunityNow(sel.Guid, true, false);
                    return(true);
                }
                catch (Exception exception)
                {
                    Exception(exception);
                }

                return(false);
            }
Example #13
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize("Performance:Prompt"), GetValue(me).ToString(), 256, StringInputDialog.Validation.None);
                if ((text == null) || (text == ""))
                {
                    return(false);
                }

                if (!float.TryParse(text, out mValue))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(false);
                }

                if (mValue > 100f)
                {
                    mValue = 100f;
                }
                else if (mValue < -100f)
                {
                    mValue = -100f;
                }
            }

            SetValue(me, mValue);
            return(true);
        }
Example #14
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                int remainingPoints = (int)(me.CelebrityManager.GetGoalPointsForCurrentLevel() - me.CelebrityManager.Points);

                string text = StringInputDialog.Show(Name, Common.Localize("CelebrityPoints:Prompt", me.IsFemale, new object[] { me, remainingPoints }), me.CelebrityManager.Points.ToString(), 256, StringInputDialog.Validation.None);
                if (string.IsNullOrEmpty(text))
                {
                    return(false);
                }

                mPoints = 0;
                if (!uint.TryParse(text, out mPoints))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(false);
                }
            }

            CelebrityLevel.CleanupFreeStuffAlarm(me);

            me.CelebrityManager.AddPointsInternal(mPoints);
            return(true);
        }
Example #15
0
 private static void QueueChanged()
 {
     foreach (InteractionInstance interaction in Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.InteractionList)
     {
         SimpleMessageDialog.Show("QueueChanged", interaction.InteractionDefinition.ToString());
     }
 }
Example #16
0
            protected override bool Run()
            {
                List <PhoneSimPicker.SimPickerInfo> sims = ListOfAllSims(base.Actor);

                if ((sims == null) || (sims.Count == 0))
                {
                    SimpleMessageDialog.Show("Pollination", "There is no one available on the lot to pollinate.");
                    return(false);
                }

                List <object> list = PhoneSimPicker.Show(true, ModalDialog.PauseMode.PauseSimulator, sims, "Select Partner", "Select", "Cancel");

                if ((list == null) || (list.Count == 0))
                {
                    return(false);
                }

                SimDescription other = list[0] as SimDescription;

                Sim otherSim = other.CreatedSim;

                if (otherSim == null)
                {
                    SimpleMessageDialog.Show("Pollination", other.FirstName + " " + other.LastName + " was unavailable for pollination.");
                    return(false);
                }

                if (otherSim == base.Actor)
                {
                    otherSim = null;
                }

                return(Pollinator.Pollinate(otherSim, base.Actor));
            }
Example #17
0
        protected override OptionResult Run(Lot lot, Household me)
        {
            Perform(lot);

            string reason = null;

            foreach (HomeInspection.Result result in new HomeInspection(lot).Satisfies(me))
            {
                switch (result.mReason)
                {
                case HomeInspection.Reason.NoDouble:
                    if (!MasterController.Settings.mCheckForNoDoubleBed)
                    {
                        continue;
                    }
                    break;

                case HomeInspection.Reason.TooFewBeds:
                    continue;
                }

                reason += Common.NewLine + Common.Localize("HomeInspection:" + result.mReason, false, new object[] { result.mExisting, result.mRequired });
            }

            SimpleMessageDialog.Show(Name, Common.Localize("HomeInspection:Header") + reason);
            return(OptionResult.SuccessClose);
        }
Example #18
0
        protected override bool PrivatePerform()
        {
            Common.WriteLog(FilePersistence.ExportContents(), false);

            SimpleMessageDialog.Show(Common.Localize("ExportSettings:MenuName"), Common.Localize("ExportSettings:Success"));
            return(true);
        }
Example #19
0
        public override bool OnLotPick(ulong id)
        {
            try
            {
                if (mPlacing)
                {
                    return(false);
                }

                UIBinInfo lotInfo = FindBinInfoForLot(id, MaptagTypes.None);
                if (lotInfo == null)
                {
                    return(false);
                }

                if (mModel.IsLotLocked(lotInfo.LotId) && !World.IsEditInGameFromWBMode())
                {
                    Simulator.AddObject(new Sims3.UI.OneShotFunctionTask(delegate
                    {
                        SimpleMessageDialog.Show(null, Sims3.UI.Responder.Instance.LocalizationModel.LocalizeString("Ui/Tooltip/Maptag:Locked", new object[0x0]), ModalDialog.PauseMode.PauseTask);
                    }));
                    return(false);
                }

                OnSelection(lotInfo);
                return(true);
            }
            catch (Exception e)
            {
                Common.Exception("OnLotPick", e);
                return(false);
            }
        }
Example #20
0
        // this could be further broken down into another class (IntegerSettingOption) but not right now
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            OptionResult result = base.Run(parameters);

            if (result != OptionResult.Failure)
            {
                string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", false), ""); // def

                if (string.IsNullOrEmpty(text))
                {
                    return(OptionResult.Failure);
                }

                int value;
                if (!int.TryParse(text, out value))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(OptionResult.Failure);
                }

                foreach (OccupationNames name in base.mPicks)
                {
                    NRaas.CareerSpace.PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(name, true);
                    settings.minCoworkers = value;
                    NRaas.Careers.Settings.UpdateCareerSettings(settings);
                }

                Common.Notify("Generic:Success");
                return(OptionResult.SuccessLevelDown);
            }

            return(result);
        }
Example #21
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            Occupation occupation = GetOccupation(me);

            if (occupation == null)
            {
                return(false);
            }

            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me, occupation.PaidDaysOff }), "0", 256, StringInputDialog.Validation.None);
                if (string.IsNullOrEmpty(text))
                {
                    return(false);
                }

                if (!int.TryParse(text, out mValue))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(false);
                }
            }

            occupation.mDaysOff += mValue;

            if (occupation.mDaysOff < 0)
            {
                occupation.mDaysOff = 0;
            }

            return(true);
        }
Example #22
0
        protected override OptionResult Run(Lot lot, Household me)
        {
            if (me != null)
            {
                if (!ApplyAll)
                {
                    string text = StringInputDialog.Show(Name, Common.Localize("FamilyFunds:Prompt", false, new object[] { me.Name, me.FamilyFunds }), "0");
                    if (string.IsNullOrEmpty(text))
                    {
                        return(OptionResult.Failure);
                    }

                    mDelta = 0;
                    if (!int.TryParse(text, out mDelta))
                    {
                        SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                        return(OptionResult.Failure);
                    }
                }

                me.ModifyFamilyFunds(mDelta);
            }

            return(OptionResult.SuccessClose);
        }
Example #23
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize("GenderPreference:MalePrompt", me.IsFemale, new object[] { me }), me.mGenderPreferenceMale.ToString(), 256, StringInputDialog.Validation.None);
                if ((text == null) || (text == ""))
                {
                    return(false);
                }

                mPreferenceMale = 0;
                if (!int.TryParse(text, out mPreferenceMale))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(false);
                }

                text = StringInputDialog.Show(Name, Common.Localize("GenderPreference:FemalePrompt", me.IsFemale, new object[] { me }), me.mGenderPreferenceFemale.ToString(), 256, StringInputDialog.Validation.None);
                if ((text == null) || (text == ""))
                {
                    return(false);
                }

                mPreferenceFemale = 0;
                if (!int.TryParse(text, out mPreferenceFemale))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(false);
                }
            }

            me.mGenderPreferenceMale   = mPreferenceMale;
            me.mGenderPreferenceFemale = mPreferenceFemale;
            return(true);
        }
Example #24
0
        protected override bool Run(SimDescription a, SimDescription b)
        {
            Relationship relation = Relationship.Get(a, b, true);

            if (relation == null)
            {
                return(true);
            }

            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize("RelationshipByValue:Prompt", a.IsFemale, new object[] { a, b }), relation.LTR.Liking.ToString());
                if (string.IsNullOrEmpty(text))
                {
                    return(false);
                }

                mValue = 0;
                if (!float.TryParse(text, out mValue))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(false);
                }
            }

            relation.LTR.SetLiking(mValue);
            return(true);
        }
Example #25
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            Career career = me.Occupation as Career;

            if (career == null)
            {
                return(true);
            }

            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize("CareerBonus:Prompt", me.IsFemale, new object[] { me, career.mPayPerHourExtra }), "0", 256, StringInputDialog.Validation.None);
                if (string.IsNullOrEmpty(text))
                {
                    return(false);
                }

                if (!float.TryParse(text, out mValue))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(false);
                }
            }

            career.mPayPerHourExtra += mValue;

            if (career.mPayPerHourExtra < 0)
            {
                career.mPayPerHourExtra = 0;
            }

            return(true);
        }
Example #26
0
        // this could be further broken down into another class (IntegerSettingOption) but not right now
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            OptionResult result = base.Run(parameters);

            if (result != OptionResult.Failure)
            {
                foreach (OccupationNames name in base.mPicks)
                {
                    string defaultText = string.Empty;
                    if (name != OccupationNames.Any)
                    {
                        NRaas.CareerSpace.PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(name, true);

                        defaultText = settings.mMaxCoworkers.ToString();
                    }

                    string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", false), defaultText);

                    if (string.IsNullOrEmpty(text))
                    {
                        return(OptionResult.Failure);
                    }

                    int value;
                    if (!int.TryParse(text, out value))
                    {
                        SimpleMessageDialog.Show(Name, Common.Localize("InputError:Numeric"));
                        return(OptionResult.Failure);
                    }

                    if (name == OccupationNames.Any)
                    {
                        foreach (Career career in CareerManager.CareerList)
                        {
                            PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(career.Guid, true);

                            settings.mMaxCoworkers = value;

                            NRaas.Careers.Settings.SetCareerData(settings);
                        }

                        Common.Notify(GetTitlePrefix() + " " + Common.Localize("Selection:All") + " " + value);
                    }
                    else
                    {
                        PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(name, true);
                        settings.mMaxCoworkers = value;

                        NRaas.Careers.Settings.SetCareerData(settings);

                        Common.Notify(GetTitlePrefix() + " " + CareerManager.GetStaticCareer(name).Name + " " + value);
                    }
                }

                Common.Notify(Common.Localize("Generic:Success"));
                return(OptionResult.SuccessLevelDown);
            }

            return(result);
        }
Example #27
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize("BabyMultiple:Prompt", me.IsFemale, new object[] { me, Pregnancy.kMaxBabyMultiplier }), me.Pregnancy.mMultipleBabiesMultiplier.ToString());
                if (string.IsNullOrEmpty(text))
                {
                    return(false);
                }

                mMultiple = 0;
                if (!float.TryParse(text, out mMultiple))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return(false);
                }

                if (mMultiple < 0)
                {
                    mMultiple = 0;
                }
                else if (mMultiple > Pregnancy.kMaxBabyMultiplier)
                {
                    mMultiple = Pregnancy.kMaxBabyMultiplier;
                }
            }

            me.Pregnancy.mMultipleBabiesMultiplier = mMultiple;
            return(true);
        }
 private static void sendDebugMsg(string msg)
 {
     if (debugOn)
     {
         SimpleMessageDialog.Show("WolfFeet - Debugging Enabled", msg);
     }
 }
Example #29
0
        protected override OptionResult Run(GameHitParameters <Sim> parameters)
        {
            foreach (SimDescription sim in new SimSelection(Name, PortraitPanel.Settings.SelectedSims, new SortColumn()).SelectMultiple())
            {
                string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", sim.IsFemale, new object[] { sim }), PortraitPanel.Settings.GetSimSort(sim).ToString());
                if (string.IsNullOrEmpty(text))
                {
                    return(OptionResult.Failure);
                }

                int value;
                if (!int.TryParse(text, out value))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    continue;
                }

                PortraitPanel.Settings.SetSimSort(sim, value);
            }

            PortraitPanel.Settings.AddSelectedSimsFilter();

            SkewerEx.Instance.PopulateSkewers();

            return(OptionResult.SuccessRetain);
        }
Example #30
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List <Opportunity> allOpportunities = OpportunityEx.GetAllOpportunities(me.CreatedSim, OpportunityCategory.None);

            if (allOpportunities.Count == 0)
            {
                SimpleMessageDialog.Show(Name, Common.Localize("Opportunity:None"));
                return(false);
            }

            List <Item> allOptions = new List <Item>();

            foreach (Opportunity item in allOpportunities)
            {
                string name = item.Name;
                if (item.IsCareer)
                {
                    name = Common.LocalizeEAString("Ui/Caption/HUD/CareerPanel:Career") + ": " + name;
                }

                allOptions.Add(new Item(item, me.CreatedSim, name, allOpportunities));
            }

            Item selection = new CommonSelection <Item>(Name, allOptions, new CompletedColumn()).SelectSingle();

            if (selection == null)
            {
                return(false);
            }

            return(OpportunityEx.Perform(me, selection.Value.Guid));
        }
		public void ShowSimpleMessageDialog()
		{
			using (var dlg = new SimpleMessageDialog("my message", "my title"))
			{
				dlg.Show();
				System.Threading.Thread.Sleep(2000);
			}
		}
		public void ShowSimpleMessageDialog_CaptionBarCanBeHidden()
		{
			using (var dlg = new SimpleMessageDialog("the caption bar can be hidden if truly desired", ""))
			{
				dlg.Show();
				System.Threading.Thread.Sleep(2000);
			}
		}
		public void ShowSimpleMessageDialog_LongMessageWraps()
		{
			const string longMessage = "my very long message which likes to wrap and wrap and wrap and wrap and wrap and wrap and wrap";
			using (var dlg = new SimpleMessageDialog(longMessage, "my title"))
			{
				dlg.Show();
				System.Threading.Thread.Sleep(2000);
			}
		}
Example #34
0
        /// <summary>
        /// First, we try to get the token quickly and quietly.
        /// If that fails, we put up a dialog and wait a number of seconds while we wait for the token to come free.
        /// </summary>
        /// <param name="uniqueIdentifier"></param>
        /// <param name="applicationName">Optional; used for user messaging</param>
        /// <param name="secondsToWait">Default = 10; Number of seconds the dialog will be displayed while waiting for the token to come free</param>
        /// <returns>True if we successfully acquired the token, false otherwise</returns>
        public static bool AcquireToken(string uniqueIdentifier, string applicationName = null, int secondsToWait = 10)
        {
            Guard.AgainstNull(uniqueIdentifier, "uniqueIdentifier");

            bool tokenAcquired = AcquireTokenQuietly(uniqueIdentifier);
            if (tokenAcquired)
                return true;

            string waitingMsg = applicationName == null ?
                L10NSharp.LocalizationManager.GetString("Application.WaitingFinish.General", "Waiting for other application to finish...") :
                String.Format(
                    L10NSharp.LocalizationManager.GetString("Application.WaitingFinish.Specific", "Waiting for other {0} to finish...", "{0} is the application name"),
                    applicationName);
            using (var dlg = new SimpleMessageDialog(waitingMsg, applicationName))
            {
                dlg.Show();
                try
                {
                    for (int i=0; i < secondsToWait; i++)
                {
                        tokenAcquired = AcquireTokenQuietly(uniqueIdentifier);
                        if (tokenAcquired)
                            break;
                        Thread.Sleep(1000);
                    }
                }
                catch (Exception e)
                {
                    string errorMsg = applicationName == null ?
                        L10NSharp.LocalizationManager.GetString("Application.ProblemStarting.General",
                        "There was a problem starting the application which might require that you restart your computer.") :
                        String.Format(
                            L10NSharp.LocalizationManager.GetString("Application.ProblemStarting.Specific",
                                "There was a problem starting {0} which might require that you restart your computer.", "{0} is the application name"),
                            applicationName);
                    ErrorReport.NotifyUserOfProblem(e, errorMsg);
                }
            }

            if (!tokenAcquired) // cannot acquire
            {
                string errorMsg = applicationName == null ?
                        L10NSharp.LocalizationManager.GetString("Application.AlreadyRunning.General",
                        "Another copy of the application is already running. If you cannot find it, restart your computer.") :
                        String.Format(
                            L10NSharp.LocalizationManager.GetString("Application.AlreadyRunning.Specific",
                                "Another copy of {0} is already running. If you cannot find that {0}, restart your computer.",
                                "{0} is the application name"),
                            applicationName);
                ErrorReport.NotifyUserOfProblem(errorMsg);
                return false;
            }
            return true;
        }
		public void ShowSimpleMessageDialog_CaptionNotProvided_StillHasCaptionBar()
		{
			using (var dlg = new SimpleMessageDialog("the caption bar is still there, though empty"))
			{
				dlg.Show();
				System.Threading.Thread.Sleep(2000);
			}
			using (var dlg = new SimpleMessageDialog("the caption bar is still there, though empty", null))
			{
				dlg.Show();
				System.Threading.Thread.Sleep(2000);
			}
		}
Example #36
0
 public void MakeBloomPack(string path)
 {
     try
     {
         if(File.Exists(path))
         {
             //UI already go permission for this
             File.Delete(path);
         }
         Logger.WriteEvent("Making BloomPack");
         using (var pleaseWait = new SimpleMessageDialog("Creating BloomPack..."))
         {
             try
             {
                 pleaseWait.Show();
                 pleaseWait.BringToFront();
                 Application.DoEvents();//actually show it
                 Cursor.Current = Cursors.WaitCursor;
                 using (var zip = new ZipFile(Encoding.UTF8))
                 {
                     string dir = TheOneEditableCollection.PathToDirectory;
                     //nb: without this second argument, we don't get the outer directory included, and we need that for the name of the collection
                     zip.AddDirectory(dir, System.IO.Path.GetFileName(dir));
                     zip.Save(path);
                 }
                 //show it
                 Logger.WriteEvent("Showing BloomPack on disk");
                 Process.Start(Path.GetDirectoryName(path));
                 Analytics.Track("Create BloomPack");
             }
             finally
             {
                 Cursor.Current = Cursors.Default;
                 pleaseWait.Close();
             }
         }
     }
     catch (Exception e)
     {
         Palaso.Reporting.ErrorReport.NotifyUserOfProblem(e, "Could not make the BloomPack");
     }
 }