/// <summary> /// Determines what happens when a location is clicked /// </summary> /// <param name="sender">The object which sent the click</param> /// <param name="e">Event arguments</param> private void location_Click(object sender, RoutedEventArgs e) { TransparentButton tb = sender as TransparentButton; int id = tb.data; mc.handlePotentAction(MainController.CHANGE_LOC, id); }
/// <summary> /// Валидация для кнопки интерфейса /// </summary> private void ButtonValidate() { //Если все контролы не выделены пользователем и все отфотканы if (_imagesControlList.Values.FirstOrDefault(pb => (pb.IsNeedReFoting)) == null && _fotoVulae == _currentFotoIndex) { //Все отфоткано, можно валить отсюда _isFinshedFoting = true; UiElementsActivatesThenPhotingFinished(); } else { //Либо еще не все фотки сделаны, либо пользователь пометил что то на перефотографирование _isFinshedFoting = false; if (_imagesControlList.Values.FirstOrDefault(pb => (pb.IsNeedReFoting)) != null) { //Пользователь пометил фотку на перефотографирование pbStartBtn.Enabled = true; if (_transpBtnStart != null) { _transpBtnStart.Dispose(); } _transpBtnStart = new TransparentButton(this, pbStartBtn, _btnStartActive, _btnStartDown, ClickOnMainButton); } else { if (pbStartBtn.Enabled)//Что бы попали сюда только раз { UiElementDiactivateThenPhotingStart(); } } } }
/// <summary> /// Determines what happens when a sublocation is clicked /// </summary> /// <param name="sender">The sender for this event</param> /// <param name="e">Event arguments</param> private void SublocationClicked(object sender, RoutedEventArgs e) { TransparentButton sbtn = sender as TransparentButton; if (sbtn != null) { int index = Sublocations.Children.IndexOf(sbtn); if (index + 1 == _UIModel.SublocationModel.CurrentSublocation) { if (!_UIModel.SublocationModel.Scavenged[index] && DrawYesNoOption("Do you wish to scavenge the location?")) { mc.handlePotentAction(MainController.SCAVENGE, 0); } else if (!_UIModel.SublocationModel.Scavenged[index]) { DrawDialogueBox("You are already at that location"); } } else if (DrawYesNoOption("Are you sure you wish to move to that location?")) { mc.handlePotentAction(MainController.CHANGE_SUB, index + 1); UpdatePlayer(); } } }
private void MailSendView_Load(object sender, EventArgs e) { //Проинициализировать кнопки _transBtnSend = new TransparentButton(this, pbSend, _btnSendActive, _btnSendDown, SendEmail); new TransparentButton(this, pbNext, _btnNextActive, _btnNextDown, ClickNextButton); TransparentAdder.SetTransparentControl(this, pbFone, _imgMailBackground); //Фон под текстбоксом ввода емейла TransparentAdder.SetTransparentControl(this, pbNote, _textSendToEmail); //Текст над полем ввода эмейла }
public OverlayPurchase(RelativeLayout parentLayout) : base(parentLayout) { Debug.LogToFileMethod(); Analytics.TrackPage(Analytics.PAGE_PURCHASE); // shadow to darken display imgOverlay = new Image(); imgOverlay.Source = "@drawable/ovr_shadow.png"; imgOverlay.SizeChanged += OnLayoutSizeChanged; imgOverlay.Aspect = Aspect.Fill; imgOverlay.WidthRequest = layout.Width; imgOverlay.HeightRequest = layout.Height; // app store button message imgMessage = new Image(); imgMessage.Source = Localization.ovr_purchase; imgMessage.SizeChanged += OnLayoutSizeChanged; // app store button btnAppStore = new TransparentButton(); btnAppStore.SizeChanged += OnLayoutSizeChanged; btnAppStore.Clicked += OnAppStoreClicked; // on touch outside app store button -> cancel tgrCancel = new TapGestureRecognizer(); tgrCancel.Tapped += OnCancelTapped; imgOverlay.GestureRecognizers.Add(tgrCancel); imgMessage.GestureRecognizers.Add(tgrCancel); layout.Children.Add ( imgOverlay, Constraint.RelativeToParent(parent => parent.Width * 0.5 - imgOverlay.Width * 0.5), Constraint.RelativeToParent(parent => parent.Height * 0.5 - imgOverlay.Height * 0.5) ); layout.Children.Add ( imgMessage, Constraint.RelativeToParent(parent => parent.Width * 0.5 - imgMessage.Width * 0.5), Constraint.RelativeToParent(parent => parent.Height * 0.5 - imgMessage.Height * 0.5) ); layout.Children.Add ( btnAppStore, Constraint.RelativeToView(imgMessage, (parent, view) => view.X + view.Width * 0.25), Constraint.RelativeToView(imgMessage, (parent, view) => view.Y + view.Height * 0.75), Constraint.RelativeToView(imgMessage, (parent, view) => view.Width * 0.5), Constraint.RelativeToView(imgMessage, (parent, view) => view.Height * 0.25) ); }
/// <summary> /// Деактивировать элементы интерфейса, когда начинаем фотографирование /// </summary> private void UiElementDiactivateThenPhotingStart() { pbStartBtn.Enabled = false; if (_transpBtnStart != null) { _transpBtnStart.Dispose(); } _transpBtnStart = new TransparentButton(this, pbStartBtn, _btnStartNotActive, null, ClickOnMainButton); pbUp.Enabled = false; pbDown.Enabled = false; }
/// <summary> /// Updates the data behind the sublocation map /// </summary> /// <param name="sublocation">The sublocation to update</param> /// <param name="mode">The mode for the update, /// 0 = change current location to sublocation passed /// 1 = update sublocation so that it is scavenged</param> public void UpdateSublocationMap(int sublocation, int mode) { if (mode == 0) { _UIModel.SublocationModel.CurrentSublocation = sublocation; } else if (mode == 1) { TransparentButton tb = Sublocations.Children[sublocation - 1] as TransparentButton; tb.ImageSwitch = true; _UIModel.SublocationModel.Scavenged[sublocation - 1] = true; } }
private void FotoMakeView_Load(object sender, EventArgs e) { pbOne.Visible = false; pbTwo.Visible = false; pbThree.Visible = false; //Доавить подписчика на источник фотографий (фотки отправлять в эту форму, делегат SetLiveViewCadr) if (_cameraService.IsActivated) { _cameraService.AddSubscriber(SetLiveViewCadr); } _imagesControlList.Add(PhotoCadrNumber.FistCadr, new PictureBoxCoverage(pbGotFoto1, _serviceProvider)); _imagesControlList.Add(PhotoCadrNumber.SecondCadr, new PictureBoxCoverage(pbGotFoto2, _serviceProvider)); _imagesControlList.Add(PhotoCadrNumber.ThirdCadr, new PictureBoxCoverage(pbGotFoto3, _serviceProvider)); _imagesControlList.Add(PhotoCadrNumber.FourthCadr, new PictureBoxCoverage(pbGotFoto4, _serviceProvider)); _imagesControlList.Add(PhotoCadrNumber.FifthCadr, new PictureBoxCoverage(pbGotFoto5, _serviceProvider)); _imagesControlList.Add(PhotoCadrNumber.SixthCadr, new PictureBoxCoverage(pbGotFoto6, _serviceProvider)); _imagesControlList.Add(PhotoCadrNumber.SeventhCadr, new PictureBoxCoverage(pbGotFoto7, _serviceProvider)); _imagesControlList.Add(PhotoCadrNumber.EighthCadr, new PictureBoxCoverage(pbGotFoto8, _serviceProvider)); //Скрыть текст сверху и снизу, он должен появиться только после окончания фотографирования pbTextBottom.Hide(); pbTextTitle.Hide(); //Сделать кнопку Далее _transpBtnStart = new TransparentButton(this, pbStartBtn, _btnStartActive, _btnStartDown, ClickOnMainButton); //Приляпаем картинки на стрелки вверх/вниз TransparentAdder.SetTransparentControl(this, pbUp, _btnRowUp); TransparentAdder.SetTransparentControl(this, pbDown, _btnRowDown); // Сделать прозрачными PictureBox с фотками SetTransparentToPictBox(); //Сделать прозрачными PictureBox с цифрами TransparentAdder.SetTransparentControl(this, pbOne, _imgOne); TransparentAdder.SetTransparentControl(this, pbTwo, _imgTwo); TransparentAdder.SetTransparentControl(this, pbThree, _imgThree); //Сделать прозрачным Панель с фотками TransparentAdder.SetTransparentControl(this, panel1, null); }
/// <summary> /// Активировать элементы интерфейса, когда закончили фоткать /// </summary> private void UiElementsActivatesThenPhotingFinished() { pbStartBtn.Enabled = true; if (_transpBtnStart != null) { _transpBtnStart.Dispose(); } _transpBtnStart = new TransparentButton(this, pbStartBtn, _btnNextActive, _btnNextDown, ClickOnMainButton); pbUp.Enabled = true; pbDown.Enabled = true; //Включить 2 текса сверху и снизу pbTextBottom.Show(); pbTextTitle.Show(); TransparentAdder.SetTransparentControl(this, pbTextBottom, _imgTextBottomSlide3); TransparentAdder.SetTransparentControl(this, pbTextTitle, _imgTextTitleSlide3); }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e) { base.OnElementChanged(e); if (Control != null) { var button = e.NewElement; btn = e.NewElement as TransparentButton; // Create a drawable for the button's normal state _normal = new Android.Graphics.Drawables.GradientDrawable(); if (button.BackgroundColor.R == -1.0 && button.BackgroundColor.G == -1.0 && button.BackgroundColor.B == -1.0) { _normal.SetColor(Android.Graphics.Color.ParseColor(Globals.WHITE)); } else if (button.BackgroundColor != Color.Black) { _normal.SetColor(button.BackgroundColor.ToAndroid()); } else { _normal.SetColor(Android.Graphics.Color.ParseColor(Globals.WHITE)); } _normal.SetCornerRadius(10); // Create a drawable for the button's pressed state _pressed = new Android.Graphics.Drawables.GradientDrawable(); var highlight = Context.ObtainStyledAttributes(new int[] { Android.Resource.Attribute.ColorActivatedHighlight }).GetColor(0, Android.Graphics.Color.ParseColor(Globals.RED)); _pressed.SetColor(highlight); // Add the drawables to a state list and assign the state list to the button var sld = new StateListDrawable(); sld.AddState(new int[] { Android.Resource.Attribute.StatePressed }, _pressed); sld.AddState(new int[] { }, _normal); Control.SetBackgroundDrawable(sld); } }
public void Dispose() { if (isDisposed) { return; } isDisposed = true; layout.Children.Remove(btnAppStore); layout.Children.Remove(imgMessage); layout.Children.Remove(imgOverlay); layout = null; //imgOverlay.GestureRecognizers.Remove(tgrCancel); // FIXME crash if called from within touch event handler imgOverlay = null; //imgMessage.GestureRecognizers.Remove(tgrCancel); // FIXME crash if called from within touch event handler imgMessage = null; tgrCancel.Tapped -= OnCancelTapped; tgrCancel = null; btnAppStore.Clicked -= OnAppStoreClicked; btnAppStore = null; AppStore.Instance.SetListener(null); }
void Dispose() { if (isDisposed) { return; } isDisposed = true; layout.Children.Remove(btnHelp); layout.Children.Remove(btnOk); layout.Children.Remove(imgMessage); layout.Children.Remove(imgOverlay); layout = null; //imgOverlay.GestureRecognizers.Remove(tgrCancel); // FIXME crash if called from within touch event handler imgOverlay = null; //imgMessage.GestureRecognizers.Remove(tgrCancel); // FIXME crash if called from within touch event handler imgMessage = null; tgrCancel.Tapped -= OnCancelTapped; tgrCancel = null; btnOk.Clicked -= OnButtonOkClicked; btnOk = null; btnHelp.Clicked -= OnButtonHelpClicked; btnHelp = null; }
/// <summary> /// Initialises the sublocation map /// </summary> /// <param name="subloc">List of sublocation for this map</param> /// <param name="currentSubLocation">The current sublocation which the player is at</param> public void InitialiseSublocationMap(List <Sublocation> subloc, int currentSubLocation) { List <String> imagePaths = subloc.Select(value => value.GetImagePath()).ToList(); List <bool> scavenged = subloc.Select(value => value.GetScavenged()).ToList(); _UIModel.SublocationModel.Scavenged = scavenged; _UIModel.SublocationModel.CurrentSublocation = currentSubLocation; Sublocations.Children.Clear(); for (int i = 0; i < subloc.Count; i++) { BitmapImage sublocationIcon = new BitmapImage(); sublocationIcon.BeginInit(); //Cannot locate resource 'longroadhome;resources/civic-1.png sublocationIcon.UriSource = new Uri("pack://application:,,,/Resources/" + subloc[i].GetImagePath() + ".png"); //sublocationIcon.UriSource = new Uri("pack://application:,,,/Resources/Civic_1.png"); sublocationIcon.EndInit(); BitmapImage scavengedIcon = new BitmapImage(); scavengedIcon.BeginInit(); scavengedIcon.UriSource = new Uri("pack://application:,,,/Resources/" + subloc[i].GetImagePath() + "_Scavenged.png"); scavengedIcon.EndInit(); TransparentButton button = new TransparentButton(); button.EnabledImage = sublocationIcon; button.DisabledImage = scavengedIcon; button.DisplayedImage = sublocationIcon; button.ImageSwitch = scavenged[i]; button.Click += new RoutedEventHandler(SublocationClicked); Grid.SetRow(button, 0); Grid.SetColumn(button, i); Grid.SetRowSpan(button, 2); Sublocations.Children.Add(button); } }
/// <summary> /// Initialise the world map /// </summary> /// <param name="worldMapBM">Bit representing the background of the map</param> /// <param name="buttonAreas">The Points on the map for the location buttons</param> public void InitialiseWorldMap(System.Drawing.Bitmap worldMapBM, SortedList <int, System.Windows.Point> buttonAreas) { this.worldMapBM = worldMapBM; this.buttonAreas = buttonAreas; worldMapButtons = new SortedList <int, TransparentButton>(); // Get images for unvisited and visited locations BitmapImage unvisitedBMI = new BitmapImage(); unvisitedBMI.BeginInit(); unvisitedBMI.UriSource = new Uri("pack://application:,,,/Resources/unvisited_location.png"); unvisitedBMI.EndInit(); BitmapImage visitedBMI = new BitmapImage(); visitedBMI.BeginInit(); visitedBMI.UriSource = new Uri("pack://application:,,,/Resources/visited_location.png"); visitedBMI.EndInit(); // Add buttons for each button area foreach (var kvpair in buttonAreas) { TransparentButton tb = new TransparentButton(); tb.EnabledImage = unvisitedBMI; tb.DisabledImage = visitedBMI; tb.DisplayedImage = unvisitedBMI; tb.data = kvpair.Key; tb.ImageSwitch = false; tb.Click += location_Click; Canvas.SetLeft(tb, kvpair.Value.X - 5); Canvas.SetTop(tb, kvpair.Value.Y - 4); worldMap.Children.Add(tb); worldMapButtons.Add(kvpair.Key, tb); } // Set up background mapView.Source = Bitmap2BitmapSource(worldMapBM); worldMap.Height = mapView.Source.Height * 1.65; worldMap.Width = mapView.Source.Width * 1.65; // Set start location to visited and set the character pointer to that location button TransparentButton startButton; if (worldMapButtons.TryGetValue(0, out startButton)) { startButton.ImageSwitch = true; } Point characterLocation; if (buttonAreas.TryGetValue(0, out characterLocation)) { zoomBorder.charLoc = characterLocation; zoomBorder.Reset(); BitmapImage temp = new BitmapImage(); temp.BeginInit(); temp.UriSource = new Uri("pack://application:,,,/Resources/Character-stand.png"); temp.EndInit(); characterPointer.Source = temp; characterPointer.Height = 35; characterPointer.Width = 10; Canvas.SetLeft(characterPointer, characterLocation.X + 4); Canvas.SetTop(characterPointer, characterLocation.Y - 23); worldMap.Children.Remove(characterPointer); worldMap.Children.Add(characterPointer); } }
public RadioButtonElement(TransparentButton transparentButton, SpriteText spriteText, Sprite sprite) { TransparentButton = transparentButton; SpriteText = spriteText; Sprite = sprite; }