Skip to content

Commit f7b46e6

Browse files
Add Highlighter Ability.
1 parent 12a32f4 commit f7b46e6

File tree

7 files changed

+61
-5
lines changed

7 files changed

+61
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
![image](https://github.com/mohammadKarimi/Riter/blob/main/screenshots/Preview.png)
2424
![image](https://github.com/mohammadKarimi/Riter/blob/main/screenshots/Preview_Panel.png)
2525
![image](https://github.com/mohammadKarimi/Riter/blob/main/screenshots/Preview_Whiteboard.png)
26-
26+
![image](https://github.com/mohammadKarimi/Riter/blob/main/screenshots/Preview_Highlighter.png)
2727
<br/>
2828
The project is called "Riter," and it is a drawing application built using WPF (Windows Presentation Foundation). Here's a brief overview of the project:
2929

screenshots/Preview_Highlighter.png

759 KB
Loading

src/Riter/Core/Consts/ButtonNames.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ public class ButtonNames
1515
public const string ErasingButton = "ErasingButton";
1616

1717
public const string SettingButton = "SettingButton";
18+
19+
public const string HighlighterButton = "HighlighterButton";
1820
}

src/Riter/Core/UI/ToolBox.xaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,18 @@
6363
</StackPanel>
6464
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="2,0,2,0">
6565
<Border Margin="0,0,2,0" Width="32" Height="32" CornerRadius="4" HorizontalAlignment="Center" VerticalAlignment="Center">
66-
<Button ToolTip="Change Color [Ctrl+2]" Style="{StaticResource ToolboxButtonStyle}" Content="{StaticResource Icon_Brush}" />
66+
<Button ToolTip="Highlighter [Ctrl+2]" Content="{StaticResource Icon_Highlighetr}" Command="{Binding DrawingHighlighterCommand}">
67+
<Button.Style>
68+
<Style TargetType="Button" BasedOn="{StaticResource ToolboxButtonStyle}">
69+
<Setter Property="Tag" Value="UnSelected"/>
70+
<Style.Triggers>
71+
<DataTrigger Binding="{Binding ButtonSelectedName}" Value="HighlighterButton">
72+
<Setter Property="Tag" Value="Selected"/>
73+
</DataTrigger>
74+
</Style.Triggers>
75+
</Style>
76+
</Button.Style>
77+
</Button>
6778
</Border>
6879
<Border Width="12" Height="32" CornerRadius="4" HorizontalAlignment="Center" VerticalAlignment="Center">
6980
<ContentControl Content="{StaticResource Icon_BrushArrow}" />

src/Riter/Resources/Icons.xaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<Path Data="M21.9238 15.4801L21.9221 15.4781C21.9221 15.4781 21.7161 15.2312 21.3045 14.8413C21.3045 14.8413 20.4604 14.0416 19.459 13.374C19.459 13.374 18.5048 12.7379 17.5205 12.2923C17.5205 12.2923 17.4471 13.6964 16.9827 15.0048C16.9827 15.0048 16.4528 16.4974 15.4918 17.6392C15.4918 17.6392 13.2944 20.25 9.75 20.25C9.75 20.25 7.24247 20.25 5.84571 18.5739C5.84571 18.5739 5.21211 17.8136 4.96281 16.838C4.96281 16.838 4.71798 15.88 4.8852 14.8767C4.8852 14.8767 5.24708 12.7054 7.2024 11.2976C7.2024 11.2976 9.35184 9.75 12.75 9.75C12.75 9.75 14.348 9.75 15.8793 10.1336C15.8793 10.1336 15.5546 8.53833 14.5504 7.32104C14.5504 7.32104 12.8418 5.25 9.75 5.25C9.75 5.25 7.20059 5.25 4.78102 7.18565C4.78102 7.18565 3.5498 8.17063 2.8603 9.13593C2.74468 9.29779 2.56951 9.40709 2.3733 9.4398C2.33442 9.44628 2.29509 9.44968 2.25568 9.44998L2.25 9.45C2.09368 9.45 1.94127 9.40116 1.81407 9.3103C1.63021 9.17897 1.51536 8.97175 1.50143 8.74624C1.50048 8.73084 1.5 8.71542 1.5 8.7C1.5 8.54368 1.54884 8.39127 1.6397 8.26407C1.6397 8.26407 2.4502 7.12937 3.84398 6.01435C3.84398 6.01435 6.67441 3.75 9.75 3.75C9.75 3.75 13.5489 3.75 15.7074 6.36646C15.7074 6.36646 16.653 7.51265 17.1237 9.02293C17.1237 9.02293 17.3698 9.81244 17.4683 10.6419C17.4683 10.6419 18.9107 11.2057 20.291 12.126C20.291 12.126 21.399 12.8646 22.3361 13.7524C22.3361 13.7524 22.8131 14.2043 23.0758 14.5194C23.186 14.6516 23.2477 14.8183 23.2499 14.9904L23.25 15C23.25 15.2226 23.1511 15.4337 22.9801 15.5762C22.8479 15.6864 22.6817 15.7477 22.5096 15.7499L22.5 15.75C22.2774 15.75 22.0663 15.6511 21.9238 15.4801ZM16.0315 11.9813C16.0315 11.9813 16.0346 11.8564 16.0345 11.7334C16.0345 11.7334 14.4306 11.25 12.75 11.25C12.75 11.25 9.83566 11.25 8.07885 12.5149C8.07885 12.5149 6.62507 13.5616 6.3648 15.1233C6.3648 15.1233 6.12446 16.5653 6.99804 17.6136C6.99804 17.6136 7.94503 18.75 9.75 18.75C9.75 18.75 12.5963 18.75 14.3442 16.6733C14.3442 16.6733 15.9622 14.7508 16.0315 11.9813Z" Fill="#1C1C1C"/>
5858
</Canvas>
5959
<Canvas Width="24" Height="24" x:Key="Icon_Pen1x">
60-
<Path StrokeThickness="6" Data="M21.9238 15.4801L21.9221 15.4781C21.9221 15.4781 21.7161 15.2312 21.3045 14.8413C21.3045 14.8413 20.4604 14.0416 19.459 13.374C19.459 13.374 18.5048 12.7379 17.5205 12.2923C17.5205 12.2923 17.4471 13.6964 16.9827 15.0048C16.9827 15.0048 16.4528 16.4974 15.4918 17.6392C15.4918 17.6392 13.2944 20.25 9.75 20.25C9.75 20.25 7.24247 20.25 5.84571 18.5739C5.84571 18.5739 5.21211 17.8136 4.96281 16.838C4.96281 16.838 4.71798 15.88 4.8852 14.8767C4.8852 14.8767 5.24708 12.7054 7.2024 11.2976C7.2024 11.2976 9.35184 9.75 12.75 9.75C12.75 9.75 14.348 9.75 15.8793 10.1336C15.8793 10.1336 15.5546 8.53833 14.5504 7.32104C14.5504 7.32104 12.8418 5.25 9.75 5.25C9.75 5.25 7.20059 5.25 4.78102 7.18565C4.78102 7.18565 3.5498 8.17063 2.8603 9.13593C2.74468 9.29779 2.56951 9.40709 2.3733 9.4398C2.33442 9.44628 2.29509 9.44968 2.25568 9.44998L2.25 9.45C2.09368 9.45 1.94127 9.40116 1.81407 9.3103C1.63021 9.17897 1.51536 8.97175 1.50143 8.74624C1.50048 8.73084 1.5 8.71542 1.5 8.7C1.5 8.54368 1.54884 8.39127 1.6397 8.26407C1.6397 8.26407 2.4502 7.12937 3.84398 6.01435C3.84398 6.01435 6.67441 3.75 9.75 3.75C9.75 3.75 13.5489 3.75 15.7074 6.36646C15.7074 6.36646 16.653 7.51265 17.1237 9.02293C17.1237 9.02293 17.3698 9.81244 17.4683 10.6419C17.4683 10.6419 18.9107 11.2057 20.291 12.126C20.291 12.126 21.399 12.8646 22.3361 13.7524C22.3361 13.7524 22.8131 14.2043 23.0758 14.5194C23.186 14.6516 23.2477 14.8183 23.2499 14.9904L23.25 15C23.25 15.2226 23.1511 15.4337 22.9801 15.5762C22.8479 15.6864 22.6817 15.7477 22.5096 15.7499L22.5 15.75C22.2774 15.75 22.0663 15.6511 21.9238 15.4801ZM16.0315 11.9813C16.0315 11.9813 16.0346 11.8564 16.0345 11.7334C16.0345 11.7334 14.4306 11.25 12.75 11.25C12.75 11.25 9.83566 11.25 8.07885 12.5149C8.07885 12.5149 6.62507 13.5616 6.3648 15.1233C6.3648 15.1233 6.12446 16.5653 6.99804 17.6136C6.99804 17.6136 7.94503 18.75 9.75 18.75C9.75 18.75 12.5963 18.75 14.3442 16.6733C14.3442 16.6733 15.9622 14.7508 16.0315 11.9813Z" Fill="Black"/>
60+
<Path StrokeThickness="6" Data="M21.9238 15.4801L21.9221 15.4781C21.9221 15.4781 21.7161 15.2312 21.3045 14.8413C21.3045 14.8413 20.4604 14.0416 19.459 13.374C19.459 13.374 18.5048 12.7379 17.5205 12.2923C17.5205 12.2923 17.4471 13.6964 16.9827 15.0048C16.9827 15.0048 16.4528 16.4974 15.4918 17.6392C15.4918 17.6392 13.2944 20.25 9.75 20.25C9.75 20.25 7.24247 20.25 5.84571 18.5739C5.84571 18.5739 5.21211 17.8136 4.96281 16.838C4.96281 16.838 4.71798 15.88 4.8852 14.8767C4.8852 14.8767 5.24708 12.7054 7.2024 11.2976C7.2024 11.2976 9.35184 9.75 12.75 9.75C12.75 9.75 14.348 9.75 15.8793 10.1336C15.8793 10.1336 15.5546 8.53833 14.5504 7.32104C14.5504 7.32104 12.8418 5.25 9.75 5.25C9.75 5.25 7.20059 5.25 4.78102 7.18565C4.78102 7.18565 3.5498 8.17063 2.8603 9.13593C2.74468 9.29779 2.56951 9.40709 2.3733 9.4398C2.33442 9.44628 2.29509 9.44968 2.25568 9.44998L2.25 9.45C2.09368 9.45 1.94127 9.40116 1.81407 9.3103C1.63021 9.17897 1.51536 8.97175 1.50143 8.74624C1.50048 8.73084 1.5 8.71542 1.5 8.7C1.5 8.54368 1.54884 8.39127 1.6397 8.26407C1.6397 8.26407 2.4502 7.12937 3.84398 6.01435C3.84398 6.01435 6.67441 3.75 9.75 3.75C9.75 3.75 13.5489 3.75 15.7074 6.36646C15.7074 6.36646 16.653 7.51265 17.1237 9.02293C17.1237 9.02293 17.3698 9.81244 17.4683 10.6419C17.4683 10.6419 18.9107 11.2057 20.291 12.126C20.291 12.126 21.399 12.8646 22.3361 13.7524C22.3361 13.7524 22.8131 14.2043 23.0758 14.5194C23.186 14.6516 23.2477 14.8183 23.2499 14.9904L23.25 15C23.25 15.2226 23.1511 15.4337 22.9801 15.5762C22.8479 15.6864 22.6817 15.7477 22.5096 15.7499L22.5 15.75C22.2774 15.75 22.0663 15.6511 21.9238 15.4801ZM16.0315 11.9813C16.0315 11.9813 16.0346 11.8564 16.0345 11.7334C16.0345 11.7334 14.4306 11.25 12.75 11.25C12.75 11.25 9.83566 11.25 8.07885 12.5149C8.07885 12.5149 6.62507 13.5616 6.3648 15.1233C6.3648 15.1233 6.12446 16.5653 6.99804 17.6136C6.99804 17.6136 7.94503 18.75 9.75 18.75C9.75 18.75 12.5963 18.75 14.3442 16.6733C14.3442 16.6733 15.9622 14.7508 16.0315 11.9813Z" Fill="Black"/>
6161
</Canvas>
6262

6363
<Canvas Width="24" Height="24" x:Key="Icon_Pen2x">
@@ -249,4 +249,11 @@
249249

250250
</Canvas>
251251

252+
<Canvas Width="24" Height="24" x:Key="Icon_Highlighetr">
253+
<Path Data="M3 6C3 6 3 5.37868 3.43934 4.93934C3.43934 4.93934 3.87868 4.5 4.5 4.5H18.75C18.75 4.5 19.3713 4.5 19.8107 4.93934C19.8107 4.93934 20.25 5.37868 20.25 6V12C20.25 12 20.25 12.6213 19.8107 13.0607C19.8107 13.0607 19.3713 13.5 18.75 13.5H4.5C4.5 13.5 3.87868 13.5 3.43934 13.0607C3.43934 13.0607 3 12.6213 3 12V6ZM4.5 6V12H18.75V6H4.5Z" Fill="#1C1C1C"/>
254+
<Path Data="M11.25 18.5625V21.75C11.25 22.1642 11.5858 22.5 12 22.5C12.4142 22.5 12.75 22.1642 12.75 21.75V18.5625C12.75 18.564 12.7505 18.5642 12.7505 18.5642L12.7519 18.5631C12.7537 18.5606 12.7567 18.5598 12.7567 18.5598L22.1617 15.8807C22.6467 15.7371 22.9463 15.3394 22.9463 15.3394C23.2459 14.9416 23.25 14.4437 23.25 14.4437L23.25 9.75C23.25 9.12868 22.8107 8.68934 22.8107 8.68934C22.3713 8.25 21.75 8.25 21.75 8.25H19.5C19.0858 8.25 18.75 8.58579 18.75 9C18.75 9.41421 19.0858 9.75 19.5 9.75H21.75L21.75 14.4313C21.75 14.4344 21.7481 14.4369 21.7481 14.4369L21.7477 14.4382L21.7507 14.4381L12.3308 17.1215C11.8533 17.2629 11.5537 17.6606 11.5537 17.6606C11.2541 18.0584 11.25 18.5625 11.25 18.5625Z" Fill="#1C1C1C"/>
255+
<Path Data="M3.75 8.25H1.5C1.08579 8.25 0.75 8.58579 0.75 9C0.75 9.41421 1.08579 9.75 1.5 9.75H3.75C4.16421 9.75 4.5 9.41421 4.5 9C4.5 8.58579 4.16421 8.25 3.75 8.25Z" Fill="#1C1C1C"/>
256+
257+
</Canvas>
258+
252259
</ResourceDictionary>

src/Riter/ViewModel/PallateStateViewModel.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ public partial class PalleteStateViewModel : INotifyPropertyChanged
3737
public DrawingAttributes InkDrawingAttributes => new()
3838
{
3939
Color = (Color)ColorConverter.ConvertFromString(_state.InkColor),
40-
Height = _state.SizeOfBrush,
41-
Width = _state.SizeOfBrush,
40+
Height = _state.IsHighlighter ? _state.SizeOfBrush * 2 : _state.SizeOfBrush,
41+
Width = _state.IsHighlighter ? _state.SizeOfBrush * 2 : _state.SizeOfBrush,
42+
IsHighlighter = _state.IsHighlighter,
43+
IgnorePressure = true,
44+
StylusTip = _state.IsHighlighter ? StylusTip.Rectangle : StylusTip.Ellipse,
4245
};
4346

4447
/// <summary>
@@ -144,6 +147,7 @@ public PalleteStateViewModel(PalleteState palleteState, IStrokeHistoryService st
144147
TrashButtonCommand = new RelayCommand(Trash);
145148
SetInkColorButtonCommand = new RelayCommand<string>(_state.SetInkColor);
146149
SetSizeOfBrushCommand = new RelayCommand<string>(_state.SetSizeOfBrush);
150+
DrawingHighlighterCommand = new RelayCommand(_state.EnableHighlighter);
147151
}
148152

149153
/// <summary>
@@ -195,4 +199,6 @@ public PalleteStateViewModel(PalleteState palleteState, IStrokeHistoryService st
195199
/// Gets click on brush size buttons in setting pannel.
196200
/// </summary>
197201
public ICommand SetSizeOfBrushCommand { get; private set; }
202+
203+
public ICommand DrawingHighlighterCommand { get; private set; }
198204
}

src/Riter/ViewModel/PalleteState.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.ComponentModel;
22
using System.Windows.Controls;
3+
using System.Windows.Ink;
4+
using System.Windows.Media;
35
using Microsoft.Extensions.DependencyInjection;
46
using Riter.Core;
57
using Riter.Core.Consts;
@@ -23,6 +25,7 @@ public class PalleteState : INotifyPropertyChanged
2325
private string _inkColor;
2426
private string _colorSelected;
2527
private double _sizeOfBrush;
28+
private bool _isHighlighter;
2629

2730
/// <summary>
2831
/// Initializes a new instance of the <see cref="PalleteState"/> class.
@@ -51,6 +54,15 @@ public bool IsReleased
5154
});
5255
}
5356

