These are chat archives for ZaneDubya/UltimaXNA

11th
Sep 2015
Zane Wagner
@ZaneDubya
Sep 11 2015 16:55
@jeffboulanger Saw you uploaded connectuo!
Neat.
Question for you - do you know what wm windows sends when a window is snapped to fill half the screen on windows 10?
Not just aero snap - but the secondary snap that occurs after you snap a first app to fill half the screen.
Jeff Boulanger
@jeffboulanger
Sep 11 2015 16:58
@ZaneDubya i just moved it there from Codeplex, it already existed on codeplex ;)
the snap you get by pressing windowskey+left right?
left/right
Zane Wagner
@ZaneDubya
Sep 11 2015 17:09
The one that happens after that - the secondary snap
Jeff Boulanger
@jeffboulanger
Sep 11 2015 17:10
I'd imagine you only get the Windows Size changed event
but lemme see
from that link: This is correct. There are no special notifications sent as a result of Aero Snap. It uses the standard WM_MOVING/WM_MOVE and WM_SIZING/WM_SIZE messages. If you process these without calling DefWindowProc, Aero Snap will not work for your window.
Jeff Boulanger
@jeffboulanger
Sep 11 2015 17:15
Yes, you could listen for WM_SIZE, but you're probably better off in general using WM_WINDOWPOSCHANGED. It's a "new" function, introduced in, err, Windows 3.1. :-)
haha
Jeff Boulanger
@jeffboulanger
Sep 11 2015 17:35
what r you trying to solve with snap?
Zane Wagner
@ZaneDubya
Sep 11 2015 18:34
XNA handles being snapped just fine - but when you snap another window to one half, and then snap an XNA window to fill the remaining half, the XNA events that would signal resize/movement don't fire :(
Jeff Boulanger
@jeffboulanger
Sep 11 2015 18:35
weird
maybe, figure out how to not allow snapping?
all of this is probably not worth much of the effort imo
;)
dont snap uxna
lol
problem solved
Zane Wagner
@ZaneDubya
Sep 11 2015 19:07
haha
too easy ;|
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:16
Zane Wagner
@ZaneDubya
Sep 11 2015 21:33
hahahaha
So much hatred!
Those guys are so terrible.
Why google
Why
Just why
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:33
;)
Zane Wagner
@ZaneDubya
Sep 11 2015 21:33
:D
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:34
i just hit a pivotable moment in my mvvm career
Zane Wagner
@ZaneDubya
Sep 11 2015 21:34
?
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:34
C# 6 added nameof()
finally!
nameof(MyProperty)
Zane Wagner
@ZaneDubya
Sep 11 2015 21:34
Oh that's brilliant!!!!
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:34
calculates the propertyname at compile time
With mvvm you have to pass the name of the property to a handler, so that the binding can update the UI based on a name
so if you had MyProperty
and it changed
you had to do OnPropertyChanged("MyProperty")
which sucks cause if you refactor, you have to remember to change the string name
so the solution was that you had to write crazy code to extract property names at runtime
    public static string ExtractPropertyName<T>(Expression<Func<T>> propertyExpression)
    {
        if (propertyExpression == null)
        {
            throw new ArgumentNullException("propertyExpression");
        }

        var memberExpression = propertyExpression.Body as MemberExpression;

        if (memberExpression == null)
        {
            var unaryExpression = propertyExpression.Body as UnaryExpression;

            if (unaryExpression != null)
            {
                memberExpression = unaryExpression.Operand as MemberExpression;

                Guard.RequireIsNotNull(memberExpression, "The expression is not a member access expression.", "memberExpression");
            }
        }

        var property = memberExpression.Member as PropertyInfo;

        Guard.RequireIsNotNull(property, "The member access expression does not access a property.", "propertyExpression");

        MethodInfo getMethod = property.GetMethod;

        if (getMethod.IsStatic)
        {
            throw new ArgumentException("The referenced property is a static property.", "propertyExpression");
        }

        return memberExpression.Member.Name;
    }
