├── gif.gif
├── src
├── key.snk
├── Directory.Build.props
├── Breakpoints.Avalonia
│ ├── Xmlns.cs
│ ├── ResponsivityBreakpoints.axaml
│ ├── ResponsivityBreakpoints.axaml.cs
│ ├── Controls
│ │ ├── Breakpoint.axaml
│ │ ├── TemplatedBreakpoint.axaml
│ │ ├── Breakpoint.cs
│ │ ├── TemplatedBreakpoint.cs
│ │ └── Breakpoints.cs
│ ├── Nullables.cs
│ ├── Breakpoints.Avalonia.csproj
│ ├── Collections
│ │ └── BreakpointList.cs
│ └── Markup
│ │ └── BreakpointExtension.cs
├── Breakpoints.Avalonia.Xmlns
│ ├── Xmlns.cs
│ └── Breakpoints.Avalonia.Xmlns.csproj
├── Breakpoints.Avalonia.TestApp
│ ├── UserControl1.axaml.cs
│ ├── App.axaml
│ ├── App.axaml.cs
│ ├── Program.cs
│ ├── app.manifest
│ ├── Breakpoints.Avalonia.TestApp.csproj
│ ├── MainWindow.axaml.cs
│ ├── MainWindow.axaml
│ └── UserControl1.axaml
├── Breakpoints.Avalonia.sln
└── .editorconfig
├── LICENSE
├── .gitignore
└── README.md
/gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AVVI94/Breakpoints.Avalonia/HEAD/gif.gif
--------------------------------------------------------------------------------
/src/key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AVVI94/Breakpoints.Avalonia/HEAD/src/key.snk
--------------------------------------------------------------------------------
/src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | enable
4 | 11.0.10
5 | Latest
6 | 2.3
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/Xmlns.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Metadata;
2 | [assembly: XmlnsDefinition("https://github.com/AVVI94", "AVVI94.Breakpoints.Avalonia")]
3 | [assembly: XmlnsDefinition("https://github.com/AVVI94", "AVVI94.Breakpoints.Avalonia.Controls")]
4 | [assembly: XmlnsDefinition("https://github.com/AVVI94", "AVVI94.Breakpoints.Avalonia.Markup")]
5 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.Xmlns/Xmlns.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Metadata;
2 | [assembly: XmlnsDefinition("https://github.com/avaloniaui", "AVVI94.Breakpoints.Avalonia")]
3 | [assembly: XmlnsDefinition("https://github.com/avaloniaui", "AVVI94.Breakpoints.Avalonia.Controls")]
4 | [assembly: XmlnsDefinition("https://github.com/avaloniaui", "AVVI94.Breakpoints.Avalonia.Markup")]
5 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.TestApp/UserControl1.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 | using Avalonia.Markup.Xaml;
4 | using System.Diagnostics;
5 | using System.Threading;
6 |
7 | namespace Breakpoints.Avalonia.TestApp;
8 |
9 | public partial class UserControl1 : UserControl
10 | {
11 | public UserControl1()
12 | {
13 | InitializeComponent();
14 | }
15 | }
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.TestApp/App.axaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/ResponsivityBreakpoints.axaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/ResponsivityBreakpoints.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 | using Avalonia.Styling;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Text;
7 |
8 | namespace AVVI94.Breakpoints.Avalonia;
9 |
10 | public class ResponsivityBreakpoints : Styles
11 | {
12 | public ResponsivityBreakpoints()
13 | {
14 | AvaloniaXamlLoader.Load(this);
15 | }
16 |
17 | public ResponsivityBreakpoints(IResourceHost owner) : base(owner)
18 | {
19 | AvaloniaXamlLoader.Load(this);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.Xmlns/Breakpoints.Avalonia.Xmlns.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | True
6 | ..\key.snk
7 | True
8 | Jan Král
9 | AVVI94.$(RootNamespace)
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.TestApp/App.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls.ApplicationLifetimes;
3 | using Avalonia.Markup.Xaml;
4 |
5 | namespace Breakpoints.Avalonia.TestApp
6 | {
7 | public partial class App : Application
8 | {
9 | public override void Initialize()
10 | {
11 | AvaloniaXamlLoader.Load(this);
12 | }
13 |
14 | public override void OnFrameworkInitializationCompleted()
15 | {
16 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
17 | {
18 | desktop.MainWindow = new MainWindow();
19 | }
20 |
21 | base.OnFrameworkInitializationCompleted();
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/Controls/Breakpoint.axaml:
--------------------------------------------------------------------------------
1 |
4 |
6 |
7 |
8 |
9 |
10 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.TestApp/Program.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using System;
3 |
4 | namespace Breakpoints.Avalonia.TestApp
5 | {
6 | internal class Program
7 | {
8 | // Initialization code. Don't use any Avalonia, third-party APIs or any
9 | // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
10 | // yet and stuff might break.
11 | [STAThread]
12 | public static void Main(string[] args) => BuildAvaloniaApp()
13 | .StartWithClassicDesktopLifetime(args);
14 |
15 | // Avalonia configuration, don't remove; also used by visual designer.
16 | public static AppBuilder BuildAvaloniaApp()
17 | => AppBuilder.Configure()
18 | .UsePlatformDetect()
19 | .WithInterFont()
20 | .LogToTrace();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/Controls/TemplatedBreakpoint.axaml:
--------------------------------------------------------------------------------
1 |
4 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.TestApp/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Jan Král
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.TestApp/Breakpoints.Avalonia.TestApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | WinExe
4 | net8.0
5 | enable
6 | true
7 | app.manifest
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/Nullables.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace System.Diagnostics.CodeAnalysis;
6 |
7 | /// Specifies that an output will not be null even if the corresponding type allows it. Specifies that an input argument was not null when the call returns.
8 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
9 | internal sealed class NotNullAttribute : Attribute;
10 |
11 | /// Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it.
12 | [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
13 | internal sealed class NotNullWhenAttribute : Attribute
14 | {
15 | /// Initializes the attribute with the specified return value condition.
16 | ///
17 | /// The return value condition. If the method returns this value, the associated parameter will not be null.
18 | ///
19 | public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
20 |
21 | /// Gets the return value condition.
22 | public bool ReturnValue { get; }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/Breakpoints.Avalonia.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | True
6 | True
7 | False
8 | $(AssemblyName)
9 | Jan Král
10 | Breakpoints.Avalonia is a library for Avalonia UI (https://avaloniaui.net/) that provides responsive design capabilities using breakpoints. It allows you to define different UI layouts and behaviors based on the size of the application window.
11 | https://github.com/AVVI94/Breakpoints.Avalonia
12 | README.md
13 | https://github.com/AVVI94/Breakpoints.Avalonia
14 | true
15 | ..\key.snk
16 | AVVI94.Breakpoints.Avalonia
17 | $(RootNamespace)
18 | Avalonia, breakpoints, responsivity, responsive, desktop
19 |
20 |
21 |
22 |
23 | True
24 | \
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.TestApp/MainWindow.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using AVVI94.Breakpoints.Avalonia.Collections;
3 | using System;
4 | using System.Diagnostics;
5 |
6 | namespace Breakpoints.Avalonia.TestApp
7 | {
8 | public partial class MainWindow : Window
9 | {
10 | public MainWindow()
11 | {
12 | InitializeComponent();
13 | BreakpointList bp = [
14 | ("XS", 600),
15 | ("S", 800),
16 | ("M", 1000),
17 | ("L", 1200),
18 | ("XL", 1400),
19 | ("XXL", 1600)
20 | ];
21 | AVVI94.Breakpoints.Avalonia.Controls.Breakpoints.SetValues(this, bp);
22 |
23 | GridInfoTextBox.Text = """
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | """;
35 | }
36 |
37 | bool flag = false;
38 | private void Button_Click(object? sender, global::Avalonia.Interactivity.RoutedEventArgs e)
39 | {
40 | var button = (Button)sender!;
41 | if(flag)
42 | {
43 | ((StackPanel)button.Parent!).Children.RemoveAt(((StackPanel)button.Parent).Children.Count - 1);
44 | flag = false;
45 | }
46 | else
47 | {
48 | ((StackPanel)button.Parent!).Children.Add(new UserControl1());
49 | flag = true;
50 | }
51 |
52 | GC.Collect();
53 | GC.WaitForPendingFinalizers();
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio Version 17
3 | VisualStudioVersion = 17.11.35312.102
4 | MinimumVisualStudioVersion = 10.0.40219.1
5 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{838EF520-3CF7-447D-B1CD-AF3468F41DEC}"
6 | ProjectSection(SolutionItems) = preProject
7 | .editorconfig = .editorconfig
8 | Directory.Build.props = Directory.Build.props
9 | ..\README.md = ..\README.md
10 | EndProjectSection
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Breakpoints.Avalonia", "Breakpoints.Avalonia\Breakpoints.Avalonia.csproj", "{D444E0FE-960B-4B38-9ED8-5740DAE5A2CD}"
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Breakpoints.Avalonia.TestApp", "Breakpoints.Avalonia.TestApp\Breakpoints.Avalonia.TestApp.csproj", "{D74723CE-B5C8-4845-A8A5-54E50FEBA4BB}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Breakpoints.Avalonia.Xmlns", "Breakpoints.Avalonia.Xmlns\Breakpoints.Avalonia.Xmlns.csproj", "{DB2989BC-0EDD-4DF9-92B8-CD8F3D456F73}"
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|Any CPU = Debug|Any CPU
21 | Release|Any CPU = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {D444E0FE-960B-4B38-9ED8-5740DAE5A2CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {D444E0FE-960B-4B38-9ED8-5740DAE5A2CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {D444E0FE-960B-4B38-9ED8-5740DAE5A2CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {D444E0FE-960B-4B38-9ED8-5740DAE5A2CD}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {D74723CE-B5C8-4845-A8A5-54E50FEBA4BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {D74723CE-B5C8-4845-A8A5-54E50FEBA4BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {D74723CE-B5C8-4845-A8A5-54E50FEBA4BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {D74723CE-B5C8-4845-A8A5-54E50FEBA4BB}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {DB2989BC-0EDD-4DF9-92B8-CD8F3D456F73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {DB2989BC-0EDD-4DF9-92B8-CD8F3D456F73}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {DB2989BC-0EDD-4DF9-92B8-CD8F3D456F73}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {DB2989BC-0EDD-4DF9-92B8-CD8F3D456F73}.Release|Any CPU.Build.0 = Release|Any CPU
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | GlobalSection(ExtensibilityGlobals) = postSolution
41 | SolutionGuid = {5063A987-1D2E-4643-A985-424CACF6671D}
42 | EndGlobalSection
43 | EndGlobal
44 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/Collections/BreakpointList.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Avalonia = global::Avalonia;
3 | using BP = AVVI94.Breakpoints.Avalonia.Controls.Breakpoints;
4 | using NsBreakpoints = AVVI94.Breakpoints.Avalonia;
5 |
6 | namespace AVVI94.Breakpoints.Avalonia.Collections;
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 |
13 | ///
14 | /// An ordered list of breakpoints with keys and values
15 | ///
16 | public sealed class BreakpointList : IEnumerable, IEnumerable>
17 | {
18 | private readonly Dictionary _keyValuePairs = [];
19 | private readonly SortedSet<(double Value, string Key)> _sortedValues = [];
20 |
21 | ///
22 | /// Provides a read-only view of the items in the list
23 | ///
24 | public IReadOnlyDictionary Items => _keyValuePairs;
25 | ///
26 | /// Provides a read-only view of the breakpoints in the list sorted from min to max.
27 | ///
28 | public IEnumerable<(double Value, string Key)> SortedItems => _sortedValues;
29 |
30 | ///
31 | /// Add a new key-value pair to the list
32 | ///
33 | /// Breakpoint name
34 | /// Breakpoint value
35 | /// Thrown if the breakpoint name or value is already present in the collection.
36 | public void Add(string key, double value)
37 | {
38 | if (_keyValuePairs.ContainsKey(key))
39 | throw new ArgumentException("The key already exists.");
40 |
41 | if (!_sortedValues.Add((value, key)))
42 | throw new ArgumentException("The value already exists.");
43 |
44 | _keyValuePairs[key] = value;
45 | }
46 |
47 | ///
48 | /// Add a new key-value pair to the list, inteded to be used with collection initializers
49 | ///
50 | /// Breakpoint
51 | public void Add((string Key, double Value) item) => Add(item.Key, item.Value);
52 |
53 | ///
54 | /// Try to get the value of a breakpoint
55 | ///
56 | /// Breakpoint name
57 | /// [OUT] Value of the breakpoint
58 | ///
59 | public bool TryGetValue(string key, out double value) => _keyValuePairs.TryGetValue(key, out value);
60 |
61 | ///
62 | /// Remove a breakpoint from the list
63 | ///
64 | /// Name of the breakpoint
65 | ///
66 | public bool Remove(string key)
67 | {
68 | if (_keyValuePairs.TryGetValue(key, out double value))
69 | {
70 | _keyValuePairs.Remove(key);
71 | _sortedValues.Remove((value, key));
72 | return true;
73 | }
74 | return false;
75 | }
76 |
77 | ///
78 | /// Get or set the value of a breakpoint
79 | ///
80 | /// Name of the breakpoint
81 | /// Value of the breakpoint
82 | public double this[string key]
83 | {
84 | get => _keyValuePairs[key];
85 | set
86 | {
87 | if (_keyValuePairs.ContainsKey(key))
88 | {
89 | var oldValue = _keyValuePairs[key];
90 | _sortedValues.Remove((oldValue, key));
91 | _keyValuePairs[key] = value;
92 | _sortedValues.Add((value, key));
93 | }
94 | else
95 | {
96 | Add(key, value);
97 | }
98 | }
99 | }
100 | ///
101 | /// Get the key-value pair at the specified index
102 | ///
103 | /// Breakpoint index
104 | ///
105 | ///
106 | public (string Key, double Value) this[int index]
107 | {
108 | get
109 | {
110 | if (index < 0 || index >= _sortedValues.Count)
111 | throw new IndexOutOfRangeException();
112 |
113 | var item = _sortedValues.ElementAt(index);
114 | return (item.Key, item.Value);
115 | }
116 | }
117 | ///
118 | /// Number of breakpoints in the list
119 | ///
120 | public int Count => _keyValuePairs.Count;
121 |
122 | ///
123 | /// Find the next breakpoint with a value greater than the specified value.
124 | ///
125 | /// Searched value
126 | /// Breakpoint name and value or if no next breakpoint was found.
127 | public KeyValuePair? FindNext(double value)
128 | {
129 | var next = _sortedValues.FirstOrDefault(x => x.Value > value);
130 | return next == default ? null : new(next.Key, next.Value);
131 | }
132 |
133 | ///
134 | /// Find the previous breakpoint with a value less than the specified value.
135 | ///
136 | /// Searched value
137 | ///
138 | /// Breakpoint name and value or if no previous breakpoint was found.
139 | ///
140 | public KeyValuePair? FindPrevious(double value)
141 | {
142 | var previous = _sortedValues.LastOrDefault(x => x.Value < value);
143 | return previous == default ? null : new(previous.Key, previous.Value);
144 | }
145 |
146 | public KeyValuePair? FindCurrent(double value)
147 | {
148 | var current = _sortedValues.LastOrDefault(x => value >= x.Value);
149 | return current == default ? FindNext(value) ?? FindPrevious(value) : new(current.Key, current.Value);
150 | }
151 |
152 | ///
153 | /// Get an enumerator for the breakpoints. Implemented mainly for collection initializers.
154 | ///
155 | public IEnumerator GetEnumerator()
156 | {
157 | return ((IEnumerable)Items).GetEnumerator();
158 | }
159 |
160 | IEnumerator> IEnumerable>.GetEnumerator()
161 | {
162 | return Items.GetEnumerator();
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.TestApp/MainWindow.axaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
16 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
54 |
55 |
56 |
59 |
60 |
61 |
64 |
65 |
67 |
70 |
71 |
73 |
76 |
77 |
79 |
82 |
83 |
85 |
88 |
89 |
90 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
113 |
117 |
120 |
121 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/Controls/Breakpoint.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 | using Avalonia.Controls.Templates;
4 | using Avalonia.Data;
5 | using Avalonia.Layout;
6 | using Avalonia.Logging;
7 | using Avalonia.Metadata;
8 | using Avalonia.VisualTree;
9 | using System;
10 | using System.Collections.Specialized;
11 | using System.Diagnostics;
12 | using System.Linq;
13 | using System.Text;
14 |
15 | namespace AVVI94.Breakpoints.Avalonia.Controls;
16 |
17 | ///
18 | /// A control that can be used to hide or show content based on the current breakpoint.
19 | ///
20 | public partial class Breakpoint : ContentControl, IDisposable
21 | {
22 | private bool _isDisposed;
23 | Layoutable? _breakpointProvider;
24 |
25 | ///
26 | /// Enabled StyledProperty definition
27 | ///
28 | public static readonly StyledProperty EnabledProperty =
29 | AvaloniaProperty.Register(nameof(Enabled), true, defaultBindingMode: BindingMode.TwoWay);
30 |
31 | ///
32 | /// Gets or sets the Enabled property.
33 | ///
34 | public bool Enabled
35 | {
36 | get => GetValue(EnabledProperty);
37 | set => SetValue(EnabledProperty, value);
38 | }
39 |
40 | ///
41 | /// For StyledProperty definition
42 | ///
43 | public static readonly StyledProperty ForProperty =
44 | AvaloniaProperty.Register(nameof(For));
45 |
46 | ///
47 | /// Gets or sets the For property.
48 | ///
49 | public string For
50 | {
51 | get => GetValue(ForProperty);
52 | set => SetValue(ForProperty, value);
53 | }
54 |
55 | ///
56 | /// UpperBound StyledProperty definition
57 | ///
58 | public static readonly StyledProperty UpperBoundProperty =
59 | AvaloniaProperty.Register(nameof(UpperBound));
60 |
61 | ///
62 | /// Gets or sets the UpperBound property.
63 | ///
64 | public string? UpperBound
65 | {
66 | get => GetValue(UpperBoundProperty);
67 | set => SetValue(UpperBoundProperty, value);
68 | }
69 |
70 | ///
71 | /// IsExclusive StyledProperty definition
72 | ///
73 | public static readonly StyledProperty IsExclusiveProperty =
74 | AvaloniaProperty.Register(nameof(IsExclusive));
75 |
76 | ///
77 | /// Gets or sets the IsExclusive property.
78 | ///
79 | public bool IsExclusive
80 | {
81 | get => GetValue(IsExclusiveProperty);
82 | set => SetValue(IsExclusiveProperty, value);
83 | }
84 |
85 | ///
86 | protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
87 | {
88 | base.OnAttachedToVisualTree(e);
89 | if (string.IsNullOrEmpty(For))
90 | {
91 | Logger.TryGet(LogEventLevel.Error, LogArea.Visual)?.Log(this, "The For property must be set to a valid value.");
92 | throw new InvalidOperationException("The For property must be set to a valid breakpoint value.");
93 | }
94 |
95 | if (Design.IsDesignMode)
96 | {
97 | var src = Breakpoints.FindDesignTimeParentWithDesignBreakpoint(this);
98 | if (src is null)
99 | {
100 | IsVisible = Enabled = true;
101 | return;
102 | }
103 | IsVisible = Breakpoints.GetDesignCurrentBreakpoint(src) == For;
104 | return;
105 | }
106 |
107 | if (!Breakpoints.TryFindBreakpoints(this, out _, out _breakpointProvider))
108 | {
109 | Logger.TryGet(LogEventLevel.Error, LogArea.Visual)?.Log(this, "Breakpoint not found, setting the Enabled property to true so this element is always visible.");
110 | Enabled = true;
111 | return;
112 | }
113 |
114 | Debug.Assert(_breakpointProvider is not null);
115 |
116 | _breakpointProvider!.PropertyChanged += BreakpointProvider_PropertyChanged;
117 | UpdateBreakpoint();
118 | }
119 |
120 | private void BreakpointProvider_PropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
121 | {
122 | if (e.Property == Breakpoints.CurrentBreakpointProperty)
123 | {
124 | UpdateBreakpoint();
125 | }
126 | }
127 |
128 | ///
129 | protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
130 | {
131 | base.OnDetachedFromVisualTree(e);
132 | Dispose();
133 | }
134 |
135 | ///
136 | protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e)
137 | {
138 | base.OnPropertyChanged(e);
139 | if (e.Property.Name == nameof(Enabled))
140 | {
141 | UpdateBreakpoint();
142 | }
143 | }
144 |
145 | private void UpdateBreakpoint()
146 | {
147 | if (!Enabled)
148 | {
149 | IsVisible = false;
150 | InvalidateVisual();
151 | return;
152 | }
153 | if (!string.IsNullOrEmpty(UpperBound))
154 | {
155 | IsVisible = Breakpoints.IsBetween(this, For, UpperBound!);
156 | return;
157 | }
158 | IsVisible = Breakpoints.ShouldBeVisible(this, For, IsExclusive);
159 | }
160 |
161 | ///
162 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
163 | ///
164 | public void Dispose()
165 | {
166 | Dispose(true);
167 | GC.SuppressFinalize(this);
168 | }
169 |
170 | ///
171 | /// Releases the unmanaged resources used by the and optionally releases the managed resources.
172 | ///
173 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
174 | protected virtual void Dispose(bool disposing)
175 | {
176 | if (_isDisposed)
177 | return;
178 |
179 | if (disposing)
180 | {
181 | // dispose managed resources here
182 | if (_breakpointProvider != null)
183 | {
184 | _breakpointProvider.PropertyChanged -= BreakpointProvider_PropertyChanged;
185 | }
186 | }
187 |
188 | // dispose unmanaged resources here
189 | _breakpointProvider = null;
190 | _isDisposed = true;
191 | }
192 | }
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia.TestApp/UserControl1.axaml:
--------------------------------------------------------------------------------
1 |
11 |
13 |
15 |
16 |
18 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
59 |
60 |
61 |
64 |
65 |
66 |
69 |
70 |
72 |
75 |
76 |
78 |
81 |
82 |
84 |
87 |
88 |
90 |
93 |
94 |
95 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
118 |
122 |
125 |
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/Controls/TemplatedBreakpoint.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 | using Avalonia.Controls.Templates;
4 | using Avalonia.Data;
5 | using Avalonia.Layout;
6 | using Avalonia.Logging;
7 | using Avalonia.Metadata;
8 | using AVVI94.Breakpoints.Avalonia.Collections;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Diagnostics;
12 | using System.Linq;
13 | using System.Text;
14 |
15 | namespace AVVI94.Breakpoints.Avalonia.Controls;
16 |
17 | ///
18 | /// A control that can change its content based on the current breakpoint
19 | ///
20 | public class TemplatedBreakpoint : ContentControl, IAddChild, IDisposable
21 | {
22 | ///
23 | /// Breakpoint provider resolved for this control.
24 | ///
25 | protected Layoutable? _breakpointProvider;
26 |
27 | ///
28 | /// BreakpointTemplates StyledProperty definition
29 | ///
30 | public static readonly StyledProperty> BreakpointTemplatesProperty =
31 | AvaloniaProperty.Register>(nameof(BreakpointTemplates), []);
32 |
33 | ///
34 | /// Gets or sets the BreakpointTemplates property.
35 | ///
36 | [Content]
37 | public IList BreakpointTemplates
38 | {
39 | get => this.GetValue(BreakpointTemplatesProperty);
40 | set => SetValue(BreakpointTemplatesProperty, value);
41 | }
42 |
43 | ///
44 | protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
45 | {
46 | base.OnAttachedToVisualTree(e);
47 |
48 | if (Design.IsDesignMode)
49 | {
50 | var src = Breakpoints.FindDesignTimeParentWithDesignBreakpoint(this);
51 | BreakpointTemplate? template = BreakpointTemplates.First();
52 | if (src is not null)
53 | {
54 | var bp = Breakpoints.GetDesignCurrentBreakpoint(src);
55 | foreach (var item in BreakpointTemplates)
56 | {
57 | if (item.For == bp)
58 | {
59 | template = item;
60 | break;
61 | }
62 | }
63 | }
64 | Content = template?.ContentTemplate?.Build(null);
65 | return;
66 | }
67 |
68 | if (!Breakpoints.TryFindBreakpoints(this, out _, out _breakpointProvider))
69 | {
70 | Logger.TryGet(LogEventLevel.Error, LogArea.Visual)?.Log(this, "Breakpoint not found, setting the Enabled property to true so this element is always visible.");
71 | return;
72 | }
73 |
74 | Debug.Assert(_breakpointProvider is not null);
75 |
76 | _breakpointProvider!.PropertyChanged += TemplatedBreakpoint_PropertyChanged;
77 | UpdateBreakpoint();
78 | }
79 |
80 | private void TemplatedBreakpoint_PropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
81 | {
82 | if (e.Property == Breakpoints.CurrentBreakpointProperty)
83 | {
84 | UpdateBreakpoint();
85 | }
86 | }
87 |
88 | ///
89 | protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
90 | {
91 | base.OnDetachedFromVisualTree(e);
92 | Dispose();
93 | }
94 |
95 | ///
96 | /// Updates the currently visible breakpoint content based on the current breakpoint and the available templates in .
97 | ///
98 | protected virtual void UpdateBreakpoint()
99 | {
100 | if (!IsEnabled || _breakpointProvider is null)
101 | {
102 | IsVisible = false;
103 | Content = null;
104 | InvalidateVisual();
105 | return;
106 | }
107 |
108 | var bps = Breakpoints.GetValues(_breakpointProvider);
109 | var current = Breakpoints.GetCurrentBreakpoint(_breakpointProvider);
110 | if (string.IsNullOrEmpty(current))
111 | {
112 | return;
113 | }
114 | double currentBp = bps.TryGetValue(current, out var val) ? val : 0;
115 |
116 | BreakpointTemplate? selectedTemplate = null;
117 | double highestBp = -1;
118 | double smallestBp = double.MaxValue;
119 | BreakpointTemplate? smallestTemplate = null;
120 |
121 | foreach (var template in BreakpointTemplates)
122 | {
123 | if (bps.Get(template.For) is double bp and not -1)
124 | {
125 | if (bp < smallestBp)
126 | {
127 | smallestBp = bp;
128 | smallestTemplate = template;
129 | }
130 |
131 | if (bp <= currentBp && bp > highestBp)
132 | {
133 | selectedTemplate = template;
134 | highestBp = bp;
135 | }
136 | }
137 | }
138 |
139 | selectedTemplate ??= smallestTemplate;
140 |
141 | Content = selectedTemplate?.ContentTemplate?.Build(null);
142 | }
143 |
144 | ///
145 | public void AddChild(BreakpointTemplate child)
146 | {
147 | this.BreakpointTemplates.Add(child);
148 | }
149 |
150 | public void Dispose()
151 | {
152 | if (_breakpointProvider is not null)
153 | {
154 | _breakpointProvider.PropertyChanged -= TemplatedBreakpoint_PropertyChanged;
155 | _breakpointProvider = null;
156 | }
157 | BreakpointTemplates.Clear();
158 | Content = null;
159 | InvalidateVisual();
160 | }
161 | }
162 |
163 | ///
164 | /// A template for a breakpoint in a control that can change its content based on the current breakpoint.
165 | ///
166 | public class BreakpointTemplate : AvaloniaObject
167 | {
168 | ///
169 | /// For DirectProperty definition
170 | ///
171 | public static readonly DirectProperty ForProperty =
172 | AvaloniaProperty.RegisterDirect(nameof(For),
173 | o => o.For,
174 | (o, v) => o.For = v);
175 |
176 | private string _For = "";
177 | ///
178 | /// Gets or sets the For property. This DirectProperty
179 | /// indicates the brakpoint that this template is for.
180 | ///
181 | public string For
182 | {
183 | get => _For;
184 | set => SetAndRaise(ForProperty, ref _For, value);
185 | }
186 |
187 | ///
188 | /// ContentTemplate StyledProperty definition
189 | ///
190 | public static readonly StyledProperty ContentTemplateProperty =
191 | AvaloniaProperty.Register(nameof(ContentTemplate));
192 |
193 | ///
194 | /// Gets or sets the ContentTemplate property.
195 | ///
196 | [Content]
197 | public IDataTemplate? ContentTemplate
198 | {
199 | get => this.GetValue(ContentTemplateProperty);
200 | set => SetValue(ContentTemplateProperty, value);
201 | }
202 | }
203 |
204 | static class Ext
205 | {
206 | public static double Get(this BreakpointList b, string key)
207 | {
208 | return b.TryGetValue(key, out var value) ? value : -1;
209 | }
210 | }
211 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.tlog
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.)
298 | *.vbp
299 |
300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project)
301 | *.dsw
302 | *.dsp
303 |
304 | # Visual Studio 6 technical files
305 | *.ncb
306 | *.aps
307 |
308 | # Visual Studio LightSwitch build output
309 | **/*.HTMLClient/GeneratedArtifacts
310 | **/*.DesktopClient/GeneratedArtifacts
311 | **/*.DesktopClient/ModelManifest.xml
312 | **/*.Server/GeneratedArtifacts
313 | **/*.Server/ModelManifest.xml
314 | _Pvt_Extensions
315 |
316 | # Paket dependency manager
317 | .paket/paket.exe
318 | paket-files/
319 |
320 | # FAKE - F# Make
321 | .fake/
322 |
323 | # CodeRush personal settings
324 | .cr/personal
325 |
326 | # Python Tools for Visual Studio (PTVS)
327 | __pycache__/
328 | *.pyc
329 |
330 | # Cake - Uncomment if you are using it
331 | # tools/**
332 | # !tools/packages.config
333 |
334 | # Tabs Studio
335 | *.tss
336 |
337 | # Telerik's JustMock configuration file
338 | *.jmconfig
339 |
340 | # BizTalk build output
341 | *.btp.cs
342 | *.btm.cs
343 | *.odx.cs
344 | *.xsd.cs
345 |
346 | # OpenCover UI analysis results
347 | OpenCover/
348 |
349 | # Azure Stream Analytics local run output
350 | ASALocalRun/
351 |
352 | # MSBuild Binary and Structured Log
353 | *.binlog
354 |
355 | # NVidia Nsight GPU debugger configuration file
356 | *.nvuser
357 |
358 | # MFractors (Xamarin productivity tool) working folder
359 | .mfractor/
360 |
361 | # Local History for Visual Studio
362 | .localhistory/
363 |
364 | # Visual Studio History (VSHistory) files
365 | .vshistory/
366 |
367 | # BeatPulse healthcheck temp database
368 | healthchecksdb
369 |
370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
371 | MigrationBackup/
372 |
373 | # Ionide (cross platform F# VS Code tools) working folder
374 | .ionide/
375 |
376 | # Fody - auto-generated XML schema
377 | FodyWeavers.xsd
378 |
379 | # VS Code files for those working on multiple tools
380 | .vscode/*
381 | !.vscode/settings.json
382 | !.vscode/tasks.json
383 | !.vscode/launch.json
384 | !.vscode/extensions.json
385 | *.code-workspace
386 |
387 | # Local History for Visual Studio Code
388 | .history/
389 |
390 | # Windows Installer files from build outputs
391 | *.cab
392 | *.msi
393 | *.msix
394 | *.msm
395 | *.msp
396 |
397 | # JetBrains Rider
398 | *.sln.iml
399 |
--------------------------------------------------------------------------------
/src/Breakpoints.Avalonia/Markup/BreakpointExtension.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 | using Avalonia.Data.Converters;
4 | using Avalonia.Layout;
5 | using Avalonia.Markup.Xaml;
6 | using Avalonia.Markup.Xaml.XamlIl.Runtime;
7 | using Avalonia.Threading;
8 | using Avalonia.VisualTree;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Diagnostics;
12 | using System.Reactive.Subjects;
13 | using System.Text;
14 | using System.Threading;
15 | using Avalonia = global::Avalonia;
16 | using BP = AVVI94.Breakpoints.Avalonia.Controls.Breakpoints;
17 | using NsBreakpoints = AVVI94.Breakpoints.Avalonia;
18 |
19 | namespace AVVI94.Breakpoints.Avalonia.Markup;
20 |
21 | public class BreakpointExtension : MarkupExtension, IObservable