private async void BtnConfirm_Click(object sender, RoutedEventArgs e)
        {
            if (picRef.Equals(defPicture))
            {
                this.Close();
            }
            if (!string.IsNullOrWhiteSpace(picRef))
            {
                try
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        Picture.Picture1 = picRef;
                    }));
                    await Task.Run(() => adminInterfacePictures.UpdateAsync(Picture.Id, Picture));

                    this.Close();
                }
                catch (Exception ex)
                {
                    popup        = ConfigurePopup.Configure(popup, ex.Message, BtnConfirm, PlacementMode.Top);
                    popup.IsOpen = true;
                }
            }
            else
            {
                popup        = ConfigurePopup.Configure(popup, "No picture was selected", BtnConfirm, PlacementMode.Top);
                popup.IsOpen = true;
            }
        }
Example #2
0
        private async void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (LvAll.SelectedItem != null)
            {
                try
                {
                    var c   = LvAll.SelectedItem as Country;
                    var res = await RemoveEntity.Remove <Country>(AdminInterface, c);

                    if (res)
                    {
                        await Task.Run(() => RefreshList());
                    }
                    //await Task.Run(() => AdminInterface.RemoveAsync(c));
                }
                catch (Exception ex)
                {
                    popup        = ConfigurePopup.Configure(popup, ex.Message, BtnDelete, PlacementMode.Bottom);
                    popup.IsOpen = true;
                }
            }
            else
            {
                popup        = ConfigurePopup.Configure(popup, "Select item first!", LvAll, PlacementMode.Right);
                popup.IsOpen = true;
            }
        }
 private void BtnSetPicture_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(Tb.Text) && !Tb.Text.Equals(defPicture))
     {
         picRef = Tb.Text;
     }
     else
     {
         var od = new OpenFileDialog();
         popup.IsOpen = false;
         od.Filter    = "Image Files|*.jpg;*.jpeg;*.png;*.bmp;";
         if ((bool)od.ShowDialog())
         {
             picRef = od.FileName;
         }
         else
         {
             popup        = ConfigurePopup.Configure(popup, "No picture was selected", BtnSetPicture, PlacementMode.Top);
             popup.IsOpen = true;
             return;
         }
     }
     Picture.Picture1 = picRef;
     SetPicture();
 }
Example #4
0
 private void BtnConfirm_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(Tb.Text))
     {
         popup        = ConfigurePopup.Configure(popup, "Enter country name first!", BtnConfirm, PlacementMode.Top);
         popup.IsOpen = true;
         return;
     }
     else
     {
         Country = new Country()
         {
             CountryName = Tb.Text
         };
         try
         {
             AdminInterface.Add(Country);
             this.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
 private void BtnConfirm_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(picLink))
     {
         try
         {
             Picture = new Picture()
             {
                 Picture1 = picLink
             };
             adminInterfacePictures.Add(Picture);
             this.Close();
         }
         catch (Exception ex)
         {
             popup        = ConfigurePopup.Configure(popup, ex.Message, BtnConfirm, PlacementMode.Top);
             popup.IsOpen = true;
         }
     }
     else
     {
         popup        = ConfigurePopup.Configure(popup, "No picture was selected", BtnConfirm, PlacementMode.Top);
         popup.IsOpen = true;
     }
 }
