Re: Fruit basket program with Windows Presentation Foundation

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Wed, 09 Jun 2010 07:47:41 -0400

A collection of my C# fruit basket programs is at
http://empowermentzone.com/cs_fruit.zip

The fruit basket web site is at
http://FruitBasket.QuantumMyst.com

To give folks a better sense of what this site offers, I am pasting its front page below.

Jamal

Welcome to the fruit basket demo site



--------------------------------------------------------------------------------



Skip to main contents" Return to the Homepage Go to the contact page View the sites disclaimer policy Here we have for your easy evaluation the description of several programming languages, Plus a small simple project and the generation files for it, so you can look at a project in several of the languages and evaluate whether it makes sense too and/or seems usable by you for programming.

the languages are currently broken down into two groupings, the PC group, which are languages like visual basic, ruby, C, C++ and C#, where the application generally runs on the computer of the person using it, and the server side group, which includes PHP, Java Script, and Perl, where the application usually runs on a server on the Internet, and displays its work to you through a Internet browser.

Each of the entries listed below will have a header 3 with the language, and the contributing author's names, and any special add in's to the project. this header also serves as a link to a description of the language which will open in a separate window. After the header there will be a link, so you can download The entire package with any text documentation the author included, the program files, and an exacutible if there is one, (if the language creates one, and/or the author included it) in a standard zip format file.




