/// <summary> /// </summary> /// <param name="parentRegistry">The parent registry. If it not already contains a registry with the key <see cref="RegistryIdentifier"/>, /// a new <see cref="IRegistry"/> will be created and added to the given registry. </param> /// <param name="height">The height of the statusbar.</param> /// <param name="customColumn">The index for the <see cref="CustomFactoryIdentifier"/> - a column to use as you wish.</param> /// <param name="taskColumn">The index for the task visualizer to use. If negativ, no task visualizer will be added. </param> /// <param name="legendColumn">The index for the column to use. If negativ, no legend will be added. </param> /// <param name="gridLengths"></param> public StatusBarFactory(IRegistry parentRegistry, double height, int customColumn, int taskColumn, int legendColumn, params GridLength[] gridLengths) { if (parentRegistry == null || !parentRegistry.ContainsKey(RegistryIdentifier)) { Registry = new Registry(parentRegistry); parentRegistry?.Add(RegistryIdentifier, Registry); } else { Registry = (IRegistry)parentRegistry[RegistryIdentifier]; } if (height <= 0) { throw new ArgumentOutOfRangeException(nameof(height)); } if (gridLengths.Length == 0) { throw new ArgumentException(@"Value cannot be an empty collection.", nameof(gridLengths)); } CheckColumn(customColumn, gridLengths.Length); CheckColumn(taskColumn, gridLengths.Length); CheckColumn(legendColumn, gridLengths.Length); _height = height; _customColumn = customColumn; _taskColumn = taskColumn; _legendColumn = legendColumn; _gridLengths = gridLengths; }
/// <summary> /// This methods assigns the factories (if not already present) /// to the registry passed. This is used to ensure that default factories are assigned. /// </summary> protected virtual void AssignFactories(IRegistry registry, Application app, WPFMonitor monitor) { if (!registry.ContainsKey(RootPanelFactoryIdentifier)) { registry[RootPanelFactoryIdentifier] = new RootPanelFactory(); } if (!registry.ContainsKey(TitleBarFactoryIdentifier)) { registry[TitleBarFactoryIdentifier] = new TitleBarFactory(registry); } if (!registry.ContainsKey(TabControlFactoryIdentifier)) { registry[TabControlFactoryIdentifier] = new TabControlFactory(monitor); } if (!registry.ContainsKey(StatusBarFactoryIdentifier)) { registry[StatusBarFactoryIdentifier] = new StatusBarFactory(registry, 32, new GridLength(3, GridUnitType.Star), new GridLength(1, GridUnitType.Star), new GridLength(3, GridUnitType.Star)); } if (!registry.ContainsKey(LoadingIndicatorFactoryIdentifier)) { registry[LoadingIndicatorFactoryIdentifier] = LoadingIndicatorFactory.Factory; } if (!registry.ContainsKey(NotifyIconFactoryIdentifier)) { registry[NotifyIconFactoryIdentifier] = new DefaultSigmaNotifyIconFactory(SigmaIconPath, () => ExecuteOnRoot(Monitor, win => win.CustomMaximise()), () => ExecuteOnRoot(Monitor, win => win.PropagateAction(child => child.ForceClose()))); } }
/// <summary> /// /// </summary> /// <param name="parentRegistry">The parent registry. If it not already contains a registry with the key <see cref="RegistryIdentifier"/>, /// a new <see cref="IRegistry"/> will be created and added to the given registry. </param> /// <param name="margin"></param> /// <param name="padding"></param> public TitleBarFactory(IRegistry parentRegistry, Thickness margin, Thickness padding) { if (parentRegistry == null || !parentRegistry.ContainsKey(RegistryIdentifier)) { Registry = new Registry(parentRegistry); parentRegistry?.Add(RegistryIdentifier, Registry); } else { Registry = (IRegistry)parentRegistry[RegistryIdentifier]; } Margin = margin; Padding = padding; TitleBarFuncs = new List <Func <Application, Window, TitleBarItem> >(); }
/// <summary> /// Get the parameter type for a certain registry entry. /// Note: This is just a convenience method which fetches the values and calls <see cref="IParameterisationManager.GetParameterType(string,System.Type,System.Type)"/> /// </summary> /// <param name="identifier">The direct identifier within the given registry.</param> /// <param name="registry">The registry to fetch the value from.</param> /// <returns>The parameter type the fetched value from the given registry should be parameterised as.</returns> public IParameterType GetParameterType(string identifier, IRegistry registry) { if (identifier == null) { throw new ArgumentNullException(nameof(identifier)); } if (registry == null) { throw new ArgumentNullException(nameof(registry)); } if (!registry.ContainsKey(identifier)) { throw new KeyNotFoundException($"Identifier {identifier} does not exist in given registry."); } return(GetParameterType(identifier, registry.GetAssociatedType(identifier), registry[identifier].GetType())); }
/// <summary> /// Get a registry copy containing a copy of given required values. /// </summary> /// <param name="registry">The registry.</param> /// <param name="resolvedRegistryEntries">The RESOLVED registry entries.</param> /// <returns>A registry copy containing a copy of given required values.</returns> public static IRegistry GetRegistryCopyForResolvedEntries(IRegistry registry, ISet <string> resolvedRegistryEntries) { IRegistry rootCopy = new Registry(tags: registry.Tags.ToArray()); foreach (string entry in resolvedRegistryEntries) { string[] parts = entry.Split('.'); IRegistry currentRoot = registry; IRegistry currentRootCopy = rootCopy; for (int i = 0; i < parts.Length - 1; i++) { string part = parts[i]; if (!currentRoot.ContainsKey(part)) { throw new InvalidOperationException($"Cannot access non-existing registry \"{part}\" from full entry \"{entry}\" (level {i})."); } IRegistry nextRoot = currentRoot[part] as IRegistry; if (nextRoot == null) { throw new InvalidOperationException($"Cannot access non-registry entry \"{part}\" from full entry \"{entry}\" (level {i}), should be instance of {nameof(IRegistry)}."); } if (!currentRootCopy.ContainsKey(part)) { currentRootCopy[part] = new Registry(parent: currentRootCopy, tags: nextRoot.Tags.ToArray()); currentRootCopy = currentRootCopy.Get <IRegistry>(part); } currentRoot = nextRoot; } string lastPart = parts[parts.Length - 1]; object copiedValue = RegistryUtils.DeepestCopy(currentRoot[lastPart]); currentRootCopy[lastPart] = copiedValue; } return(rootCopy); }
/// <summary> /// Checks whether an environment exists with the given name. /// </summary> /// <param name="environmentName">The environment name.</param> /// <returns>A boolean indicating if an environment with the given name exists.</returns> public static bool Exists(string environmentName) { return(ActiveSigmaEnvironments.ContainsKey(environmentName)); }
/// <summary> /// Check if this registry's contents equal another registry's contents. /// </summary> /// <param name="other">The other registry.</param> /// <returns>A boolean indicating if this registry's contents equal another registry's contents.</returns> public bool RegistryContentEquals(IRegistry other) { return(other != null && MappedValues.Count == other.Count && MappedValues.Keys.All(k => other.ContainsKey(k) && Equals(MappedValues[k], other[k]))); }