Example #6
0
        private async void BtnConfirm_Click(object sender, RoutedEventArgs e)
        {
            popup        = ConfigurePopup.Configure(popup, "Fill all the fields first!", BtnConfirm, PlacementMode.Top);
            popup.IsOpen = false;
            texts        = ListTextBoxesHelper.GetText(SP.Children);
            if (ListTextBoxesHelper.StringsNotEmpty(texts))
            {
                try
                {
                    if (!DecimalNumberChecker.Check(texts[1]))
                    {
                        popup        = ConfigurePopup.Configure(popup, "Only decimal numbers in price are allowed in price field!", BtnConfirm, PlacementMode.Top);
                        popup.IsOpen = true;
                        return;
                    }
                    await Task.Run(() => AdminInterface.UpdateAsync(Attraction.Id, Attraction));

                    this.Close();
                }
                catch (Exception ex)
                {
                    popup        = ConfigurePopup.Configure(popup, ex.Message, BtnConfirm, PlacementMode.Top);
                    popup.IsOpen = true;
                }
            }
            else
            {
                popup.IsOpen = true;
            }
        }
 private void BtnConfirm_Click(object sender, RoutedEventArgs e)
 {
     popup        = ConfigurePopup.Configure(popup, "Fill all fields first and select picture!", BtnConfirm, PlacementMode.Top);
     popup.IsOpen = false;
     texts.Clear();
     texts.Add((SP.Children[0] as TextBox).Text);
     if (!ListTextBoxesHelper.StringsNotEmpty(texts) || !hotel.Pictures.Any())
     {
         popup.IsOpen = true;
     }
     else
     {
         if (CB.SelectedItem == null)
         {
             popup        = ConfigurePopup.Configure(popup, "Select an item!", CB, PlacementMode.Right);
             popup.IsOpen = true;
         }
         else
         {
             City c = CB.SelectedItem as City;
             hotel.City = c;
             try
             {
                 AdminInterface.Add(hotel);
                 this.Close();
             }
             catch (Exception ex)
             {
                 popup        = ConfigurePopup.Configure(popup, ex.Message, BtnConfirm, PlacementMode.Top);
                 popup.IsOpen = true;
             }
         }
     }
 }
        private async void BtnAddPicture_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog od = new OpenFileDialog();

            popup.IsOpen = false;
            od.Filter    = "Image Files|*.jpg;*.jpeg;*.png;*.bmp;";
            if ((bool)od.ShowDialog())
            {
                Picture pic = new Picture()
                {
                    Picture1 = od.FileName
                };
                try
                {
                    AdminInterfacePictures.Add(pic);
                    var p = await(AdminInterfacePictures as AdminInterfacePictures).GetByReferenceAsync(od.FileName);
                    hotel.Pictures.Add(p);
                }
                catch (Exception ex)
                {
                    popup        = ConfigurePopup.Configure(popup, ex.Message, BtnConfirm, PlacementMode.Top);
                    popup.IsOpen = true;
                }
            }
        }
        private async void BtnConfirm_Click(object sender, RoutedEventArgs e)
        {
            popup        = ConfigurePopup.Configure(popup, "Fill all fields first and select picture!", BtnConfirm, PlacementMode.Top);
            popup.IsOpen = false;
            texts.Clear();
            texts.Add((SP.Children[0] as TextBox).Text);
            if (!ListTextBoxesHelper.StringsNotEmpty(texts) || !Hotel.Pictures.Any())
            {
                popup.IsOpen = true;
            }
            else
            {
                City c = CB.SelectedItem as City;
                Hotel.City = c;
                try
                {
                    await Task.Run(() => AdminInterface.UpdateAsync(Hotel.Id, Hotel));

                    this.Close();
                }
                catch (Exception ex)
                {
                    popup        = ConfigurePopup.Configure(popup, ex.Message, BtnConfirm, PlacementMode.Top);
                    popup.IsOpen = true;
                }
            }
        }
Example #10
0
        private async void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (LvAll.SelectedItem == null)
            {
                popup        = ConfigurePopup.Configure(popup, "Select an item first!", BtnListAll, PlacementMode.Bottom);
                popup.IsOpen = true;
                return;
            }
            try
            {
                var p = await AdminInterface.GetAsync((LvAll.SelectedItem as PictureInfo).Id);

                if (p != null)
                {
                    await Task.Run(() => AdminInterface.RemoveAsync(p));

                    await Task.Run(() => RefreshList());
                }
            }
            catch (Exception ex)
            {
                popup        = ConfigurePopup.Configure(popup, ex.Message, BtnListAll, PlacementMode.Bottom);
                popup.IsOpen = true;
            }
        }
Example #11
0
 public AddAttraction(IAdminInterface <Attraction> adminInterface)
 {
     InitializeComponent();
     AdminInterface = adminInterface;
     Attraction     = new Attraction();
     SP.DataContext = Attraction;
     popup          = ConfigurePopup.Configure(popup, "Fill all the fields first!", BtnConfirm, PlacementMode.Top);
 }
Example #12
0
        private async void TryUpdate()
        {
            try
            {
                await Task.Run(() => AdminInterface.UpdateAsync(City.Id, City));

                this.Close();
            }
            catch (Exception ex)
            {
                popup = ConfigurePopup.Configure(popup, ex.Message, BtnConfirm, PlacementMode.Top);
            }
        }
 private void BtnUpdate_Click(object sender, RoutedEventArgs e)
 {
     popup.IsOpen = false;
     if (LvAll.SelectedItem != null)
     {
         UpdateAttraction update = new UpdateAttraction(LvAll.SelectedItem as Attraction, AdminInterface);
         update.ShowDialog();
     }
     else
     {
         popup        = ConfigurePopup.Configure(popup, "Select item first!", LvAll, PlacementMode.Right);
         popup.IsOpen = true;
     }
 }