57+
/// <summary>
58+
/// Gets a value indicating whether gets a value of Enabling Highlighter Pen.
59+
/// </summary>
60+
public bool IsHighlighter
61+
{
62+
get => _isHighlighter;
63+
private set => SetProperty(ref _isHighlighter, value, "InkDrawingAttributes");
64+
}
65+
5466
/// <summary>
5567
/// Gets a value of InkColor.
5668
/// </summary>
@@ -143,6 +155,7 @@ public void SetInkColor(string color)
143155
/// <param name="buttonName">The name of the button pressed to start drawing ink.</param>
144156
public void StartDrawing()
145157
{
158+
IsHighlighter = false;
146159
if (IsReleased is false && ButtonSelectedName == ButtonNames.DrawingButton)
147160
{
148161
ResetToDefault();
@@ -167,6 +180,10 @@ public void StartErasing()
167180
ButtonSelectedName = ButtonNames.ErasingButton;
168181
}
169182

183+
/// <summary>
184+
/// Set Type of Ink editing Mode for Line and shape mode.
185+
/// </summary>
186+
/// <param name="inkCanvasEditing">type of edition.</param>
170187
public void SetInkCanvasEditingMode(InkCanvasEditingMode inkCanvasEditing) => InkEditingMode = inkCanvasEditing;
171188

172189
/// <summary>
@@ -201,6 +218,19 @@ public void SetSizeOfBrush(string size)
201218
ResetPreviousButton();
202219
}
203220

221+
/// <summary>
222+
/// Enable Highlighter pen.
223+
/// </summary>
224+
public void EnableHighlighter()
225+
{
226+
IsHighlighter = true;
227+
ButtonSelectedName = ButtonNames.HighlighterButton;
228+
InkEditingMode = InkCanvasEditingMode.Ink;
229+
IsReleased = false;
230+
SettingPanelVisibility = false;
231+
OnPropertyChanged("InkDrawingAttributes");
232+
}
233+
204234
/// <summary>
205235
/// Raises the PropertyChanged event when a property value changes.
206236
/// </summary>

0 commit comments

Comments
 (0)