the language definitions were extracted from the following sites:
Computing Dictionary Online
and
Wikipedia (TheFreeDictionary.com by Eunice Klicker, a member of this project that had to drop out due to health issues, we thank her resoundingly for her work and efforts to bring this language comparison site to fruition!




if you do not find a language listed here, and would like to see an example in it, Please use the links on the " Contact Us " page to ask for it, and I will do my best to find a programmer who knows the language well enough to assemble the files for you. On the other hand, if your a programmer in a language that we do not have listed here, please! Down load a copy of the Fruit Basket Demo criteria, and generate a set of files in your language! Then contact me by Using the links on the Contact Us Page to E-Mail me and we will be happy to put them up on the site for download by others looking to find out about the wide variety of programming languages out here for your use.




* Important Notice! *, All the items listed below this point have been provided by volunteers, and are offered for download as is!, which brings them under this sites disclaimer policy, clicking on any link below this notice is an agreement to this policy!. You can read the full disclaimer on the Policies Page.

Primarily Application Programming Languages

Assembly, by Ken Perry
Assembly Fruit Basket Demo files





AutoIt, by Tyler Littlefield
Autoit Fruit Basket Demo files




AutoIt with Layout by Code, by Jamal Mazrui
Autoit using layout by Code Fruit Basket Demo files


C in win 32 with RC File, by Ken Perry
C win32 with RC file Fruit Basket Demo files


C Sharp (C#) 2003, by Shannon Gerdts
C# 2003 Fruit Basket Demo files


C Sharp (C#) 2005, by assorted authors

*Note: there are several of this version so i packaged them all together as one file, thanks for them goes to; Jamal Mazrui, Eunice Clicker, Martin Slack, and Ken Perry.
C# 2005 Fruit Basket Demo files


C Sharp (C#) 2005 with data binding and layout panels, by Jamal Mazrui

C# 2005 with Data Binding and Layout Panels Fruit Basket Demo files


Euphoria, by Jamal Mazrui
Euphoria Fruit Basket Demo files


Iron Python, byJamal Mazrui
Fruit Basket Demo in IronPython


Java, by Sina Bahram and Ken Perry
Java Fruit Basket Demo files


J Sharp (J#) 2005, by Jamal Mazrui

J# 2005 Fruit Basket Demo files


LISP, by Ken Perry
LISP Fruit Basket Demo files


Power Basic, by Jamal Mazrui
Power Basic Fruit Basket Demo files


Ruby, by Jamal Mazrui and Jay Macarty
Ruby Fruit Basket Demo files


Visual Basic (VB) 6, by Isaias Couch
VB 6 Fruit Basket Demo files


Visual Basic.net 2005, by Isaias Couch
VB.net 2005 Fruit Basket Demo files


WinBatch, by Jamal Mazrui
WinBatch Fruit Basket Demo files


WPF (Windows Presentation Foundation) by Jacob
WPF Fruit Basket Demo files


primarily Internet Programming Languages
JavaScript, by Jamal Mazrui
JavaScript Fruit Basket Demo files


Perl, by Octavian Rasnita
Perl Fruit Basket Demo files




Perl with WxWidgets , by Jamal Mazrui
Perl with WxWidgets Fruit Basket Demo files


Python with WxWidgets , by Jamal Mazrui
Python with WxWidgets Fruit Basket Demo files


HTA (HTML Application) by Ken Perry
HTA Fruit Basket Demo files


Return to top of page





On 6/8/2010 11:04 PM, prateek aggarwal wrote:
wow!
this was something i have been looking for these days.

thanks lot for posting.
is there any direct link where all the archived programs of fruit
basket can be accessed?
i'm sure there would be few programs which will help me lot in my
projects and learning.

also, i'm looking for a sample program of WCF as well.

any help?

regards,
prateek agarwal.


On 6/9/10, Jamal Mazrui<empower@xxxxxxxxx>  wrote:
   From the archive
http://EmpowermentZone.com/wpf_fruit.zip

This contains essentially the same fruit basket program written with
both the C# 4.0 and Visual Basic 10.0 command-line compilers that are
distributed with the .NET Framework 4.0.  Recent language features
including type inference, property initializers, and lambda functions
are used.  Source code is in the files wpf_fruit.cs and wpf_fruit.vb --
the contents of which are also pasted below.  Batch files to build the
executables are compileCS.bat and compileVB.bat.  Help on compiler
options is also included in the files csc_help.txt and vbc_help.txt.

Windows Presentation Foundation (WPF) is used as the GUI library.  Since
its classes have some of the same names as those of the Windows Forms
library (WinForms), the appropriate assemblies need to be referenced as
parameters to the compiler.  The included response files, csc.rsp and
vbc.rsp, provide these references (the only difference between them is
that the C# one uses a /lib parameter whereas the VB one uses a /libpath
parameter to specify the directory containing WPF assemblies).

WinForms is generally a set of wrappers for native Win32 controls, which
integrate Microsoft Active Accessibility (MSAA) as an accessibility API.
   WPF is a new GUI library, written from the ground up to support
fancier visual effects, including animation.  Rather than MSAA, the
accessibility API is User Interface Automation (UIA).

Current screen readers vary considerably in their support for UIA, as
illustrated by this fruit basket program.  Window-Eyes 7.2 provides
almost no meaningful access.  JAWS 10.0 provides partial access in
voicing some controls but not others.  JAWS 11.0 and NVDA provide
complete access.

Some differences between WPF and WinForms include the following:

*  An underscore character (_) rather than ampersand character (&) is
used to indicate the access key of a control (where Alt+Letter activates
it).  For the access key of a label to work, its Target property also
needs to be set, e.g., to the TextBox that should receive focus when the
key is pressed.

*  The StackPanel and Grid layout containers of WPF correspond to the
FlowLayoutPanel and TableLayoutPanel containers of WinForms.  The source
code illustrates layout with alternate containers, as well as alternate
methods for actavating the dialog.

*  The layout of the GUI may be expressed either in code, as done in
this program, or in a separate text file written in the Extensible
Application Markup Language (XAML).  A fruit basket program developed
with Visual Studio and XAML has been contributed by Jacob Kruger in the
archive at
http://fruitbasket.quantummyst.com/downloads/fruitbasket-wpf.zip

Jamal


/*
content of wpf_fruit.cs
Fruit Basket program in C# 4.0 with Windows Presentation Foundation
Public domain by Jamal Mazrui
June 8, 2010
*/

// Import namespaces
using System;
using System.Windows;
using System.Windows.Controls;

// Define class
class FruitBasket: Application {

// Define entry point of program
[STAThread]
static void Main() {
// Create controls;
var txtFruit = new TextBox();
var lblFruit = new Label {Content = "_Fruit:", Target = txtFruit};
var btnAdd = new Button {Content = "_Add", IsDefault = true};
var lstBasket = new ListBox();
      var lblBasket = new Label {Content = "_Basket:", Target = lstBasket};
var btnDelete = new Button {Content = "_Delete"};

// Define Add event handler;
btnAdd.Click += (o, e) =>  {
var sFruit = txtFruit.Text.Trim();
if (sFruit == "") MessageBox.Show("No fruit to add!", "Alert");
else {
lstBasket.Items.Add(sFruit);
txtFruit.Clear();
lstBasket.SelectedIndex = lstBasket.Items.Count - 1;
}
};

// Define Delete event handler;
btnDelete.Click += (o,e) =>  {
var iFruit = lstBasket.SelectedIndex;
if (iFruit == -1) MessageBox.Show("No fruit to delete!", "Alert");
else {
lstBasket.Items.RemoveAt(iFruit);
if (iFruit == lstBasket.Items.Count) iFruit--;
lstBasket.SelectedIndex = iFruit;
}
};

// Complete layout
Window dlg;
var bUseGrid = true;
// bUseGrid = false;
if (bUseGrid) {
var grid = new Grid();
grid.ColumnDefinitions.Clear();
for (var i = 0; i<  3; i++) grid.ColumnDefinitions.Add(new
ColumnDefinition {Width = new GridLength(1, GridUnitType.Auto)});

grid.RowDefinitions.Clear();
for (var i = 0; i<  2; i++) grid.RowDefinitions.Add(new RowDefinition
{Height = new GridLength(1, GridUnitType.Auto)});

foreach (var widget in new UIElement[] {lblFruit, txtFruit, btnAdd,
lblBasket, lstBasket, btnDelete}) grid.Children.Add(widget);
dlg = new Window {Title = "Fruit Basket", Content = grid, SizeToContent
= SizeToContent.WidthAndHeight, HorizontalAlignment =
HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center};
}
else {
var panelAdd = new StackPanel {Orientation = Orientation.Horizontal};
foreach (var widget in new UIElement[] {lblFruit, txtFruit, btnAdd})
panelAdd.Children.Add(widget);

var panelDelete = new StackPanel {Orientation = Orientation.Horizontal};
foreach (var widget in new UIElement[] {lblBasket, lstBasket,
btnDelete}) panelDelete.Children.Add(widget);

var panelMain = new StackPanel {Orientation = Orientation.Vertical};
foreach (var widget in new UIElement[] {panelAdd, panelDelete})
panelMain.Children.Add(widget);

dlg = new Window {Title = "Fruit Basket", Content = panelMain,
SizeToContent = SizeToContent.WidthAndHeight, HorizontalAlignment =
HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center};
}

// Define closing event handler
dlg.Closing += (o, e) =>  e.Cancel = (MessageBox.Show("Close program?",
"Confirm", MessageBoxButton.YesNo) == MessageBoxResult.No);

// Finalize dialog
txtFruit.Focus();

var bUseApplication = true;
// bUseApplication = false;
if (bUseApplication) {
var app = new FruitBasket();
app.Run(dlg);
}
else dlg.ShowDialog();
} // Main method
} // FruitBasket class

// End of wpf_fruit.cs


'content of wpf_fruit.vb
'Fruit Basket program in Visual Basic 10 with Windows Presentation
Foundation
'Public domain by Jamal Mazrui
'June 8, 2010

Option Explicit On
Option Strict On

' Import namespaces
Imports System.Windows
Imports System.Windows.Controls

' Define class
Class FruitBasket
Inherits Application

' Define entry point of program
<STAThread>  Shared Sub Main()

' Create controls;
Dim txtFruit = New TextBox()
Dim lblFruit = New Label With {.Content = "_Fruit:", .Target = txtFruit }
Dim btnAdd = New Button With { .Content = "_Add", .IsDefault = True }
Dim lstBasket = New ListBox()
Dim lblBasket = New Label With { .Content = "_Basket:", .Target =
lstBasket }
Dim btnDelete = New Button With { .Content = "_Delete" }

' Define Add event handler;
AddHandler btnAdd.Click, Sub()
Dim sFruit = txtFruit.Text.Trim()
If sFruit = "" Then
MessageBox.Show("No fruit to add!", "Alert")
Else
lstBasket.Items.Add(sFruit)
txtFruit.Clear()
lstBasket.SelectedIndex = lstBasket.Items.Count - 1
End If
End Sub

' Define Delete event handler;
AddHandler btnDelete.Click, Sub()
Dim iFruit = lstBasket.SelectedIndex
If iFruit = -1 Then
MessageBox.Show("No fruit to delete!", "Alert")
Else
lstBasket.Items.RemoveAt(iFruit)
If iFruit = lstBasket.Items.Count Then iFruit -= 1
lstBasket.SelectedIndex = iFruit
End If
End Sub

' Complete layout
Dim dlg As Window
Dim bUseGrid = True
' bUseGrid = false;
If bUseGrid Then
Dim grid = New Grid()
grid.ColumnDefinitions.Clear()
For i = 0 To 2
grid.ColumnDefinitions.Add(New ColumnDefinition With { .Width = New
GridLength(1, GridUnitType.Auto) })
Next

grid.RowDefinitions.Clear()
For i = 0 To 1
grid.RowDefinitions.Add(New RowDefinition With { .Height = New
GridLength(1, GridUnitType.Auto) })
Next

For Each widget In New UIElement() {lblFruit, txtFruit, btnAdd,
lblBasket, lstBasket, btnDelete}
grid.Children.Add(widget)
Next

dlg = New Window With { .Title =
"Fruit Basket", .Content = grid, .SizeToContent =
SizeToContent.WidthAndHeight, .HorizontalAlignment =
HorizontalAlignment.Center, .VerticalAlignment = VerticalAlignment.Center }
Else
Dim panelAdd = New StackPanel With { .Orientation = Orientation.Horizontal }
For Each widget In New UIElement() {lblFruit, txtFruit, btnAdd}
panelAdd.Children.Add(widget)
Next

Dim panelDelete = New StackPanel With {.Orientation =
Orientation.Horizontal}
For Each widget In New UIElement() {lblBasket, lstBasket, btnDelete}
panelDelete.Children.Add(widget)
Next

Dim panelMain = New StackPanel With {.Orientation = Orientation.Vertical}
For Each widget In New UIElement() {panelAdd, panelDelete}
panelMain.Children.Add(widget)
Next

dlg = New Window With {.Title = "Fruit Basket", .Content = panelMain,
.SizeToContent = SizeToContent.WidthAndHeight, .HorizontalAlignment =
HorizontalAlignment.Center, .VerticalAlignment = VerticalAlignment.Center}
End If

' Define closing event handler
AddHandler dlg.Closing, Sub(o, e)
If MessageBox.Show("Close program?", "Confirm", MessageBoxButton.YesNo)
= MessageBoxResult.No Then e.Cancel = True
End Sub

' Finalize dialog
txtFruit.Focus()

Dim bUseApplication = True
' bUseApplication = false
If bUseApplication Then
Dim app = New FruitBasket()
app.Run(dlg)
Else
dlg.ShowDialog()
End If
End Sub
End Class
' End of wpf_fruit.vb
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: