mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 14:24:43 -07:00
Gotten some files back, in the end they were referenced from the xaml
This commit is contained in:
parent
84be12b826
commit
52d122eb13
5 changed files with 176 additions and 92 deletions
69
src/Greenshot.Editor/Controls/Emoji/ChunkHelper.cs
Normal file
69
src/Greenshot.Editor/Controls/Emoji/ChunkHelper.cs
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* Greenshot - a free and open source screenshot tool
|
||||||
|
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
|
||||||
|
*
|
||||||
|
* For more information see: https://getgreenshot.org/
|
||||||
|
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 1 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Greenshot.Editor.Controls.Emoji;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This seems to enumerate multiple IEnumerables.
|
||||||
|
/// TODO: Replace this with LINQ
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
internal sealed class ChunkHelper<T> : IEnumerable<IEnumerable<T>>
|
||||||
|
{
|
||||||
|
private readonly IEnumerable<T> _elements;
|
||||||
|
private readonly int _size;
|
||||||
|
private bool _hasMore;
|
||||||
|
|
||||||
|
public ChunkHelper(IEnumerable<T> elements, int size)
|
||||||
|
{
|
||||||
|
_elements = elements;
|
||||||
|
_size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<IEnumerable<T>> GetEnumerator()
|
||||||
|
{
|
||||||
|
using var enumerator = _elements.GetEnumerator();
|
||||||
|
_hasMore = enumerator.MoveNext();
|
||||||
|
while (_hasMore)
|
||||||
|
{
|
||||||
|
yield return GetNextBatch(enumerator).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<T> GetNextBatch(IEnumerator<T> enumerator)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _size; ++i)
|
||||||
|
{
|
||||||
|
yield return enumerator.Current;
|
||||||
|
_hasMore = enumerator.MoveNext();
|
||||||
|
if (!_hasMore)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
<StackPanel x:Class="Greenshot.Editor.Controls.EmojiPicker"
|
<StackPanel x:Class="Greenshot.Editor.Controls.Emoji.EmojiPicker"
|
||||||
x:Name="StackPanel_INTERNAL"
|
x:Name="StackPanel_INTERNAL"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
|
|
@ -17,10 +17,9 @@ using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Greenshot.Editor.Controls.Emoji;
|
|
||||||
|
|
||||||
namespace Greenshot.Editor.Controls
|
namespace Greenshot.Editor.Controls.Emoji;
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The event which is created when the emoji is picked
|
/// The event which is created when the emoji is picked
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -78,8 +77,15 @@ namespace Greenshot.Editor.Controls
|
||||||
|
|
||||||
private void OnEmojiPicked(object sender, RoutedEventArgs e)
|
private void OnEmojiPicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is not Control { DataContext: Emojis.Emoji emoji }) return;
|
if (sender is not Control { DataContext: Emojis.Emoji emoji })
|
||||||
if (emoji.Variations.Count != 0 && sender is not Button) return;
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (emoji.Variations.Count != 0 && sender is not Button)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Selection = emoji.Text;
|
Selection = emoji.Text;
|
||||||
Button_INTERNAL.IsChecked = false;
|
Button_INTERNAL.IsChecked = false;
|
||||||
|
@ -126,4 +132,3 @@ namespace Greenshot.Editor.Controls
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -42,7 +42,11 @@ public class Emojis
|
||||||
[XmlElement(ElementName = "Emoji")]
|
[XmlElement(ElementName = "Emoji")]
|
||||||
public List<Emoji> Emojis { get; set; } = new();
|
public List<Emoji> Emojis { get; set; } = new();
|
||||||
|
|
||||||
|
public IEnumerable<IEnumerable<Emoji>> EmojiChunkList => new ChunkHelper<Emoji>(EmojiList, 8);
|
||||||
|
|
||||||
public string Icon => SubGroups.FirstOrDefault()?.Emojis.FirstOrDefault()?.Text;
|
public string Icon => SubGroups.FirstOrDefault()?.Emojis.FirstOrDefault()?.Text;
|
||||||
|
|
||||||
|
public IEnumerable<Emoji> EmojiList => SubGroups.SelectMany(s => s.Emojis);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Emoji
|
public class Emoji
|
||||||
|
|
|
@ -26,7 +26,7 @@ using System.Windows.Forms;
|
||||||
using System.Windows.Forms.Integration;
|
using System.Windows.Forms.Integration;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using Greenshot.Editor.Controls;
|
using Greenshot.Editor.Controls.Emoji;
|
||||||
using Greenshot.Editor.Helpers;
|
using Greenshot.Editor.Helpers;
|
||||||
using Image = System.Drawing.Image;
|
using Image = System.Drawing.Image;
|
||||||
|
|
||||||
|
@ -95,7 +95,10 @@ namespace Greenshot.Editor.Drawing.Emoji
|
||||||
// Create one picker control by surface
|
// Create one picker control by surface
|
||||||
// TODO: This is not ideal, as we need to controls from the surface, should replace this with a different solution.
|
// TODO: This is not ideal, as we need to controls from the surface, should replace this with a different solution.
|
||||||
_emojiPickerHost = _parent.Controls.Find("EmojiPickerHost", false).OfType<ElementHost>().FirstOrDefault();
|
_emojiPickerHost = _parent.Controls.Find("EmojiPickerHost", false).OfType<ElementHost>().FirstOrDefault();
|
||||||
if (_emojiPickerHost != null) return;
|
if (_emojiPickerHost != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_emojiPicker = new EmojiPicker();
|
_emojiPicker = new EmojiPicker();
|
||||||
_emojiPicker.Picked += (_, args) =>
|
_emojiPicker.Picked += (_, args) =>
|
||||||
|
@ -136,7 +139,10 @@ namespace Greenshot.Editor.Drawing.Emoji
|
||||||
/// <param name="e">PropertyChangedEventArgs</param>
|
/// <param name="e">PropertyChangedEventArgs</param>
|
||||||
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!e.PropertyName.Equals(nameof(Selected))) return;
|
if (!e.PropertyName.Equals(nameof(Selected)))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Selected)
|
if (!Selected)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue