Fix menus. Fix Parameter sorting. Fix erroneous bindings. Fix issue with display of model name not showing an underscore in the name.
Label control was interpreting it as an accelerator. Other code cleanup.
This commit is contained in:
@@ -1140,7 +1140,9 @@ namespace TradeBlotter.ViewModels
|
||||
cmParams = sessionParams.CMParams;
|
||||
NVPCollection nvpCollection = sessionParams.CMParams.ToNVPCollection();
|
||||
nvpDictionary = nvpCollection.ToDictionary();
|
||||
nvpDictionaryKeys = new ObservableCollection<String>(nvpDictionary.Keys);
|
||||
List<String> dictionaryKeys = new List<String>(nvpDictionary.Keys);
|
||||
dictionaryKeys.Sort();
|
||||
nvpDictionaryKeys = new ObservableCollection<String>(dictionaryKeys);
|
||||
selectedParameter = nvpDictionaryKeys[0];
|
||||
positions = new CMPositionModelCollection();
|
||||
positions.Add(sessionParams.ActivePositions);
|
||||
|
||||
@@ -1255,7 +1255,9 @@ namespace TradeBlotter.ViewModels
|
||||
configuration=sessionParams.CMTParams;
|
||||
NVPCollection nvpCollection=sessionParams.CMTParams.ToNVPCollection();
|
||||
nvpDictionary=nvpCollection.ToDictionary();
|
||||
nvpDictionaryKeys=new ObservableCollection<String>(nvpDictionary.Keys);
|
||||
List<String> dictionaryKeys=new List<String>(nvpDictionary.Keys);
|
||||
dictionaryKeys.Sort();
|
||||
nvpDictionaryKeys=new ObservableCollection<String>(dictionaryKeys);
|
||||
selectedParameter=nvpDictionaryKeys[0];
|
||||
positions=new CMTPositionModelCollection();
|
||||
positions.Add(sessionParams.ActivePositions);
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace TradeBlotter.ViewModels
|
||||
// session section
|
||||
private ModelStatistics modelStatistics=null;
|
||||
private NVPDictionary nvpDictionary=null;
|
||||
private ObservableCollection<String> nvpDictionaryKeys=null;
|
||||
private ObservableCollection<String> nvpDictionaryKeys = default;
|
||||
private MGSHConfiguration configuration=null;
|
||||
private MGSHSessionParams sessionParams;
|
||||
private String selectedParameter=null;
|
||||
@@ -132,6 +132,7 @@ namespace TradeBlotter.ViewModels
|
||||
StopMonitor();
|
||||
base.OnDispose();
|
||||
}
|
||||
|
||||
// ******************************************************************************************** P E R S I S T E N C E ********************************************************************************************
|
||||
public override bool CanPersist()
|
||||
{
|
||||
@@ -233,7 +234,7 @@ namespace TradeBlotter.ViewModels
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnMomentumViewModelPropertyChanged(object sender, PropertyChangedEventArgs eventArgs)
|
||||
{
|
||||
}
|
||||
@@ -1371,7 +1372,7 @@ namespace TradeBlotter.ViewModels
|
||||
sessionParams=MGSHSessionManager.RestoreSession(pathFileName);
|
||||
if(null==sessionParams)
|
||||
{
|
||||
MessageBox.Show(String.Format("Unable to open {0}",pathFileName));
|
||||
MessageBox.Show(String.Format("Unable to open {0}",pathFileName),"Error",MessageBoxButton.OK,MessageBoxImage.Exclamation ,MessageBoxResult.OK,MessageBoxOptions.DefaultDesktopOnly);
|
||||
pathFileName=null;
|
||||
return false;
|
||||
}
|
||||
@@ -1380,12 +1381,14 @@ namespace TradeBlotter.ViewModels
|
||||
configuration=sessionParams.Configuration;
|
||||
NVPCollection nvpCollection=sessionParams.Configuration.ToNVPCollection();
|
||||
nvpDictionary=nvpCollection.ToDictionary();
|
||||
nvpDictionaryKeys=new ObservableCollection<String>(nvpDictionary.Keys);
|
||||
List<String> dictionaryKeys=new List<String>(nvpDictionary.Keys);
|
||||
dictionaryKeys.Sort();
|
||||
nvpDictionaryKeys=new ObservableCollection<String>(dictionaryKeys);
|
||||
selectedParameter=nvpDictionaryKeys[0];
|
||||
positions=new MGSHPositionModelCollection();
|
||||
positions.Add(sessionParams.ActivePositions); // active positions will go into their assigned slot
|
||||
positions.Add(sessionParams.HedgePositions, sessionParams.ActivePositions.GetMaxSlotNumber()+1); // -1 is a special slot so active hedge positions will always appear in the slot position 1 past the max
|
||||
positions.Add(sessionParams.AllPositions);
|
||||
//// positions.Add(sessionParams.HedgePositions, -1); // hedge positions will go into slot -1
|
||||
UpdatePositionPrices(false);
|
||||
UpdatePositionRSI3(true);
|
||||
RunPerformance();
|
||||
@@ -1393,7 +1396,7 @@ namespace TradeBlotter.ViewModels
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
MessageBox.Show(String.Format("Unable to open {0}",pathFileName));
|
||||
MessageBox.Show(String.Format("Unable to open {0}",pathFileName),"Error",MessageBoxButton.OK,MessageBoxImage.Exclamation ,MessageBoxResult.OK,MessageBoxOptions.DefaultDesktopOnly);
|
||||
pathFileName=null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace TradeBlotter.ViewModels
|
||||
};
|
||||
Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => { HeadlinesThreadProc(); }), DispatcherPriority.Normal);
|
||||
}
|
||||
|
||||
private void DisplaySplashScreen()
|
||||
{
|
||||
if(System.Diagnostics.Debugger.IsAttached)return;
|
||||
@@ -90,8 +91,6 @@ namespace TradeBlotter.ViewModels
|
||||
{
|
||||
workspaceViewModel.Dispose();
|
||||
}
|
||||
// PriceCache.GetInstance().Dispose();
|
||||
// try{MGPriceCache.GetInstance().Dispose();}catch(Exception){;}
|
||||
try{LocalPriceCache.GetInstance().Dispose();}catch(Exception){;}
|
||||
try{GBPriceCache.GetInstance().Dispose();}catch(Exception){;}
|
||||
try{PriceCache.GetInstance().Dispose();}catch(Exception){;}
|
||||
@@ -123,7 +122,20 @@ namespace TradeBlotter.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Windows.Controls.MenuItem menuItem=new System.Windows.Controls.MenuItem() { Header = viewModel.Title,Command = new RelayCommand(param=>{this.SetActiveWorkspace(viewModel);return;})};
|
||||
System.Windows.Controls.MenuItem menuItem=new System.Windows.Controls.MenuItem()
|
||||
{
|
||||
Name = "MainWindowViewModelMenu",
|
||||
Header = viewModel.Title,Command = new RelayCommand(param=>
|
||||
{
|
||||
this.SetActiveWorkspace(viewModel);
|
||||
return;
|
||||
}
|
||||
),
|
||||
HorizontalAlignment=HorizontalAlignment.Left,
|
||||
VerticalAlignment=VerticalAlignment.Center,
|
||||
VerticalContentAlignment=VerticalAlignment.Center,
|
||||
HorizontalContentAlignment=HorizontalAlignment.Left
|
||||
};
|
||||
menuItem.FontWeight=FontWeights.DemiBold;
|
||||
menuItem.FontStyle=FontStyles.Italic;
|
||||
|
||||
@@ -141,8 +153,12 @@ namespace TradeBlotter.ViewModels
|
||||
multiBinding.Bindings.Add(headerBinding);
|
||||
multiBinding.Converter=new NameMultiValueConverter();
|
||||
BindingOperations.SetBinding(menuItem,System.Windows.Controls.MenuItem.HeaderProperty,multiBinding);
|
||||
|
||||
menuCollection.Add(menuItem);
|
||||
if(!menuCollectionDictionary.ContainsKey(viewModel))menuCollectionDictionary.Add(viewModel,menuItem);
|
||||
if(!menuCollectionDictionary.ContainsKey(viewModel))
|
||||
{
|
||||
menuCollectionDictionary.Add(viewModel,menuItem);
|
||||
}
|
||||
UIServices.SortMenuItems(menuCollection);
|
||||
}
|
||||
catch(Exception exception)
|
||||
@@ -152,7 +168,6 @@ namespace TradeBlotter.ViewModels
|
||||
finally
|
||||
{
|
||||
}
|
||||
// base.OnPropertyChanged("MenuItems");
|
||||
}
|
||||
public void RemoveMenuItem(WorkspaceViewModel viewModel)
|
||||
{
|
||||
@@ -165,7 +180,6 @@ namespace TradeBlotter.ViewModels
|
||||
// ****************************************************************************************************************************************************************
|
||||
public void InstantiateWorkspace(SaveParameters saveParameters)
|
||||
{
|
||||
// WorkspacePersistenceHelper.Load(saveParameters, workspaces,InstantiateWorkspace);
|
||||
WorkspaceViewModel workspaceViewModel=WorkspacePersistenceHelper.Load(saveParameters, workspaces, InstantiateWorkspace);
|
||||
AddMenuItem(workspaceViewModel);
|
||||
}
|
||||
@@ -243,12 +257,20 @@ namespace TradeBlotter.ViewModels
|
||||
private void OnWorkspacesChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.NewItems != null && e.NewItems.Count != 0)
|
||||
{
|
||||
foreach (WorkspaceViewModel workspace in e.NewItems)
|
||||
{
|
||||
workspace.RequestClose += this.OnWorkspaceRequestClose;
|
||||
}
|
||||
}
|
||||
|
||||
if (e.OldItems != null && e.OldItems.Count != 0)
|
||||
{
|
||||
foreach (WorkspaceViewModel workspace in e.OldItems)
|
||||
{
|
||||
workspace.RequestClose -= this.OnWorkspaceRequestClose;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnWorkspaceRequestClose(object sender, EventArgs e)
|
||||
{
|
||||
@@ -259,7 +281,8 @@ namespace TradeBlotter.ViewModels
|
||||
RemoveMenuItem(workspace);
|
||||
if(null!=workspace.Referer)this.SetActiveWorkspace(workspace.Referer);
|
||||
}
|
||||
// *********************************************************************************************************************************************************
|
||||
|
||||
// *********************************************************************************************************************************************************
|
||||
private void ShowAllTrades()
|
||||
{
|
||||
BlotterViewModel workspace = this.Workspaces.FirstOrDefault(vm => vm is BlotterViewModel) as BlotterViewModel;
|
||||
@@ -288,7 +311,6 @@ namespace TradeBlotter.ViewModels
|
||||
BlotterTradeModel trade = TradeRepository.GetInstance().GetTrade(tradeId);
|
||||
if(null==trade)return;
|
||||
trade=trade.Clone();
|
||||
// workspace = new TradeEntryViewModel(trade, TradeRepository.GetInstance(),false);
|
||||
workspace=new TradeEntryViewModel(trade,TradeRepository.GetInstance());
|
||||
this.Workspaces.Add(workspace);
|
||||
}
|
||||
|
||||
@@ -1132,7 +1132,9 @@ namespace TradeBlotter.ViewModels
|
||||
configuration=sessionParams.Configuration;
|
||||
NVPCollection nvpCollection=sessionParams.Configuration.ToNVPCollection();
|
||||
nvpDictionary=nvpCollection.ToDictionary();
|
||||
nvpDictionaryKeys=new ObservableCollection<String>(nvpDictionary.Keys);
|
||||
List<String> dictionaryKeys=new List<String>(nvpDictionary.Keys);
|
||||
dictionaryKeys.Sort();
|
||||
nvpDictionaryKeys=new ObservableCollection<String>(dictionaryKeys);
|
||||
selectedParameter=nvpDictionaryKeys[0];
|
||||
positions=new MGPositionModelCollection();
|
||||
positions.Add(sessionParams.ActivePositions);
|
||||
|
||||
@@ -46,15 +46,23 @@ namespace TradeBlotter.ViewModels
|
||||
protected ViewModelBase()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract SaveParameters GetSaveParameters();
|
||||
|
||||
public abstract void SetSaveParameters(SaveParameters saveParameters);
|
||||
|
||||
public abstract bool CanPersist();
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
this.OnDispose();
|
||||
}
|
||||
|
||||
public virtual String DisplayName { get; protected set; }
|
||||
public virtual String DisplayName
|
||||
{
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
|
||||
protected virtual void OnDispose()
|
||||
{
|
||||
|
||||
@@ -4,23 +4,30 @@ using System.Windows.Input;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using TradeBlotter.Command;
|
||||
using Telerik.Windows.Input.Touch;
|
||||
|
||||
namespace TradeBlotter.ViewModels
|
||||
{
|
||||
public delegate void InstantiateWorkspace(SaveParameters saveParameters);
|
||||
public abstract class WorkspaceViewModel : ViewModelBase
|
||||
{
|
||||
// Relay Command
|
||||
private RelayCommand closeCommand;
|
||||
|
||||
// Events
|
||||
public event EventHandler RequestClose;
|
||||
|
||||
private InstantiateWorkspace workspaceInstantiator;
|
||||
private bool canClose=true;
|
||||
private bool isClosed=false;
|
||||
|
||||
private String title="WorkspaceViewModel";
|
||||
public WorkspaceViewModel Referer{get;set;}
|
||||
|
||||
protected WorkspaceViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public InstantiateWorkspace WorkspaceInstantiator
|
||||
{
|
||||
get
|
||||
@@ -32,14 +39,19 @@ namespace TradeBlotter.ViewModels
|
||||
workspaceInstantiator = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand CloseCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == closeCommand) closeCommand = new RelayCommand(param => this.OnRequestClose());
|
||||
if (null == closeCommand)
|
||||
{
|
||||
closeCommand = new RelayCommand(param => this.OnRequestClose());
|
||||
}
|
||||
return closeCommand;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsClosed
|
||||
{
|
||||
get { return isClosed; }
|
||||
@@ -52,6 +64,7 @@ namespace TradeBlotter.ViewModels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanClose
|
||||
{
|
||||
get { return canClose; }
|
||||
@@ -64,6 +77,7 @@ namespace TradeBlotter.ViewModels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual String Title
|
||||
{
|
||||
get
|
||||
@@ -76,6 +90,15 @@ namespace TradeBlotter.ViewModels
|
||||
base.OnPropertyChanged("Title");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual String Header
|
||||
{
|
||||
get
|
||||
{
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRequestClose()
|
||||
{
|
||||
EventHandler handler = this.RequestClose;
|
||||
|
||||
Reference in New Issue
Block a user