These are chat archives for AvaloniaUI/Avalonia

17th
May 2018
Peter Worden
@Sn3akyP3t3_gitlab
May 17 2018 03:35
Visual studio 2017 on another machine refuses to launch a vanilla project out of the box, but builds correctly. I've re-installed dotnet core 2, but still no joy.
2018-05-16 22_28_42-Microsoft Visual Studio.png
Wiesław Šoltés
@wieslawsoltes
May 17 2018 05:51

i believe we're still waiting on a fix for SharpDX on .net core

@grokys @danwalmsley I did run successfully Core2D on .NET Core with Direct2D enabled. Tested on Win10 and Win7 SP1.

Rayyan Tahir
@RayyanTahir
May 17 2018 06:29

I have a Checkbox bound to a bool flag. When I change it's IsChecked property by clicking on it, the flag doesn't take it's value. I'm trying to do a TwoWay Multibinding.

My Xaml code:

<CheckBox Name="checkbox" BorderBrush="#9EB1C0" Width="20">
      <CheckBox.IsChecked>
        <MultiBinding Converter="{StaticResource BooleanToInvertedVisibilityConverter}" Mode="TwoWay">
          <Binding Path="IsChecked"/>
          <Binding>
            <Binding.Source>
              <sys:Boolean>False</sys:Boolean>
            </Binding.Source>
          </Binding>
        </MultiBinding>
      </CheckBox.IsChecked>
    </CheckBox>

My binding source:

private bool ischecked { get; set; }
        public bool IsChecked
        {
            get { return ischecked; }
            set
            {
                if (ischecked != value)
                {
                    ischecked = value;
                    PropertyChanged?.Invoke(value, new PropertyChangedEventArgs("IsChecked"));
                }
            }
        }
Converter code:
class BooleanToInvertedVisibilityConverter : IMultiValueConverter
    {
        public object Convert(IList<object> values, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                bool Value = (bool)values[0];
                bool Invert = (bool)values[1];
                if(Value)
                {
                    return (Invert ? false : true);
                }
                else
                {
                    return (Invert ? true : false);
                }
            }
            catch(Exception)
            {
                return false;
            }
        }
    }
