/// <summary>Opens the specified Control Panel item.</summary> /// <param name="item">The Control Panel item.</param> /// <param name="page">Optional. The Control Panel page.</param> /// <returns> /// <see langword="true"/> if this item is supported and has been opened. <see langword="false"/> if an error prevented opening or /// the item or page was unsupported on this OS. /// </returns> /// <exception cref="ArgumentOutOfRangeException">page</exception> public static bool Open(ControlPanelItem item, string page = null) { if (page != null && Array.IndexOf(item.ValidPages(), page) == -1) { throw new ArgumentOutOfRangeException(nameof(page)); } return(CP.Open(item.CanonicalName(), page)); }
public void SaveControlPanelItem(ControlPanelItem controlPanelItem) { //using (NHTransactionScope tx = new NHTransactionScope()) //{ Repository<ControlPanelItem>.Save(controlPanelItem); // tx.VoteCommit(); //} }
/// <summary>Opens the specified Control Panel item.</summary> /// <param name="item">The Control Panel item.</param> /// <param name="page">Optional. The Control Panel page.</param> /// <exception cref="ArgumentOutOfRangeException">page</exception> public static void Open(ControlPanelItem item, string page = null) { if (page != null && Array.IndexOf(item.ValidPages(), page) == -1) { throw new ArgumentOutOfRangeException(nameof(page)); } // TODO: handle minOsVer gracefully CP.Open(item.CanonicalName(), page, null); }
public void DeleteControlPanelItem(ControlPanelItem controlPanelItem) { //using (NHTransactionScope tx = new NHTransactionScope()) //{ Repository<ControlPanelItem>.Delete(controlPanelItem); //foreach (ControlPanelItemRole controlPanelItemRole in controlPanelItem.ControlPanelItemRoles) // DeleteControlPanelItemRole(controlPanelItemRole); //controlPanelItem.ControlPanelItemRoles.Clear(); // tx.VoteCommit(); //} }
private static CPAssociateAttribute GetAttr(ControlPanelItem value) => typeof(ControlPanelItem).GetField(value.ToString())?.GetCustomAttributes <CPAssociateAttribute>().FirstOrDefault();
/// <summary>Gets the list of valid pages for a Control Panel item.</summary> /// <param name="cp">The <see cref="ControlPanelItem"/> value.</param> /// <returns>The list of valid pages.</returns> /// <exception cref="InvalidOperationException">No information exists for the <see cref="ControlPanelItem"/> value.</exception> public static string[] ValidPages(this ControlPanelItem cp) => GetAttr(cp)?.ValidPages ?? throw new InvalidOperationException();
/// <summary>Gets the module name for a Control Panel item.</summary> /// <param name="cp">The <see cref="ControlPanelItem"/> value.</param> /// <returns>The module name.</returns> /// <exception cref="InvalidOperationException">No information exists for the <see cref="ControlPanelItem"/> value.</exception> public static string ModuleName(this ControlPanelItem cp) => GetAttr(cp)?.ModuleName ?? throw new InvalidOperationException();
/// <summary>Gets the minimum Windows client for a Control Panel item.</summary> /// <param name="cp">The <see cref="ControlPanelItem"/> value.</param> /// <returns>The minimum Windows client.</returns> /// <exception cref="InvalidOperationException">No information exists for the <see cref="ControlPanelItem"/> value.</exception> public static PInvoke.PInvokeClient MinClient(this ControlPanelItem cp) => GetAttr(cp)?.MinClient ?? throw new InvalidOperationException();
/// <summary>Gets the GUID for a Control Panel item.</summary> /// <param name="cp">The <see cref="ControlPanelItem"/> value.</param> /// <returns>The GUID.</returns> /// <exception cref="InvalidOperationException">No information exists for the <see cref="ControlPanelItem"/> value.</exception> public static Guid Guid(this ControlPanelItem cp) => GetAttr(cp)?.Guid ?? throw new InvalidOperationException();
/// <summary>Gets the canonical name for a Control Panel item.</summary> /// <param name="cp">The <see cref="ControlPanelItem"/> value.</param> /// <returns>The canonical name.</returns> /// <exception cref="InvalidOperationException">No information exists for the <see cref="ControlPanelItem"/> value.</exception> public static string CanonicalName(this ControlPanelItem cp) => GetAttr(cp)?.CanonicalName ?? throw new InvalidOperationException();
/// <summary>Gets the path of a Control Panel item.</summary> /// <param name="item">The Control Panel item.</param> /// <returns>The path.</returns> public static string GetPath(ControlPanelItem item) => CP.GetPath(item.CanonicalName());