コード例 #1
0
        public void BuildSkipsEntriesWithNullValues()
        {
            var input = CreateResult(DefaultEntry.WithValue(null));

            var result = input.Build(Source, Entity);

            CollectionAssert.IsEmpty(result);
        }
コード例 #2
0
        public void BuildSkipsEntriesWithNullForms()
        {
            var input = CreateResult(DefaultEntry.WithForm(null));

            var result = input.Build(Source);

            CollectionAssert.IsEmpty(result);
        }
        public void BuildUsesDefaultConditionIfEntryHasNullCondition()
        {
            var          input    = CreateResult(DefaultEntry.WithCondition(null));
            const string expected = "default condition";

            var result = input.Build(expected);

            Assert.AreEqual(expected, result[0].Condition);
        }
        public void BuildDoesNotConvertNullStats()
        {
            var input = CreateResult(
                new[] { DefaultEntry.WithStat(null) },
                statConverter: s => s ?? throw new ArgumentNullException());

            var result = input.Build(null);

            Assert.Null(result[0].Stat);
        }
        public void BuildDoesNotConvertNullValues()
        {
            var input = CreateResult(
                new[] { DefaultEntry.WithValue(null) },
                valueConverter: v => v ?? throw new ArgumentNullException());

            var result = input.Build(null);

            Assert.Null(result[0].Value);
        }
コード例 #6
0
        public void MergeWithBothSingleEntryAndConditionInBothAndsConditions()
        {
            var expected       = Mock.Of <IConditionBuilder>();
            var rightCondition = Mock.Of <IConditionBuilder>();
            var leftCondition  = Mock.Of <IConditionBuilder>(c => c.And(rightCondition) == expected);
            var entryLeft      = EmptyEntry
                                 .WithCondition(leftCondition);
            var entryRight = DefaultEntry
                             .WithCondition(rightCondition);
            var left  = CreateResult(entryLeft);
            var right = CreateResult(entryRight);

            var result = left.MergeWith(right);

            Assert.AreEqual(expected, result.Entries.Single().Condition);
        }
コード例 #7
0
 public static bool RegisterDefaults <T> (int priority, Func <T> constructor)
     where T : class, ITestDefaults
 {
     lock (syncRoot) {
         object           value;
         DefaultEntry <T> entry;
         if (!defaults.TryGetValue(typeof(T), out value))
         {
             entry = new DefaultEntry <T> (priority, constructor);
             defaults.Add(typeof(T), entry);
             return(true);
         }
         entry = (DefaultEntry <T>)value;
         if (priority <= entry.Priority)
         {
             return(false);
         }
         entry = new DefaultEntry <T> (priority, constructor);
         defaults [typeof(T)] = entry;
         return(true);
     }
 }
