/// <summary>
        ///   <para>Deletes selected product from the database</para>
        /// </summary>
        /// <param name="row">The row.</param>
        private async void DeleteProduct(DataRowView row)
        {
            try
            {
                string message = "Er du sikker du vil slette dette produkt?";
                string caption = "Advarsel";
                System.Windows.MessageBoxButton buttons = System.Windows.MessageBoxButton.YesNo;
                System.Windows.MessageBoxResult result;

                // Displays the MessageBox.
                result = MessageBox.Show(message, caption, buttons);
                switch (result == System.Windows.MessageBoxResult.Yes)
                {
                case true:
                {
                    var query = $"DELETE FROM `girozilla`.`products` WHERE `Product_ID` = {row.Row.ItemArray[0].ToString()}";

                    AsyncMySqlHelper.UpdateDataToDatabase(query, "ConnString").Wait();

                    MessageBox.Show($"Produktet nr:{row.Row.ItemArray[0].ToString()} er nu slettet");

                    Log.Information($"Successfully deleted product #{row.Row.ItemArray[0].ToString()}");
                    break;
                }
                }
                await Task.FromResult(true);
            }
            catch (Exception ex)
            {
                await Task.FromResult(false);

                MessageBox.Show("En uventet fejl er sket", "FEJL");
                Log.Error(ex, "Unexpected Error");
            }
        }
Beispiel #2
0
 ShowMessageBoxHelper(
     System.Windows.Window parent,
     string text,
     string title,
     System.Windows.MessageBoxButton buttons,
     System.Windows.MessageBoxImage image
     )
 {
     (new SecurityPermission(SecurityPermissionFlag.UnmanagedCode)).Assert();
     try
     {
         // if we have a known parent window set, let's use it when alerting the user.
         if (parent != null)
         {
             System.Windows.MessageBox.Show(parent, text, title, buttons, image);
         }
         else
         {
             System.Windows.MessageBox.Show(text, title, buttons, image);
         }
     }
     finally
     {
         SecurityPermission.RevertAssert();
     }
 }
Beispiel #3
0
 //Удаление файла
 private void contentControlDeleteTrack_MouseUp(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (tracksDataGrid.SelectedItems.Count == 0)
         {
             return;
         }
         string caption = IsMoreThanOneTrackSelected() ? "Удаление треков" : "Удаление трека";
         string message = IsMoreThanOneTrackSelected() ? "Вы уверены, что хотите удалить выбранные треки?" : "Вы уверены, что хотите удалить выбранный трек?";
         System.Windows.MessageBoxButton button = System.Windows.MessageBoxButton.YesNo;
         if (System.Windows.MessageBox.Show(message, caption, button) == MessageBoxResult.Yes)
         {
             foreach (Track trackToDelete in tracksDataGrid.SelectedItems)
             {
                 try
                 {
                     File.Delete(trackToDelete.filePath);
                 }
                 catch (IOException ex)
                 {
                     System.Windows.MessageBox.Show("Не удаётся удалить файл " + System.IO.Path.GetFileName(trackToDelete.filePath) + " потому что он занят другим процессом");
                     continue;
                 }
                 tracksList.Remove(trackToDelete);
             }
             tracksDataGrid.ItemsSource = null;
             tracksDataGrid.ItemsSource = tracksList;
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("\n" + ex + "\n");
     }
 }
Beispiel #4
0
 private void Window_Deactivated(object sender, EventArgs e)
 {
     if (bSkipModifyConfirmation == false)
     {
         System.Windows.MessageBoxButton buttons = System.Windows.MessageBoxButton.YesNo;
         string message = "Are you sure to leave Quick Capture? Your note will be discarded.";
         string caption = "";
         if (bNoteModified == true && (System.Windows.MessageBox.Show(message, caption, buttons, System.Windows.MessageBoxImage.Warning, System.Windows.MessageBoxResult.No) == System.Windows.MessageBoxResult.No))
         {
             this.Visibility = Visibility.Visible;
             this.Focus();
             this.Topmost = true;
             return;
         }
         else
         {
             if (IsSingleInstance())
             {
                 this.Visibility = Visibility.Hidden;
             }
             else
             {
                 System.Diagnostics.Process.GetCurrentProcess().Kill();
             }
         }
     }
 }
