These are chat archives for AvaloniaUI/Avalonia

6th
Dec 2015
bheidkamp3
@bheidkamp3
Dec 06 2015 02:03 UTC
Hey, I'm looking to better understand perspex and hopefully contribute to the project. I'm a c# developer working with wpf right now and this seemed like an interesting project to work on in my free time
Darnell Williams
@Seeker1437
Dec 06 2015 02:06 UTC
Hi @bheidkamp3 !
Welcome, the first place to take a look at is our up for grabs issues here:
https://github.com/Perspex/Perspex/labels/up-for-grabs
bheidkamp3
@bheidkamp3
Dec 06 2015 02:12 UTC
okay great, a lot of this including git is new to me so I don't know how much I'll be able to contribute yet but this issue seems like it could be a good starting point to get a feel for some of the specifics
Perspex/Perspex#226
I also read over the contributing post on your github page
Darnell Williams
@Seeker1437
Dec 06 2015 02:17 UTC
Ah yes, if you need help with getting start I may be able to lend a hand with getting your environment set up
danwalmsley
@danwalmsley
Dec 06 2015 02:42 UTC
shame we have not heard from @ncarrillo in a while!!!
danwalmsley
@danwalmsley
Dec 06 2015 17:31 UTC
guys is there a quick hack to get scrollviewers offsets from control inside it?
Johan Larsson
@JohanLarsson
Dec 06 2015 18:54 UTC
do you guys have R# open source licenses?
José Manuel Nieto
@SuperJMN
Dec 06 2015 18:59 UTC
No 😓
Darnell Williams
@Seeker1437
Dec 06 2015 22:19 UTC
I have personal, I think @grokys had a spate
spare*
danwalmsley
@danwalmsley
Dec 06 2015 22:27 UTC
@kekekeks I think im getting some wierd exception in Linux
hard to tell whats happening
its when an INotifyPropertyChanged gets fired
here is exception
danwalmsley
@danwalmsley
Dec 06 2015 22:35 UTC
@kekekeks its something in my code sorry
somewhere in my code im calling WeakEventManager.GetCurrentManager... it justs gives me not implemented ... :(
Nikita Tsukanov
@kekekeks
Dec 06 2015 22:38 UTC
Because Mono don't have WPF implementation
You can try to use this one
danwalmsley
@danwalmsley
Dec 06 2015 22:43 UTC
@kekekeks many thanks
danwalmsley
@danwalmsley
Dec 06 2015 23:09 UTC
@kekekeks doesnt seem to have a way to unsubscribe?
Nikita Tsukanov
@kekekeks
Dec 06 2015 23:10 UTC
Yup
danwalmsley
@danwalmsley
Dec 06 2015 23:10 UTC
just does it when object gets disposed?
or not implemented?
its for a part of code taken from the AvalonEdit control
I have some classes that derive from WeakEventManagerBase...
Nikita Tsukanov
@kekekeks
Dec 06 2015 23:11 UTC
not yet implemented
danwalmsley
@danwalmsley
Dec 06 2015 23:11 UTC
so was hoping to just implment that....
using your WeakSubscriptionManager underneath
it should be possible or it uses a completely different design?
public abstract class WeakEventManagerBase<TManager, TEventSource> : WeakEventManager
        where TManager : WeakEventManagerBase<TManager, TEventSource>, new()
        where TEventSource : class
    {
        /// <summary>
        /// Creates a new WeakEventManagerBase instance.
        /// </summary>
        protected WeakEventManagerBase()
        {
            Debug.Assert(GetType() == typeof(TManager));
        }

        /// <summary>
        /// Adds a weak event listener.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
        public static void AddListener(TEventSource source, IWeakEventListener listener)
        {

            CurrentManager.ProtectedAddListener(source, listener);
        }

        /// <summary>
        /// Removes a weak event listener.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
        public static void RemoveListener(TEventSource source, IWeakEventListener listener)
        {
            CurrentManager.ProtectedRemoveListener(source, listener);
        }

        /// <inheritdoc/>
        protected sealed override void StartListening(object source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            StartListening((TEventSource)source);
        }

        /// <inheritdoc/>
        protected sealed override void StopListening(object source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            StopListening((TEventSource)source);
        }

        /// <summary>
        /// Attaches the event handler.
        /// </summary>
        protected abstract void StartListening(TEventSource source);

        /// <summary>
        /// Detaches the event handler.
        /// </summary>
        protected abstract void StopListening(TEventSource source);

        /// <summary>
        /// Gets the current manager.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
        protected static TManager CurrentManager
        {
            get
            {
                Type managerType = typeof(TManager);
                TManager manager = (TManager)GetCurrentManager(managerType);
                if (manager == null)
                {
                    manager = new TManager();
                    SetCurrentManager(managerType, manager);
                }
                return manager;
            }
        }
    }
}
thats the code im trying to port...
Nikita Tsukanov
@kekekeks
Dec 06 2015 23:13 UTC
Well, I'm not sure that you need it at all
What exactly do you need from WeakEventManager?
danwalmsley
@danwalmsley
Dec 06 2015 23:16 UTC
if you look here:
this here in constructor
creates object of type TextSegmentCollection
that object uses weakevent listener for events coming from the TextDocument it wraps... to map changes to offsets, etc
Nikita Tsukanov
@kekekeks
Dec 06 2015 23:18 UTC
Do you unsubscribe explicitly?
danwalmsley
@danwalmsley
Dec 06 2015 23:18 UTC
I think I might be able to try and get rid of its dependency on weak event manager..
not sure!!! haha its because this is in a part of code i pinched from AvalonEdit...
I think I can get rid of the weak event part... and manually update it
i'll look into it further..
Do we have an IWeakEventListener interface then?
Usage example
Nikita Tsukanov
@kekekeks
Dec 06 2015 23:40 UTC
Guys, I've found a way to dynamically select dll path for P/Invoke without that nasty LoadLibrary/GetProcAddress/dlopen/dlsym stuff
            var asm = AppDomain.CurrentDomain.DefineDynamicAssembly (new System.Reflection.AssemblyName (Guid.NewGuid ().ToString ()),
                System.Reflection.Emit.AssemblyBuilderAccess.RunAndCollect);
            var module = asm.DefineDynamicModule("MAIN");
            var type = module.DefineType ("WAT");

            var method = type.DefineMethod ("malloc", 
                             MethodAttributes.Static | MethodAttributes.Public | MethodAttributes.PinvokeImpl,
                             typeof(IntPtr), new[]{ typeof(IntPtr) });
            var attr = new CustomAttributeBuilder (typeof(DllImportAttribute).GetConstructors () [0], new object[]{ "libc" });

            method.SetCustomAttribute (attr);
            var ctype = type.CreateType ();
            var cmethod = ctype.GetMethod ("malloc");

            var res = (IntPtr)cmethod.Invoke (null, new object[]{ new IntPtr (10) });
            Console.WriteLine (res);