コード例 #8
0
        public TaskPopup( TodoTask task, Action onCancel = null, Action onSubmit = null)
        {
            Task = task;

            SelectedDate = task.date;
            timePicker.Time = task.date.TimeOfDay;

            BackgroundColor = StyleManager.MainColor;
            WidthRequest = 300;

            titleLabel = new DefaultLabel {Text = Task.title, HorizontalOptions = LayoutOptions.CenterAndExpand};
            titleEdit = new DefaultEntry {Text = Task.title, HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.Transparent};
            titleEdit.WidthRequest = 250;

            var editButton = new Image {HorizontalOptions = LayoutOptions.End, Source = "edit_task.png"};
            var doneButton = new Image {HorizontalOptions = LayoutOptions.End, Source = "ok.png"};

            titlePanel = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding = 10,
                Children = {titleLabel, editButton}
            };

            var editPanel = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding = new Thickness(10, 0),
                Children = {titleEdit, doneButton}
            };

            topPanel = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Content = titlePanel,
            };

            editButton.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => Device.BeginInvokeOnMainThread (() => {
                    topPanel.Content = editPanel;
                    titleEdit.Focus ();
                }))
            });

            doneButton.GestureRecognizers.Add (new TapGestureRecognizer {
                Command = new Command (() => Device.BeginInvokeOnMainThread (UpdateTitle))
            });

            if (string.IsNullOrWhiteSpace (task.title)) {
                Device.BeginInvokeOnMainThread(() =>
                    {
                        topPanel.Content = editPanel;
                        titleEdit.Focus();
                        ((Entry)editPanel.Children [0]).Focus ();
                    });
                ((Entry)editPanel.Children [0]).Focus ();
            }

            popupFragment = new ContentView();
            datePicker = new PopupDatePicker {
                OnItemSelected = view => {
                    if (view != null){
                        popupFragment.Content = view;
                    }
                }
            };
            datePicker.DateChanged += (sender, e) => {
                SelectedDate = datePicker.SelectedDate;
            };
            popupFragment.Content = datePicker.DefaultView;

            var categoryIcon = new Image {HorizontalOptions = LayoutOptions.EndAndExpand, HeightRequest = 12, Source = task.GetCategory().IconSource};

            categoryPicker = new CategoryPicker();
            categoryPicker.SelectedIndex = 0;

            foreach (Category category in CategoryHelper.AllCategories) {
                categoryPicker.Items.Add (category.Name);
                if (task.category == category.Name) {
                    categoryPicker.SelectedIndex = categoryPicker.Items.Count - 1;
                }
            }

            categoryPicker.SelectedIndexChanged += ( sender, args ) => categoryIcon.Source = CategoryHelper.AllCategories[categoryPicker.SelectedIndex].IconSource;
            var selectCategoryArrow = new Image { HorizontalOptions = LayoutOptions.End, Source = "select.png", HeightRequest = 10 };
            selectCategoryArrow.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => categoryPicker.Focus ())
            });

            var categoryLayout = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = {
                    new DefaultLabel {Text = "Category", TextColor = StyleManager.MainColor},
                    categoryIcon,
                    categoryPicker,
                    selectCategoryArrow
                }
            };

            isFavorite = task.isFavorite;
            var starResource = isFavorite ? FAVORITE_IMG : NOT_FAVORITE_IMG;

            var favoriteLabel = new DefaultLabel { Text = "Mark as favorite", TextColor = StyleManager.MainColor };
            var favoriteImage = new Image {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Source = starResource,
                HeightRequest = 15
            };
            var favoriteLayout = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = { favoriteLabel, favoriteImage}
            };

            favoriteImage.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => Device.BeginInvokeOnMainThread (() => {
                    isFavorite = !isFavorite;
                    favoriteImage.Source = isFavorite ? FAVORITE_IMG : NOT_FAVORITE_IMG;
                }))
            });

            var actionText = "Create";

            if (!string.IsNullOrWhiteSpace (task.title))
                actionText = "Update";

            var buttons = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing = 0,
                Children = {
                    new DefaultButton {
                        Text = "Cancel",
                        TextColor = Color.White,
                        BackgroundColor = Color.Silver,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Command = new Command (onCancel.Dispatch)
                    },
                    new DefaultButton {
                        Text = actionText,
                        TextColor = Color.White,
                        BackgroundColor = StyleManager.MainColor,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Command = new Command (() => Device.BeginInvokeOnMainThread (() => {
                            UpdateTask (task);
                            onSubmit.Dispatch ();
                        }))
                    }
                }
            };

            var mainLayout = new StackLayout {
                Padding = 15,
                BackgroundColor = StyleManager.AccentColor,
                Spacing = 20,
                Children = { // TODO time picker, pass time
                    timePicker, categoryLayout, favoriteLayout, buttons
                }
            };

            Children.Add(topPanel);
            Children.Add(datePicker);
            Children.Add(popupFragment);
            Children.Add(mainLayout);
        }
