Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender">The object sender of the event.</param>
 /// <param name="e"></param>
 private void ImageSize_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         Model.ImageSize = ImageSizeExtensions.Index(((ComboBox)sender).SelectedIndex).ToSize();
         Refresh_UcListViewStoragesServer();
     }
     catch (Exception ex)
     {
         log.Error(ex.Output(), ex);
         MessageBoxs.Error(ex);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Method called on delete click to delete a Album.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> sender of the event.</param>
        /// <param name="e">Routed event arguments <see cref="RoutedEventArgs"/>.</param>
        public override void DeleteItems_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Start to busy application.
                MessageBoxs.IsBusy = true;
                log.Warn("Deleting Album. Please wait...");

                // Check if an AclGroup is founded.
                if (SelectedItem != null)
                {
                    // Alert user for acceptation.
                    MessageBoxResult result = MessageBox.Show
                                              (
                        String.Format(
                            Dialogs.Properties.Translations.MessageBox_Acceptation_DeleteGeneric,
                            Local.Properties.Translations.Album,
                            SelectedItem.Name
                            ),
                        Local.Properties.Translations.ApplicationName,
                        MessageBoxButton.YesNoCancel
                                              );

                    // If accepted, try to update page model collection.
                    if (result == MessageBoxResult.Yes)
                    {
                        NotifyDeleted(SelectedItem);
                    }
                }
                else
                {
                    string message = $"{typeof(AlbumEntity).Name} not found !";
                    log.Warn(message);
                    MessageBoxs.Warning(message);
                }
            }

            catch (Exception ex)
            {
                log.Error(ex.Output(), ex);
                MessageBoxs.Error(ex.Output());
            }

            // Stop to busy application.
            finally
            {
                log.Warn("Deleting Album. Please wait...");
                MessageBoxs.IsBusy = false;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Method called on plugin control menu click event.
 /// </summary>
 /// <param name="sender">The <see cref="object"/> sender of the event.</param>
 /// <param name="e">The routed event arguments <see cref="RoutedEventArgs"/></param>
 private void MenuControl_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         IComponent ic = ((IModule)((MenuItem)sender).Tag).Component;
         if (ic != null && ic.Context != null)
         {
             ComponentNavigator.NavigateToPlugin(ic.Context);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex.Output());
         MessageBoxs.Error(ex);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Method called on add item click event.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> sender of the event.</param>
        /// <param name="e">Routed event arguments <see cref="RoutedEventArgs"/>.</param>
        public override void AddItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Start to busy application.
                MessageBoxs.IsBusy = true;
                log.Warn("Adding Album informations. Please wait...");

                // Show open file dialog box
                using (WindowFormAlbumLayout dlg = new WindowFormAlbumLayout(new AlbumEntity()))
                {
                    bool?result = dlg.ShowDialog();

                    /*
                     * if (!dlg.Activate())
                     * {
                     *  log.Warn("Albums edit file dialog boxn is busy. Please try again.");
                     *  MessageBoxs.Warning("Albums edit file dialog boxn is busy. Please try again.");
                     *  dlg.Close();
                     * }
                     */

                    // Process open file dialog box results
                    if (result == true)
                    {
                        NotifyAdded(dlg.NewForm);
                    }
                    else
                    {
                        NotifyCanceled(dlg.NewForm);
                    }
                }
            }

            catch (Exception ex)
            {
                log.Error(ex.Output(), ex);
                MessageBoxs.Error(ex.Output());
            }

            // Stop to busy application.
            finally
            {
                log.Warn("Updating Album informations. Done.");
                MessageBoxs.IsBusy = false;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Method called on edit <see cref="AlbumEntity"/> click event.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> sender of the event.</param>
        /// <param name="e">Routed event arguments <see cref="RoutedEventArgs"/>.</param>
        public override void EditItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Start to busy application.
                MessageBoxs.IsBusy = true;
                log.Warn("Editing Album informations. Please wait...");

                // Check if an AclGroup is founded.
                if (SelectedItem != null)
                {
                    // Show open file dialog box
                    WindowFormAlbumLayout dlg = new WindowFormAlbumLayout(SelectedItem);
                    bool?result = dlg.ShowDialog();

                    // Process open file dialog box results
                    if (result == true)
                    {
                        NotifyChanged(dlg.NewForm);
                    }
                    else
                    {
                        NotifyCanceled(dlg.NewForm);
                    }

                    log.Warn("Editing Album informations. Done.");
                }
                else
                {
                    string message = $"{typeof(AlbumEntity).Name} not found !";
                    log.Warn(message);
                    MessageBoxs.Warning(message);
                }
            }

            catch (Exception ex)
            {
                log.Error(ex.Output(), ex);
                MessageBoxs.Error(ex.Output());
            }

            // Stop to busy application.
            finally
            {
                MessageBoxs.IsBusy = false;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Method called on sever edit settings event click.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> sender of the event.</param>
        /// <param name="e">The routed event arguments <see cref="RoutedEventArgs"/>.</param>
        private void ServerSettings_Click(object sender, RoutedEventArgs e)
        {
            using (WindowFormServerLayout dlg = new WindowFormServerLayout(ApplicationBase.Options.Remote.Servers.FindDefaultFirst()))
            {
                try
                {
                    bool?result = dlg.ShowDialog();

                    if (result == true)
                    {
                        dlg.NewFormData.IsDefault = true;

                        var def = ApplicationBase.Options.Remote.Servers.FindDefaultFirst();
                        if (def == null)
                        {
                            ApplicationBase.Options.Remote.Servers.Add(dlg.NewFormData);
                        }
                        else
                        {
                            ApplicationBase.Options.Remote.Servers.ReplaceDefault(dlg.NewFormData);
                        }


                        var eee = ApplicationBase.Options.Remote.Servers;

                        ApplicationBase.SaveOptions();
                        if (HttpWebServerApplication.IsStarted)
                        {
                            ServerRestart_Click(sender, e);
                        }
                    }
                    else
                    {
                        var def = ApplicationBase.Options.Remote.Servers.FindDefaultFirst();
                        def.Bind(dlg.OldFormData);
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex.Output(), ex);
                    MessageBoxs.Error(ex);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pe"></param>
        /// <param name="propertyPathName"></param>
        /// <param name="sDir"></param>
        /// <returns></returns>
        public bool FileSearch(PictureEntity pe, string propertyPathName, string sDir)
        {
            bool IsChanged = false;

            try
            {
                string filename = Path.Combine(sDir, Path.GetFileName(pe.GetPropertyValue(propertyPathName).ToString()));

                log.Info(string.Format("Searching Picture : {0}", filename));
                Trace.TraceInformation(filename);

                if (File.Exists(filename))
                {
                    FileInfo fi    = new FileInfo(filename);
                    string   lProp = propertyPathName.Replace("Path", "Length");
                    long?    l     = (long)pe.GetPropertyValue(lProp);

                    if (l == null || l == 0 || fi.Length == l)
                    {
                        pe.SetPropertyValue(propertyPathName, fi.FullName);
                        pe.SetPropertyValue(lProp, fi.Length);
                        return(true);
                    }
                }

                foreach (string d in Directory.GetDirectories(sDir))
                {
                    IsChanged = FileSearch(pe, propertyPathName, d);
                }
            }
            catch (UnauthorizedAccessException uae)
            {
                log.Info(uae.Message);
            }
            catch (Exception e)
            {
                log.Error(e);
                MessageBoxs.Error(string.Format("Searching Picture {0} failed !\n\r {1}", propertyPathName, e.Message));
            }

            return(IsChanged);
        }
Beispiel #8
0
        /// <summary>
        /// Method called on Section delete event.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> sender of the event.</param>
        /// <param name="e">Entity changes event arguments <see cref="EntityChangesEventArgs"/>.</param>
        private void PicturesCollection_Added(object sender, EntityChangesEventArgs e)
        {
            try
            {
                //// Start to busy application.
                //MessageBoxs.IsBusy = true;
                //log.Warn("Starting adding Picture(s). Please wait...");

                //// Get item from list.
                //PictureEntity[] items = (PictureEntity[])e.NewEntities;

                //// Stop to busy application.
                //log.Warn("Ending adding Picture(s).");
                //MessageBoxs.IsBusy = false;
            }
            catch (Exception ex)
            {
                log.Error(ex.Output(), ex);
                MessageBoxs.Error(ex.Output());
            }
        }
Beispiel #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender">The object sender of the event.</param>
        /// <param name="e">Event arguments.</param>
        private void UcDataGridUsers_UserChanged(object sender, EntityChangesEventArgs e)
        {
            MessageBoxs.IsBusy = true;
            log.Warn("Editing User informations. Please wait...");

            try
            {
                Model.SaveUserChanges((UserEntity)e.NewEntity);
                log.Info("Editing User informations. Done.");
            }
            catch (Exception ex)
            {
                log.Error(ex.Output(), ex);
                MessageBoxs.Error(ex);
            }
            finally
            {
                log.Warn("Editing User informations. End.");
                MessageBoxs.IsBusy = false;
            }
        }
Beispiel #10
0
        /// <summary>
        ///
        /// </summary>
        public async Task SingleAlbum(int pk)
        {
            log.Info(string.Format(Properties.Logs.SendingClientCommand, MethodBase.GetCurrentMethod().Name, Server.Host, Server.Port));

            // Initialize sections server response.
            ServerResponseAlbum serverResponse = null;

            try
            {
                // Send command SingleSection to the server.
                // Decode response as JSon format to exploit sections list.
                HttpResponseMessage response = WebClient.Client.SingleAlbum(pk);
                string message = await WebClient.Client.Read(response);

                serverResponse = JsonConvert.DeserializeObject <ServerResponseAlbum>(message);

                if (response.StatusCode == HttpStatusCode.OK && serverResponse.Authentication)
                {
                    RaiseSingleAlbumSuccess(Server, serverResponse);
                }
                else if (response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    RaiseSingleAlbumFailed(Server, serverResponse);
                }
                else
                {
                    RaiseSingleAlbumFailed(Server, serverResponse);
                    MessageBoxs.Error($"Server single section {Server.Host}:{Server.Port} failed !\n\r {response.StatusCode.ToString()} : {serverResponse.Error}");
                }
            }
            catch (Exception e)
            {
                RaiseSingleAlbumFailed(Server, serverResponse);
                MessageBoxs.Fatal(e, $"Server single section {Server.Host}:{Server.Port} failed !");
            }
        }
Beispiel #11
0
        /// <summary>
        /// Method to create the <see cref="StackPanel"/> title container.
        /// </summary>
        /// <returns>A <see cref="StackPanel"/> as title container.</returns>
        private static StackPanel GetTitle(DriveInfo di)
        {
            // Get the icon image of the Drive.
            BitmapImage icon  = Win32Icon.IconFromHandle(di.Name).ToBitmap().ToBitmapImage();
            StackPanel  title = title = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Height      = 20,
                Children    =
                {
                    new Border()
                    {
                        Child = new Image
                        {
                            Width  = icon.Width,
                            Height = icon.Height,
                            Source = icon
                        }
                    }
                }
            };

            try
            {
                TextBlock volName = null;

                if (di.IsReady)
                {
                    volName = new TextBlock
                    {
                        Text   = $"{di.VolumeLabel} ({di.Name.ToString()})",
                        Margin = new Thickness(5, 0, 0, 0)
                    };
                }
                else
                {
                    volName = new TextBlock
                    {
                        Text       = $"Volume not ready ! ({di.Name.ToString()})",
                        Margin     = new Thickness(5, 0, 0, 0),
                        Foreground = Brushes.Red
                    };
                }

                title.Children.Add(volName);
            }

            catch (IOException io)
            {
                log.Debug(io.Output());
                MessageBoxs.Error(io);

                title.Children.Add(
                    new TextBlock
                {
                    Text       = $"Volume not ready ! ({di.Name.ToString()})",
                    Margin     = new Thickness(5, 0, 0, 0),
                    Foreground = Brushes.Red
                }
                    );

                title.ToolTip = io.Message;
            }

            catch (Exception e)
            {
                log.Debug(e.Output());
                MessageBoxs.Fatal(e);
            }

            return(title);
        }
Beispiel #12
0
        /// <summary>
        /// Method called on delete click event to delete a Album.
        /// </summary>
        /// <param name="sender">The object sender of the event.</param>
        /// <param name="e">Routed event arguments.</param>
        public async override void DeleteItems_Click(object sender, RoutedEventArgs e)
        {
            // Check if the selected items list is not null.
            if (SelectedItems == null)
            {
                NullReferenceException ex = Exceptions.GetReferenceNull(nameof(SelectedItems), typeof(IEnumerable <AlbumEntity>));
                log.Warn(ex.Output(), ex);
                MessageBoxs.Warning(ex.Output());
                return;
            }

            // Alert user for acceptation.
            MessageBoxResult result = MessageBox.Show
                                      (
                String.Format(Fotootof.Layouts.Dialogs.Properties.Translations.MessageBox_Acceptation_DeleteGeneric, Local.Properties.Translations.Album, SelectedItems.Count),
                Local.Properties.Translations.ApplicationName,
                MessageBoxButton.YesNoCancel
                                      );

            // If not accept, do nothing at this moment.
            if (result != MessageBoxResult.Yes)
            {
                return;
            }

            // If accepted, try to update page model collection.
            try
            {
                // Start to busy application.
                MessageBoxs.IsBusy = true;
                log.Warn("Deleting Album(s). Please wait...");

                // Delete item from database.
                await AlbumEntityCollection.DbDeleteAsync(SelectedItems);

                // Important : No need to defer for list view items refresh.
                log.Warn("Updating Album(s) list view items...");
                foreach (AlbumEntity item in SelectedItems)
                {
                    Items.Remove(item);
                }

                // Refresh of the list view items source.
                log.Warn("Refreshing Album(s) list view...");
                ItemsCollection.Items.Refresh();

                // Raise the on delete event.
                log.Warn("Refreshing Album(s) list view...");
                NotifyDeleted(SelectedItems.ToArray());
            }

            catch (Exception ex)
            {
                log.Error(ex.Output(), ex);
                MessageBoxs.Error(ex.Output());
            }

            // Stop to busy application.
            finally
            {
                log.Warn("Deleting Album(s). Done.");
                MessageBoxs.IsBusy = false;
            }
        }