|
I agree. Unless you need some sort of 'clever' or 'fancy' UI, I don't see many advantages. Honestly, how many times have you wanted to re-style a whole UI.
WPF certainly has nothing to recommend it when considering updating apps built on 'old' frameworks like Froms or MFC.
|
|
|
|
|
 with ShowUI in PowerShell there is no need of XML
a little tool with ShowUI in PowerShell :
Import-Module ShowUi
############################################################################
# Hibernate_WPF_V2.ps1
# start with Cmd-Batch example:
# @echo off
# cd /D C:\Users\Public\Documents\prog\Hibernate
# start powershell -STA -WindowStyle Hidden -Command .\Hibernate_WPF_V2.ps1
############################################################################
function global:Hours_and_Mins ( [Int16]$MinsTill ) {
if ( -not ( $MinsTill -gt 0 -and $MinsTill -lt 1440 ) ) {
return "--:--"
}
do { #get certain time
$nowdue = Get-Date
$now = Get-Date
$nowminutes = $now.Minute
$nowhours = $now.Hour
} while ( ( $nowminutes -ne $nowdue.Minute ) -or ( $nowhours -ne $nowdue.Hour ) )
$TimeAtTill = $now.AddMinutes( 0.5 + $MinsTill ) #a half minute in plus
# Write-Host ("TimeAtTill: " + $TimeAtTill.ToString("HH:mm:ss"))
$HoursAndMins = $TimeAtTill.ToString("HH:mm")
return ( $HoursAndMins )
}
function global:MinutesTill ( [string]$AtTimStr, [ref]$TodayTomor ) {
$now = Get-Date
try {
[DateTime]$AtTim = Get-Date $AtTimStr
} catch {
[DateTime]$AtTim = $now.AddMonths( 12 )
}
if ( ( [int64]$span = [Math]::round(( $AtTim - $now ).TotalMinutes )) -lt 0 ) {
$span += 1440
$TodayTomor.value = "tomorrow"
} else {
$TodayTomor.value = "today"
}
return ( $span )
}
function global:BtnOKdekorate ( [object]$Btn, [string] $clicked ) {
if ( $clicked -eq "clicked" ) {
$Btn.Tag = $Btn.Name
$Btn.FontSize = 13.0
$Btn.Content = "count down"
$Btn.Foreground = "green"
} else {
$Btn.Tag = $clicked
$Btn.FontSize = 22.0
$Btn.Content = "OK"
$Btn.Foreground = "black"
}
}
#############################################################
# main
#############################################################
New-Window -Name MainWindow -Width 200 -Height 286 -title 'Minutes till hibernate' `
-ResizeMode CanMinimize -Background Pink -Top 0 -Left 0 {
New-StackPanel -Margin 7 -Background Pink {
New-TextBox -Text "minutes`ntill hibernate" -IsReadOnly $True `
-Background Pink -BorderThickness 0 -FontFamily Arial -FontSize 22.0 `
-HorizontalContentAlignment Center `
-TextWrapping Wrap `
-On_GotFocus {
$TxtForMinutes.Focus()
}
New-Separator -Height 1 -Background Pink
New-Label "Minutes:" -FontFamily Consolas -FontSize 13.0 -FontWeight Bold
New-TextBox -Name TxtForMinutes -Text "0" <# init value defined in windows onLoad event routine #> `
-TabIndex 2 `
-FontFamily Consolas -FontSize 24.0 `
-HorizontalContentAlignment Right -FontWeight Bold -Tag "" `
-On_TextChanged {
# Write-Host ("enter Change Event for " + $this.name + "`: " + $this.gettype() + " Tag=" + $this.tag)
if ( $this.Tag.Length -gt 0 ) {
# Write-Host ("Enter code for the Change Event for " + $this.name + "`: " + $this.gettype() + " Tag=" + $this.tag )
try {
[int16]$Mins = [convert]::ToInt16($this.Text)
} catch {
[int16]$Mins = -1
}
if ( $btnOK.IsEnabled = ( $Mins -gt 0 -and $Mins -lt 1440 ) ) {
$this.Background = "white"
if ( $this.Tag -ne $TxtForTime.Name ) {
$ResultFromHours_and_Mins = Hours_and_Mins( $Mins )
# Write-Host ("after Hours_and_Mins " + $ResultFromHours_and_Mins + " from " + $Mins )
$TxtForTime.Tag = $this.Name #I'm the sender
$TxtForTime.Text = $ResultFromHours_and_Mins
}
} else {
$this.Background = "red"
}
if ( "X" -eq $this.Tag ) {
BtnOKdekorate $btnOK "X"
}
}
$this.Tag = "X"
}
New-Separator -Height 1 -Background Pink
New-Label "Time:" -FontFamily Consolas -FontSize 13.0 -FontWeight Bold
New-StackPanel -name StkForTime -Background Pink -Orientation Horizontal -HorizontalAlignment Center {
New-Label -Name "lblDay" -content " " -Background White -Width 100 `
-FontFamily Consolas -FontSize 20.0 `
-HorizontalContentAlignment Center -FontWeight Bold
New-TextBox -Name TxtForTime -Text "--`:--" -Width 80 `
-FontFamily Consolas -FontSize 24.0 `
-HorizontalContentAlignment Right -FontWeight Bold -Tag "" `
-On_TextChanged {
# Write-Host ("enter Change Event for " + $this.name + "`: " + $this.gettype() + " Tag=" + $this.tag)
if ( $this.Tag.Length -gt 0 ) {
# Write-Host ("Enter code for the Change Event for " + $this.name + "`: " + $this.gettype() + " Tag=" + $this.tag )
$TodayStr = ""
[int64]$span = MinutesTill ($this.Text) ([ref]$TodayStr)
# Write-Host ("after MinutesTill span=" + $span + " Todaystr=" + $TodayStr )
if ( $btnOK.IsEnabled = ( $span -le 1439 -and $span -ge 1 ) ) {
$this.Background = "white"
if ( $this.Tag -ne $TxtForMinutes.Name ) {
$TxtForMinutes.Tag = $this.Name #I'm the sender
$TxtForMinutes.Text = $span
}
} else {
$this.Background = "red"
$TodayStr = " "
}
if ( "Y" -eq $this.Tag ) {
BtnOKdekorate $btnOK "Y"
}
$lblDay.Content = $TodayStr
}
$this.Tag = "Y"
}
}
New-Separator -Height 15 -Background Pink
New-StackPanel -name StkForBtn -Background Pink -Orientation Horizontal -HorizontalAlignment Center {
New-Button -Content "OK" -name btnOK -Margin 5 -Width 80 -Height 32 `
-FontFamily Consolas -FontSize 22.0 -FontWeight Bold `
-Tag "" `
-On_Click {
BtnOKdekorate $this "clicked"
}
New-Button -Content "Cancel" -name btnCancel -Margin 5 -Width 80 -Height 32 -FontFamily Consolas -FontSize 22.0 -TabIndex 1 `
-On_Click {
Close-Control
}
} # end of second StackPanel
} # end of first StackPanel
} -on_Load {
#####################################################
$TxtForMinutes.text = "60" #initial Value of minutes
#####################################################
$btnCancel.Focus()
Register-PowerShellCommand -ScriptBlock {
# Write-Host ("TimerEvent at " + ( Get-Date ).ToString("HH:mm:ss") )
if ( $btnOK.Tag -eq $btnOK.Name ) {
# calc new minutes from now and TxtForTime
$TodayStr = ""
[int64]$MinsByTimer = MinutesTill ($TxtForTime.Text) ([ref]$TodayStr)
$TxtForMinutes.Tag = $TxtForTime.Name #simulate that Inf comes from TxtForTime
$TxtForMinutes.Text = $MinsByTimer
if ( 0 -eq $MinsByTimer ) {
# disable further processings
$btnOK.IsEnabled = $False
$btnOK.Tag = "Z"
# shutdown /h
$EXE = 'C:\Windows\System32\shutdown.exe'
[string[]]$PARGS = '/h'
# Write-Host ( "Hibernate with " + $EXE + " " + $PARGS )
start-process $EXE -ArgumentList $PARGS -NoNewWindow
$btnOK.Content = "hibernated"
$btnOK.Foreground = "cyan"
}
} else {
if ( $btnOK.IsEnabled ) {
[int16]$MinsByTimer = [convert]::ToInt16($TxtForMinutes.Text)
$Hours_and_MinsByTimer = Hours_and_Mins( $MinsByTimer )
# Write-Host ("after Hours_and_Mins " + $Hours_and_MinsByTimer + " from " + $MinsByTimer )
$TxtForTime.Tag = $TxtForMinutes.Name #simulate that Inf comes from TxtForMinutes
$TxtForTime.Text = $Hours_and_MinsByTimer
}
}
} -run -interval "0:0:30" #each 30 seconds
} -show > $Null
modified 28-Feb-14 12:42pm.
|
|
|
|
|
Funny as the main reason presented here is the polished look and feel you get from WPF. Yet if you look at Windows 8+ and Visual Studio 2012 and on, the visual interfaces are absolutely ugly. Polished look - where? What an excuse to force an ugly practically useless product onto developers.
|
|
|
|
|
I did not buy Visual Studio for a polished look. I want something that is there when I need it, and gets out of the way when I don't. I have found VS2012 (2010 also used WPF BTW) and VS2013 to be pretty good about that. The ui elements do not draw any undue attention to them and I can focus on my work. Additionally, I have some degrading eyesight and the Dark Theme in 2012 and 2013 work wonderfully for me. The monochrome-ish design supports the dark theme. Too many colors would make the dark theme unusable.
|
|
|
|
|
Don't know if this has been answered but will take the liberty to state it again.
WPF was an ambitious plan to change the way we work with Windows development. It was part of Framework 3.0 which was a part of Vista. Ironically it wasn't a full Framework at all, but just three sets of BIG APIs designed to change different parts of the coding process.
Before we delve into WPF, we must touch the other two (Windows Communication Foundation [WCF] and Windows Workflow Foundation [WF]) and know that all three share the same XAML description language.
WCF is a modern replacement for the old .asmx model which allows you to build a Web Service inside any CIL *.exe and build Web Services beyond SOAP. I currently use them to connect BizTalk to SAP using SAP Connector.
WF was an ambitious plan to create Enterprise Service Bus potential in everyday applications, connecting WebServices to business flows and logic, using graphic programming.
Last, but not least, came WPF, the Windows Presentation Foundation, which was an attempt to 'reimagine' the desktop experience. It was thought that during Vista, application developers would abandon Win32 in favor of WPF. That didn't happened since the impact of the Web was far greater than Microsoft had expected. Enterprise had already went full web and all modern application development was being done in Java or ASP.NET.
So Microsoft created Silverlight, to revive WPF into a Web Plus thing, just like Flash. But then came the mobile revolution and people started making apps instead of applications, and apps became companions to web pages (aka a thin client world).
Today WPF lives on in the Metro paradigm for both Windows 8 and Windows Phone 8. Windows Phone 7 was a type of Silverlight, but WinRT (the common framework for 8's) is more WPF like. All Metro apps can communicate with WCF services and could (theoretically) use WF workflows. Few people are going this route as Node.js and JSON have replaced SOAP as a communication approach except in the B2B side.
As for the reason to use an XML markup system to describe the app, instead of doing it graphically and programmatically like WinForms, you must know that the concept behind WPF was that the markup is just a partial class of the codebehind. That way you could have the View separated from the Controller and Model. This was an approach created by the NeXT Cube and NextStep (the fore father of iOS and OS X) in a system called Model-View-Presenter. The language used was called a plist had no programmatic equivalent which allowed more flexibility and no need to translate the graphic approach and no need for interface construction during startup, thus generating faster code.
Blessings are not just for the ones who kneel. Luckily...
|
|
|
|
|
I really enjoyed this eloquent analysis, thanks ! I did some work on the NeXT machine back in the day; it was interesting, but short-lived.
For me, I see no difference, except outer format, between the Designer.cs code-behind in Windows Forms, and XAML in WPF, except that in WPF I found the XAML got in the way of designing, and designing got in the way of XAML ... but, perhaps I didn't hang in there long enough with WPF to reach even the first plateau in the learning curve (which most programmers do describe as "steep").
One reason for not sticking with WPF had to with my perception it did not have a reliable future, as an investment of my time, and intellect.
Never understood why the code-behind in Win Forms wasn't written in some XML compatible format, anyhow.
“The best hope is that one of these days the Ground will get disgusted enough just to walk away ~ leaving people with nothing more to stand ON than what they have so bloody well stood FOR up to now.” Kenneth Patchen, Poet
|
|
|
|
|
What you are talking about is more of a XAML nature. While XAML is a part of WPF, it is only the popular method by which WPF user interface items are expressed. WPF itself has a lot more to do with performance, binding, and event handling than just XAML.
For instance, WPF offloads almost all UI display processing to the graphics hardware, while Windows Forms relies on the CPU to process each repaint.
WPFs binding ability, arguably one of it's neatest and most useful features allows for true (and fairly simple to implement) separation of concerns between application logic and UI display logic.
I will also say that the UI elements have a very good dynamic sizing engine built under them. I could never have done some of the things that I have done in WPF with Windows Forms.
|
|
|
|
|
Shiny new toys, that was it's purpose back then...
|
|
|
|
|
You pose some good, very-honest questions preaa. Here's my thoughts,
"Why would you put your UI in painful XML tags when you can use Windows forms?"
Once you get used to the XML, it actually becomes far easier and gives you a lot better control. Actually, you *can* still compose your gui by creating your widgets in your code-behind, but once you become as one with the XML, you find that you can weave a GUI as simple or as capable as you want, with non-rectangular elements, animation and other visual effects that are impossible with Windows Forms, and the binding facility is quite advanced. I've been spending the last decade creating a lot of desktop applications, and WPF is my #1 tool of choice. Nearly everything can be defined using the same 'language' (XAML) - and I am not limited to standard widgets. I've created some fairly sophisticated 3D CAD programs, a beating-heart animation (that reflects the measurements being taken of an actual patient's heart), and a geographical-display that shows aircraft moving across it, with drop-shadows and multiple cameras (all, still without leaving the world of XAML). I created one family of pretty 3D-effect buttons, and easily share it across all of my WPF projects while overriding certain of it's properties. I never liked using a "designer" to place controls onto my GUI, and am so comfortable with XAML that it takes me only seconds to type up a fairly decent form that responses as the user resizes the window, adapts to changing text values, etc.
"If it were to separate UI completely with the behaviour, aren't the developers doing that already with clean layering architecture with the forms based applications?"
WPF provides a way to achieve a far cleaner separation of presentation from domain behavior. In fact, you can have your graphic artists load up the same Visual Studio solution into, for example, Blend, and fine-tune the visual aspects, at the same time that the developers are working on the code.
"load .. on a browser?"
That (XBAP deployment) in my opinion, was an additional deployment option, that neither I nor most developers I know ever used. SilverLight, on the other hand, did seem to take off for a while and I felt it was an excellent solution for a time, until HTML5 and CSS3 provided more standardized solutions for the same problem-space and SilverLight got de-emphasized. I think it's safe to simply ignore that option.
I see the world of desktop apps, and online apps, as usually serving two very different spaces. A lot of users do not want to be dependent upon an Internet connection being up and running smoothly, and they don't want latency in the responsiveness of their GUI - especially those that are more than just form-filling applications. I do also enjoy HTML/CSS, and kind of wish the two worlds had more overlap.
James Hurst
"The greatness of a nation and its moral progress can be judged by the way its animals are treated."
Mahatma Gandhi
|
|
|
|
|
Well thanks again for lots of insights.
I do not have a clear picture of where WPF knowledge will take me as a developer. I am also an ASP.NET MVC developer and earlier did a lot of iOS work.
I thought windows desktop applications were obsolete until I saw some cool apps on Windows 8. I bought myself a Win 8 touch machine and I really liked the weather app and some others.
So, I think that WPF and all the other 1000 things like silverlight or RT etc are going to help me create these desktop apps on Win 8. Will that be cool? I don't know.
nevertheless, lot of good answers that help me.
BEst
|
|
|
|
|
"Quietly tap amateur and run a circuit, nominated first one then caught the era of Tutankhamun for example."(9)
Gettable.
---------------------------------
Obscurum per obscurius.
Ad astra per alas porci.
Quidquid latine dictum sit, altum videtur .
|
|
|
|
|
Indeed:
Quietly P
tap H
amateur A
and run R
a A
circuit, O
nominated first N
one I
then caught C
the era of Tutankhamun for example
PHARAONIC
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Well done.
---------------------------------
Obscurum per obscurius.
Ad astra per alas porci.
Quidquid latine dictum sit, altum videtur .
|
|
|
|
|
You were too quick for me, I was going to go with:
I've been saving this one for you ...
Enormous construction projects are politically correct, containing funny god round what the knights said ... (9)
|
|
|
|
|
Very good - except I can't work "ekki-ekki-ekki-pitang-zoom-boing"[^] into the answer...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
|
Start with the clue:
"Quietly tap amateur and run a circuit, nominated first one then caught the era of Tutankhamun for example."(9)
OK, the answer has 9 letters, and probably either means the beginning or end of the clue:
Quietly tap amateur and run a circuit
Or
the era of Tutankhamun for example. The latter looks more likely.
So look at the rest of it:
Quietly tap amateur and run a circuit, nominated first one then caught Some of these are known crossword clue words, (and some are Cricket terms, which DD tends to like anyway:
Quietly - P for "Pianissimo": an Italian word, meaning "very soft", used in musical scores
tap - You get hot and cold taps, so probably either H or C
amateur -
and run
a - If I need a vowel, there is "A" here.
circuit,
nominated
first - Ah! This could well mean "first letter of preceding word" so assume "N"
one - I is the Roman numeral for one
then caught - C from Cricketing terms and abreviations.
So we have "PH__A_NIC" so we are looking for one letter for each of the bits we haven't tried too hard on yet:
amateur - Single letter for Amateur: A
and run - "R" - again, Cricket terms.
circuit - Ah! Single letter, could be "C" (perhaps) or "O" - it's a circuit!
Bolt these in, and it's clear:
PHARAONIC - "of, relating to, or characteristic of a pharaoh or the pharaohs" (Merriam Webster Online)
And King Tut was a Pharaoh...
Simples!
I don't think I actually did it like that: it was a lot more "read clue - oh it's PHARAONIC, now why?" but that's the general principle.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
How long it took you to write this? Don't you have work to do?
|
|
|
|
|
Not long - I type fast.
I work for myself, so I set my hours, and my priorities.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
What do you do? Do you make profits?
|
|
|
|
|
Mohamad M. Mohamad wrote: What do you do?
Um. Given the nature of this site, would you care to guess?
Mohamad M. Mohamad wrote: Do you make profits?
I have a roof over my head, and I can still eat.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
OriginalGriff wrote: Given the nature of this site, would you care to guess?
Software Developer???
OriginalGriff wrote: I have a roof over my head, and I can still eat
Why you didn't go for employment in a company?
|
|
|
|
|
Pretty good guess!
I used to work for other people, first Government departments, then medium companies, then small ones.
Then I was MD of a small company for some years, then I went to being me, myself and I.
I like it: I'm responsible to me, for me, and everything that happens is either my good work, or my fault. There is no politics, no dodging the blame, no interviewing morons who lied on their CVs, no people quitting when the project reaches urgent status.
I can make decisions (mind you, I always did - just sometimes I wasn't supposed to) and I don't have to argue with anyone to get something done. I also don't have to worry if one month there isn't enough to pay the staff and the suppliers - which has happened in the past - It's obvious: pay what you have to, and pay me what I can. Employees don't work like that!
Yes, there are down sides but it suits me. And nobody can tell me what to do or threaten to fire me if I won't work the whole weekend while they swan off to the pub!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Are you hiring 
|
|
|
|
|
Sorry - no!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|