コード例 #9
0
        public TaskPopup(TodoTask task, Action onCancel = null, Action onSubmit = null)
        {
            Task = task;

            SelectedDate    = task.date;
            timePicker.Time = task.date.TimeOfDay;

            BackgroundColor = StyleManager.MainColor;
            WidthRequest    = 300;

            titleLabel = new DefaultLabel {
                Text = Task.title, HorizontalOptions = LayoutOptions.CenterAndExpand
            };
            titleEdit = new DefaultEntry {
                Text = Task.title, HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.Transparent
            };
            titleEdit.WidthRequest = 250;

            var editButton = new Image {
                HorizontalOptions = LayoutOptions.End, Source = "edit_task.png"
            };
            var doneButton = new Image {
                HorizontalOptions = LayoutOptions.End, Source = "ok.png"
            };


            titlePanel = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = 10,
                Children          = { titleLabel, editButton }
            };

            var editPanel = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(10, 0),
                Children          = { titleEdit, doneButton }
            };

            topPanel = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Content           = titlePanel,
            };

            editButton.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => Device.BeginInvokeOnMainThread(() => {
                    topPanel.Content = editPanel;
                    titleEdit.Focus();
                }))
            });

            doneButton.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => Device.BeginInvokeOnMainThread(UpdateTitle))
            });

            if (string.IsNullOrWhiteSpace(task.title))
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    topPanel.Content = editPanel;
                    titleEdit.Focus();
                    ((Entry)editPanel.Children [0]).Focus();
                });
                ((Entry)editPanel.Children [0]).Focus();
            }

            popupFragment = new ContentView();
            datePicker    = new PopupDatePicker {
                OnItemSelected = view => {
                    if (view != null)
                    {
                        popupFragment.Content = view;
                    }
                }
            };
            datePicker.DateChanged += (sender, e) => {
                SelectedDate = datePicker.SelectedDate;
            };
            popupFragment.Content = datePicker.DefaultView;

            var categoryIcon = new Image {
                HorizontalOptions = LayoutOptions.EndAndExpand, HeightRequest = 12, Source = task.GetCategory().IconSource
            };

            categoryPicker = new CategoryPicker();
            categoryPicker.SelectedIndex = 0;

            foreach (Category category in CategoryHelper.AllCategories)
            {
                categoryPicker.Items.Add(category.Name);
                if (task.category == category.Name)
                {
                    categoryPicker.SelectedIndex = categoryPicker.Items.Count - 1;
                }
            }

            categoryPicker.SelectedIndexChanged += (sender, args) => categoryIcon.Source = CategoryHelper.AllCategories[categoryPicker.SelectedIndex].IconSource;
            var selectCategoryArrow = new Image {
                HorizontalOptions = LayoutOptions.End, Source = "select.png", HeightRequest = 10
            };

            selectCategoryArrow.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => categoryPicker.Focus())
            });


            var categoryLayout = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    new DefaultLabel {
                        Text = "Category", TextColor = StyleManager.MainColor
                    },
                    categoryIcon,
                    categoryPicker,
                    selectCategoryArrow
                }
            };

            isFavorite = task.isFavorite;
            var starResource = isFavorite ? FAVORITE_IMG : NOT_FAVORITE_IMG;

            var favoriteLabel = new DefaultLabel {
                Text = "Mark as favorite", TextColor = StyleManager.MainColor
            };
            var favoriteImage = new Image {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Source            = starResource,
                HeightRequest     = 15
            };
            var favoriteLayout = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          = { favoriteLabel, favoriteImage }
            };

            favoriteImage.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => Device.BeginInvokeOnMainThread(() => {
                    isFavorite           = !isFavorite;
                    favoriteImage.Source = isFavorite ? FAVORITE_IMG : NOT_FAVORITE_IMG;
                }))
            });

            var actionText = "Create";

            if (!string.IsNullOrWhiteSpace(task.title))
            {
                actionText = "Update";
            }

            var buttons = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing           = 0,
                Children          =
                {
                    new DefaultButton {
                        Text              = "Cancel",
                        TextColor         = Color.White,
                        BackgroundColor   = Color.Silver,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Command           = new Command(onCancel.Dispatch)
                    },
                    new DefaultButton {
                        Text              = actionText,
                        TextColor         = Color.White,
                        BackgroundColor   = StyleManager.MainColor,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Command           = new Command(() => Device.BeginInvokeOnMainThread(() => {
                            UpdateTask(task);
                            onSubmit.Dispatch();
                        }))
                    }
                }
            };

            var mainLayout = new StackLayout {
                Padding         = 15,
                BackgroundColor = StyleManager.AccentColor,
                Spacing         = 20,
                Children        =            // TODO time picker, pass time
                {
                    timePicker, categoryLayout, favoriteLayout, buttons
                }
            };

            Children.Add(topPanel);
            Children.Add(datePicker);
            Children.Add(popupFragment);
            Children.Add(mainLayout);
        }
