Here's the same code running it through a C# converter:
Private NotInheritable Class LogoPlacement Private Sub New() End Sub
_ Public Shared Sub AddLogo(application As Microsoft.LightSwitch.Client.IClientApplication, alignment As System.Windows.HorizontalAlignment)
Microsoft.LightSwitch.Threading.Dispatchers.Main.BeginInvoke(Function() LogoPlacement.AddLogo(System.Windows.Application.Current.RootVisual, alignment)
End Function)
End Sub
Friend Shared Sub AddLogo(element As UIElement, alignment As System.Windows.HorizontalAlignment)
If rcb IsNot Nothing Then Return End If
For i As Integer = 0 To System.Windows.Media.VisualTreeHelper.GetChildrenCount(element) - 1
If rcb IsNot Nothing Then
Return End If
Dim child As UIElement = DirectCast(System.Windows.Media.VisualTreeHelper.GetChild(element, i), UIElement)
AddLogo(child, alignment) Next
If TypeOf element Is Microsoft.LightSwitch.Runtime.Shell.Implementation.Standard.RibbonCommandBar Then
rcb = TryCast(element, Microsoft.LightSwitch.Runtime.Shell.Implementation.Standard.RibbonCommandBar) Dim myImage As New Image() With { _ Key .Stretch = System.Windows.Media.Stretch.Uniform, _ Key .Margin = New Thickness(2, 8, 14, 8), _ Key .HorizontalAlignment = alignment, _ Key .Cursor = System.Windows.Input.Cursors.Hand _ }
myImage.SetValue(ComponentViewModelService.ViewModelNameProperty, "Default.LogoViewModel")
myImage.SetBinding(Image.SourceProperty, New System.Windows.Data.Binding() With { _ Key .Path = New PropertyPath("Logo") _ })
myImage.MouseLeftButtonUp += Function(s, e) MessageBox.Show("Here may be some About...")
myImage.SizeChanged += Function(s, e)
Dim left As Double = If(TryCast(s, Image).HorizontalAlignment = HorizontalAlignment.Left, e.NewSize.Width + 10.0, 0.0)
Dim right As Double = If(TryCast(s, Image).HorizontalAlignment = HorizontalAlignment.Right, e.NewSize.Width + 10.0, 0.0)
rcb.Padding = New Thickness(left, 0, right, 0)
End Function
DirectCast(rcb.Parent, Grid).Children.Add(myImage) End If
End Sub
Private Shared rcb As RibbonCommandBar = Nothing
End Class
By fishy on
Friday, January 20, 2012
|
That was REALLY fast fishy! Respect!
By kchristo on
Friday, January 20, 2012
|
I haven't tested it.
By the way, thank you so much for all the work you've done. I really appreciate it.
I am going to be adding your code to my commercial product.
By fishy on
Friday, January 20, 2012
|
I got so much help from the community when staring with LS that giving back to the community is an obligation to me. Glad to know my code is helpful. As soon as I find the time I will also be publishing the commercial version of CLASS Extensions. A have a lot of goodies added since the free version.
By Kostas Christodoulou on
Friday, January 20, 2012
|
Hi Kostas, Can't wait trying it out.
I understand correctly that your extension class can be used directly in the client project of a LS project? Which references are required. Is it necessary to have the extension framework installed?
Thank a lot ! paul.
By paul van bladel on
Saturday, January 21, 2012
|
Sorry, I was lazy, I could have find myself which references to add: it's the Microsoft.LightSwitch.Client.Internal.dll.
I tried first to use the extension method in the Application_Initialize() method, but that's not working. In your start up screen it works great ! e.g.: partial void SearchCustomers_Run(ref bool handled) { this.AddLogo(System.Windows.HorizontalAlignment.Left);
}
Thanks Kostas. You are the Extension Method Master !
By paul van bladel on
Saturday, January 21, 2012
|
Sorry for any trouble Paul. I could (and probably should) inlude references and "usings". I should also mention the start up screen thing. It was mentioned in original LR_ post in the thread that caused all these. Also another idea (more generic than startup screen since you might not want to have one) would be upon application initialization hooking (via IServiceProxy.NotificationsService if I am not mistaken) to ScreenOpened or ScreenActivated (I don't recall right now) and run on every screen as after the first time calling the method will do nothing at all.
By Kostas Christodoulou on
Saturday, January 21, 2012
|
No trouble at all, Kostas. I'm very happy to have finally a decent and simple way to add a logo. Still some questions. In the app properties, it seems to be possible to load multiple logo's. Do you know if it's possible to choose one programmatically? Is it anyhow possible to set the logo image programatically? Enjoy the weekend. paul.t
By paul van bladel on
Saturday, January 21, 2012
|
I' m afraid I cannot help you with this multiple logo thing. At least not at the time being. I will look into it though.
By kchristo on
Saturday, January 21, 2012
|
Paul, regarding the multiple logo issue. I am afraid you are mistaken. You cannot have multiple logos. You can select one from the assembly's resources. The window opening shows all available resources. And you can set your one and only logo either from the existing resources or add a new one. The question whether you can bind to any resource of the assembly and not only the one selected for logo (binding through the logo mechanism) is a different one and it's also discussed in the original thread. Take a look there.Hope this helps.
By kchristo on
Wednesday, January 25, 2012
|
Thank you, your code works perfect.
By Keith Craigo on
Thursday, January 26, 2012
|
You are welcome Keith. I am glad that my contribution is appreciated :-)
By kchristo on
Thursday, January 26, 2012
|
That is exactly what I need, however... - I need the code in VB - Can you tell me where to add this code? Thanks for your help
By Edgar on
Friday, January 27, 2012
|
Edgar if you read the comments above you will find the code in VB AND when to call the code. The answer to where to put the code is in a separate file in your client project or any other libraby project your client project has access to.
By kchristo on
Saturday, January 28, 2012
|
1) i cannot add system.drawing reference to Client Reference, it said only silverlight assemblies will work with this project
2) what assembly do i need to add for Casting ((Grid) rcb.Parent), since in Application.cs cannot recognize Grid.
Thanks a lot!
By TripleStar on
Friday, April 13, 2012
|
You don't need System.Drawing. If you are looking for Image it's System.Windows.Controls. This also what you need for Grid. Here http://code.msdn.microsoft.com/Application-Logo-Demo-8edb214d you can find a complete sample of using the code.
By kchristo on
Friday, April 13, 2012
|
moasesehoghoghi |
By omid on
Wednesday, October 3, 2018
|
http://moasesehoghoghi.com/
By omid on
Wednesday, October 3, 2018
|
http://moasesehoghoghi.com/
By omid on
Wednesday, October 3, 2018
|
I am glad that I visited this website and Thanks for sharing this. South City Escorts | Call Girls in Arjun Nagar | Escorts in Huda City Centre |
By Sheeba on
Wednesday, August 4, 2021
|
Stellar post and good website.
~Sheeba
By Escorts in Huda City Centre on
Wednesday, August 4, 2021
|
MLB Shop Wholesale NHL Jerseys NFL Fan Shop NBA Jerseys Wholesale Jerseys Cheapest Football Jerseys Cheap Jerseys Cheap NHL Jerseys New NFL Jerseys Cheap Jerseys Wholesale NFL Jerseys NFL Shop Official MLB Store NFL Store NFL Jersey NBA Jerseys Official NFL Jersey Wholesale NBA Jerseys MLB Jerseys Cheap NHL Jerseys NFL Jersey NFL Jerseys MLB Store NFL Jerseys China NFL Jerseys Cheap Jerseys Custom Baseball Jerseys NFL Shop NHL Jerseys Cheap NFL Jerseys From China Wholesale Jerseys Baseball Jerseys NFL Gear NBA Shop Wholesale Jerseys NHL Apparel NFL Apparel NFL Store Online Shopping NFL Jerseys MLB Shop Cheap NBA Basketball Jerseys Cheap Jerseys Wholesale Cheap NBA Basketball Jerseys NFL Jerseys Cheap NBA Jersey
By Walker on
Saturday, November 20, 2021
|
Thank you so much for sharing this amazing information with us. if you want to fully enjoy it. Keep sharing !!
By Somya Mittal on
Saturday, December 18, 2021
|
A very energetic article, I loved that bit, Blogs deliver a large amount of creativity. I am sure this piece of writing has touched all the internet viewers.
By Dwarka escorts on
Tuesday, December 28, 2021
|
Nike Jordan 29 Jordan 12 Nikes Jordan 22 Nike Canada Cheap Jordans Jordan 13 Wholesale Jordans Jordan 17 Adidas Outlet Store Pandora Jewelry Jordan 16 Adidas Outlet Nike Shoes Wholesale Nike Outlet Jordan 6s Jordan Retro 11 Wholesale Cheap Jordans Nike Pandora Jewelry Nike Outlet Store Online Shopping Nike Foamposites Red Bottom Heels MLB Shop Jordans 28 Nike Cortez Men Louboutin Shoes Air Jordan 24 Nike Shoes Jordan 11 Cheap Jordans Free Shipping Wholesale NHL Shop Nike Running Shoes Women NHL Store Jordan 27 Nike Sneakers Nike Running Shoes Nike Air Max 270 Jordan 4 Nike Factory Store Air Max 2019 Adidas Wholesale Nike Sneakers Pandora Air Jordan 33 shoes Pandora Charms Air Jordan 31 Jordan 30 Jordan 1 Yeezy Butter Off White Nike Shoes Adidas Yeezy Wholesale Nike Shoes Nike Roshe Nike Shoes Men Jordan AJ 1 Nike Air Force 1 Nike Jordan 1 High Pandora Jewelry Cheap Nike Shoes From China Cheap Jordans Wholesale Nike Factory Outlet Store Online Nike Shoes Air Max Adidas Yeezy 700 NFL Jerseys Jordan 11 Pandora Jewelry Official Site Pandora Rings Wholesale Nike Shoes Nike Outlet Store Online Shopping Nike Air Zoom Nike Shoes Nike Air Uptempo Kids Jordans Air Jordan 12 Louboutin Shoes Nike Shoes For Women Nike Air Force 1 Nike Outlet NBA Store Air Jordan Shoes Jordan 2 Cheap Jordan Shoes Adidas Nike Free Rn Jordan 23 Air Jordan 33 Huaraches Nike Wholesale Wholesale Nike Shoes NMD Nike Metcon Nike Air Force 1 Men Nike Shoes Nike Air Force 1 New Jordans 2021 Nike Blazer Air Jordan 34 Nike Huaraches Wholesale Jordans Nike Air Force Ones Jordans 13 Nike Wholesale Wholesale Adidas Nike Hyperdunk Nike Air Max Men Jordan Retro Fjallraven Rings Pandora Jordan 25 Jordans 32 Adidas Shoes Wholesale Jerseys Nike Clearance Nike Huarache Nike Womens Air Jordan Shoes Toddler Jordan Pandora Bracelet Charms Pandora Jewelry Jordan 33 Nike Zoom Air Force 1 Jordan 26 Air Jordan 11 Low Retro 12 Air Jordan 15 Jordan 21 Nike Wholesale Nike Shoes Black Friday Deals NHL Jerseys Nike Shoes Canada Nike Outlet Store Jordans 20 Nike Air Jordan Dior Jordans Nike Air Max 720 Jordan 14 Jordan 19 Nike Running Shoes Nike Dunk Nike Air Max 270 Air Jordan 5 What The Michael Jordan Shoes Air Jordan 35 Jordans 18 Nike Slippers Nike Air Force 1 Wholesale Adidas Nike Outlet Online Cheap Nikes From China Cheap Jerseys Wholesale Lebron Shoes
By Katina on
Tuesday, January 4, 2022
|
Custom Baseball Jerseys NFL Jerseys NFL Jersey NBA Jerseys MLB Shop NFL Shop NHL Jerseys Wholesale Wholesale Jerseys NFL Gear Wholesale NFL Jerseys Wholesale Jerseys Wholesale Jerseys MLB Store Official Site MLB Shop Cheap NFL Jerseys NHL Store Online Wholesale NFL Jerseys NBA Jersey Wholesale Jerseys Cheap Football Jerseys NFL Jerseys NBA Shop NFL Jerseys Wholesale Custom NHL Jerseys NFL Jerseys NFL Store Online Shopping NFL Fan Shop Cheap NFL Jerseys NBA Jerseys MLB Store Official NFL Shop Wholesale Jerseys Cheap NBA Jerseys From China Baseball Jerseys Cheap Jerseys NFL Football Jerseys NFL Jerseys NFL Jerseys Best NFL Jerseys Cheap NBA Jerseys From China Cheap NHL Hockey Jerseys NHL Jerseys Custom NBA Jerseys Cheap Jerseys From China Cheap MLB Jerseys From China
By Parker on
Sunday, January 16, 2022
|
Nice article and you describe the syntax in a good manner
By Independent Delhi escorts on
Monday, January 24, 2022
|
thanks for share this article
By Lucknow Escorts Service on
Tuesday, January 25, 2022
|
Hello friend, I have read your web page. Really it is relevant to dedicated subject. Keep it continue with this website
By Gita escort on
Friday, March 11, 2022
|
Hello friend, I have read your web page. Really it is relevant to dedicated subject. Keep it continue with this website https://www.delhihotservices.com
By Gita escort on
Friday, March 11, 2022
|
This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information. Keep it up. https://dgirls.in/ https://www.ctgirls.in/ http://www.delhi37.in/ https://ishaagarg.in/ https://www.dimple-gupta.com/ https://www.dimple-gupta.com/escorts-call-girls-in-aerocity.html https://www.dimple-gupta.com/pullman-hotel-new-delhi-aerocity-escorts.html https://www.dimple-gupta.com/ibis-hotel-aerocity-new-delhi-escorts.html https://www.dimple-gupta.com/call-girls-in-dwarka.html https://www.dimple-gupta.com/escorts-in-mahipalpur.html https://www.dimple-gupta.com/call-girls-in-connaught-place.html https://www.dimple-gupta.com/escorts-call-girls-in-south-delhi.html https://www.dimple-gupta.com/escorts-in-noida.html https://www.dimple-gupta.com/escorts-in-janakpuri.html https://www.dimple-gupta.com/escorts-call-girls-in-hauz-khas.html https://www.yaina.in/bengaluru/ https://dgirls.in/bangalore-call-girls/
By shivanisharma on
Sunday, October 9, 2022
|
This is the post I was looking for roulette I am very happy to finally read about the Thank you very much. Your post was of great help to me If you are interested in the column I wrote, please visit my site . https://www.chandigarh69.in/delhi-escorts.html http://www.escortserviceinjaipur.in/delhi-escorts.html http://www.gorgeous-london-escorts.com/delhi-escorts.html http://www.chennaiescortservice.info/delhi-escorts.html http://www.jaipurescortscallgirls.com/delhi-escorts.html
By Vershasharma on
Wednesday, December 7, 2022
|