Skip to content

Commit

Permalink
Added the possibility to import Bookmarks (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Jul 25, 2024
1 parent 8d562bc commit cf55c2f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
18 changes: 17 additions & 1 deletion ColorPicker/Pages/BookmarksPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using ColorPicker.Classes;
using ColorPicker.UserControls;
using Microsoft.Win32;
using System.Diagnostics;
using System.IO;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
Expand Down Expand Up @@ -186,8 +189,21 @@ private void AddCollectionBtn_Click(object sender, RoutedEventArgs e)

private void ImportBtn_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new()
{
Filter = "XML|*.xml",
Title = Properties.Resources.Import
}; // Create file dialog

}
if (openFileDialog.ShowDialog() ?? true)
{
Global.Bookmarks = XmlSerializerManager.LoadFromXml<Bookmarks>(openFileDialog.FileName); // Import
XmlSerializerManager.SaveToXml(Global.Bookmarks , Global.BookmarksPath);
MessageBox.Show(Properties.Resources.ImportBookmarksSucess, Properties.Resources.ColorPickerMax, MessageBoxButton.OK, MessageBoxImage.Information); // Show error message

InitUI();
}
}

private void ExportBtn_Click(object sender, RoutedEventArgs e)
{
Expand Down
9 changes: 9 additions & 0 deletions ColorPicker/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -795,4 +795,7 @@
<data name="ExportBookmarksSuccess" xml:space="preserve">
<value>Bookmarks were sucessfully exported.</value>
</data>
<data name="ImportBookmarksSucess" xml:space="preserve">
<value>Bookmarks were sucessfully imported.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -799,4 +799,7 @@
<data name="ExportBookmarksSuccess" xml:space="preserve">
<value>Les signets ont été exportés avec succès.</value>
</data>
<data name="ImportBookmarksSucess" xml:space="preserve">
<value>Les signets ont été importés avec succès.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -775,4 +775,7 @@
<data name="ExportBookmarksSuccess" xml:space="preserve">
<value>Bookmarks were sucessfully exported.</value>
</data>
<data name="ImportBookmarksSucess" xml:space="preserve">
<value>Bookmarks were sucessfully imported.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -795,4 +795,7 @@
<data name="ExportBookmarksSuccess" xml:space="preserve">
<value>书签已成功导出。</value>
</data>
<data name="ImportBookmarksSucess" xml:space="preserve">
<value>已成功导入书签。</value>
</data>
</root>

0 comments on commit cf55c2f

Please sign in to comment.