void Initialize() { pickerView.Delegate = new PickerDelegate(this); pickerView.DataSource = new PickerDataSource(this); StyleButton(addButton); StyleButton(subtractButton); StyleButton(setButton); StyleButton(NullButton); StylePadButton(NumberButton0); StylePadButton(NumberButton1); StylePadButton(NumberButton2); StylePadButton(NumberButton3); StylePadButton(NumberButton4); StylePadButton(NumberButton5); StylePadButton(NumberButton6); StylePadButton(NumberButton7); StylePadButton(NumberButton8); StylePadButton(NumberButton9); StylePadButton(ClearButton); StyleButton(SwapButton); SwapButton.SetImage(UIExtensions.GetSmallIcon("sort"), UIControlState.Normal); NullButton.Hidden = !this.Nullable; _NumPadMode = NSUserDefaults.StandardUserDefaults.BoolForKey("NumPadMode"); UpdatePadView(); }
void OnButtonClick(SwapButton button) { if (button1 == null) { button1 = button; } else if (button == button1) { button1 = null; button.Default(); } else if (button2 == null) { button2 = button; Swap(); } }
void Swap() { Vector3 button2Pos = button2.transform.localPosition; int button2ChildIndex = button2.transform.GetSiblingIndex(); button2.transform.SetSiblingIndex(button1.transform.GetSiblingIndex()); button1.transform.SetSiblingIndex(button2ChildIndex); button2.transform.localPosition = button1.transform.localPosition; button1.transform.localPosition = button2Pos; button1.Default(); button2.Default(); if (button1.link != null && button2.link != null) { Vector3 button2LinkPos = button2.link.transform.localPosition; int button2LinkChildIndex = button2.link.transform.GetSiblingIndex(); button2.link.transform.SetSiblingIndex(button1.link.transform.GetSiblingIndex()); button1.link.transform.SetSiblingIndex(button2LinkChildIndex); button2.link.transform.localPosition = button1.link.transform.localPosition; button1.link.transform.localPosition = button2LinkPos; } int button1Index = buttonList.FindIndex((obj) => obj == button1); int button2Index = buttonList.FindIndex((obj) => obj == button2); buttonList.Insert(button1Index, button2); buttonList.RemoveAt(button1Index + 1); buttonList.Insert(button2Index, button1); buttonList.RemoveAt(button2Index + 1); button1 = null; button2 = null; Complete(); }