- SofaAdditionalExamples_-_Step_by_Step.zip
- Examples
- Step by step SofaComponization
- 0. Original CSWPFMasterDetailBinding
- 1. From Application To Component
- 2. From Simple Component to sub-Components
- 3. About Perspectives
- External dependencies
- log4net.dll
- Mef.Codeplex
- System.ComponentModel.Composition.Codeplex.dll
- System.ComponentModel.Composition.Registration.dll
- System.Reflection.Context.dll
- Prism.Mef_Codeplex
- Microsoft.Practices.Prism.dll
- Microsoft.Practices.Prism.Interactivity.dll
- Microsoft.Practices.Prism.MefExtensions.dll
- Microsoft.Practices.Prism.UnityExtensions.dll
- Microsoft.Practices.ServiceLocation.dll
- Microsoft.Practices.Unity.dll
- Microsoft.Practices.Unity.Interception.dll
- WPFToolkit.dll
- Libraries
- ExternalFrameworks.dll
- Sofa.Commons.dll
- Sofa.Component.dll
- Sofa.Container.dll
- Sofa.Themes.dll
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Sofa.Container;
using Sofa.Commons;
using System.IO;
using System.Windows;
using System.Deployment.Application;
using System.Windows.Controls;
namespace CSWPFMasterDetailBinding
{
public enum Mode
{
Perspectives,
All
}
public class PerspectiveHelper
{
#region Declarations
SofaContainer sofaContainer;
UserControl baseWindow;
string optionalTemplateSelection = "<Optional template selection>";
//Used for BaseWindow menu
public List<string> perspectivesList
{
get
{
//List all perspectives (and not templates) in the Perspective directory.
return listPerspectives(Mode.Perspectives);
}
}
string _perspectiveDirectoryName
{
get
{
if (!ApplicationDeployment.IsNetworkDeployed)
return string.Concat(ContainerParameter.DebugDirectoryLocation, "\\Sofa\\Perspectives");
else
return string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\Sofa\\Perspectives");
}
}
#endregion Declarations
public PerspectiveHelper(SofaContainer sofaContainer, UserControl baseWindow)
{
this.sofaContainer = sofaContainer;
this.baseWindow = baseWindow;
}
#region Methods
public void SaveCurrentPerspective()
{
if (sofaContainer.CurrentPerspective != null)
{
sofaContainer.SavePerspective(sofaContainer.CurrentPerspective);
}
}
public void LoadPerspective(string perspectiveName)
{
SaveCurrentPerspective();
Perspective p = sofaContainer.LoadPerspective(perspectiveName);
}
#endregion Methods
#region Utils
string getNameFromFileName(string fileName)
{
fileName = fileName == null ? "" : fileName;
int p = fileName.IndexOf(".xml");
if (p != -1) fileName = fileName.Substring(0, p);
string[] fileNames = fileName.Split('\\');
if (fileNames.Length >= 1) return fileNames[fileNames.Length - 1];
else return "";
}
List<string> listPerspectives(Mode mode)
{
List<string> templatesList = new List<string>();
//Add "<Optional template selection>"
if (mode == Mode.All) templatesList.Add(optionalTemplateSelection);
DirectoryInfo di = new DirectoryInfo(_perspectiveDirectoryName);
FileInfo[] rgFiles = null;
rgFiles = di.GetFiles("*.xml");
foreach (FileInfo fi in rgFiles)
{
//tests should be improved, but this is an example...
//"_XFileExplorerPerspectiveTemplate" specific template, cannot be used
//fi.Name.Length != 36: Templates used by SofaExplorer instances, name includes SofaComponent's GUI
if ((mode == Mode.All) | (!fi.Name.StartsWith("_") && fi.Name != "_XFileExplorerPerspectiveTemplate" && fi.Name.Length != 36))
{
templatesList.Add(getNameFromFileName(fi.Name));
}
}
return templatesList;
}
#endregion Utils
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.