danwalmsley
@danwalmsley
Dec 06 2015 23:42 UTC
@kekekeks with formatted text and fontfamily I was using Consolas... but on linux that is not available
so I have to use monospace or similar...
Nikita Tsukanov
@kekekeks
Dec 06 2015 23:42 UTC
Consolas is a proprietary font, you know
danwalmsley
@danwalmsley
Dec 06 2015 23:42 UTC
does perspex have a way to specify a series of fonts,,,
so I can have several fonts to choose from ,,, and it selects the first one that matches..
oh
basically I need a monospace font for Linux, Windows and Mac...
Nikita Tsukanov
@kekekeks
Dec 06 2015 23:43 UTC
Some day we'll implement font API that will even allow you to ship your own fonts
danwalmsley
@danwalmsley
Dec 06 2015 23:43 UTC
that would be awesome
I was hoping I could do FontFamily = "Consolas Monospace Courier"
and it would select the first one it recognizes
Nikita Tsukanov
@kekekeks
Dec 06 2015 23:44 UTC
yep, we can do that, I think
But to do it in xplat way we still need font api
danwalmsley
@danwalmsley
Dec 06 2015 23:45 UTC
Ah... i did
FontFamily = "Consolas, Monospace"
and it worked
Nikita Tsukanov
@kekekeks
Dec 06 2015 23:45 UTC
nice
danwalmsley
@danwalmsley
Dec 06 2015 23:45 UTC
with comma in there!! woohoow
Nikita Tsukanov
@kekekeks
Dec 06 2015 23:45 UTC
I'm not sure that it's portable
danwalmsley
@danwalmsley
Dec 06 2015 23:46 UTC
check it out... monospace on Ubuntu looks awesome!!!
blob
its mad all done on perspex...
i know its only in alpha but the power is already pretty incredible!!