Example #14
0
 private async void BtnListAll_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (LvAll.DataContext != null)
         {
             return;
         }
         LvAll.DataContext = await AdminInterface.GetEntitiesAsync();
     }
     catch (Exception ex)
     {
         popup        = ConfigurePopup.Configure(popup, ex.Message, BtnListAll, PlacementMode.Bottom);
         popup.IsOpen = true;
     }
 }
        private async void BtnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (LvAll.SelectedItem == null)
            {
                popup        = ConfigurePopup.Configure(popup, "Select an item first!", BtnListAll, PlacementMode.Bottom);
                popup.IsOpen = true;
                return;
            }
            UpdateHotel update = new UpdateHotel(AdminInterface)
            {
                Hotel = (LvAll.SelectedItem as Hotel)
            };

            update.ShowDialog();
            await Task.Run(() => RefreshList());
        }
Example #16
0
 private async void BtnConfirm_Click(object sender, RoutedEventArgs e)
 {
     popup        = ConfigurePopup.Configure(popup, "Fill all fields first!", BtnConfirm, PlacementMode.Top);
     popup.IsOpen = false;
     texts.Clear();
     texts.Add((SP.Children[0] as TextBox).Text);
     if (!ListTextBoxesHelper.StringsNotEmpty(texts))
     {
         popup.IsOpen = true;
     }
     else
     {
         if (CB.SelectedItem != null)
         {
             City.Country = CB.SelectedItem as Country;
         }
         await Task.Run(() => TryUpdate());
     }
 }
Example #17
0
        private async void BtnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (LvAll.SelectedItem != null)
            {
                var p = await AdminInterface.GetAsync((LvAll.SelectedItem as PictureInfo).Id);

                var update = new UpdatePicture(AdminInterface)
                {
                    Picture = p
                };
                update.ShowDialog();
            }
            else
            {
                popup        = ConfigurePopup.Configure(popup, "Select an item first!", BtnListAll, PlacementMode.Bottom);
                popup.IsOpen = true;
                return;
            }
        }
Example #18
0
        public void ShowPopup()
        {
            if (PopupLayoutEngine == null)
            {
                PopupLayoutEngine = new PopupLayoutEngine(this.PopupContent, this, this.PopDirection, 0, this.AlignToRightEdge);
            }
            menuVisible = true;

            this.PopupContent?.ClearRemovedFlag();

            if (this.DynamicPopupContent != null)
            {
                this.PopupContent = this.DynamicPopupContent();
            }

            if (this.PopupContent == null ||
                this.PopupContent.Children.Count <= 0)
            {
                menuVisible = false;
                return;
            }

            this.OnBeforePopup();

            popupWidget = new PopupWidget(this.PopupContent, PopupLayoutEngine, MakeScrollable)
            {
                BorderWidth = 1,
                BorderColor = this.PopupBorderColor,
            };

            popupWidget.Closed += (s, e) =>
            {
                menuVisible = false;
                popupWidget = null;

                this.PopupWindowClosed?.Invoke(this, null);
            };

            ConfigurePopup?.Invoke(this, popupWidget);

            popupWidget.Focus();
        }
Example #19
0
 private void BtnConfirm_Click(object sender, RoutedEventArgs e)
 {
     popup.IsOpen = false;
     texts        = ListTextBoxesHelper.GetText(SP.Children);
     if (ListTextBoxesHelper.StringsNotEmpty(texts))
     {
         if (!DecimalNumberChecker.Check(texts[1]))
         {
             popup        = ConfigurePopup.Configure(popup, "Only decimal numbers in price are allowed in price field!", BtnConfirm, PlacementMode.Top);
             popup.IsOpen = true;
             return;
         }
         AdminInterface.Add(Attraction);
         this.Close();
     }
     else
     {
         popup.IsOpen = true;
     }
 }
 private async void BtnDelete_Click(object sender, RoutedEventArgs e)
 {
     popup.IsOpen = false;
     if (LvAll.SelectedItem != null)
     {
         try
         {
             Attraction a = LvAll.SelectedItem as Attraction;
             await Task.Run(() => AdminInterface.RemoveAsync(a));
         }
         catch (Exception ex)
         {
             popup        = ConfigurePopup.Configure(popup, ex.Message, BtnDelete, PlacementMode.Bottom);
             popup.IsOpen = true;
         }
     }
     else
     {
         popup        = ConfigurePopup.Configure(popup, "Select item first!", LvAll, PlacementMode.Right);
         popup.IsOpen = true;
     }
 }
Example #21
0
        private async void BtnListAll_Click(object sender, RoutedEventArgs e)
        {
            PictureHelper ph = new PictureHelper();

            try
            {
                if (LvAll.DataContext != null)
                {
                    return;
                }
                var pics = await ph.GetAllPictures(AdminInterface);

                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    LvAll.DataContext = pics;
                }));
            }
            catch (Exception ex)
            {
                popup        = ConfigurePopup.Configure(popup, ex.Message, BtnListAll, PlacementMode.Bottom);
                popup.IsOpen = true;
            }
        }
Example #22
0
 private void OnConfiurePopup(ConfigurePopup e)
 {
 }