public void AddInputGroup(int index, InputGroup inputGroup) { string query = "REPLACE INTO InputGroups " + "VALUES ('" + index + "','" + (int)inputGroup.InputGroupType + "','" + inputGroup.Segments + "');"; database.RunQueryNoResult(query); }
public void Dispose_CanBeDisposedMultipleTimes() { StringWriter writer = new StringWriter(new StringBuilder()); InputGroup formActions = new InputGroup(writer); writer.Write("Content"); formActions.Dispose(); formActions.Dispose(); String expected = "<div class=\"input-group\">Content</div>"; String actual = writer.GetStringBuilder().ToString(); Assert.AreEqual(expected, actual); }
/// <summary> /// Converts current element to a MVC HTML string /// </summary> /// <returns>MVC HTML string representation of current element</returns> public string ToHtml() { Wrapper.CssClasses.Add("form-group"); if (RenderBehavior == EFormControlBehavior.Default) { Wrapper.InnerHtml = (Label == null ? string.Empty : Label.ToHtml()) + Input.ToHtml(); } else { Wrapper.InnerHtml = InputGroup.ToHtml(); } return(Wrapper.ToHtml()); }
public void BasicPropertyCopyTest() { var group = new InputGroup { Geotag = true, Name = "Name" }; var copy = new InputGroup(group, false); Assert.AreEqual(group.Valid, copy.Valid); Assert.AreEqual(group.Geotag, copy.Geotag); Assert.IsEmpty(copy.Inputs); Assert.AreEqual(group.Name, copy.Name); }
private string GetLogin(InputGroup group) { bool isSource = (group == InputGroup.Source); AuthType authType = GetAuthType(group); if (authType == AuthType.Sql) { return(isSource ? TextBoxSourceLogin.Text : TextBoxDestinationLogin.Text); } else // Windows Auth { return(string.Empty); } }
private string GetPassword(InputGroup group) { bool isSource = (group == InputGroup.Source); AuthType authType = GetAuthType(group); if (authType == AuthType.Sql) { return(isSource ? TextBoxSourcePassword.Text : TextBoxDestinationPassword.Text); } else { return(string.Empty); } }
public void DeleteGroup(InputGroup group) { if (!Map) { return; } int index = Map.Groups.IndexOf(group); if (index == -1) { return; } DeleteGroup(index); }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); InputGroup ctrl = (InputGroup)sender; if (e.PropertyName == InputGroup.XBackgroundColorProperty.PropertyName) { drawable.SetColor(ctrl.XBackgroundColor.ToAndroid()); } else if (e.PropertyName == InputGroup.BorderColorProperty.PropertyName) { drawable.SetStroke(ctrl.BorderThickness, ctrl.BorderColor.ToAndroid()); } }
public virtual void Add(int index, InputGroup group) { if (!Map) { return; } //If index is out of range, add the item at the end if (index < 0 || index >= Map.Groups.Count) { index = Map.Groups.Count - 1; } Map.Groups.Insert(index + 1, group); Select(index + 1); }
public void DisplayConditionInputCopyTest1() { var input = new SliderInput(); input.DisplayConditions.Add(new InputDisplayCondition(input, InputValueCondition.Equals, "a", false)); var group = new InputGroup { Inputs = { input } }; var copy = new InputGroup(group, false); Assert.AreSame(input, input.DisplayConditions.Single().Input); Assert.AreSame(input, group.Inputs.Single()); Assert.AreNotSame(group.Inputs.Single(), copy.Inputs.Single()); Assert.AreSame(copy.Inputs.Single(), copy.Inputs.Single().DisplayConditions.Single().Input); }
private AuthType GetAuthType(InputGroup group) { bool isSource = (group == InputGroup.Source); int selectedIndex; if (isSource) { selectedIndex = ComboBoxSourceAuth.SelectedIndex; } else { selectedIndex = ComboBoxDestinationAuth.SelectedIndex; } return((selectedIndex == 0) ? AuthType.Windows : AuthType.Sql); }
public void BasicInputTest() { var input = new SliderInput(); var inputId = input.Id; var group = new InputGroup { Geotag = true, Inputs = { input } }; Assert.AreEqual(input.Id, group.Inputs.Single().Id); Assert.AreSame(group.Inputs.Single(), input); Assert.AreEqual(group.Id, group.Inputs.Single().GroupId); }
public void BasicPropertyCopyTest() { var group = new InputGroup { Geotag = true, Name = "Name" }; var copy = group.Copy(false); Assert.AreEqual(group.Id, copy.Id); Assert.AreEqual(group.Valid, copy.Valid); Assert.AreEqual(group.Geotag, copy.Geotag); Assert.True(copy.Inputs.Count == 0); Assert.AreEqual(group.Name, copy.Name); }
void InitializeToolsActionsInputs() { InputGroup group = new InputGroup(); KeyCode keyCode = KeyCode.Alpha1; InputUnit unit; //push '1' -> select first item on tool panel //push '6' -> select 6th item for (int i = 1; i <= 8; ++i, ++keyCode) { unit = new InputUnit { InputCheckerByKey = Input.GetKeyDown, Key = keyCode }; int j = i; unit.Pushed += () => m_controller.SetTool(j); group.m_inputUnits.Add(i.ToString(), unit); } //scroll down -> select next item on tool panel //scroll up -> select previous item on tool panel unit = new InputUnit(); unit.Pushed += () => { float scroll = Input.GetAxis("Mouse ScrollWheel"); if (scroll > 0) { m_controller.SelectPreviousTool(); } else if (scroll < 0) { m_controller.SelectNextTool(); } }; group.m_inputUnits.Add(InputManager.SelectToolWithScroll, unit); //push 'Q' -> drop item in hands unit = new InputUnit { InputCheckerByKey = Input.GetKeyDown, Key = KeyCode.Q }; unit.Pushed += m_controller.DropSelectedItem; group.m_inputUnits.Add(InputManager.DropItem, unit); m_inputGroups.Add(InputManager.ToolsActionsGroup, group); }
public void SelectInput(int index) { if (index >= _inputs.Count) { return; } if (_lastIndex != -1) { inputSelectorButtons[_lastIndex].gameObject.GetComponent <Image>().color = _startingNormalColor; } _lastIndex = index; inputSelectorButtons[index].gameObject.GetComponent <Image>().color = Color.gray; _selectedInput = _inputs[index]; keys.text = _selectedInput.keys; link.text = _selectedInput.link; }
public static void Run(string inputFilePath, string outputFilePath) { List <BuyEntity> buyEntityList = ExcelReader.ReadEntityList <BuyEntity>(inputFilePath, "本期进项明细"); List <SellEntity> sellEntityList = ExcelReader.ReadEntityList <SellEntity>(inputFilePath, "本期销项明细"); List <MappingEntity> mappingEntityList = ExcelReader.ReadEntityList <MappingEntity>(inputFilePath, "商务报表"); InputGroup inputGroup = ToInputGroup(buyEntityList, sellEntityList, mappingEntityList); Process(inputGroup); List <OutputBuyEntity> outputBuyEntityList = new List <OutputBuyEntity>(); List <OutputSellEntity> outputSellEntityList = new List <OutputSellEntity>(); ToOutputEntity(inputGroup, outputBuyEntityList, outputSellEntityList); ExcelHelper.WriteToExcel(outputFilePath, getRemarkList()); ExcelHelper.WriteToExcel(outputFilePath, outputBuyEntityList); ExcelHelper.WriteToExcel(outputFilePath, outputSellEntityList); }
protected void ResetEditor() { groupProperty = Property.FindPropertyRelative("groupName"); useDefaultProperty = Property.FindPropertyRelative("useDefaultGroup"); contentProperty = Property.FindPropertyRelative(ContentPropertyName); SelectCurrentProperties(); groupBar.OnItemSelect += (object o) => { InputGroup group = o as InputGroup; if (group.groupName == groupProperty.stringValue) { return; } groupProperty.stringValue = group.groupName; selectedItem = -1; }; }
public void DisplayConditionInputCopyTest5() { var input1 = new SliderInput(); var input2 = new SliderInput(); input1.DisplayConditions.Add(new InputDisplayCondition(input2, InputValueCondition.Equals, "a", false)); var group = new InputGroup { Inputs = { input1 } }; var copy = group.Copy(false); Assert.AreSame(input2, input1.DisplayConditions.Single().Input); Assert.AreSame(input1, group.Inputs.Single()); Assert.AreNotSame(group.Inputs.Single(), copy.Inputs.Single()); Assert.AreNotSame(input2, copy.Inputs.Single().DisplayConditions.Single().Input); Assert.AreEqual(input2.Id, copy.Inputs.Single().DisplayConditions.Single().Input.Id); }
public void DisplayConditionInputCopyTest2() { var input1 = new SliderInput(); var input2 = new SliderInput(); input2.DisplayConditions.Add(new InputDisplayCondition(input2, InputValueCondition.Equals, "a", false)); var group = new InputGroup { Inputs = { input1, input2 } }; var copy = new InputGroup(group, false); Assert.AreSame(input2, input2.DisplayConditions.Single().Input); Assert.AreSame(input1, group.Inputs.Skip(0).Take(1).Single()); Assert.AreSame(input2, group.Inputs.Skip(1).Take(1).Single()); Assert.AreNotSame(input1, copy.Inputs.Skip(0).Take(1).Single()); Assert.AreNotSame(input2, copy.Inputs.Skip(1).Take(1).Single()); Assert.AreSame(copy.Inputs.Skip(1).Take(1).Single(), copy.Inputs.Skip(1).Take(1).Single().DisplayConditions.Single().Input); }
private void InitPowerSelect(TapGestureRecognizer gesture) { SearchBox = new EbXTextBox { IsReadOnly = this.ReadOnly, Placeholder = $"Search {this.Label}...", FontSize = 15, BorderColor = Color.Transparent }; SearchBox.Focused += async(sender, args) => await OnSearchBoxFocused();; Label icon = new Label { Style = (Style)HelperFunctions.GetResourceValue("SSIconLabel"), GestureRecognizers = { gesture } }; XControl = new InputGroup(SearchBox, icon) { XBackgroundColor = Background }; }
/// <summary> /// /// </summary> /// <param name="buyEntityList">本期进项明细</param> /// <param name="sellEntityList">本期销项明细</param> /// <param name="mappingEntityList">商务报表</param> /// <returns></returns> private static InputGroup ToInputGroup(List <BuyEntity> buyEntityList, List <SellEntity> sellEntityList, List <MappingEntity> mappingEntityList) { InputGroup returnValue = new InputGroup(); if (buyEntityList != null && buyEntityList.Count > 0) { returnValue.BuyModelList = ToModel(buyEntityList); } if (sellEntityList != null && sellEntityList.Count > 0) { returnValue.SellModelList = ToModel(sellEntityList); } if (mappingEntityList != null && mappingEntityList.Count > 0) { returnValue.MappingModelList = ToModel(mappingEntityList); } return(returnValue); }
void InitializeMenuInputs() { InputGroup group = new InputGroup(); //push escape -> call EscapeHandler InputUnit unit = new InputUnit { InputCheckerByKey = Input.GetKeyDown, Key = KeyCode.Escape }; unit.Pushed += EscapeHandler; group.m_inputUnits.Add(InputManager.Escape, unit); //push Tab -> call InventoryHandler unit = new InputUnit { InputCheckerByKey = Input.GetKeyDown, Key = KeyCode.Tab }; unit.Pushed += InventoryHandler; group.m_inputUnits.Add(InputManager.Inventory, unit); m_inputGroups.Add(InputManager.MenuGroup, group); }
void InitializePlacementInputs() { InputGroup group = new InputGroup(); //push 'F' -> call placement method InputUnit unit = new InputUnit { InputCheckerByKey = Input.GetKeyDown, Key = KeyCode.F }; unit.Pushed += m_controller.ObjectPlacement; group.m_inputUnits.Add(InputManager.PlaceObject, unit); //push 'R' -> call rotating method in placement mode unit = new InputUnit { InputCheckerByKey = Input.GetKey, Key = KeyCode.R }; unit.Pushed += m_controller.ObjectRotating; group.m_inputUnits.Add(InputManager.RotateObject, unit); m_inputGroups.Add(InputManager.PlacementGroup, group); }
public void PromptForInputsAsync(string windowTitle, IEnumerable <Input> inputs, CancellationToken?cancellationToken, Action <List <Input> > callback) { InputGroup inputGroup = new InputGroup(windowTitle); foreach (Input input in inputs) { inputGroup.Inputs.Add(input); } PromptForInputsAsync(null, false, DateTimeOffset.MinValue, new InputGroup[] { inputGroup }.ToList(), cancellationToken, inputGroups => { if (inputGroups == null) { callback(null); } else { callback(inputGroups.SelectMany(g => g.Inputs).ToList()); } }); }
public void ScriptCopyNewIdTest() { ScriptProbe probe = new ScriptProbe(); ScriptRunner runner = new ScriptRunner("test", probe); Script script = new Script(runner); InputGroup group = new InputGroup(); Input input1 = new SliderInput(); Input input2 = new SliderInput(); group.Inputs.Add(input1); group.Inputs.Add(input2); script.InputGroups.Add(group); Script copy = script.Copy(true); Assert.AreSame(script.Runner, copy.Runner); Assert.AreNotEqual(script.Id, copy.Id); Assert.AreEqual(script.InputGroups.Single().Id, copy.InputGroups.Single().Id); Assert.AreEqual(script.InputGroups.Single().Inputs.First().Id, copy.InputGroups.Single().Inputs.First().Id); Assert.AreEqual(script.InputGroups.Count, copy.InputGroups.Count); Assert.AreEqual(script.InputGroups.Single().Inputs.Count, copy.InputGroups.Single().Inputs.Count); }
private void InitSimpleSelect(TapGestureRecognizer gesture) { picker = new EbXPicker { Title = $"Select {this.Label}", ItemsSource = this.Options, ItemDisplayBinding = new Binding("DisplayName"), IsEnabled = !this.ReadOnly, BorderColor = Color.Transparent }; picker.SelectedIndexChanged += (sender, e) => this.ValueChanged(); Label icon = new Label { Style = (Style)HelperFunctions.GetResourceValue("PSIconLabel"), GestureRecognizers = { gesture } }; XControl = new InputGroup(picker, icon) { XBackgroundColor = Background, HasShadow = false }; }
void InitializeMovingInputs() { InputGroup group = new InputGroup(); InputUnit unit = new InputUnit { InputCheckerByKey = Input.GetKey, Key = KeyCode.W }; unit.Pushed += m_movingController.MoveForward; group.m_inputUnits.Add(InputManager.MoveForward, unit); unit = new InputUnit { InputCheckerByKey = Input.GetKey, Key = KeyCode.S }; unit.Pushed += m_movingController.MoveBack; group.m_inputUnits.Add(InputManager.MoveBack, unit); unit = new InputUnit { InputCheckerByKey = Input.GetKey, Key = KeyCode.A }; unit.Pushed += m_movingController.MoveLeft; group.m_inputUnits.Add(InputManager.MoveLeft, unit); unit = new InputUnit { InputCheckerByKey = Input.GetKey, Key = KeyCode.D }; unit.Pushed += m_movingController.MoveRight; group.m_inputUnits.Add(InputManager.MoveRight, unit); unit = new InputUnit { InputCheckerByKey = Input.GetKeyDown, Key = KeyCode.Space }; unit.Pushed += m_movingController.Jump; group.m_inputUnits.Add(InputManager.Jump, unit); m_inputGroups.Add(InputManager.MovingGroup, group); }
public void getImageWeightsTest() { Image image = Image.FromFile(@"C:\Users\Sean\Pictures\test.png"); // Initialize to an appropriate value InputGroup[] inputGroups = new InputGroup[] {new InputGroup(InputGroupType.Grid,2)}; // Initialize to an appropriate value double[] expected = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.4, 0.4, 0.4, 0.4, 1.0, 1.0, 1.0, 1.0, 1.0, 0.4, 0.4, 0.4, 0.4, 0.4, 1.0, 1.0, 1.0, 1.0, 1.0, 0.4, 0.4, 0.4, 0.4, 0.4, 1.0, 1.0, 1.0, 1.0, 1.0, 0.4, 0.4, 0.4, 0.4, 0.4, 1.0, 1.0, 1.0, 1.0, 1.0, 0.4, 0.4, 0.4, 0.4, 0.4, 1.0, 1.0, 1.0, 1.0, 1.0 }; // Initialize to an appropriate value double[] actual; actual = Utils.getImageWeights(image, inputGroups); for (int i = 0; i < actual.Length; i++) { Assert.AreEqual(actual[i], expected[i]); } }
public void Add(InputGroup selectedGroup, InputGroup group) => Add(Map ? Map.Groups.IndexOf(selectedGroup) : -1, group);
public void Add(InputGroup group) => Add(-1, group);
public ScriptInputGroupsPage(Script script) { Title = "Input Groups"; ListView groupsList = new ListView(ListViewCachingStrategy.RecycleElement); groupsList.ItemTemplate = new DataTemplate(typeof(TextCell)); groupsList.ItemTemplate.SetBinding(TextCell.TextProperty, nameof(InputGroup.Name)); groupsList.ItemsSource = script.InputGroups; groupsList.ItemTapped += async(o, e) => { if (groupsList.SelectedItem == null) { return; } InputGroup selectedInputGroup = groupsList.SelectedItem as InputGroup; int selectedIndex = script.InputGroups.IndexOf(selectedInputGroup); List <string> actions = new string[] { "Edit", "Copy", "Delete" }.ToList(); if (selectedIndex < script.InputGroups.Count - 1) { actions.Insert(0, "Move Down"); } if (selectedIndex > 0) { actions.Insert(0, "Move Up"); } string selectedAction = await DisplayActionSheet(selectedInputGroup.Name, "Cancel", null, actions.ToArray()); if (selectedAction == "Move Up") { script.InputGroups.Move(selectedIndex, selectedIndex - 1); } else if (selectedAction == "Move Down") { script.InputGroups.Move(selectedIndex, selectedIndex + 1); } else if (selectedAction == "Edit") { List <InputGroup> previousInputGroups = script.InputGroups.Where((inputGroup, index) => index < selectedIndex).ToList(); ScriptInputGroupPage inputGroupPage = new ScriptInputGroupPage(selectedInputGroup, previousInputGroups); await Navigation.PushAsync(inputGroupPage); groupsList.SelectedItem = null; } else if (selectedAction == "Copy") { script.InputGroups.Add(selectedInputGroup.Copy(true)); } else if (selectedAction == "Delete") { if (await DisplayAlert("Delete " + selectedInputGroup.Name + "?", "This action cannot be undone.", "Delete", "Cancel")) { script.InputGroups.Remove(selectedInputGroup); groupsList.SelectedItem = null; } } }; ToolbarItems.Add(new ToolbarItem(null, "plus.png", () => { script.InputGroups.Add(new InputGroup { Name = "New Input Group" }); })); Content = groupsList; }
public InputGroupPage(InputGroup inputGroup, int stepNumber, int totalSteps, bool canNavigateBackward, bool showCancelButton, string nextButtonTextOverride, CancellationToken?cancellationToken, string cancelConfirmation, string incompleteSubmissionConfirmation, string submitConfirmation, bool displayProgress) { _canNavigateBackward = canNavigateBackward; _displayedInputCount = 0; _responseTaskCompletionSource = new TaskCompletionSource <NavigationResult>(); StackLayout contentLayout = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(10, 20, 10, 20), Children = { new Label { Text = inputGroup.Name, FontSize = 20, HorizontalOptions = LayoutOptions.CenterAndExpand } } }; #region progress bar if (displayProgress) { float progress = (stepNumber - 1) / (float)totalSteps; contentLayout.Children.Add(new Label { Text = "Progress: " + Math.Round(100 * progress) + "%", FontSize = 15, HorizontalOptions = LayoutOptions.CenterAndExpand }); contentLayout.Children.Add(new ProgressBar { Progress = progress, HorizontalOptions = LayoutOptions.FillAndExpand }); } #endregion #region required field label if (inputGroup.Inputs.Any(input => input.Display && input.Required)) { contentLayout.Children.Add(new Label { Text = "Required fields are indicated with *", FontSize = 15, TextColor = Color.Red, HorizontalOptions = LayoutOptions.Start }); } #endregion #region inputs List <Input> displayedInputs = new List <Input>(); int viewNumber = 1; int inputSeparatorHeight = 10; foreach (Input input in inputGroup.Inputs) { if (input.Display) { View inputView = input.GetView(viewNumber); if (inputView != null) { // add media view to inputs that have media attached // this is done here because the media needs to be attached on appearing and disposed on disappearing if (input is MediaInput mediaInput && mediaInput.HasMedia) { Appearing += async(s, e) => { await mediaInput.InitializeMediaAsync(); }; Disappearing += async(s, e) => { await mediaInput.DisposeMediaAsync(); }; } // frame all enabled inputs that request a frame if (input.Enabled && input.Frame) { inputView = new Frame { Content = inputView, BorderColor = Color.Accent, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start, HasShadow = false, Padding = new Thickness(10) }; } // add some vertical separation between inputs if (_displayedInputCount > 0) { contentLayout.Children.Add(new BoxView { Color = Color.Transparent, HeightRequest = inputSeparatorHeight }); } contentLayout.Children.Add(inputView); displayedInputs.Add(input); if (input.DisplayNumber) { viewNumber++; } _displayedInputCount++; } } } // add final separator if we displayed any inputs if (_displayedInputCount > 0) { contentLayout.Children.Add(new BoxView { Color = Color.Transparent, HeightRequest = inputSeparatorHeight }); } #endregion StackLayout navigationStack = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, }; #region previous/next buttons StackLayout previousNextStack = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand }; // add a prevous button if we're allowed to navigate back if (_canNavigateBackward) { Button previousButton = new Button { HorizontalOptions = LayoutOptions.FillAndExpand, FontSize = 20, Text = "Previous" }; previousButton.Clicked += (o, e) => { _responseTaskCompletionSource.TrySetResult(NavigationResult.Backward); }; previousNextStack.Children.Add(previousButton); } Button nextButton = new Button { HorizontalOptions = LayoutOptions.FillAndExpand, FontSize = 20, Text = stepNumber < totalSteps ? "Next" : "Submit" #if UI_TESTING // set style id so that we can retrieve the button when UI testing , StyleId = "NextButton" #endif }; if (nextButtonTextOverride != null) { nextButton.Text = nextButtonTextOverride; } nextButton.Clicked += async(o, e) => { if (!inputGroup.Valid && inputGroup.ForceValidInputs) { await DisplayAlert("Mandatory", "You must provide values for all required fields before proceeding.", "Back"); } else { string confirmationMessage = ""; NavigationResult navigationResult = NavigationResult.Forward; // warn about incomplete inputs if a message is provided if (!inputGroup.Valid && !string.IsNullOrWhiteSpace(incompleteSubmissionConfirmation)) { confirmationMessage += incompleteSubmissionConfirmation; } if (nextButton.Text == "Submit") { // confirm submission if a message is provided if (!string.IsNullOrWhiteSpace(submitConfirmation)) { // if we already warned about incomplete fields, make the submit confirmation sound natural. if (!string.IsNullOrWhiteSpace(confirmationMessage)) { confirmationMessage += " Also, this is the final page. "; } // confirm submission confirmationMessage += submitConfirmation; } navigationResult = NavigationResult.Submit; } if (string.IsNullOrWhiteSpace(confirmationMessage) || await DisplayAlert("Confirm", confirmationMessage, "Yes", "No")) { _responseTaskCompletionSource.TrySetResult(navigationResult); } } }; previousNextStack.Children.Add(nextButton); navigationStack.Children.Add(previousNextStack); #endregion #region cancel button and token if (showCancelButton) { Button cancelButton = new Button { HorizontalOptions = LayoutOptions.FillAndExpand, FontSize = 20, Text = "Cancel" }; // separate cancel button from previous/next with a thin visible separator navigationStack.Children.Add(new BoxView { Color = Color.Gray, HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 0.5 }); navigationStack.Children.Add(cancelButton); cancelButton.Clicked += async(o, e) => { if (string.IsNullOrWhiteSpace(cancelConfirmation) || await DisplayAlert("Confirm", cancelConfirmation, "Yes", "No")) { _responseTaskCompletionSource.TrySetResult(NavigationResult.Cancel); } }; } contentLayout.Children.Add(navigationStack); // allow the cancellation token to set the result of this page cancellationToken?.Register(() => { _responseTaskCompletionSource.TrySetResult(NavigationResult.Cancel); }); #endregion Appearing += (o, e) => { // the page has appeared so mark all inputs as viewed foreach (Input displayedInput in displayedInputs) { displayedInput.Viewed = true; } }; Disappearing += async(o, e) => { // the page is disappearing, so dispose of inputs foreach (Input displayedInput in displayedInputs) { displayedInput.OnDisappearing(await ResponseTask); } }; Content = new ScrollView { Content = contentLayout }; }
/// <summary>add a new input and return its idx and the idx for the group it is in. will return groupIdx=-1 and inputIdx=-1 if the inputdef was not added</summary> public InputIdxCache AddInput(InputDefinition definition) { if (!definition.isUsed) return new InputIdxCache() { groupIdx = -1, inputIdx = -1 }; // not actually used, dont add InputIdxCache idx = new InputIdxCache(); // get the group idx, else add group idx.groupIdx = GetInputGroupIdx(definition.groupName); if (idx.groupIdx < 0) { InputGroup group = new InputGroup() { name = definition.groupName }; inputGroups.Add(group); idx.groupIdx = inputGroups.IndexOf(group); } // check if the input was already raged before and show warning if so (someone forgot to unload an input binder) int inputIdx = GetInputIdx(idx.groupIdx, definition.inputName); if (inputIdx < 0) { inputGroups[idx.groupIdx].inputs.Add(definition); idx.inputIdx = inputGroups[idx.groupIdx].inputs.IndexOf(definition); if (definition.callback != null) callbackList.Add(definition); // add to special list too else if (definition.isCustom && !string.IsNullOrEmpty(definition.eventGUID)) { RPGEvent e = UniRPGGlobal.DB.GetEvent(new GUID(definition.eventGUID)); if (e != null) { definition.cachedEvent = e; callbackList.Add(definition); } } } else { if (!definition.isCustom) Debug.LogError(string.Format("InputBinder Error. It seems like you are trying to load an InputBinder that is already loaded. Forgot to unload it when you should have? {0} :: {1}", definition.groupName, definition.inputName)); return new InputIdxCache() { groupIdx = -1, inputIdx = -1 }; } return idx; }
public InputGroup[] GetInputGroups() { string query = "SELECT * " + "FROM InputGroups; ";// + //"ORDER BY Index;"; DataSet result = database.RunQuery(query); if (result.Tables.Count > 0) { InputGroup[] inputGroups = new InputGroup[result.Tables[0].Rows.Count]; for (int i = 0; i < result.Tables[0].Rows.Count; i++) { DataRow row = result.Tables[0].Rows[i]; InputGroup inputGroup = new InputGroup( (InputGroupType)Convert.ToInt32(row["Type"]), Convert.ToInt32(row["Segments"])); inputGroups[i] = inputGroup; } return inputGroups; } return new InputGroup[0]; }