Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renamed TaskViewModel to FormViewModel (to use Task name for future f…

…eature)

Renamed Screen to ViewWorkspace
  • Loading branch information...
commit e2119530bf28884186fae5c642d793ee1b830722 1 parent 98ff9e7
@nikhilk authored
View
3  History.txt
@@ -5,6 +5,9 @@
or by setting View.Model attached property.
- Replaced Window and ViewUserControl with View
- Renamed ApplicationContext.WindowName/Window with MainViewName/MainView
+- Renamed Screen to ViewWorkspace and ApplicationContext.ScreenStyle to
+ WorkspaceStyle
+- Renamed TaskViewModel to FormViewModel
0.3.3 Release
View
2  samples/Experiments/NumberEditForm.xaml.cs
@@ -8,7 +8,7 @@
namespace Experiments {
- public class NumberEditModel : TaskViewModel {
+ public class NumberEditModel : FormViewModel {
private int _number;
View
2  samples/TaskList/Views/EditTaskForm.Model.cs
@@ -6,7 +6,7 @@
namespace TaskList {
- public class EditTaskFormModel : TaskViewModel {
+ public class EditTaskFormModel : FormViewModel {
private Task _task;
private Task _originalTask;
View
37 src/Client/Core/Applications/ApplicationContext.cs
@@ -51,7 +51,7 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
private IDictionary<string, string> _startupArguments;
private string _themeName;
private string _mainViewName;
- private Style _screenStyle;
+ private Style _workspaceStyle;
private IComponentContainer _componentContainer;
private ComponentCollection _components;
private Dictionary<Type, List<WeakDelegateReference>> _eventMap;
@@ -135,19 +135,6 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
}
/// <summary>
- /// The style applied to the screen or the root visual of the application.
- /// </summary>
- public Style ScreenStyle {
- get {
- return _screenStyle;
- }
- set {
- EnsureUnstarted();
- _screenStyle = value;
- }
- }
-
- /// <summary>
/// Gets the settings associated with the running application.
/// </summary>
public IsolatedStorageSettings Settings {
@@ -212,6 +199,20 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
}
}
+ /// <summary>
+ /// The style applied to the ViewWorkspace representing the root visual of the application,
+ /// and the container of the main view.
+ /// </summary>
+ public Style WorkspaceStyle {
+ get {
+ return _workspaceStyle;
+ }
+ set {
+ EnsureUnstarted();
+ _workspaceStyle = value;
+ }
+ }
+
internal void EnsureUnstarted() {
if (_started) {
throw new InvalidOperationException("This property can only be set declaratively in XAML or in the Application's constructor.");
@@ -411,11 +412,11 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
_mainView = mainView;
- Screen screen = new Screen();
- screen.Style = ScreenStyle;
+ ViewWorkspace workspace = new ViewWorkspace();
+ workspace.Style = WorkspaceStyle;
- Application.Current.RootVisual = screen;
- screen.Run(mainView);
+ Application.Current.RootVisual = workspace;
+ workspace.Run(mainView);
}
View
4 src/Client/Core/Core.csproj
@@ -197,7 +197,7 @@
<Compile Include="_System\ComponentModel\Navigation\RedirectActionResult.cs" />
<Compile Include="_System\ComponentModel\Navigation\IController.cs" />
<Compile Include="_System\ComponentModel\ScriptExpression.cs" />
- <Compile Include="_System\ComponentModel\TaskViewModel.cs" />
+ <Compile Include="_System\ComponentModel\FormViewModel.cs" />
<Compile Include="_System\Presentation\BindingShim.cs" />
<Compile Include="_System\Presentation\Controls\ViewModelAttribute.cs" />
<Compile Include="_System\Presentation\Controls\IAsyncControl.cs" />
@@ -306,7 +306,7 @@
<Compile Include="UserInterface\Navigation\Page.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="UserInterface\Screen.cs">
+ <Compile Include="UserInterface\ViewWorkspace.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UserInterface\TextFilter.cs">
View
6 src/Client/Core/Themes/generic.xaml
@@ -48,13 +48,13 @@
</Setter>
</Style>
- <!-- Screen -->
- <Style TargetType="fxui:Screen">
+ <!-- ViewWorkspace -->
+ <Style TargetType="fxui:ViewWorkspace">
<Setter Property="Background" Value="White" />
<Setter Property="FormBackground" Value="#20000000" />
<Setter Property="Template">
<Setter.Value>
- <ControlTemplate TargetType="fxui:Screen">
+ <ControlTemplate TargetType="fxui:ViewWorkspace">
<Grid x:Name="RootElement">
<ContentPresenter x:Name="ViewPresenter" />
</Grid>
View
16 src/Client/Core/UserInterface/Form.cs
@@ -137,8 +137,8 @@ public class Form : View {
_parentForm.Focus();
}
- Screen currentScreen = Application.Current.RootVisual as Screen;
- currentScreen.Close(this, _parentForm);
+ ViewWorkspace currentWorkspace = Application.Current.RootVisual as ViewWorkspace;
+ currentWorkspace.Close(this, _parentForm);
if (_closedHandler != null) {
_closedHandler(this, EventArgs.Empty);
@@ -146,7 +146,7 @@ public class Form : View {
}
private void OnCancelCommand() {
- TaskViewModel model = View.GetViewModel(this) as TaskViewModel;
+ FormViewModel model = View.GetViewModel(this) as FormViewModel;
if (model != null) {
model.Cancel(delegate() {
Close(FormResult.Cancel);
@@ -173,7 +173,7 @@ public class Form : View {
}
private void OnOKCommand() {
- TaskViewModel model = View.GetViewModel(this) as TaskViewModel;
+ FormViewModel model = View.GetViewModel(this) as FormViewModel;
if (model != null) {
model.Commit(delegate() {
Close(FormResult.OK);
@@ -193,10 +193,12 @@ public class Form : View {
/// Shows the Form as a modal dialog.
/// </summary>
public void Show() {
- Screen currentScreen = Application.Current.RootVisual as Screen;
- if (currentScreen != null) {
- currentScreen.Show(this);
+ ViewWorkspace currentWorkspace = Application.Current.RootVisual as ViewWorkspace;
+ if (currentWorkspace != null) {
+ currentWorkspace.Show(this);
}
+
+ // TODO: Error otherwise?
}
internal void Show(Panel parentPanel, Form parentForm, FrameworkElement overlayElement) {
View
35 src/Client/Core/UserInterface/Screen.cs → ...lient/Core/UserInterface/ViewWorkspace.cs
@@ -1,4 +1,4 @@
-// Screen.cs
+// ViewWorkspace.cs
// Copyright (c) Nikhil Kothari, 2008. All Rights Reserved.
// http://www.nikhilk.net
//
@@ -17,21 +17,20 @@
namespace SilverlightFX.UserInterface {
- // TODO: Add visual states for empty and for main view
// TODO: Add effect properties for showing/hiding forms and main view
/// <summary>
- /// Represents the root visual of an application.
+ /// Represents the workspace containing the main view of the application.
/// </summary>
[TemplatePart(Name = "RootElement", Type = typeof(Grid))]
[TemplatePart(Name = "ViewPresenter", Type = typeof(ContentPresenter))]
- public sealed class Screen : ContentControl {
+ public sealed class ViewWorkspace : ContentControl {
/// <summary>
/// Represents the FormBackground property.
/// </summary>
public static readonly DependencyProperty FormBackgroundProperty =
- DependencyProperty.Register("FormBackground", typeof(Brush), typeof(Screen), null);
+ DependencyProperty.Register("FormBackground", typeof(Brush), typeof(ViewWorkspace), null);
private ContentPresenter _viewPresenter;
private Grid _rootElement;
@@ -40,10 +39,10 @@ public sealed class Screen : ContentControl {
private Form _currentForm;
/// <summary>
- /// Initializes an instance of a Screen control.
+ /// Initializes an instance of a ViewWorkspace control.
/// </summary>
- public Screen() {
- DefaultStyleKey = typeof(Screen);
+ public ViewWorkspace() {
+ DefaultStyleKey = typeof(ViewWorkspace);
}
/// <summary>
@@ -81,7 +80,7 @@ public sealed class Screen : ContentControl {
internal void Run(View mainView) {
if (_mainView != null) {
- throw new InvalidOperationException("The screen already contains content.");
+ throw new InvalidOperationException("The workspace already contains a view.");
}
_mainView = mainView;
@@ -94,20 +93,20 @@ public sealed class Screen : ContentControl {
}
/// <summary>
- /// Shows the specified content in the screen. Typically the Screen is created and its
- /// content is set by the framework internally when you call XApplication.Run.
- /// If you create the Screen yourself, you can initialize its content by calling this
+ /// Shows the specified content in the workspace. Typically the Workspace is created and its
+ /// content is set by the framework internally by ApplicationContext.
+ /// If you create the Workspace yourself, you can initialize its content by calling this
/// method.
/// </summary>
- /// <param name="screenContent">The content to show on the screen.</param>
- public void Show(FrameworkElement screenContent) {
- if (screenContent == null) {
- throw new ArgumentNullException("screenContent");
+ /// <param name="content">The content to show on the workspace.</param>
+ public void Show(FrameworkElement content) {
+ if (content == null) {
+ throw new ArgumentNullException("content");
}
- View view = screenContent as View;
+ View view = content as View;
if (view == null) {
- view = new View(screenContent);
+ view = new View(content);
}
Run(view);
View
10 ...e/_System/ComponentModel/TaskViewModel.cs → ...e/_System/ComponentModel/FormViewModel.cs
@@ -1,4 +1,4 @@
-// TaskViewModel.cs
+// FormViewModel.cs
// Copyright (c) Nikhil Kothari, 2008. All Rights Reserved.
// http://www.nikhilk.net
//
@@ -14,11 +14,11 @@ namespace System.ComponentModel {
/// <summary>
/// Provides a base class for implementing models that encapsulate
- /// data and behavior associated with a task that can be canceled or
- /// committed. While this is independent of presentation, this model
- /// is typically associated with a Form.
+ /// data and behavior associated with a Form that can be canceled or
+ /// committed. The FormViewModel typically represents a task whose
+ /// completion causes the form to be closed.
/// </summary>
- public abstract class TaskViewModel : ViewModel {
+ public abstract class FormViewModel : ViewModel {
private bool _committed;
private bool _completed;
Please sign in to comment.
Something went wrong with that request. Please try again.