コード例 #10
0
ファイル: XmlAdd.cs プロジェクト: Crome696/ServUO
		public static void RestoreDefs(DefaultEntry defs)
		{
			if(defs == null) return;
			defs.MinDelay = TimeSpan.FromMinutes(5);
			defs.MaxDelay = TimeSpan.FromMinutes(10);
			defs.RefractMin = TimeSpan.FromMinutes(0);
			defs.RefractMax = TimeSpan.FromMinutes(0);
			defs.TODStart = TimeSpan.FromMinutes(0);
			defs.TODEnd = TimeSpan.FromMinutes(0);
			defs.Duration = TimeSpan.FromMinutes(0);
			defs.DespawnTime = TimeSpan.FromHours(0);
			defs.Group = false;
			defs.Team = 0;
			defs.ProximitySound = 0x1F4;
			defs.SpeechTrigger = null;
			defs.SkillTrigger = null;
			defs.SequentialSpawn = -1;
			defs.HomeRangeIsRelative = true;
			defs.SpawnRange = 5;
			defs.HomeRange = 5;
			defs.ProximityRange = -1;
			defs.TODMode = XmlSpawner.TODModeType.Realtime;
			defs.KillReset = 1;
			defs.SpawnerName = "Spawner";
			defs.AllowGhostTrig = false;
			defs.AllowNPCTrig = false;
			defs.SpawnOnTrigger = false;
			defs.SmartSpawning = false;
			defs.ExternalTriggering = false;
			defs.TriggerOnCarried = null;
			defs.NoTriggerOnCarried = null;
			defs.ProximityMsg = null;
			defs.TriggerProbability = 1;
			defs.PlayerTriggerProp = null;
			defs.TriggerObjectProp = null;
			defs.DefsExt = null;
			defs.AddGumpX = 440;
			defs.AddGumpY = 0;
			defs.SpawnerGumpX = 0;
			defs.SpawnerGumpY = 0;
			defs.FindGumpX = 0;
			defs.FindGumpY = 0;
			defs.AutoNumber = false;
			defs.AutoNumberValue = 0;
          

			if(defs.SelectionList != null) Array.Clear(defs.SelectionList,0,defs.SelectionList.Length);
			if(defs.NameList != null) Array.Clear(defs.NameList,0,defs.NameList.Length);
		}
コード例 #11
0
ファイル: XmlAdd.cs プロジェクト: Crome696/ServUO
		public static DefaultEntry GetDefaults(string account, string name)
		{
			// find the default entry corresponding to the account and username
			if(DefaultEntryList != null)
			{
				for(int i = 0;i < DefaultEntryList.Count;i++)
				{
					DefaultEntry entry = (DefaultEntry)DefaultEntryList[i];
					if( entry != null && string.Compare( entry.PlayerName, name, true ) == 0 && string.Compare( entry.AccountName, account, true ) == 0)
					{
						return entry;
					}
				}
			}
			// if not found then add one
			DefaultEntry newentry = new DefaultEntry();
			newentry.PlayerName = name;
			newentry.AccountName = account;
			if(DefaultEntryList == null)
				DefaultEntryList = new ArrayList();
			DefaultEntryList.Add(newentry);
			return newentry;
		}
