initial oogynize check in _ this actually used to work!
|
After Width: | Height: | Size: 48 KiB |
BIN
Client Services/GUIWPForms/GUIWPFPages/PageImages/Close.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
Client Services/GUIWPForms/GUIWPFPages/PageImages/CloseAll.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 49 KiB |
BIN
Client Services/GUIWPForms/GUIWPFPages/PageImages/Hide.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
Client Services/GUIWPForms/GUIWPFPages/PageImages/House.png
Normal file
|
After Width: | Height: | Size: 943 B |
BIN
Client Services/GUIWPForms/GUIWPFPages/PageImages/Launch.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
@@ -0,0 +1,20 @@
|
||||
<Page x:Class="Foo.ClientServices.GUIWPForms.WorkspaceSelector_DeleteWorkspacePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="WorkspaceSelector_DeleteWorkspacePage" Height="312" Width="250" Loaded="Page_Loaded">
|
||||
<Grid>
|
||||
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="1" RadiusX="1" Grid.ColumnSpan="2">
|
||||
<Rectangle.Fill>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
|
||||
<GradientStop Color="#FF000000" Offset="0.238"/>
|
||||
<GradientStop Color="#FE333333" Offset="0.778"/>
|
||||
<GradientStop Color="#FE202020" Offset="0.613"/>
|
||||
<GradientStop Color="#FE333333" Offset="0.87"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<Button Height="23" Margin="32,0,0,51" Name="btnNo" VerticalAlignment="Bottom" IsCancel="True" HorizontalAlignment="Left" Width="75" Click="btnNo_Click">_No</Button>
|
||||
<Button HorizontalAlignment="Right" Margin="0,0,26,52" Name="btnYes" Width="75" Height="22" IsDefault="True" VerticalAlignment="Bottom" Click="btnYes_Click">_Yes</Button>
|
||||
<TextBlock Margin="32,38,26,91" Name="txtAreYouSure" Foreground="White" TextWrapping="Wrap" TextAlignment="Left" />
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
using Foo.DataAccessLayer;
|
||||
using Foo.DataAccessLayer.DataTypes;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace Foo.ClientServices.GUIWPForms
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WorkspaceSelector_DeleteWorkspacePage.xaml
|
||||
/// </summary>
|
||||
public partial class WorkspaceSelector_DeleteWorkspacePage : Page
|
||||
{
|
||||
// passed to us by parent
|
||||
private WorkspaceSelector m_WorkspaceSelectorObj = null;
|
||||
private bool m_bPerformanceCache = false;
|
||||
|
||||
// private state variables
|
||||
private string m_strWorkspaceName;
|
||||
|
||||
public WorkspaceSelector_DeleteWorkspacePage(bool bPerformanceCache)
|
||||
{
|
||||
m_strWorkspaceName = String.Empty;
|
||||
m_bPerformanceCache = bPerformanceCache;
|
||||
if (!m_bPerformanceCache)
|
||||
{
|
||||
}
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when page gets loaded
|
||||
/// </summary>
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!m_bPerformanceCache)
|
||||
{
|
||||
// Make sure that the Selector Frame is big enough to hold this page
|
||||
m_WorkspaceSelectorObj = (WorkspaceSelector)this.Tag;
|
||||
|
||||
// Make sure that we have a workspace Name to work with otherwise Navigate Back
|
||||
if (String.IsNullOrEmpty(GUIState.LastSelectedWorkspaceName))
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
else
|
||||
m_strWorkspaceName = GUIState.LastSelectedWorkspaceName;
|
||||
|
||||
// Set Height and Width
|
||||
m_WorkspaceSelectorObj.Height = this.Height + m_WorkspaceSelectorObj.MarginTopBottom;
|
||||
m_WorkspaceSelectorObj.Width = this.Width;
|
||||
|
||||
// Set the Warning Label for this Particular Workspace
|
||||
ConstructAreYouSureMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a thorough Warning Message to be displayed to the user in the label
|
||||
/// Iterates and warns the user of exactly the number of changes that will occur in the system
|
||||
/// </summary>
|
||||
private void ConstructAreYouSureMessage()
|
||||
{
|
||||
int nArtifactsCount = Data.Artifacts.GetArtifactLinkCountForWorkspace(m_strWorkspaceName);
|
||||
int nUniqueArtifactsCount = Data.Artifacts.GetUniqureArtifactsCountForWorkspace(m_strWorkspaceName);
|
||||
if (nArtifactsCount >= 0 && nUniqueArtifactsCount >= 0)
|
||||
{
|
||||
StringBuilder sr = new StringBuilder();
|
||||
sr.Append(String.Format("Are you Sure you want to Delete Workspace '{0}'? \n\n", m_strWorkspaceName));
|
||||
sr.Append(String.Format("This Workspace contains {0} Artifact Links ", (nArtifactsCount - nUniqueArtifactsCount)));
|
||||
sr.Append(String.Format("and {0} Artifacts. ", nUniqueArtifactsCount));
|
||||
sr.Append(String.Format("\n\n In Total: {0} Items will be deleted. There is no way to undo this operation.", nArtifactsCount));
|
||||
txtAreYouSure.Text = sr.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// an error occured
|
||||
Foo.Platform.ErrorReporting.UserError.Show("An Error Occurred", "Navigating you back to the WorkspaceSelector");
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button Yes Event Handler - Go ahead and delete the workspace
|
||||
/// </summary>
|
||||
private void btnYes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Data.Workspace.DeleteWorkspace(GUIState.LastSelectedWorkspaceName))
|
||||
{
|
||||
|
||||
// Show Confirm Delete Message and Go Back
|
||||
StringBuilder sr = new StringBuilder();
|
||||
sr.Append(String.Format("The Workspace '{0}' was deleted successfully. \n\n", m_strWorkspaceName));
|
||||
sr.Append("You will no longer be able to access this Workspace and any Artifacts that were exclusive to it.");
|
||||
ShowMessageAndNavigateBack(sr.ToString());
|
||||
|
||||
// Set GUI State
|
||||
GUIState.LastSelectedWorkspaceName = String.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
// an error occured
|
||||
Foo.Platform.ErrorReporting.UserError.Show("An Error Occurred", String.Format("An Error occured while deleting the Workspace {0}. Navigating you back to the WorkspaceSelector", m_strWorkspaceName));
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the passed in message in the text box and then navigates back to the main page
|
||||
/// </summary>
|
||||
/// <param name="strMessage"></param>
|
||||
private void ShowMessageAndNavigateBack(string strMessage)
|
||||
{
|
||||
// Hide the buttons
|
||||
btnYes.Visibility = Visibility.Hidden;
|
||||
btnNo.Visibility = Visibility.Hidden;
|
||||
|
||||
// Show Message
|
||||
txtAreYouSure.Text = strMessage;
|
||||
|
||||
// Pause for 2 second and Navigate Back
|
||||
DispatcherTimer dispatcherTimer = new DispatcherTimer();
|
||||
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
|
||||
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 500);
|
||||
dispatcherTimer.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Timer set specifically to allow the message to be seen for a little bit before navigating back
|
||||
/// </summary>
|
||||
void dispatcherTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
DispatcherTimer dispatcherTimer = (DispatcherTimer) sender;
|
||||
dispatcherTimer.Stop();
|
||||
|
||||
// Navigate Back
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button No Event Handler - Go back to parent
|
||||
/// </summary>
|
||||
private void btnNo_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<Page x:Class="Foo.ClientServices.GUIWPForms.WorkspaceSelector_NewWorkspacePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="WorkspaceSelector_NewWorkspacePage" Height="312" Width="250" Loaded="Page_Loaded">
|
||||
<Grid>
|
||||
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="1" RadiusX="1" Grid.ColumnSpan="2">
|
||||
<Rectangle.Fill>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
|
||||
<GradientStop Color="#FF000000" Offset="0.238"/>
|
||||
<GradientStop Color="#FE333333" Offset="0.778"/>
|
||||
<GradientStop Color="#FE202020" Offset="0.613"/>
|
||||
<GradientStop Color="#FE333333" Offset="0.87"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<Button IsCancel="True" Height="23" Margin="32,0,0,51" Name="btnNo" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="75" Click="btnNo_Click">_Cancel</Button>
|
||||
<Button IsDefault="True" HorizontalAlignment="Right" Margin="0,0,26,52" Name="btnYes" Width="75" Height="22" VerticalAlignment="Bottom" Click="btnYes_Click">C_reate</Button>
|
||||
<Label Margin="32,20,26,0" Name="lblCreateWorkspaceTitle" Foreground="White" VerticalContentAlignment="Top" Height="68" VerticalAlignment="Top" HorizontalContentAlignment="Center">
|
||||
<TextBlock Margin="0,0,0,0" Name="txtCreateWorkspaceTitle" TextWrapping="Wrap" Text="" TextAlignment="Center" />
|
||||
</Label>
|
||||
<Label Height="31" Margin="37,86,26,0" Name="lblEnterNewName" VerticalAlignment="Top" Foreground="White" HorizontalContentAlignment="Center">Enter New Name:</Label>
|
||||
<TextBox Margin="37,115,26,0" Name="txtNewName" Height="23" VerticalAlignment="Top" TextChanged="txtNewName_TextChanged" />
|
||||
<Label Margin="38,136,26,148" Name="lblWarningMessage" HorizontalContentAlignment="Right" Foreground="OrangeRed" FontSize="11" FontStyle="Italic">Label</Label>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Foo.ClientServices.GUIWPForms
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WorkspaceSelector_NewWorkspacePage.xaml
|
||||
/// </summary>
|
||||
public partial class WorkspaceSelector_NewWorkspacePage : Page
|
||||
{
|
||||
// passed to us by parent
|
||||
private WorkspaceSelector m_WorkspaceSelectorObj = null;
|
||||
private bool m_bPerformanceCache = false;
|
||||
|
||||
// private state variables
|
||||
private bool m_bIsValidName;
|
||||
|
||||
public WorkspaceSelector_NewWorkspacePage(bool bPerformanceCache)
|
||||
{
|
||||
m_bPerformanceCache = bPerformanceCache;
|
||||
if (!m_bPerformanceCache)
|
||||
{
|
||||
}
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!m_bPerformanceCache)
|
||||
{
|
||||
// Make sure that the Selector Frame is big enough to hold this page
|
||||
m_WorkspaceSelectorObj = (WorkspaceSelector)this.Tag;
|
||||
m_WorkspaceSelectorObj.Height = this.Height + m_WorkspaceSelectorObj.MarginTopBottom;
|
||||
m_WorkspaceSelectorObj.Width = this.Width;
|
||||
|
||||
// Set the Warning Label for this Particular Workspace
|
||||
ConstructAreYouSureMessage();
|
||||
|
||||
// Set intial Error Message
|
||||
SetWarningMessage("Enter Characters");
|
||||
m_bIsValidName = false;
|
||||
|
||||
// Set intial focus
|
||||
txtNewName.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a renaming Message to be displayed to the user
|
||||
/// </summary>
|
||||
private void ConstructAreYouSureMessage()
|
||||
{
|
||||
StringBuilder sr = new StringBuilder();
|
||||
sr.Append("Create New Workspace \n");
|
||||
txtCreateWorkspaceTitle.Text = sr.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the validator label to a warning message
|
||||
/// </summary>
|
||||
/// <param name="strMessage"></param>
|
||||
private void SetWarningMessage(string strMessage)
|
||||
{
|
||||
lblWarningMessage.Foreground = new SolidColorBrush(Colors.OrangeRed);
|
||||
lblWarningMessage.Content = strMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the validator label to a success message
|
||||
/// </summary>
|
||||
/// <param name="strMessage"></param>
|
||||
private void SetSuccessMessage(string strMessage)
|
||||
{
|
||||
lblWarningMessage.Foreground = new SolidColorBrush(Colors.RoyalBlue);
|
||||
lblWarningMessage.Content = strMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button Yes Event Handler - Go ahead and Create the new WorkspaceName
|
||||
/// </summary>
|
||||
private void btnYes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (m_bIsValidName)
|
||||
{
|
||||
if (!DataAccessLayer.Data.Workspace.InsertWorkspaceName(txtNewName.Text))
|
||||
{
|
||||
// an error occured
|
||||
Foo.Platform.ErrorReporting.UserError.Show("An Error Occurred", "Creating the Workspace Failed! Navigating you back to the WorkspaceSelector");
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set GUI State
|
||||
GUIState.LastSelectedWorkspaceName = txtNewName.Text;
|
||||
|
||||
// Show Success Message
|
||||
ShowMessageAndNavigateBack(String.Format("Workspace '{0}' has been successfully created", txtNewName.Text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the passed in message in the text box and then navigates back to the main page
|
||||
/// </summary>
|
||||
/// <param name="strMessage"></param>
|
||||
private void ShowMessageAndNavigateBack(string strMessage)
|
||||
{
|
||||
// Hide the buttons
|
||||
btnYes.Visibility = Visibility.Hidden;
|
||||
btnNo.Visibility = Visibility.Hidden;
|
||||
|
||||
// Hide the textbox and Labels
|
||||
lblEnterNewName.Visibility = Visibility.Hidden;
|
||||
txtNewName.Visibility = Visibility.Hidden;
|
||||
lblWarningMessage.Visibility = Visibility.Hidden;
|
||||
|
||||
// Show Message
|
||||
txtCreateWorkspaceTitle.Text = strMessage;
|
||||
|
||||
// Dynamically calculate the height of the textbox * No need to do this in this case *
|
||||
// System.Drawing.Size sz = new System.Drawing.Size((int)this.Width, int.MaxValue);
|
||||
// Font font = new Font(txtRenameWorkspaceTitle.FontFamily.ToString(), (float)txtRenameWorkspaceTitle.FontSize);
|
||||
// sz = TextRenderer.MeasureText(txtRenameWorkspaceTitle.Text, font, sz, TextFormatFlags.WordBreak);
|
||||
// Change Height as needed
|
||||
// lblRenameWorkspaceTitle.Height = sz.Height;
|
||||
// txtRenameWorkspaceTitle.Height = sz.Height;
|
||||
|
||||
// default to change height to Max available space
|
||||
lblCreateWorkspaceTitle.Height = this.Height - m_WorkspaceSelectorObj.MarginTopBottom;
|
||||
txtCreateWorkspaceTitle.Height = this.Height - m_WorkspaceSelectorObj.MarginTopBottom;
|
||||
|
||||
// Pause for 1.5 second and Navigate Back
|
||||
DispatcherTimer dispatcherTimer = new DispatcherTimer();
|
||||
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
|
||||
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 500);
|
||||
dispatcherTimer.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Timer set specifically to allow the message to be seen for a little bit before navigating back
|
||||
/// </summary>
|
||||
void dispatcherTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
DispatcherTimer dispatcherTimer = (DispatcherTimer)sender;
|
||||
dispatcherTimer.Stop();
|
||||
|
||||
// Navigate Back
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button No Event Handler - Go back to parent
|
||||
/// </summary>
|
||||
private void btnNo_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform NewWorkspaceName TextBox Validation
|
||||
/// </summary>
|
||||
private void txtNewName_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
System.Windows.Controls.TextBox textBox = (System.Windows.Controls.TextBox)sender;
|
||||
if (String.IsNullOrEmpty(textBox.Text))
|
||||
{
|
||||
SetWarningMessage("Enter Characters");
|
||||
m_bIsValidName = false;
|
||||
}
|
||||
else if (!DataAccessLayer.DataTypes.DataTypeValidation.IsValidWorkspaceName(textBox.Text))
|
||||
{
|
||||
SetWarningMessage("Invalid Workspace Name");
|
||||
m_bIsValidName = false;
|
||||
}
|
||||
else if (DataAccessLayer.Data.Workspace.DoesWorkspaceNameExist(textBox.Text))
|
||||
{
|
||||
SetWarningMessage("Workspace Name Already Exists");
|
||||
m_bIsValidName = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSuccessMessage("Valid Workspace Name");
|
||||
m_bIsValidName = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<Page x:Class="Foo.ClientServices.GUIWPForms.WorkspaceSelector_RenameWorkspacePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="WorkspaceSelector_RenameWorkspacePage" Height="312" Width="250" Loaded="Page_Loaded">
|
||||
<Grid>
|
||||
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="1" RadiusX="1" Grid.ColumnSpan="2">
|
||||
<Rectangle.Fill>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
|
||||
<GradientStop Color="#FF000000" Offset="0.238"/>
|
||||
<GradientStop Color="#FE333333" Offset="0.778"/>
|
||||
<GradientStop Color="#FE202020" Offset="0.613"/>
|
||||
<GradientStop Color="#FE333333" Offset="0.87"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<Button Height="23" Margin="32,0,0,51" Name="btnNo" VerticalAlignment="Bottom" IsCancel="True" HorizontalAlignment="Left" Width="75" Click="btnNo_Click">_Cancel</Button>
|
||||
<Button HorizontalAlignment="Right" Margin="0,0,26,52" Name="btnYes" IsDefault="True" Width="75" Height="22" VerticalAlignment="Bottom" Click="btnYes_Click">_Rename</Button>
|
||||
<Label Margin="32,20,26,0" Name="lblRenameWorkspaceTitle" Foreground="White" VerticalContentAlignment="Top" Height="68" VerticalAlignment="Top" HorizontalContentAlignment="Center">
|
||||
<TextBlock Margin="0,0,0,0" Name="txtRenameWorkspaceTitle" TextWrapping="Wrap" Text="" TextAlignment="Center" />
|
||||
</Label>
|
||||
<Label Height="31" Margin="37,86,26,0" Name="lblEnterNewName" VerticalAlignment="Top" Foreground="White" HorizontalContentAlignment="Center">Enter New Name:</Label>
|
||||
<TextBox Margin="37,115,26,0" Name="txtNewName" Height="23" VerticalAlignment="Top" TextChanged="txtNewName_TextChanged" />
|
||||
<Label Margin="38,136,26,148" Name="lblWarningMessage" HorizontalContentAlignment="Right" Foreground="OrangeRed" FontSize="11" FontStyle="Italic">Label</Label>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,210 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Foo.ClientServices.GUIWPForms
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WorkspaceSelector_RenameWorkspacePage.xaml
|
||||
/// </summary>
|
||||
public partial class WorkspaceSelector_RenameWorkspacePage : Page
|
||||
{
|
||||
// passed to us by parent
|
||||
private WorkspaceSelector m_WorkspaceSelectorObj = null;
|
||||
private bool m_bPerformanceCache = false;
|
||||
|
||||
// private state variables
|
||||
private string m_strWorkspaceName;
|
||||
private bool m_bIsValidName;
|
||||
|
||||
public WorkspaceSelector_RenameWorkspacePage(bool bPerformanceCache)
|
||||
{
|
||||
m_bPerformanceCache = bPerformanceCache;
|
||||
if (!m_bPerformanceCache)
|
||||
{
|
||||
}
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!m_bPerformanceCache)
|
||||
{
|
||||
// Make sure that the Selector Frame is big enough to hold this page
|
||||
m_WorkspaceSelectorObj = (WorkspaceSelector)this.Tag;
|
||||
|
||||
// Make sure that we have a workspace Name to work with otherwise Navigate Back
|
||||
if (String.IsNullOrEmpty(GUIState.LastSelectedWorkspaceName))
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
else
|
||||
m_strWorkspaceName = GUIState.LastSelectedWorkspaceName;
|
||||
|
||||
// Set Height and Width
|
||||
m_WorkspaceSelectorObj.Height = this.Height + m_WorkspaceSelectorObj.MarginTopBottom;
|
||||
m_WorkspaceSelectorObj.Width = this.Width;
|
||||
|
||||
// Set the Warning Label for this Particular Workspace
|
||||
ConstructAreYouSureMessage();
|
||||
|
||||
// Set intial Error Message
|
||||
SetWarningMessage("Enter Characters");
|
||||
m_bIsValidName = false;
|
||||
|
||||
// Set intial focus
|
||||
txtNewName.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a renaming Message to be displayed to the user
|
||||
/// </summary>
|
||||
private void ConstructAreYouSureMessage()
|
||||
{
|
||||
StringBuilder sr = new StringBuilder();
|
||||
sr.Append(String.Format("Rename Workspace '{0}'\n", m_strWorkspaceName));
|
||||
txtRenameWorkspaceTitle.Text = sr.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the validator label to a warning message
|
||||
/// </summary>
|
||||
/// <param name="strMessage"></param>
|
||||
private void SetWarningMessage(string strMessage)
|
||||
{
|
||||
lblWarningMessage.Foreground = new SolidColorBrush(Colors.OrangeRed);
|
||||
lblWarningMessage.Content = strMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the validator label to a success message
|
||||
/// </summary>
|
||||
/// <param name="strMessage"></param>
|
||||
private void SetSuccessMessage(string strMessage)
|
||||
{
|
||||
lblWarningMessage.Foreground = new SolidColorBrush(Colors.RoyalBlue);
|
||||
lblWarningMessage.Content = strMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button Yes Event Handler - Go ahead and Rename the WorkspaceName
|
||||
/// </summary>
|
||||
private void btnYes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (m_bIsValidName)
|
||||
{
|
||||
if (!DataAccessLayer.Data.Workspace.RenameWorkspace(m_strWorkspaceName, txtNewName.Text))
|
||||
{
|
||||
// an error occured
|
||||
Foo.Platform.ErrorReporting.UserError.Show("An Error Occurred", "Renaming the Workspace Failed! Navigating you back to the WorkspaceSelector");
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set GUI State
|
||||
GUIState.LastSelectedWorkspaceName = txtNewName.Text;
|
||||
|
||||
// Show Success Message
|
||||
ShowMessageAndNavigateBack(String.Format("'{0}' has been successfully renamed to '{1}'", m_strWorkspaceName, txtNewName.Text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the passed in message in the text box and then navigates back to the main page
|
||||
/// </summary>
|
||||
/// <param name="strMessage"></param>
|
||||
private void ShowMessageAndNavigateBack(string strMessage)
|
||||
{
|
||||
// Hide the buttons
|
||||
btnYes.Visibility = Visibility.Hidden;
|
||||
btnNo.Visibility = Visibility.Hidden;
|
||||
|
||||
// Hide the textbox and Labels
|
||||
lblEnterNewName.Visibility = Visibility.Hidden;
|
||||
txtNewName.Visibility = Visibility.Hidden;
|
||||
lblWarningMessage.Visibility = Visibility.Hidden;
|
||||
|
||||
// Show Message
|
||||
txtRenameWorkspaceTitle.Text = strMessage;
|
||||
|
||||
// Dynamically calculate the height of the textbox * No need to do this in this case *
|
||||
// System.Drawing.Size sz = new System.Drawing.Size((int)this.Width, int.MaxValue);
|
||||
// Font font = new Font(txtRenameWorkspaceTitle.FontFamily.ToString(),(float) txtRenameWorkspaceTitle.FontSize);
|
||||
// sz = TextRenderer.MeasureText(txtRenameWorkspaceTitle.Text, font, sz, TextFormatFlags.WordBreak);
|
||||
// Change Height as needed
|
||||
// lblRenameWorkspaceTitle.Height = sz.Height;
|
||||
// txtRenameWorkspaceTitle.Height = sz.Height;
|
||||
|
||||
// default to change height to Max available space
|
||||
lblRenameWorkspaceTitle.Height = this.Height - m_WorkspaceSelectorObj.MarginTopBottom;
|
||||
txtRenameWorkspaceTitle.Height = this.Height - m_WorkspaceSelectorObj.MarginTopBottom;
|
||||
|
||||
// Pause for 1.5 second and Navigate Back
|
||||
DispatcherTimer dispatcherTimer = new DispatcherTimer();
|
||||
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
|
||||
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 500);
|
||||
dispatcherTimer.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Timer set specifically to allow the message to be seen for a little bit before navigating back
|
||||
/// </summary>
|
||||
void dispatcherTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
DispatcherTimer dispatcherTimer = (DispatcherTimer)sender;
|
||||
dispatcherTimer.Stop();
|
||||
|
||||
// Navigate Back
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button No Event Handler - Go back to parent
|
||||
/// </summary>
|
||||
private void btnNo_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_StandardPage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform NewWorkspaceName TextBox Validation
|
||||
/// </summary>
|
||||
private void txtNewName_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
System.Windows.Controls.TextBox textBox = (System.Windows.Controls.TextBox)sender;
|
||||
if (String.IsNullOrEmpty(textBox.Text))
|
||||
{
|
||||
SetWarningMessage("Enter Characters");
|
||||
m_bIsValidName = false;
|
||||
}
|
||||
else if (!DataAccessLayer.DataTypes.DataTypeValidation.IsValidWorkspaceName(textBox.Text))
|
||||
{
|
||||
SetWarningMessage("Invalid Workspace Name");
|
||||
m_bIsValidName = false;
|
||||
}
|
||||
else if (DataAccessLayer.Data.Workspace.DoesWorkspaceNameExist(textBox.Text))
|
||||
{
|
||||
SetWarningMessage("Workspace Name Already Exists");
|
||||
m_bIsValidName = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSuccessMessage("Valid Workspace Name");
|
||||
m_bIsValidName = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
<Page x:Class="Foo.ClientServices.GUIWPForms.WorkspaceSelector_StandardPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Custom="http://schemas.microsoft.com/wpf/2008/toolkit"
|
||||
Title="WorkspaceSelector_StandardPage" Height="312" Loaded="Page_Loaded" Width="250" Foreground="Black">
|
||||
<Page.Resources>
|
||||
<Style x:Key="DataGridCellStyle" TargetType="{x:Type Custom:DataGridCell}">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Custom:DataGridCell}">
|
||||
<Border Background="Transparent"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="0"
|
||||
SnapsToDevicePixels="True">
|
||||
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Custom Brushes -->
|
||||
<LinearGradientBrush x:Key="RowBackgroundSelectedBrush" StartPoint="0,0" EndPoint="0,1">
|
||||
<GradientStop Color="#4F8CC7" Offset="0" />
|
||||
<GradientStop Color="#1C4B7C" Offset="0.7" />
|
||||
<GradientStop Color="#042D5B" Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
<SolidColorBrush x:Key="RowBackgroundAlternationIndex2Brush" Color="#44FF0000" />
|
||||
<SolidColorBrush x:Key="RowBackgroundAlternationIndex3Brush" Color="#44CCCCCC" />
|
||||
|
||||
<Style x:Key="DataGridDemoRowStyle" TargetType="{x:Type Custom:DataGridRow}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="AlternationIndex" Value="2" >
|
||||
<Setter Property="Background" Value="{StaticResource RowBackgroundAlternationIndex2Brush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="AlternationIndex" Value="3">
|
||||
<Setter Property="Background" Value="{StaticResource RowBackgroundAlternationIndex3Brush}" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Background" Value="{StaticResource RowBackgroundSelectedBrush}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Page.Resources>
|
||||
<Grid>
|
||||
<Rectangle x:Name="recGradiant" Stroke="Black" RadiusY="1" RadiusX="1" Grid.ColumnSpan="2">
|
||||
<Rectangle.Fill>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="1.0">
|
||||
<GradientStop Color="#FF000000" Offset="0.238"/>
|
||||
<GradientStop Color="#FE333333" Offset="0.778"/>
|
||||
<GradientStop Color="#FE202020" Offset="0.613"/>
|
||||
<GradientStop Color="#FE333333" Offset="0.87"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<my:DataGrid ItemsSource="{Binding ElementName=This, Path=WorkspacesDT.DefaultView}"
|
||||
AutoGenerateColumns="False" Margin="12,54,12,33" Name="dataGridWorkspaces"
|
||||
HorizontalScrollBarVisibility="Disabled" HeadersVisibility="None"
|
||||
VerticalScrollBarVisibility="Auto" TabIndex="1"
|
||||
GridLinesVisibility="Horizontal"
|
||||
CellStyle="{StaticResource DataGridCellStyle}"
|
||||
RowStyle="{StaticResource DataGridDemoRowStyle}"
|
||||
RowHeaderWidth="3" ColumnHeaderHeight="15"
|
||||
SelectionMode="Single" SelectionUnit="FullRow"
|
||||
CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False"
|
||||
CanUserResizeColumns="False" CanUserResizeRows="False" CanUserSortColumns="False"
|
||||
MouseRightButtonDown="dataGridWorkspaces_MouseRightButtonDown"
|
||||
MouseDoubleClick="dataGridWorkspaces_MouseDoubleClick"
|
||||
SelectedCellsChanged="dataGridWorkspaces_SelectedCellsChanged"
|
||||
xmlns:my="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" Background="White" BorderBrush="Transparent" BorderThickness="0" IsTabStop="False">
|
||||
|
||||
<my:DataGrid.Columns>
|
||||
<!--<my:DataGridTextColumn Binding="{Binding WorkspaceName}" />-->
|
||||
|
||||
<my:DataGridTemplateColumn KeyboardNavigation.TabIndex="1" Header="WorkspaceName" Width="188" IsReadOnly="True">
|
||||
<my:DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock TextWrapping="NoWrap" Text="{Binding WorkspaceName}">
|
||||
<TextBlock.ToolTip>
|
||||
<TextBlock TextWrapping="Wrap" Width="188" Text="{Binding WorkspaceName}"/>
|
||||
</TextBlock.ToolTip>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</my:DataGridTemplateColumn.CellTemplate>
|
||||
</my:DataGridTemplateColumn>
|
||||
|
||||
<my:DataGridTemplateColumn KeyboardNavigation.TabIndex="1" Header="Date" Width="20" IsReadOnly="True">
|
||||
<my:DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<!--<TextBlock Text="{Binding Date, StringFormat=d}" />-->
|
||||
<!--<Button Visibility="{Binding ButtonIsVisible}" Background="Transparent" Height="16" Width="16" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="ButtonGrid_Click">
|
||||
<Button.Content>-->
|
||||
<!--<Image Source="PageImages/Launch.png"></Image>-->
|
||||
<Image Source="{Binding ButtonResUri}" Height="16" Width="16">
|
||||
<Image.ToolTip>
|
||||
<TextBlock TextWrapping="Wrap" Width="100" Text="{Binding ButtonToolTipText}"/>
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
<!--<TextBlock Text="{Binding Word, StringFormat=d}" />-->
|
||||
<!--</Button.Content>
|
||||
</Button>-->
|
||||
</DataTemplate>
|
||||
</my:DataGridTemplateColumn.CellTemplate>
|
||||
</my:DataGridTemplateColumn>
|
||||
</my:DataGrid.Columns>
|
||||
|
||||
<!--<my:DataGrid.ContextMenu>
|
||||
<ContextMenu >
|
||||
<MenuItem x:Name="menuItemLaunch" Header="Launch">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="Images/cut.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</my:DataGrid.ContextMenu>-->
|
||||
|
||||
</my:DataGrid>
|
||||
<Label Height="28" Margin="16,-2,12,0" Name="lblCurrentWorkspace" VerticalAlignment="Top"
|
||||
Foreground="White" HorizontalContentAlignment="Center">Workspaces</Label>
|
||||
<ComboBox Height="23" Margin="33,23,32,0" Name="comboBoxSortBy" VerticalAlignment="Top" TabIndex="0" SelectionChanged="comboBoxSortBy_SelectionChanged" />
|
||||
<Button Background="Transparent" BorderThickness="0" BorderBrush="Transparent" Height="24" Width="24" HorizontalAlignment="Left" Margin="12,0,0,5" Name="btnNew" VerticalAlignment="Bottom" Click="btnNew_Click" TabIndex="2">
|
||||
<Button.Content>
|
||||
<Image Source="PageImages/AddWorkspace.png"></Image>
|
||||
</Button.Content>
|
||||
<!--<Button.ToolTip>
|
||||
<ToolTip>
|
||||
<TextBlock TextWrapping="Wrap" Width="150">Doris Loves to play with her piano. Piano is alot of fun and she likes to play with it</TextBlock>
|
||||
</ToolTip>
|
||||
</Button.ToolTip>-->
|
||||
</Button>
|
||||
<Button Background="Transparent" BorderThickness="0" BorderBrush="Transparent" Height="24" Width="24" Margin="42,0,0,5" Name="btnEdit" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="btnEdit_Click" TabIndex="3">
|
||||
<Button.Content>
|
||||
<Image Source="PageImages/EditWorkspace.png"></Image>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button Background="Transparent" BorderThickness="0" BorderBrush="Transparent" Height="24" Width="24" Margin="72,0,0,5" Name="btnDelete" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="btnDelete_Click" TabIndex="4">
|
||||
<Button.Content>
|
||||
<Image Source="PageImages/DeleteWorkspace.png"></Image>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button Background="Transparent" BorderThickness="0" BorderBrush="Transparent" Height="24" Width="24" HorizontalAlignment="Right" Margin="0,0,12,5" Name="btnCloseAll" VerticalAlignment="Bottom" Click="btnCloseAll_Click" TabIndex="5">
|
||||
<Button.Content>
|
||||
<Image Source="PageImages/CloseAll.png"></Image>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,418 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Collections.ObjectModel;
|
||||
using Microsoft.Windows.Controls;
|
||||
using System.Data;
|
||||
using System.ComponentModel;
|
||||
|
||||
// Foo Namespace
|
||||
using Foo.WorkspaceMgr;
|
||||
using Foo.DataAccessLayer;
|
||||
using Foo.DataAccessLayer.DataTypes;
|
||||
using Foo.GUILib;
|
||||
|
||||
namespace Foo.ClientServices.GUIWPForms
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WorkspaceSelector_StandardPage.xaml
|
||||
/// </summary>
|
||||
public partial class WorkspaceSelector_StandardPage : Page
|
||||
{
|
||||
// passed to us by parent
|
||||
private WorkspaceSelector m_WorkspaceSelectorObj = null;
|
||||
private bool m_bPerformanceCache = false;
|
||||
|
||||
// WorkspaceMgr - Imp
|
||||
private WorkspaceMgr.WorkspaceMgr m_WorkspaceMgr = null;
|
||||
|
||||
// private DT holds all information needed for the DataGrid
|
||||
public DataTable WorkspacesDT { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="bPerformanceCache"></param>
|
||||
public WorkspaceSelector_StandardPage(bool bPerformanceCache)
|
||||
{
|
||||
// We preload & require the WorkspaceMgr in this class
|
||||
m_WorkspaceMgr = new WorkspaceMgr.WorkspaceMgr();
|
||||
|
||||
// Preload Database call - to make sure it is fast when the user sees it
|
||||
String[] workspaceNames = Data.Workspace.GetAllWorkspaceNames(SortOrderForWorkspaces.Ascending);
|
||||
|
||||
m_bPerformanceCache = bPerformanceCache;
|
||||
if (!m_bPerformanceCache)
|
||||
{
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when we want to Update the DataGrid with new DataTable Items
|
||||
/// ~Responsible for reloading the WorkspacesDT
|
||||
/// </summary>
|
||||
private void UpdateWorkspaceGridItems(SortOrderForWorkspaces sortOrder)
|
||||
{
|
||||
// First Step - Clear the Grid
|
||||
WorkspacesDT.Rows.Clear();
|
||||
|
||||
// Second Step - Fill the Grid with the WorkspaceNames
|
||||
String[] workspaceNames = Data.Workspace.GetAllWorkspaceNames(sortOrder);
|
||||
|
||||
int i = 0;
|
||||
int selectedIndex = -1;
|
||||
foreach (string workspaceName in workspaceNames)
|
||||
{
|
||||
var row = WorkspacesDT.NewRow();
|
||||
WorkspacesDT.Rows.Add(row);
|
||||
row["WorkspaceName"] = workspaceName;
|
||||
row["ButtonResUri"] = "PageImages/Launch.png";//"PageImages/Launch.png";
|
||||
row["ButtonToolTipText"] = "Launch This Workspace";
|
||||
|
||||
// Let's Determine which index is supposed to be selected
|
||||
if (!String.IsNullOrEmpty(GUIState.LastSelectedWorkspaceName) &&
|
||||
(workspaceName == GUIState.LastSelectedWorkspaceName))
|
||||
selectedIndex = i;
|
||||
|
||||
i = i + 1; // incr.
|
||||
}
|
||||
|
||||
// Third Step - Refresh The DataGrid
|
||||
dataGridWorkspaces.ItemsSource = WorkspacesDT.DefaultView;
|
||||
// Other ways to refresh * appears to not be needed here * could be useful later
|
||||
//dataGridWorkspaces.ItemsSource = (WorkspacesDT as IListSource).GetList();
|
||||
//dataGridWorkspaces.Items.Refresh();
|
||||
|
||||
// Fourth Step - Reset the ColumnWidth of the WorkspaceName if no Scrollbar is visible
|
||||
if (workspaceNames.Length <= 13)
|
||||
{
|
||||
// scrollbar not visible
|
||||
DataGridLength gridbuffer = new DataGridLength(188 + 18);
|
||||
dataGridWorkspaces.Columns[0].Width = gridbuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
// scrollbar visible
|
||||
DataGridLength gridbuffer = new DataGridLength(188);
|
||||
dataGridWorkspaces.Columns[0].Width = gridbuffer;
|
||||
}
|
||||
|
||||
// Fifth Step - Set the Selected Index of the DataGrid to the last set
|
||||
// Workspace Or 0 if not found
|
||||
if (selectedIndex >= 0)
|
||||
dataGridWorkspaces.SelectedIndex = selectedIndex;
|
||||
else
|
||||
dataGridWorkspaces.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
#region Page Events
|
||||
|
||||
/// <summary>
|
||||
/// Called when the Page is loaded
|
||||
/// </summary>
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!m_bPerformanceCache)
|
||||
{
|
||||
// Make sure that the Selector Frame is big enough to hold this page
|
||||
m_WorkspaceSelectorObj = (WorkspaceSelector)this.Tag;
|
||||
m_WorkspaceSelectorObj.Height = this.Height + m_WorkspaceSelectorObj.MarginTopBottom;
|
||||
m_WorkspaceSelectorObj.Width = this.Width;
|
||||
|
||||
// InitializeWorkspaceDT
|
||||
WorkspacesDT = new DataTable("WorkspaceData");
|
||||
WorkspacesDT.Columns.Add(new DataColumn("WorkspaceName", typeof(string)));
|
||||
WorkspacesDT.Columns.Add(new DataColumn("ButtonResUri", typeof(string)));
|
||||
WorkspacesDT.Columns.Add(new DataColumn("ButtonToolTipText", typeof(string)));
|
||||
|
||||
// Set Workspaces Label
|
||||
lblCurrentWorkspace.Content = "Workspaces";
|
||||
|
||||
// Load ComboBox Sort Orders
|
||||
comboBoxSortBy.Items.Add(WPFHelper.CreateAComboBoxItem("Sort By Last Accessed", SortOrderForWorkspaces.LastAccessedDescending));
|
||||
comboBoxSortBy.Items.Add(WPFHelper.CreateAComboBoxItem("Sort By Most Frequently Used", SortOrderForWorkspaces.MostFrequentlyAccessedDescending));
|
||||
comboBoxSortBy.Items.Add(WPFHelper.CreateAComboBoxItem("Sort By Name", SortOrderForWorkspaces.Ascending));
|
||||
|
||||
// Load GUI State (or Default Index)
|
||||
comboBoxSortBy.SelectedIndex = GUIState.LastSelectedSotOrderWorkspacesIndex;
|
||||
|
||||
// Assign ToolTips for the Buttons
|
||||
btnNew.ToolTip = WPFHelper.CreateNewStringToolTip("New Workspace", 0, 120);
|
||||
btnEdit.ToolTip = WPFHelper.CreateNewStringToolTip("Rename Workspace", 0, 120);
|
||||
btnDelete.ToolTip = WPFHelper.CreateNewStringToolTip("Delete Workspace", 0, 120);
|
||||
btnCloseAll.ToolTip = WPFHelper.CreateNewStringToolTip("Close All Workspaces", 0, 120);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ComboBox Events
|
||||
|
||||
/// <summary>
|
||||
/// Combo Box - SortBy - Selection Change Event * Deal with repopulating the Workspace Datagrid
|
||||
/// </summary>
|
||||
private void comboBoxSortBy_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
ComboBox combobox = sender as ComboBox;
|
||||
if (combobox != null)
|
||||
{
|
||||
ComboBoxItem item = (ComboBoxItem)combobox.SelectedItem;
|
||||
string Content = item.Content.ToString();
|
||||
SortOrderForWorkspaces sortOrder = (SortOrderForWorkspaces)item.Tag;
|
||||
|
||||
// Save the State Information * Last SortOrder and Last SortOrder Index *
|
||||
GUIState.LastSelectedSotOrderWorkspaces = sortOrder;
|
||||
GUIState.LastSelectedSotOrderWorkspacesIndex = combobox.SelectedIndex;
|
||||
|
||||
// Update The Grid
|
||||
UpdateWorkspaceGridItems(sortOrder);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DataGrid Events
|
||||
|
||||
/// <summary>
|
||||
/// Upon double-click we should be launching the Workspace (unload any previously loaded ones)
|
||||
/// </summary>
|
||||
private void dataGridWorkspaces_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
|
||||
if (!String.IsNullOrEmpty(strWorkspaceName))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selection changed - Keep track of last selected workspace in GUIState
|
||||
/// </summary>
|
||||
private void dataGridWorkspaces_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
|
||||
{
|
||||
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
|
||||
if (!String.IsNullOrEmpty(strWorkspaceName))
|
||||
GUIState.LastSelectedWorkspaceName = strWorkspaceName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Whatever Workspace the User currently has selected in the Grid
|
||||
/// </summary>
|
||||
/// <returns>Selected Workpsace Or Empty String if there is none</returns>
|
||||
private string dataGrid_GetSelectedWorkspaceIfThereIsOne()
|
||||
{
|
||||
String strWorkspaceName = String.Empty;
|
||||
|
||||
// We only allow single selection
|
||||
IList<DataGridCellInfo> cells = dataGridWorkspaces.SelectedCells;
|
||||
if (cells.Count > 0)
|
||||
{
|
||||
DataGridCellInfo cell = cells[0];
|
||||
DataRowView row = (DataRowView)cell.Item;
|
||||
strWorkspaceName = row["WorkspaceName"].ToString();
|
||||
}
|
||||
return strWorkspaceName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the DataGrid Context Menu according to the Selected Workspace State
|
||||
/// </summary>
|
||||
/// <returns>valid Context Menu or Null</returns>
|
||||
private ContextMenu dataGrid_CreateDataGridContextMenu()
|
||||
{
|
||||
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
|
||||
if (!String.IsNullOrEmpty(strWorkspaceName))
|
||||
{
|
||||
// We also want to load the state of the workspace here
|
||||
ContextMenu menu = new ContextMenu();
|
||||
menu.PlacementTarget = this;
|
||||
|
||||
// Load all the MenuItems
|
||||
MenuItem m1 = new MenuItem();
|
||||
m1.Header = "Launch";
|
||||
m1.Click += new RoutedEventHandler(ContextMenu_Item_Click);
|
||||
m1.FontWeight = FontWeights.Bold;
|
||||
m1.Icon = WPFHelper.CreateWPFImageFromRelativeResourceUri("PageImages/Launch.png", 16, 16);
|
||||
menu.Items.Add(m1);
|
||||
|
||||
MenuItem m2 = new MenuItem();
|
||||
m2.Header = "Show";
|
||||
m2.Click += new RoutedEventHandler(ContextMenu_Item_Click);
|
||||
m2.Icon = WPFHelper.CreateWPFImageFromRelativeResourceUri("PageImages/Hide.png", 16, 16);
|
||||
menu.Items.Add(m2);
|
||||
|
||||
MenuItem m3 = new MenuItem();
|
||||
m3.Header = "Hide";
|
||||
m3.Click += new RoutedEventHandler(ContextMenu_Item_Click);
|
||||
m3.Icon = WPFHelper.CreateWPFImageFromRelativeResourceUri("PageImages/Hide.png", 16, 16);
|
||||
menu.Items.Add(m3);
|
||||
|
||||
MenuItem m4 = new MenuItem();
|
||||
m4.Header = "Close";
|
||||
m4.Click += new RoutedEventHandler(ContextMenu_Item_Click);
|
||||
m4.Icon = WPFHelper.CreateWPFImageFromRelativeResourceUri("PageImages/Close.png", 16, 16);
|
||||
menu.Items.Add(m4);
|
||||
|
||||
// Load all the Events
|
||||
menu.Closed += new RoutedEventHandler(ContextMenu_Closed);
|
||||
menu.MouseLeave += new MouseEventHandler(ContextMenu_MouseLeave);
|
||||
return menu;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We need to manually implement the context menu upon right click and not use wpf,
|
||||
/// because of the mouse leave event
|
||||
/// </summary>
|
||||
private void dataGridWorkspaces_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ContextMenu menu = dataGrid_CreateDataGridContextMenu();
|
||||
if (menu != null)
|
||||
{
|
||||
// Make sure that leave doesn't work
|
||||
m_WorkspaceSelectorObj.DontCloseOnMouseLeave = true;
|
||||
|
||||
// Show the Context Menu
|
||||
menu.IsOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ContextMenu Events
|
||||
|
||||
/// <summary>
|
||||
/// Context Menu - Closed Event
|
||||
/// </summary>
|
||||
void ContextMenu_Closed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Make sure that navigator leave works again
|
||||
m_WorkspaceSelectorObj.DontCloseOnMouseLeave = false;
|
||||
|
||||
// Close the Navigation Form *if the mouse is NOT over it*
|
||||
if (!WPFHelper.IsMouseCursorOverWPFormWindow(m_WorkspaceSelectorObj))
|
||||
m_WorkspaceSelectorObj.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Context Menu - Mouse Leave Event
|
||||
/// </summary>
|
||||
void ContextMenu_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
// On Leave just close the Menu
|
||||
ContextMenu menu = (ContextMenu)sender;
|
||||
menu.IsOpen = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Context Menu - Menu Item Clicked Event
|
||||
/// </summary>
|
||||
void ContextMenu_Item_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MenuItem m = (MenuItem)sender;
|
||||
|
||||
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
|
||||
if (!String.IsNullOrEmpty(strWorkspaceName))
|
||||
{
|
||||
bool bSuccess = false;
|
||||
switch (m.Header.ToString())
|
||||
{
|
||||
case "Launch":
|
||||
{
|
||||
bSuccess = m_WorkspaceMgr.LaunchWorkspace(strWorkspaceName);
|
||||
}
|
||||
break;
|
||||
|
||||
case "Show":
|
||||
{
|
||||
bSuccess = m_WorkspaceMgr.HideShowWorkspace(strWorkspaceName, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case "Hide":
|
||||
{
|
||||
bSuccess = m_WorkspaceMgr.HideShowWorkspace(strWorkspaceName, false);
|
||||
}
|
||||
break;
|
||||
|
||||
case "Close":
|
||||
{
|
||||
bSuccess = m_WorkspaceMgr.CloseWorkspace(strWorkspaceName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Button Click Events
|
||||
|
||||
/// <summary>
|
||||
/// New Button - Event Handler
|
||||
/// </summary>
|
||||
private void btnNew_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_NewWorkspacePage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edit Button - Event Handler
|
||||
/// </summary>
|
||||
private void btnEdit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
|
||||
if (!String.IsNullOrEmpty(strWorkspaceName))
|
||||
{
|
||||
GUIState.LastSelectedWorkspaceName = strWorkspaceName;
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_RenameWorkspacePage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete Button - Event Handler
|
||||
/// </summary>
|
||||
private void btnDelete_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
|
||||
if (!String.IsNullOrEmpty(strWorkspaceName))
|
||||
{
|
||||
GUIState.LastSelectedWorkspaceName = strWorkspaceName;
|
||||
m_WorkspaceSelectorObj.NavigateToChildPage(ChildPages.WorkspaceSelector_DeleteWorkspacePage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CloseAll Button - Event Handler
|
||||
/// </summary>
|
||||
private void btnCloseAll_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Does Nothing");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button on the Grid is being clicked - Event Handler
|
||||
/// </summary>
|
||||
private void ButtonGrid_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string strWorkspaceName = dataGrid_GetSelectedWorkspaceIfThereIsOne();
|
||||
if (String.IsNullOrEmpty(strWorkspaceName))
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||