/// <summary> /// Child classes must be marked with UserFriendlyAttribute, to provide user friendly name. /// </summary> /// <returns></returns> public string GetUserFriendlyName() { string name = this.GetType().Name; UserFriendlyNameAttribute.GetTypeAttributeValue(this.GetType(), ref name); return(name); }
private void AdapterManagementOperatorControl_Load(object sender, EventArgs e) { if (this.DesignMode) { return; } _adapterTypes = ReflectionHelper.GatherTypeChildrenTypesFromAssemblies(typeof(IIntegrationAdapter), false, false, ReflectionHelper.GetApplicationEntryAssemblyAndReferencedAssemblies(), null); foreach (Type type in _adapterTypes) { toolStripComboBoxAdapterType.Items.Add(UserFriendlyNameAttribute.GetTypeAttributeName(type)); } if (_adapterTypes.Count == 0) { toolStripComboBoxAdapterType.Enabled = false; toolStripButtonCreate.Enabled = false; } else { toolStripComboBoxAdapterType.SelectedIndex = 0; } }
/// <summary> /// Helper, loads custom indicators. /// </summary> void InitializeCustomPlatformIndicators() { List <Type> indicatorTypes = ReflectionHelper.GatherTypeChildrenTypesFromAssemblies(typeof(PlatformIndicator), true, false, ReflectionHelper.GetApplicationEntryAssemblyReferencedAssemblies(), new Type[] { }); lock (this) { _indicatorsGroups.Add(IndicatorGroup.Custom, new Dictionary <string, PlatformIndicator>()); foreach (Type type in indicatorTypes) {// Extract user friendly names. string name = type.Name; if (UserFriendlyNameAttribute.GetTypeAttributeValue(type, ref name)) { name = type.Name + ", " + name; } if (type.GetConstructor(new Type[] { }) == null) {// Can not create indicator since it needs a parameterless constructor. continue; } PlatformIndicator indicator = (PlatformIndicator)Activator.CreateInstance(type); _indicatorsGroups[IndicatorGroup.Custom].Add(name, indicator); } } }
/// <summary> /// Constructor. /// </summary> public IntegrationAdapter() : base("Integration Adapter", false) { this.Name = UserFriendlyNameAttribute.GetTypeAttributeName(this.GetType()); base.DefaultTimeOut = TimeSpan.FromSeconds(20); }
/// <summary> /// Will load all the indicators from the assembly. /// </summary> /// <param name="assembly"></param> public void CollectCustomIndicatorsFromAssembly(Assembly assembly) { List <Type> indicatorTypes = ReflectionHelper.GatherTypeChildrenTypesFromAssemblies(typeof(PlatformIndicator), true, false, new Assembly[] { assembly }, new Type[] { }); lock (this) { if (_indicatorsGroups.ContainsKey(IndicatorGroup.Custom) == false) { _indicatorsGroups.Add(IndicatorGroup.Custom, new Dictionary <string, PlatformIndicator>()); } foreach (Type type in indicatorTypes) {// Extract user friendly names. string name = type.Name; if (UserFriendlyNameAttribute.GetTypeAttributeValue(type, ref name)) { name = type.Name + ", " + name; } if (type.GetConstructor(new Type[] { }) == null) {// Can not create indicator since it needs a parameterless constructor. continue; } PlatformIndicator indicator = (PlatformIndicator)Activator.CreateInstance(type); _indicatorsGroups[IndicatorGroup.Custom][name] = indicator; } } }
void _component_OperationalStateChangedEvent(IOperational operational, OperationalStateEnum previousOperationState) { WinFormsHelper.BeginManagedInvoke(this, delegate { labelStatus.Text = UserFriendlyNameAttribute.GetTypeAttributeName(operational.GetType()) + " is " + operational.OperationalState.ToString(); }); }
/// <summary> /// /// </summary> /// <param name="name">The name of this client module.</param> /// <param name="singleThreadOnly">Should the module be entered with single or multiple Arbiter threads.</param> public ArbiterClientBase(bool singleThreadOnly) { string name = UserFriendlyNameAttribute.GetTypeAttributeName(this.GetType()); // Make sure not to use the default struct parameterless constructor. _subscriptionClientId = new ArbiterClientId(name, this.GetType(), this); _messageFilter = new MessageFilter(true); _singleThreadOnly = singleThreadOnly; }
/// <summary> /// /// </summary> /// <param name="name">The name of this client module.</param> /// <param name="singleThreadOnly">Should the module be entered with single or multiple Arbiter threads.</param> public ArbiterClientBase(string idName, bool singleThreadOnly) { if (string.IsNullOrEmpty(idName)) {// Try to establish user friendly name, or if not available, use class name. idName = UserFriendlyNameAttribute.GetTypeAttributeName(this.GetType()); } _subscriptionClientId = new ArbiterClientId(idName, this.GetType(), this); _messageFilter = new MessageFilter(true); _singleThreadOnly = singleThreadOnly; }
/// <summary> /// /// </summary> public AdapterManagementComponent() : base(false) { Name = UserFriendlyNameAttribute.GetTypeAttributeName(typeof(AdapterManagementComponent)); base.DefaultTimeOut = TimeSpan.FromSeconds(15); ChangeOperationalState(OperationalStateEnum.Constructed); _adapters.ItemAddedEvent += new GenericContainer <IIntegrationAdapter> .ItemUpdateDelegate(Adapters_ItemAddedEvent); _adapters.ItemRemovedEvent += new GenericContainer <IIntegrationAdapter> .ItemUpdateDelegate(Adapters_ItemRemovedEvent); }
/// <summary> /// /// </summary> public ExpertManagementControl(ExpertManagementComponent expertManager) : base(expertManager) { InitializeComponent(); this.Name = UserFriendlyNameAttribute.GetTypeAttributeName(typeof(ExpertManagementComponent)); expertManager.AddedExpertContainerEvent += new ExpertManagementComponent.ExpertContainerUpdateDelegate(expertManager_AddedExpertContainerEvent); expertManager.RemovedExpertContainerEvent += new ExpertManagementComponent.ExpertContainerUpdateDelegate(expertManager_RemovedExpertContainerEvent); expertManager.ExpertAssemblyAddedEvent += new ExpertManagementComponent.ExpertAssemblyAddedDelegate(expertManager_ExpertAssemblyAddedEvent); expertManager.ExpertAssemblyRemovedEvent += new ExpertManagementComponent.ExpertAssemblyAddedDelegate(expertManager_ExpertAssemblyRemovedEvent); }
/// <summary> /// Constructor. /// </summary> public VolumeCustom() : base(UserFriendlyNameAttribute.GetTypeAttributeName(typeof(VolumeCustom)), true, false, new string[] { "Volume" }) { base._results.SetResultSetChartType("Volume", LinesChartSeries.ChartTypeEnum.Histogram); }
void createItem_Click(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; Type componentType = (Type)item.Tag; PlatformComponent component = null; bool showPropertiesForm = ComponentManagementAttribute.GetTypeAttribute(componentType).RequestPreStartSetup; if (ComponentManagementAttribute.GetTypeAttribute(componentType).IsMandatory) {// Mandatory components we do not create, only show / hide. component = _platform.GetFirstComponentByType(componentType); component.UISerializationInfo.AddValue("componentVisible", true); platform_ActiveComponentAddedEvent(component, false); return; } if (componentType.IsSubclassOf(typeof(Expert))) { component = new LocalExpertHost(UserFriendlyNameAttribute.GetTypeAttributeName(componentType), componentType); showPropertiesForm = showPropertiesForm || ComponentManagementAttribute.GetTypeAttribute(typeof(LocalExpertHost)).RequestPreStartSetup; } else if (componentType.IsSubclassOf(typeof(WizardControl))) {// Wizards are run in Hosting forms. ConstructorInfo info = componentType.GetConstructor(new Type[] { typeof(Platform) }); if (info != null) { WizardControl wizardControl = (WizardControl)info.Invoke(new object[] { _platform }); HostingForm hostingForm = new HostingForm(UserFriendlyNameAttribute.GetTypeAttributeName(componentType), wizardControl); hostingForm.Icon = Resources.magic_wand1; hostingForm.Show(); return; } } else if (componentType.IsSubclassOf(typeof(CommonBaseControl))) {// Tester/editor etc. controls have no components, they are standalone UI components. ConstructorInfo info = componentType.GetConstructor(new Type[] { }); // If failed to find orderInfo, just fall trough to failed to create component (which remains null). if (info != null) {// Since this is a UI only component, just create and return. CommonBaseControl testerControl = (CommonBaseControl)info.Invoke(new object[] { }); /*tabControl.SelectedTab = */ AddComponentControl(testerControl, true); return; } } else { ConstructorInfo info = componentType.GetConstructor(new Type[] { }); if (info != null) { component = (PlatformComponent)info.Invoke(new object[] { }); } } // ... if (component == null) { MessageBox.Show("Failed to create component.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Set settings for component. if (component.SetInitialState(_platform.Settings) == false) { MessageBox.Show("Component failed to initialize from initial state.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (showPropertiesForm) { // Show properties for the user to configure. PropertiesForm form = new PropertiesForm("Properties", component); if (form.ShowDialog() != DialogResult.OK) { return; } } // Register to platform. _platform.RegisterComponent(component); }
void SetComponentMenuItemDropDownItems(ToolStripItemCollection items, Type parentingType, bool includeParentingType, string creationTitle, Image creationImage, Type[] constructorTypes) { if (_platform == null) { return; } if (constructorTypes != null) {// AddElement types available for creation List <Type> resultingTypes = ReflectionHelper.GatherTypeChildrenTypesFromAssemblies(parentingType, false, false, ReflectionHelper.GetApplicationEntryAssemblyAndReferencedAssemblies(), constructorTypes); if (includeParentingType && parentingType.IsAbstract == false) { resultingTypes.Add(parentingType); } foreach (Type componentType in resultingTypes) { if (componentType.IsAbstract) { continue; } string name = parentingType.Name; UserFriendlyNameAttribute.GetTypeAttributeValue(componentType, ref name); // Prepare names for showing in a menu. name = name.Replace("&", "&&"); ToolStripMenuItem newItem = new ToolStripMenuItem(creationTitle + name, creationImage); newItem.Tag = componentType; newItem.Click += new EventHandler(createItem_Click); if (_platform.CanAcceptComponent(componentType) == false) { // Maybe component is invisible mandatory, and we should be able to show it. if (ComponentManagementAttribute.GetTypeAttribute(componentType).IsMandatory) { // Look to see if mandatory UI already created. List <PlatformComponent> components = _platform.GetComponentsByType(componentType); foreach (PlatformComponent component in components) { bool visible = false; // For the button to be enabled, component must have assigned visibility flag and also its value to false. newItem.Enabled = component.UISerializationInfo.TryGetValue <bool>("componentVisible", ref visible) && visible == false; } } else { newItem.Enabled = false; } } else { newItem.Enabled = true; } items.Add(newItem); } } //// Also check the UI components that are stand alone (have no platform component). //foreach (TabPage page in tabControl.TabPages) //{ // if (((PlatformComponentControl)page.Tag).Component == null || // ((PlatformComponentControl)page.Tag).Component is PlatformComponent == false) // { // if (parentingType.IsInstanceOfType((CommonBaseControl)page.Tag)) // {// Found existing standalone component. // string name = ((CommonBaseControl)page.Tag).Name; // ToolStripMenuItem newItem = new ToolStripMenuItem("Remove " + name, ForexPlatformFrontEnd.Properties.Resources.DELETE2); // newItem.Tag = ((CommonBaseControl)page.Tag); // newItem.Click += new EventHandler(removeItem_Click); // item.DropDownItems.AddElement(newItem); // } // } //} }
public virtual bool Initialize() { this.Name = UserFriendlyNameAttribute.GetTypeAttributeName(typeof(OrderExecutionSourceClientStub)); return(true); }
{// Being a core platfrom component, make sure it component level is very low level. /// <summary> /// /// </summary> public PlatformDiagnostics() : base(true) { this.Name = UserFriendlyNameAttribute.GetTypeAttributeName(typeof(PlatformDiagnostics)); }
private void NewOrderControl_Load(object sender, EventArgs e) { if (this.DesignMode) { return; } _imageSell = buttonSell.Image; _imageBuy = buttonBuy.Image; List <Type> orderTypes = ReflectionHelper.GatherTypeChildrenTypesFromAssemblies(typeof(ActiveOrder), ReflectionHelper.GetApplicationEntryAssemblyReferencedAssemblies()); orderTypes.Add(typeof(ActiveOrder)); orderTypes.Reverse(); _orderTypes = orderTypes.ToArray(); foreach (Type type in _orderTypes) { string name = type.Name; UserFriendlyNameAttribute.GetTypeAttributeValue(type, ref name); this.comboBoxManagement.Items.Add(name); comboBoxManagement.SelectedIndex = 0; } if (DataProvider.Ask.HasValue == false || DataProvider.Ask == 0) { numericUpDownStopLoss.DecimalPlaces = 0; } else { numericUpDownStopLoss.DecimalPlaces = 5 - (int)Math.Ceiling(Math.Log10((double)DataProvider.Ask)); } if (_session.Symbol.IsForexPair) { labelVolume.Text = "Lots (1 Lot = " + _session.LotSize + " Units)"; numericUpDownVolume.DecimalPlaces = 2; numericUpDownVolume.Value = 1; } else { labelVolume.Text = "Units"; numericUpDownVolume.DecimalPlaces = 0; numericUpDownVolume.Value = 100; } numericUpDownStopLoss.Increment = (Decimal)Math.Pow(0.1, numericUpDownStopLoss.DecimalPlaces); numericUpDownTakeProfit.DecimalPlaces = numericUpDownStopLoss.DecimalPlaces; numericUpDownTakeProfit.Increment = numericUpDownStopLoss.Increment; dateTimePickerExpiry.Value = dateTimePickerExpiry.MaxDate; comboBoxSymbol.Text = _session.Symbol.Name; checkBoxBalancedPositionMode.Visible = _balancedPositionModeVisible; checkBoxBalancedPositionMode.Checked = _balancePositionModeChecked; NewOrderControl_Resize(sender, e); UpdateUI(); }
/// <summary> /// /// </summary> public MarketWatchComponent() : base(UserFriendlyNameAttribute.GetTypeAttributeName(typeof(MarketWatchComponent)), false) { }
/// <summary> /// /// </summary> public ProxyIntegrationAdapterClient() : base(UserFriendlyNameAttribute.GetTypeAttributeName(typeof(ProxyIntegrationAdapterClient)), false) { this.DefaultTimeOut = TimeSpan.FromSeconds(60); }
/// <summary> /// /// </summary> public FFNewsPlatformIndicatorChartSeries() : base(UserFriendlyNameAttribute.GetTypeAttributeName(typeof(FFNewsPlatformIndicatorChartSeries))) { }