ahopper
@ahopper
May 17 2018 06:43
@RayyanTahir there is a much simpler way to do this using '!' see the top of http://avaloniaui.net/docs/binding/converting-binding-values
Rayyan Tahir
@RayyanTahir
May 17 2018 06:44
Thank you @ahopper that helped! :smile:
ahopper
@ahopper
May 17 2018 06:46
It is well worth reading every bit of that documentation as there is some good stuff hidden in there ( not always where you might expect it to be).
Nikita Tsukanov
@kekekeks
May 17 2018 08:51
@denismaster the main problem with VSCode is that it's not and IDE
Because of the lack of the "integrated" part from "Integrated Developer Environment"
That bacically means that VSCode extensions don't have any access to the C# project information whatsoever
It lives on the OmniXAML background process
Project information is required for the previewer to run
I've tried to implement my own msbuild loader and had some success with that (it's currently partially used in AvalonStudio, I believe)
But there are other complications
danwalmsley
@danwalmsley
May 17 2018 09:35
@RayyanTahir you can use nameof(Property) instead of "Property" in your notify code
That means you will be able to refactor your code
Rayyan Tahir
@RayyanTahir
May 17 2018 09:37
That's great :+1:
Rayyan Tahir
@RayyanTahir
May 17 2018 09:42
@danwalmsley is Popup's VerticalOffset & HorizontalOffset broken?
It doesn't seem to work for me
I've also added an issue #1573
danwalmsley
@danwalmsley
May 17 2018 09:47
Il test later today, iv had to use it in some places and haven't noticed anything
@kekekeks did you see my tweet
It shows a xamarin live previewing thing
Was wondering if you think it possible here?
Nikita Tsukanov
@kekekeks
May 17 2018 09:48
Hint: it's a commercial product
It uses some complex magic and machinery to get it working
I've talked with the author half a year ago
It's a paid product for a reason ;)
It tracks the history of property values (so if you add and then remove, let's say, Background property it will actually get cleaned)
It somehow tracks external references to the controls
etc
danwalmsley
@danwalmsley
May 17 2018 10:01
Sounds difficult
Sergey Khabibullin
@x2bool
May 17 2018 10:14
Hey! What is with the quality of image scaling in Avalonia? For example if I have a png (40x40) and I want to display it with an Image control of size 20x20 it scales as expected but the quality of resulting image is really bad.
Rayyan Tahir
@RayyanTahir
May 17 2018 11:08
@x2bool I too faced image rendering problems and ended up re-scaling the png's to desired size and applying Stretch = "None" to Image
Steven Kirk
@grokys
May 17 2018 11:08
we're probably just using the wrong resampling mode
Stano Turza
@Sorien
May 17 2018 11:31

if you are using skia try

Avalonia.Skia.DrawingContextImpl

        public void DrawImage(IRef<IBitmapImpl> source, double opacity, Rect sourceRect, Rect destRect)
        {
            var impl = (BitmapImpl)source.Item;
            var s = sourceRect.ToSKRect();
            var d = destRect.ToSKRect();
            using (var paint = new SKPaint()
                    { Color = new SKColor(255, 255, 255, (byte)(255 * opacity * _currentOpacity)) })
            {
                paint.FilterQuality = SKFilterQuality.High; // <-
                Canvas.DrawBitmap(impl.Bitmap, s, d, paint);
            }
        }
Stano Turza
@Sorien
May 17 2018 11:47
there are some other interpolation algorithms in D2D https://msdn.microsoft.com/library/hh447004.aspx but not available in in SharpDX
Peter Worden
@Sn3akyP3t3_gitlab
May 17 2018 12:12
image.png
Whats the difference trying to run a project with this:
vs
dotnet run -f netcoreapp2.0
Command line launch with dotnet run works, but VS debugger launch gives me this:
image.png
danwalmsley
@danwalmsley
May 17 2018 12:36
what version of VS do you have?
Dariusz Komosiński
@MarchingCube
May 17 2018 12:37
@danwalmsley Hi, did you had time to check latest version of my PR? I checked it on different machine and I have no issues (haven't tested with Avalon studio though)
danwalmsley
@danwalmsley
May 17 2018 12:40
still has the glitches
but I'm going to check again now
I tried like 2am
Dariusz Komosiński
@MarchingCube
May 17 2018 12:40
Strange
danwalmsley
@danwalmsley
May 17 2018 12:40
so could have made a mistake
popup has always given me headaches
Dariusz Komosiński
@MarchingCube
May 17 2018 12:41
Do you have same glitches in control catalog?
danwalmsley
@danwalmsley
May 17 2018 12:48
there isn't any control that I know of that causes the same issue
perhaps tooltips might show it
let me try
I think if you fix the window resizing issue, it may well be a manifestation of the same thing
if you notice as you resize the window, that its very flicker and shaky
Dariusz Komosiński
@MarchingCube
May 17 2018 12:50
Yeah, something is off.
danwalmsley
@danwalmsley
May 17 2018 12:51
I think when popup is opened it is often resized immediately to fit content
which is similar to resizing windows
Dariusz Komosiński
@MarchingCube
May 17 2018 12:52
Well, popup is a window in the end.
danwalmsley
@danwalmsley
May 17 2018 12:52
I'm not talking about it causing the top of the window to be missed off when 125% scaling is used
just the flickering, etc
danwalmsley
@danwalmsley
May 17 2018 12:59
often when pop is opened first time its just black
no content gets rendered
Dariusz Komosiński
@MarchingCube
May 17 2018 13:00
You are using latest version of my branch, right?
Sergey Khabibullin
@x2bool
May 17 2018 13:00
@RayyanTahir Yep! That is my solution for now. But it's kind of annoying because I have to support Retina.
danwalmsley
@danwalmsley
May 17 2018 13:01
@MarchingCube yes
control catalog tooltip doesn't show it
I have popup where its opened and the datacontext gets changed
that changes content
ok I have a repro on control catalog
goto autocompletebox page
in the first textbox start typing a then l
for alabama
as it resizes you will see glitches happening
Dariusz Komosiński
@MarchingCube
May 17 2018 13:02
Oh nice, can actually repro this as well
So good news is that it is not gpu specifc
danwalmsley
@danwalmsley
May 17 2018 13:03
it happens with software rendering too?
Dariusz Komosiński
@MarchingCube
May 17 2018 13:03
nope
Seems to be D3D11 specific, does not happen on OpenGL
danwalmsley
@danwalmsley
May 17 2018 13:05
how do I get it to use OpenGL?
Dariusz Komosiński
@MarchingCube
May 17 2018 13:06
There are two options, implementing IEGLPlatformHooks and registering that. Or just change the default in code in file EGLPlatform.cs line 36, to be var platformType = EGLPlatformType.OpenGL;
But that can simply fail on your platform as you had some issues before
danwalmsley
@danwalmsley
May 17 2018 13:10
I think my issues were missing dlls
danwalmsley
@danwalmsley
May 17 2018 13:38
@MarchingCube does it look like a difficult one to fix?
Dariusz Komosiński
@MarchingCube
May 17 2018 13:44
It is a strange issue for sure, I have pushed a small fix that reduced the black and broken image to just flickering.
danwalmsley
@danwalmsley
May 17 2018 13:44
ok will test
still only with direct2d?
Dariusz Komosiński
@MarchingCube
May 17 2018 13:46
OpenGL seems work better, but it has one drawback - now when I resize it is flickering like hell during that. But at least the elements are not flying all over the place. :smile:
Did you manage to run it using OpenGL?
danwalmsley
@danwalmsley
May 17 2018 13:52
yes
just trying your fix now
seems to work fine on opengl
I just loose my cleartype that direct2d gives me
Dariusz Komosiński
@MarchingCube
May 17 2018 13:53
There is some D3D11 specific issue
danwalmsley
@danwalmsley
May 17 2018 14:02
its almost like there windows is created
with black
then a delay
then d3d renders image over
Dariusz Komosiński
@MarchingCube
May 17 2018 14:13
Will need to take a look at some gpu traces there, will take some time to figure out.
danwalmsley
@danwalmsley
May 17 2018 14:13
btw what tool do you use to do that?
Dariusz Komosiński
@MarchingCube
May 17 2018 14:14
You can use RenderDoc to capture frame traces, or GPUView for more high level overview
RenderDoc just shows screwed up texture, so there is something happening in the api I guess.
There are also nvidia tools, but they only support native applications
danwalmsley
@danwalmsley
May 17 2018 14:53
@grokys @kekekeks iv done a review on #1564 and tested it, seems to do what it says on the tin, if you guys have chance to give it a once over it would be nice to get it merged soon
Dariusz Komosiński
@MarchingCube
May 17 2018 15:01
@danwalmsley pushed yet another fix, looks quite better at least on my configuration. Now I am out of time for more fixes today, but let me know your findings after your try it.
Steven Kirk
@grokys
May 17 2018 15:44
@danwalmsley yes will take a look!
in exchange for you checking out #1461 :)
i think that one is no longer WIP
danwalmsley
@danwalmsley
May 17 2018 15:51
certainly will :)
thanks
I think once we merge animations, skia overhaul / fixes and embedded fonts, plus fix a few of the outstanding issues that have cropped up will probably be a good time to do a stable release again
that's quite a lot of changes so far
Steven Kirk
@grokys
May 17 2018 15:53
yeah!
danwalmsley
@danwalmsley
May 17 2018 15:54
@jmacato animations branch ready to be tested and merged if possible?
Jumar Macato
@jmacato
May 17 2018 15:54
@danwalmsley gimme 5 mins, just gonna double check stuff :D
danwalmsley
@danwalmsley
May 17 2018 15:55
ok i'll have a good long read through the code tonight and give it a test, make sure it doesn't break anything for AS, and play around with some of the animations :)
Steven Kirk
@grokys
May 17 2018 15:56
we still need to make the animation timer and the render timer be the same thing
but that will be a separate PR
at the moment they're two separate timers, which is stupid
danwalmsley
@danwalmsley
May 17 2018 15:57
we also have some very weird issues on monitors with scaling / hi dpi
@jmacato PageSlide.cs has a lot of commented code and a note saying temporary until animations finished
CrossFade.cs the same
Jumar Macato
@jmacato
May 17 2018 15:58
yeah, PageTransitions are dead in the water till i figure out how to wire it up to the new animations code
danwalmsley
@danwalmsley
May 17 2018 15:58
also ProgressBar.cs
Jumar Macato
@jmacato
May 17 2018 15:59
the progressbar's indefinitestate animation is also inoperative :) will do a separate PR for those but if it needs to, i'll remove the commented-out code
btw PR's ready now
danwalmsley
@danwalmsley
May 17 2018 16:00
ok thanks hopefully we can get that merged soon
Jumar Macato
@jmacato
May 17 2018 16:01
alright :smile: looking forward to that
Benedikt Schroeder
@Gillibald
May 17 2018 16:04
IAssetLoader isn't exposing all the information I need for loading fonts. Can I expose
AssemblyDescriptor to get all the information I need?
Nikita Tsukanov
@kekekeks
May 17 2018 16:16
We need to have a concept of a directory
that's why I was talking about WPF-like msbuild stage for gathering resource files
Steven Kirk
@grokys
May 17 2018 16:17
the only reason we couldn't use WPF resources before was that mono didn't support them properly
can .net core?
Nikita Tsukanov
@kekekeks
May 17 2018 16:19
For now I'd suggest to add support for obtaining resources via path with a mask
e. g. GetResources("DefaultNamespace.Fonts.MyFont.MyFont*.ttf")
@grokys the problem with WPF resources is the lack of MSBuild task that's capable of producing them
on OSX/Linux
Steven Kirk
@grokys
May 17 2018 16:20
ah ok
i was going to say "it used to work" but i guess it was only windows
does .net core support reading/writing those resources do you know?
Nikita Tsukanov
@kekekeks
May 17 2018 16:24
No idea, but it probably should
It's not that hard to create a MSBuild task
But it will introduce some complications
Especially with relative paths in XAML
Steven Kirk
@grokys
May 17 2018 16:26
hmm ok yeah. sounds like wildcards would be a decent solution for now
Nikita Tsukanov
@kekekeks
May 17 2018 16:26
I'd recommend not to do a nuget release before sorting out the resource problem
Steven Kirk
@grokys
May 17 2018 16:27
do you mean supporting WPF resources, wildcards, or our own solution?
Nikita Tsukanov
@kekekeks
May 17 2018 16:27
System.Resources.ResourceManager seems to be available since .NET Core 1.0
If it actually works, it would be nice to create a compatible MSBuild task
So we could use the built-in implementation
Steven Kirk
@grokys
May 17 2018 16:28
yeah that would be ideal
Benedikt Schroeder
@Gillibald
May 17 2018 16:29
IAssetLoader already holds all the information we need it just don't exposes that information for lookup.
Steven Kirk
@grokys
May 17 2018 16:30
@Gillibald what do you need? just to be able to enumerate the resources for an assembly?
Benedikt Schroeder
@Gillibald
May 17 2018 16:31
Yes
Even making GetAsembly public is enough
Nikita Tsukanov
@kekekeks
May 17 2018 16:31
I'm not sure if that it's a good idea
Steven Kirk
@grokys
May 17 2018 16:32
i personally don't see any problem with exposing an enumeration method
what are your reservations?
Nikita Tsukanov
@kekekeks
May 17 2018 16:32
Ideally we should be using Uris
Benedikt Schroeder
@Gillibald
May 17 2018 16:32
We could introduce a search/lookup funktion that returns all matching resources
Nikita Tsukanov
@kekekeks
May 17 2018 16:32
So one can refer to fonts and other resources using relative paths
I don't like the idea of some subsystems using the knowledge about the way how resources are stored
Our current resm: scheme was a stopgap measure to make things working "for now"
Steven Kirk
@grokys
May 17 2018 16:34
could we just say "this is a temporary solution until we have proper resources"
Nikita Tsukanov
@kekekeks
May 17 2018 16:34
That "for now" have lasted for 2 or 3 years already
Steven Kirk
@grokys
May 17 2018 16:34
yeah, it's still a stopgap measure really
Nikita Tsukanov
@kekekeks
May 17 2018 16:34
But it's not a decent solution
Steven Kirk
@grokys
May 17 2018 16:34
yup
but it'd be a shame to hold back custom font support for that reason
Nikita Tsukanov
@kekekeks
May 17 2018 16:35
That's why I'd prefer to expose some rudimentary "directory" support
Benedikt Schroeder
@Gillibald
May 17 2018 16:35
My PR isn't changing the way we use resources I just needed a way to search for resources
Nikita Tsukanov
@kekekeks
May 17 2018 16:35
on top of the current resm scheme
Steven Kirk
@grokys
May 17 2018 16:36
so wildcards? @Gillibald would that be ok?
Nikita Tsukanov
@kekekeks
May 17 2018 16:36
So we could introduce EnumerateResourcesIndirectory or something
Which would check for StartsWith in case of resm scheme
Steven Kirk
@grokys
May 17 2018 16:36
ah yeah
that could work?
Benedikt Schroeder
@Gillibald
May 17 2018 16:37
Wildcards are okay that should work for folders and files
Nikita Tsukanov
@kekekeks
May 17 2018 16:38
There is an old proverb here saying "Nothing is more permanent than a temporary solution."
Steven Kirk
@grokys
May 17 2018 16:39
hehe yeah it's very true
Nikita Tsukanov
@kekekeks
May 17 2018 16:39
That's why I'm kinda afraid of introducing dependencies on the way how resources are currently stored
Steven Kirk
@grokys
May 17 2018 16:39
but there's also "perfect is the enemy of good" :)
Benedikt Schroeder
@Gillibald
May 17 2018 16:39
Just have a look at my FontLoader implementation. GetResources
Nikita Tsukanov
@kekekeks
May 17 2018 16:41
We could expose "folder enumeration" from the asset loader
Steven Kirk
@grokys
May 17 2018 16:41
i can't remember that well, but wasn't IAssetLoader created because you couldn't access assembly info in PCL?
Nikita Tsukanov
@kekekeks
May 17 2018 16:41
That would give Name and FullPath for each "file" there
IAssetLoader is there because it's a uniform solution for resource management
So we won't have to go through each place that wants to load something when we add support for a new scheme
This way when we actually introduce a proper resource scheme everything will be able to use new urls automatically
Steven Kirk
@grokys
May 17 2018 16:49
sorry, just wasted 10 minutes looking through the history, and yeah it was added because you couldn't get the resources from a PCL.
but anyway, like you say it's a decent place to abstract out resources schemes now
so, what's the solution?
danwalmsley
@danwalmsley
May 17 2018 16:57
@grokys @kekekeks the font PR already implements wildcard resm scheme, iv tested it and works really well.
Steven Kirk
@grokys
May 17 2018 16:58
so the wildcard support just needs to be moved into the asset loader?
danwalmsley
@danwalmsley
May 17 2018 17:06
I guess so
Jeremy Koritzinsky
@jkoritzinsky
May 17 2018 18:38
@grokys I just opened #1594 with the big Markup/Data refactoring. Let me know what you think! The changes in Styling aren't necessarily required, but they helped break the dependency between the new Avalonia.Markup assembly and Avalonia.Controls.
danwalmsley
@danwalmsley
May 17 2018 19:13
@jmacato im just looking at animations stuff
Steven Kirk
@grokys
May 17 2018 19:13
ok thanks! i'll take a look after the animations PRs
danwalmsley
@danwalmsley
May 17 2018 19:14
can you only animate transform properties, or can you animate stuff like opactity, perhaps background colour, etc
?
Steven Kirk
@grokys
May 17 2018 19:16
i could be wrong, but i think if we were to add transition classes for those we could animate those
danwalmsley
@danwalmsley
May 17 2018 19:17
I worked out how to animate opacity, nice
looks like you just have to implement a public class DoubleKeyFrames : KeyFrames<double> class for any property type you want to animate
we could perhaps get in some standard ones for colors, integers, etc
Steven Kirk
@grokys
May 17 2018 19:21
yeah
danwalmsley
@danwalmsley
May 17 2018 19:25
later though
not in this pr
danwalmsley
@danwalmsley
May 17 2018 19:30
theat sidebar transition on the control catalog page where opacities change as mouse moves over them looks really nice
danwalmsley
@danwalmsley
May 17 2018 20:15
@jmacato iv submitted my review, mainly just nits, but a couple of functional ones too
Steven Kirk
@grokys
May 17 2018 20:29
@jmacato i on the other hand didn't do a code review, but kinda documented my initial thoughts on using the API
@danwalmsley not sure if you agree with any of that?
danwalmsley
@danwalmsley
May 17 2018 20:35
yes I think all of it, the syntax I was finding a bit clunky so I think the suggestions you have there are definitely an improvement
certainly more readable / intuitive.
it also threw me off having to discover DoubleKeyFrames and TransformKeyFames, etc
Steven Kirk
@grokys
May 17 2018 20:36
yeah...
i think that comes from WPF/UWP
danwalmsley
@danwalmsley
May 17 2018 20:36
perhaps the code can automatically detect the property type and select the best one
Steven Kirk
@grokys
May 17 2018 20:37
yeah, i think the reason it's not that way is to avoid having to convert the types at runtime/animation time
danwalmsley
@danwalmsley
May 17 2018 20:40
would that be a huge overhead, at 60FPS?
I guess it depends on how many properties are being animated at once, and the conversion been done
Steven Kirk
@grokys
May 17 2018 20:42
Not sure. At some point the conversion has to be done when coming from xaml anyway
danwalmsley
@danwalmsley
May 17 2018 20:45
could be that when it parses the syntax you suggested, it ends up being the same as the more verbose stuff anyway
@marchingcube seems the last fix you did for gpu has improved things a lot, still some minor resizing stuff but much better now
Peter Worden
@Sn3akyP3t3_gitlab
May 17 2018 20:58
@danwalmsley I'm running version 15.7.1 enterprise at home where the problem is occurring and that same exact version at work where I'm not having a problem.
danwalmsley
@danwalmsley
May 17 2018 21:21
Did you install any preview or different dotnet sdk versions?
danwalmsley
@danwalmsley
May 17 2018 21:54
@grokys see my update to last comment
where I mention doing something like what we did to simplify RowDefinitions
could have something really neat like this:
<KeyFrame Cue="0%" Content="Scale(0.1),Rotate(30),Setter(Opacity,1)" />
<KeyFrame Cue="50%" Content="Scale(0.5),Rotate(-10)" />
<KeyFrame Cue="100%" Content="Scale(1),Rotate(1),Setter(Opacity,0.5)" />
Steven Kirk
@grokys
May 17 2018 21:56
yeah, that might be the best solution
danwalmsley
@danwalmsley
May 17 2018 21:56
that just gets parsed into the fully verbose stuff
Steven Kirk
@grokys
May 17 2018 21:56
problem there is intellisense
danwalmsley
@danwalmsley
May 17 2018 21:56
im sure we could do some tricks though
to make intellisense pick it up
Steven Kirk
@grokys
May 17 2018 21:57
maybe even:
<KeyFrame Cue="0%" Content="Scale=0.1,Rotate=30,Opacity=1)" />
danwalmsley
@danwalmsley
May 17 2018 21:57
even better
it can recognise Scale and Rotate
as common ones, meaning RotateTransform.Angle
and if its something else assume property
could we perhaps implement a markup extension that does this kind of stuff generally, that way intellisense might be possible?
Steven Kirk
@grokys
May 17 2018 21:58
yeah, maybe? not sure really
danwalmsley
@danwalmsley
May 17 2018 21:59
perhaps something like:
hmm nah that's messy I think
the x:Bind stuff I tweeted you is doing similar stuff though
<TextBlock Text="{x:Bind ColorName}" Foreground="{x:Bind TextColor(Color)}" Margin="10,5" />
Benedikt Schroeder
@Gillibald
May 17 2018 22:03
Should i just fix the issues in my PR that you found and we wait until we know how to handle resources in the future? Will probably focus on new stuff until we found a solution.
Steven Kirk
@grokys
May 17 2018 22:06
@Gillibald do you already have wildcard handling for resources in your PR? could that just be moved to the asset loader?
Peter Worden
@Sn3akyP3t3_gitlab
May 17 2018 22:18
@danwalmsley I don't think so. I even uninstalled the SDK and re-installed to be sure it was properly registered. I read a handful of errors surrounding that dialog indicating that its some sort of networking issue although I'm not sure why that could matter in my case.
Benedikt Schroeder
@Gillibald
May 17 2018 22:20
@grokys That can only be moved if i change IAssetLoader to support query for resources
I always wanted to do that because the current implementation is just a duplicate of AssetLoader