Beispiel #5
0
 ShowMessageBoxHelper(
     IntPtr parentHwnd,
     string text,
     string title,
     System.Windows.MessageBoxButton buttons,
     System.Windows.MessageBoxImage image
     )
 {
     // NOTE: the last param must always be MessageBoxOptions.None for this to be considered TreatAsSafe
     System.Windows.MessageBox.ShowCore(parentHwnd, text, title, buttons, image, MessageBoxResult.None, MessageBoxOptions.None);
 }
Beispiel #6
0
        //Обновление датагрида (избегать излишних вызовов, занимает файлы секунды на 2)
        public void RefreshDataGrid()
        {
            try
            {
                outputDevice.Stop();
                Thread.Sleep(100);
                mainReader = null;

                //resetting datagrid and list of tracks
                tracksDataGrid.ItemsSource = null;
                tracksList.Clear();

                //for each file that satisfies set mask
                foreach (string file in System.IO.Directory.GetFiles(workingFolderPath).Where(file => allowedExtensions.Any(file.ToLower().EndsWith)))
                {
                    //Debug.WriteLine("filename = " + file);
                    try
                    {
                        var newTrack = new Track                                     //create new track based on file
                        {
                            name                = System.IO.Path.GetFileName(file),  //name of track with extension
                            duration            = GetAudioLength(file),              //audiofile length in string format mm:ss
                            extension           = System.IO.Path.GetExtension(file), //extension of file
                            filePath            = file,                              //path to file
                            audioTimeSpanLength = GetAudioTimeSpanLength(file)       //audio length in seconds (TimeSpan)
                        };
                        tracksList.Add(newTrack);
                    }
                    catch (IOException ex)
                    {
                        Debug.WriteLine("\n" + ex + "\n");
                        string caption = "Файл повреждён";
                        string message = "Файл " + System.IO.Path.GetFileName(file) + " повреждён и не может быть воспроизведён, удалить?";
                        System.Windows.MessageBoxButton buttons = System.Windows.MessageBoxButton.YesNo;
                        if (System.Windows.MessageBox.Show(message, caption, buttons) == MessageBoxResult.Yes)
                        {
                            File.Delete(file);
                        }
                        continue;
                    }
                }
                tracksDataGrid.ItemsSource = tracksList; //setting ItemSource automatically rerenders datagrid
                if (tracksDataGrid.Items.Count > 0)
                {
                    tracksDataGrid.SelectedIndex = 0; //default selected track on startup is first
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\n" + ex + "\n");
            }
        }
Beispiel #7
0
 protected void ShowMessageBox(string message, string caption, System.Windows.MessageBoxButton buttons = System.Windows.MessageBoxButton.OK)
 {
     if (!Application.Current.Dispatcher.CheckAccess())
     {
         Application.Current.Dispatcher.Invoke(() => {
             DXMessageBox.Show(message, caption, buttons);
         });
         return;
     }
     else
     {
         DXMessageBox.Show(message, caption, buttons);
     }
 }
Beispiel #8
0
 public MessageBoxResult ShowMessageBox(string message, string caption, System.Windows.MessageBoxButton buttons = System.Windows.MessageBoxButton.OK)
 {
     if (!Application.Current.Dispatcher.CheckAccess())
     {
         return(Application.Current.Dispatcher.Invoke(() =>
         {
             return MessageBox.Show(message, caption, buttons);
         }));
     }
     else
     {
         return(MessageBox.Show(message, caption, buttons));
     }
 }
Beispiel #9
0
 ShowMessageBoxHelper(
     System.Windows.Window parent,
     string text,
     string title,
     System.Windows.MessageBoxButton buttons,
     System.Windows.MessageBoxImage image
     )
 {
     // if we have a known parent window set, let's use it when alerting the user.
     if (parent != null)
     {
         System.Windows.MessageBox.Show(parent, text, title, buttons, image);
     }
     else
     {
         System.Windows.MessageBox.Show(text, title, buttons, image);
     }
 }
Beispiel #10
0
 ShowMessageBoxHelper(
     IntPtr parentHwnd,
     string text,
     string title,
     System.Windows.MessageBoxButton buttons,
     System.Windows.MessageBoxImage image
     )
 {
     (new SecurityPermission(SecurityPermissionFlag.UnmanagedCode)).Assert();
     try
     {
         // NOTE: the last param must always be MessageBoxOptions.None for this to be considered TreatAsSafe
         System.Windows.MessageBox.ShowCore(parentHwnd, text, title, buttons, image, MessageBoxResult.None, MessageBoxOptions.None);
     }
     finally
     {
         SecurityPermission.RevertAssert();
     }
 }
        /// <summary>Deletes the selected service from ServiceGrid.</summary>
        /// <param name="row">The row.</param>
        private async void DeleteSelectedServices(DataRowView[] rows)
        {
            try
            {
                string message = $"Er du sikker du vil slette {rows.Count()} fejninger?";
                string caption = "Advarsel";
                System.Windows.MessageBoxButton buttons = System.Windows.MessageBoxButton.YesNo;
                System.Windows.MessageBoxResult result;

                // Displays the MessageBox.
                result = MessageBox.Show(message, caption, buttons);
                switch (result == System.Windows.MessageBoxResult.Yes)
                {
                case true:
                {
                    foreach (DataRowView row in rows)
                    {
                        var query = $"DELETE FROM `girozilla`.`service-products` WHERE `Service-Product_SERVICEID` = {row.Row.ItemArray[0].ToString()}";

                        AsyncMySqlHelper.UpdateDataToDatabase(query, "ConnString").Wait();

                        query = $"DELETE FROM `girozilla`.`services` WHERE `Service_ID` = {row.Row.ItemArray[0].ToString()}";

                        AsyncMySqlHelper.UpdateDataToDatabase(query, "ConnString").Wait();

                        Log.Information($"Successfully deleted service #{row.Row.ItemArray[0]}");
                    }
                    MessageBox.Show($"{rows.Length} Fejninger blev slettet");
                    break;
                }
                }
                await Task.FromResult(true);
            }
            catch (Exception ex)
            {
                await Task.FromResult(false);

                MessageBox.Show("En uventet fejl er sket", "FEJL");
                Log.Error(ex, "Unexpected Error");
            }
        }
        // LA HACEMOS ESTÁTICA PARA NO NECESITAR OBJETO Y LA HACEMOS DE TIPO MessageBoxResult
        // PARA QUE NOS VALGA TANTO PARA LAS CONFIRMACIONES LA USUARIO COMO PARA LOS MENSAJES
        public static MessageBoxResult msgBox(String mensaje, String boton, String icono)
        {
            // DECLARAMOS DOS VARIABLES TIPO BOTÓN Y TIPO ICONO, LAS INICIALIZAMOS A CUALQUIER VALOR
            System.Windows.MessageBoxButton tipoBoton = System.Windows.MessageBoxButton.OK;
            MessageBoxImage tipoIcono = MessageBoxImage.Error;

            // EN FUNCIÓN DE LOS PARÁMETROS CAMBIAMOS El TIPO DE BOTÓN E ICONO
            switch (boton)
            {
            case "ok":
                tipoBoton = System.Windows.MessageBoxButton.OK;
                break;

            case "yesno":
                tipoBoton = System.Windows.MessageBoxButton.YesNo;
                break;
            }

            switch (icono)
            {
            case "info":
                tipoIcono = MessageBoxImage.Information;
                break;

            case "warning":
                tipoIcono = MessageBoxImage.Warning;
                break;

            case "error":
                tipoIcono = MessageBoxImage.Error;
                break;

            case "question":
                tipoIcono = MessageBoxImage.Question;
                break;
            }

            // MOSTRAMOS EL MENSAJE
            return(System.Windows.MessageBox.Show(mensaje, "Cuaderno del Profesor", tipoBoton, tipoIcono));
        }
 public Result ShowMessage(string message, string title = null, Button button = Button.OK, Icon icon = Icon.None)
 => MessageBox.Show(message, title ?? Vsix.Name, button, icon);
Beispiel #14
0
 public static void Show(string msg, string title = "", System.Windows.MessageBoxButton btn = System.Windows.MessageBoxButton.OK)
 {
     ModernDialog.ShowMessage(msg, title, btn);
 }
        //Diese Funtion dient zum Testen der Felden unserer verschiedenen Formulare
        // Die liefert den Wert 1, falls alles gut passiert ist. Wenn icht, dann wird der Wert 0 ausgeliefert.
        public int testFormular(List <string> elementeListe)
        {
            //Man nimmt an, alles ist nicht ok am Anfang
            int    testResult = 1;
            string error;
            Dictionary <string, string> dict = new Dictionary <string, string>();

            foreach (string element in elementeListe)
            {
                switch (element)
                {
                case "txtBox_titel":


                    if (txtBox_titel.Text == "")
                    {
                        error = "Der Titel muss eingegeben werden!";
                        dict.Add("txtBox_titel", error);
                    }
                    break;

                case "txtBox_stunden":


                    if (txtBox_stunden.Text.Trim() == "")
                    {
                        error = "Das Feld für Stunden muss mit einer Zahl zwischen 0 und 23 ausgefüllt werden!";
                        dict.Add("txtBox_stunden", error);
                    }
                    else     // Das Feld ist nicht leer
                    {
                        int stunden;
                        // Check if the point entered is numeric or not
                        if (Int32.TryParse(txtBox_stunden.Text, out stunden))
                        {       //Eine Zahl wurde eingegeben...
                            if (0 <= stunden && stunden <= 23)
                            {
                                // System.Windows.MessageBox.Show("" + stunden);
                            }
                            else
                            {
                                error = "Das Feld für Stunden muss mit einer Zahl zwischen 0 und 23 ausgefüllt werden!";
                                dict.Add("txtBox_stunden", error);
                            }
                            // Do what you want to do if numeric
                            //System.Windows.MessageBox.Show(""+stunden);
                        }
                        else
                        {
                            // Do what you want to do if not numeric
                            //System.Windows.Forms.MessageBox.Show("non numeric");
                            error = "Das Feld für Stunden muss mit einer Zahl zwischen 0 und 23 ausgefüllt werden!";
                            dict.Add("txtBox_stunden", error);
                        }
                    }
                    break;

                case "txtBox_minuten":


                    if (txtBox_minuten.Text == "")
                    {
                        error = "Das Feld für Minuten muss mit einer Zahl zwischen 0 und 59 ausgefüllt werden!";
                        dict.Add("txtBox_minuten", error);
                    }
                    else
                    {
                        int minuten;
                        // Check if the point entered is numeric or not
                        if (Int32.TryParse(txtBox_minuten.Text, out minuten))
                        {
                            // Do what you want to do if numeric
                            if (0 <= minuten && minuten <= 59)
                            {
                                //System.Windows.MessageBox.Show("" + minuten);
                            }
                            else
                            {
                                error = "Das Feld für Minuten muss mit einer Zahl zwischen 0 und 59 ausgefüllt werden!";
                                dict.Add("txtBox_minuten", error);
                            }
                        }
                        else
                        {
                            // Do what you want to do if not numeric
                            // System.Windows.Forms.MessageBox.Show("non numeric");
                            error = "Das Feld für Minuten muss mit einer Zahl zwischen 0 und 23 ausgefüllt werden!";
                            dict.Add("txtBox_minuten", error);
                        }
                    }

                    break;
                }
            }

            int anzahlDerElemente = dict.Count;

            if (anzahlDerElemente > 0)
            {
                //Es heißt, es gibt ein Problem irgendwo
                testResult = 0;
                List <string> tmpl = new List <string>();
                foreach (KeyValuePair <string, string> item in dict)
                {
                    // Console.WriteLine("Key: {0}, Value: {1}", item.Key, item.Value);
                    tmpl.Add(item.Value);

                    Console.WriteLine("Erreur au niveau de: " + item.Key + " contenu erreur: " + item.Value);
                }

                //Der Rückgabewert(eine Zeichenkette) wird erzeugt.
                string total = "";
                for (int i = 0; i < tmpl.Count; i++)
                {
                    total = total + tmpl[i] + "\n \n";
                }
                // MessageBox.Show(total);
                // Configure message box
                string caption = "Falsche oder Fehlende Angaben";
                System.Windows.MessageBoxButton buttons = MessageBoxButton.OK;
                System.Windows.MessageBoxImage  icon    = System.Windows.MessageBoxImage.Exclamation;
                // Show message box
                System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show(total, caption, buttons, icon);
                //MessageBox.Show("Some text", "Some title", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(testResult);
        }
 public Result ShowConfirm(string question, string title = null, Button button = Button.YesNo)
 => ShowMessage(question, title: title ?? "Please Confirm", button, icon: Icon.Question);
 public static Result DisplayMessage(string title = null, string message = "", Button button = Button.OK, Icon icon = Icon.None)
 => MessageBox.Show(message, title, button, icon);
Beispiel #18
0
 public System.Windows.MessageBoxResult ShowMessage(string messageBoxText, string caption, System.Windows.MessageBoxButton button)
 {
     return(MessageBoxResult.None);
 }
 System.Windows.MessageBoxResult IUIServiceWpf.ShowMessageWpf(string message, string caption, System.Windows.MessageBoxButton buttons)
 {
     return(GetService <IUIServiceWpf>().ShowMessageWpf(message, caption, buttons));
 }