コード例 #12
0
        public LoginPage()
        {
            NavigationPage.SetHasNavigationBar(this, false);

            // Status bar for iOS.
            var statusBar = new BoxView();

            if (Device.OS == TargetPlatform.iOS)
            {
                statusBar.BackgroundColor = StyleManager.DarkAccentColor;
                statusBar.HeightRequest   = 20;
            }

            // Application title & subtitle.
            var titleString = new FormattedString();

            titleString.Spans.Add(new Span {
                ForegroundColor = StyleManager.AccentColor, FontAttributes = FontAttributes.Italic, FontSize = 40, Text = "Todo "
            });
            titleString.Spans.Add(new Span {
                ForegroundColor = StyleManager.DarkAccentColor, FontAttributes = FontAttributes.Italic, FontSize = 32, Text = "app"
            });
            var title = new DefaultLabel {
                FormattedText = titleString, HorizontalOptions = LayoutOptions.Center
            };

            var subtitle = new ItalicLabel {
                Text = "Helping you doing everything", TextColor = StyleManager.AccentColor
            };

            var titleLayout = new StackLayout {
                Children = { title, subtitle },
                Spacing  = 2,
                Padding  = new Thickness(0, 30)
            };

            // Start layout (down arrow).
            var login = new ItalicLabel {
                Text = "Log in", CustomFontSize = NamedSize.Medium
            };
            var downArrow = new Image {
                Source        = "down_button.png",
                HeightRequest = 60
            };
            var startLayout = new StackLayout {
                Padding  = new Thickness(0, 100),
                Spacing  = 18,
                Children = { login, downArrow }
            };

            // Login layout.
            emailTextBox = new DefaultEntry {
                Placeholder = "Email"
            };
            passwordTextBox = new DefaultEntry {
                Placeholder = "Password", IsPassword = true
            };
            var entryLayout = new StackLayout {
                Spacing  = 15,
                Children = { emailTextBox, passwordTextBox }
            };

            submitButton = new DefaultButton {
                Command = new Command(Submit)
            };
            signUpString = new FormattedString();
            signUpString.Spans.Add(new Span {
                ForegroundColor = StyleManager.AccentColor, FontAttributes = FontAttributes.Italic
            });
            signUpString.Spans.Add(new Span {
                ForegroundColor = StyleManager.DarkAccentColor, FontAttributes = FontAttributes.Bold
            });
            var toggleModeLabel = new DefaultLabel {
                FormattedText = signUpString, HorizontalOptions = LayoutOptions.Center
            };

            var signInLayout = new StackLayout {
                Padding  = new Thickness(0, 20),
                Spacing  = 30,
                Children = { submitButton, toggleModeLabel }
            };

            var loginLayout = new StackLayout {
                Padding   = new Thickness(0, 35),
                Children  = { entryLayout, signInLayout },
                IsVisible = false
            };

            downArrow.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => {
                    loginLayout.IsVisible = true;
                    startLayout.IsVisible = false;
                })
            });

            var toggleModeGestureRecognizer = new TapGestureRecognizer();

            toggleModeGestureRecognizer.Tapped += (sender, ev) => toggleMode();
            toggleModeLabel.GestureRecognizers.Add(toggleModeGestureRecognizer);

            // Main content layout.
            var contentLayout = new StackLayout {
                Padding           = 25,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    titleLayout,
                    startLayout,
                    loginLayout
                }
            };

            Content = new StackLayout {
                Children = { statusBar, contentLayout }
            };

            setLoginMode();
        }