Zane Wagner
@ZaneDubya
Sep 11 2015 21:37
What does it look like now?
Using C# 6
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:38
which allowed you to do
        RaisePropertyChanged(() => HasLines);
now i just do
        RaisePropertyChanged(nameof(HasLines));
and compiled output looks like
        RaisePropertyChanged("HasLines");
refactoring doesnt break anything cause refactoring property names will find all usages, or it wont compile
either way you win
;)
    public WorkerTaskType Type
    {
        get { return _workerTaskType; }
        set
        {
            SetProperty(ref _workerTaskType, value)
                .RaiseOnSuccess(
                    nameof(Name),
                    nameof(IsVehicleInMilestone),
                    nameof(IsRepairStartedMilestone),
                    nameof(IsRepairCompleteMilestone),
                    nameof(IsVehicleOutMilestone));
        }
    }
things like this look amazing ;)
so 2 new things i just cant live without in C# 6 now, nameof() and null propigation
Zane Wagner
@ZaneDubya
Sep 11 2015 21:40
And you have things that hook into RaisePropertyChanged? How would they receive that message?
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:40
the UI has an interface it listens to
INotifyPropertyChanged
look familiar?
;)
Zane Wagner
@ZaneDubya
Sep 11 2015 21:41
Now that you mention it... ;)
I admit, I haven't used it for anything.
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:41
on the UI u do Text="{Binding MyProperty}"
yes you have
SettingsBase?
;)
Zane Wagner
@ZaneDubya
Sep 11 2015 21:41
I meant that I'm not listening to the properties...
... that is, not looking to receive notifications.
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:42
Anyway, the binding that gets created wires up to the the PropertyChanged event, and when it changes, gets the new value and updates the UI
it knows what binding to update based on the name
it builds a huge reflection model in the background
so its slow, but for business apps its fine
they came out with a new binding called x:Bind which actually generates the C# code at compile time, so it doesnt have to use reflection
its extremely fast ;)
The other C# 6 feature is null propigation
turns this
    private void onFinalDueDateTimeChanged()
    {
        var handler = FinalDueDateTimeChanged;

        if (handler != null)
        {
            handler(this, EventArgs.Empty);
        }
    }
into this
    private void onFinalDueDateTimeChanged()
    {
        FinalDueDateTimeChanged?.Invoke(this, EventArgs.Empty);
    }
beautiful code
Zane Wagner
@ZaneDubya
Sep 11 2015 21:43
very tidy.
Like it!
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:44
with 2015 u can do this, without changing the C# version u run on
just fyi
;)
you can also do awesome string formats
string.Format("{property1} is just like {value2}", propery2, value2);
property1*
makes it easy for when you move things around in a string format
dont have to re-index your params
actually
Zane Wagner
@ZaneDubya
Sep 11 2015 21:45
nice!
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:45
i think you dont even specify the params
string.Format("{property1} is just like {value2}")
i'd have to check
ah ya
This message was deleted
This message was deleted
WriteLine($"\t'{filename}' encrypted");
ya, easier ;)
This message was deleted
public class Person
{
  public Person(string name)
  {
    Name = name;
  }
  public Person(string firstName, string lastName)
  {
    Name = $"{firstName} {lastName}";
    Age = age;
  }
  // Validation ommitted for elucidation
  public string Name {get; set; }
  public string FirstName => Name.Split(' ')[0];
  public string LastName => Name.Split(' ')[1];
  public override string ToString() => "\{Name}(\{Age}";
}
thats pretty awesome
Jeff Boulanger
@jeffboulanger
Sep 11 2015 21:51
Granted it has an error for LastName, if the string doesnt have a space in it, but still.
and its missing a ) for ToString lol
Zane Wagner
@ZaneDubya
Sep 11 2015 21:59
haha
cool example nonetheless