content
stringlengths
5
1.04M
avg_line_length
float64
1.75
12.9k
max_line_length
int64
2
244k
alphanum_fraction
float64
0
0.98
licenses
list
repository_name
stringlengths
7
92
path
stringlengths
3
249
size
int64
5
1.04M
lang
stringclasses
2 values
using System; using System.Collections.Generic; namespace SortList { class Program { static void Main(string[] args) { List<int> numbers = new List<int>(); while (true) { int num = int.Parse(Console.ReadLine()); if (num == -1) break; numbers.Add(num); } numbers.Sort(); numbers.ForEach(Console.WriteLine); //Console.WriteLine(string.Join(" ", numbers)); } } }
20.925926
59
0.447788
[ "MIT" ]
WuWeiSage/Softuni-Contest-Problems
C#/Lists/SortList/SortList/Program.cs
567
C#
using System; using System.Diagnostics; using System.Text.RegularExpressions; namespace ScriptsLib { public static partial class Tools { /// <summary>Returns true is "this" application is running, else false.</summary> public static bool IsThisApplicationAlreadyRunning() { Regex regex = new Regex(".exe"); int instances = 0; foreach (Process p in Process.GetProcessesByName(regex.Replace(AppDomain.CurrentDomain.FriendlyName, ""))) { instances++; } return instances > 1; } } }
22.347826
109
0.715953
[ "Apache-2.0" ]
Milkenm/ScriptsLib
ScriptsLib/Tools/IsThisApplicationAlreadyRunning.cs
516
C#
using System; using NHapi.Base; using NHapi.Base.Parser; using NHapi.Base.Model; using NHapi.Model.V231.Datatype; using NHapi.Base.Log; namespace NHapi.Model.V231.Segment{ ///<summary> /// Represents an HL7 EQL message segment. /// This segment has the following fields:<ol> ///<li>EQL-1: Query Tag (ST)</li> ///<li>EQL-2: Query/ Response Format Code (ID)</li> ///<li>EQL-3: EQL Query Name (CE)</li> ///<li>EQL-4: EQL Query Statement (ST)</li> ///</ol> /// The get...() methods return data from individual fields. These methods /// do not throw exceptions and may therefore have to handle exceptions internally. /// If an exception is handled internally, it is logged and null is returned. /// This is not expected to happen - if it does happen this indicates not so much /// an exceptional circumstance as a bug in the code for this class. ///</summary> [Serializable] public class EQL : AbstractSegment { /** * Creates a EQL (EQL - embedded query language segment) segment object that belongs to the given * message. */ public EQL(IGroup parent, IModelClassFactory factory) : base(parent,factory) { IMessage message = Message; try { this.add(typeof(ST), false, 1, 32, new System.Object[]{message}, "Query Tag"); this.add(typeof(ID), true, 1, 1, new System.Object[]{message, 106}, "Query/ Response Format Code"); this.add(typeof(CE), true, 1, 60, new System.Object[]{message}, "EQL Query Name"); this.add(typeof(ST), true, 1, 4096, new System.Object[]{message}, "EQL Query Statement"); } catch (HL7Exception he) { HapiLogFactory.GetHapiLog(GetType()).Error("Can't instantiate " + GetType().Name, he); } } ///<summary> /// Returns Query Tag(EQL-1). ///</summary> public ST QueryTag { get{ ST ret = null; try { IType t = this.GetField(1, 0); ret = (ST)t; } catch (HL7Exception he) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he); throw new System.Exception("An unexpected error ocurred", he); } catch (System.Exception ex) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex); throw new System.Exception("An unexpected error ocurred", ex); } return ret; } } ///<summary> /// Returns Query/ Response Format Code(EQL-2). ///</summary> public ID QueryResponseFormatCode { get{ ID ret = null; try { IType t = this.GetField(2, 0); ret = (ID)t; } catch (HL7Exception he) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he); throw new System.Exception("An unexpected error ocurred", he); } catch (System.Exception ex) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex); throw new System.Exception("An unexpected error ocurred", ex); } return ret; } } ///<summary> /// Returns EQL Query Name(EQL-3). ///</summary> public CE EQLQueryName { get{ CE ret = null; try { IType t = this.GetField(3, 0); ret = (CE)t; } catch (HL7Exception he) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he); throw new System.Exception("An unexpected error ocurred", he); } catch (System.Exception ex) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex); throw new System.Exception("An unexpected error ocurred", ex); } return ret; } } ///<summary> /// Returns EQL Query Statement(EQL-4). ///</summary> public ST EQLQueryStatement { get{ ST ret = null; try { IType t = this.GetField(4, 0); ret = (ST)t; } catch (HL7Exception he) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he); throw new System.Exception("An unexpected error ocurred", he); } catch (System.Exception ex) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex); throw new System.Exception("An unexpected error ocurred", ex); } return ret; } } }}
31.345588
111
0.663852
[ "MPL-2.0", "MPL-2.0-no-copyleft-exception" ]
AMCN41R/nHapi
src/NHapi.Model.V231/Segment/EQL.cs
4,263
C#
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; namespace VlogRoom.Web.Models.AccountViewModels { public class ExternalLoginConfirmationViewModel { [Required] [Display(Name = "Email")] public string Email { get; set; } } }
22.8
51
0.71345
[ "MIT" ]
RosenUrkov/VlogRoom
VlogRoom/VlogRoom.Web/Models/AccountViewModels/ExternalLoginConfirmationViewModel.cs
344
C#
using System; using System.Buffers.Binary; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace Disasmo.Utils { public static class UserLogger { public static void AppendText(string text) { File.AppendAllText(LogFile, text + "\n"); } public static string LogFile { get; } = Path.GetTempFileName(); } }
21.636364
71
0.684874
[ "MIT" ]
Sergio0694/Disasmo
src/Vsix/Utils/UserLogger.cs
478
C#
// ---------------------------------------------------------------------------------- // // Copyright Microsoft Corporation // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ---------------------------------------------------------------------------------- using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Microsoft Azure Powershell")] [assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] [assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] [assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] [assembly: CLSCompliant(false)] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.0")] [assembly: AssemblyVersion("2.12.0")] [assembly: AssemblyFileVersion("2.12.0")]
46.608696
104
0.696828
[ "MIT" ]
SimonWahlin/azure-powershell
src/RecoveryServices/RecoveryServices.Backup/Properties/AssemblyInfo.cs
2,099
C#
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. // // // This file was generated, please do not edit it directly. // // Please see MilCodeGen.html for more information. // using MS.Internal; using MS.Internal.Collections; using MS.Internal.PresentationCore; using MS.Utility; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Windows.Markup; using System.Windows.Media.Media3D.Converters; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Composition; using System.Security; using System.Security.Permissions; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; using System.Windows.Media.Imaging; // These types are aliased to match the unamanaged names used in interop using BOOL = System.UInt32; using WORD = System.UInt16; using Float = System.Single; namespace System.Windows.Media.Media3D { sealed partial class EmissiveMaterial : Material { //------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods /// <summary> /// Shadows inherited Clone() with a strongly typed /// version for convenience. /// </summary> public new EmissiveMaterial Clone() { return (EmissiveMaterial)base.Clone(); } /// <summary> /// Shadows inherited CloneCurrentValue() with a strongly typed /// version for convenience. /// </summary> public new EmissiveMaterial CloneCurrentValue() { return (EmissiveMaterial)base.CloneCurrentValue(); } #endregion Public Methods //------------------------------------------------------ // // Public Properties // //------------------------------------------------------ private static void ColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { EmissiveMaterial target = ((EmissiveMaterial) d); target.PropertyChanged(ColorProperty); } private static void BrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { // The first change to the default value of a mutable collection property (e.g. GeometryGroup.Children) // will promote the property value from a default value to a local value. This is technically a sub-property // change because the collection was changed and not a new collection set (GeometryGroup.Children. // Add versus GeometryGroup.Children = myNewChildrenCollection). However, we never marshalled // the default value to the compositor. If the property changes from a default value, the new local value // needs to be marshalled to the compositor. We detect this scenario with the second condition // e.OldValueSource != e.NewValueSource. Specifically in this scenario the OldValueSource will be // Default and the NewValueSource will be Local. if (e.IsASubPropertyChange && (e.OldValueSource == e.NewValueSource)) { return; } EmissiveMaterial target = ((EmissiveMaterial) d); Brush oldV = (Brush) e.OldValue; Brush newV = (Brush) e.NewValue; System.Windows.Threading.Dispatcher dispatcher = target.Dispatcher; if (dispatcher != null) { DUCE.IResource targetResource = (DUCE.IResource)target; using (CompositionEngineLock.Acquire()) { int channelCount = targetResource.GetChannelCount(); for (int channelIndex = 0; channelIndex < channelCount; channelIndex++) { DUCE.Channel channel = targetResource.GetChannel(channelIndex); Debug.Assert(!channel.IsOutOfBandChannel); Debug.Assert(!targetResource.GetHandle(channel).IsNull); target.ReleaseResource(oldV,channel); target.AddRefResource(newV,channel); } } } target.PropertyChanged(BrushProperty); } #region Public Properties /// <summary> /// Color - Color. Default value is Colors.White. /// </summary> public Color Color { get { return (Color) GetValue(ColorProperty); } set { SetValueInternal(ColorProperty, value); } } /// <summary> /// Brush - Brush. Default value is null. /// </summary> public Brush Brush { get { return (Brush) GetValue(BrushProperty); } set { SetValueInternal(BrushProperty, value); } } #endregion Public Properties //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods /// <summary> /// Implementation of <see cref="System.Windows.Freezable.CreateInstanceCore">Freezable.CreateInstanceCore</see>. /// </summary> /// <returns>The new Freezable.</returns> protected override Freezable CreateInstanceCore() { return new EmissiveMaterial(); } #endregion ProtectedMethods //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck) { // If we're told we can skip the channel check, then we must be on channel Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel)); if (skipOnChannelCheck || _duceResource.IsOnChannel(channel)) { base.UpdateResource(channel, skipOnChannelCheck); // Read values of properties into local variables Brush vBrush = Brush; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hBrush = vBrush != null ? ((DUCE.IResource)vBrush).GetHandle(channel) : DUCE.ResourceHandle.Null; // Pack & send command packet DUCE.MILCMD_EMISSIVEMATERIAL data; unsafe { data.Type = MILCMD.MilCmdEmissiveMaterial; data.Handle = _duceResource.GetHandle(channel); data.color = CompositionResourceManager.ColorToMilColorF(Color); data.hbrush = hBrush; // Send packed command structure channel.SendCommand( (byte*)&data, sizeof(DUCE.MILCMD_EMISSIVEMATERIAL)); } } } internal override DUCE.ResourceHandle AddRefOnChannelCore(DUCE.Channel channel) { if (_duceResource.CreateOrAddRefOnChannel(this, channel, System.Windows.Media.Composition.DUCE.ResourceType.TYPE_EMISSIVEMATERIAL)) { Brush vBrush = Brush; if (vBrush != null) ((DUCE.IResource)vBrush).AddRefOnChannel(channel); AddRefOnChannelAnimations(channel); UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */ ); } return _duceResource.GetHandle(channel); } internal override void ReleaseOnChannelCore(DUCE.Channel channel) { Debug.Assert(_duceResource.IsOnChannel(channel)); if (_duceResource.ReleaseOnChannel(channel)) { Brush vBrush = Brush; if (vBrush != null) ((DUCE.IResource)vBrush).ReleaseOnChannel(channel); ReleaseOnChannelAnimations(channel); } } internal override DUCE.ResourceHandle GetHandleCore(DUCE.Channel channel) { // Note that we are in a lock here already. return _duceResource.GetHandle(channel); } internal override int GetChannelCountCore() { // must already be in composition lock here return _duceResource.GetChannelCount(); } internal override DUCE.Channel GetChannelCore(int index) { // Note that we are in a lock here already. return _duceResource.GetChannel(index); } #endregion Internal Methods //------------------------------------------------------ // // Internal Properties // //------------------------------------------------------ #region Internal Properties // // This property finds the correct initial size for the _effectiveValues store on the // current DependencyObject as a performance optimization // // This includes: // Brush // internal override int EffectiveValuesInitialSize { get { return 1; } } #endregion Internal Properties //------------------------------------------------------ // // Dependency Properties // //------------------------------------------------------ #region Dependency Properties /// <summary> /// The DependencyProperty for the EmissiveMaterial.Color property. /// </summary> public static readonly DependencyProperty ColorProperty; /// <summary> /// The DependencyProperty for the EmissiveMaterial.Brush property. /// </summary> public static readonly DependencyProperty BrushProperty; #endregion Dependency Properties //------------------------------------------------------ // // Internal Fields // //------------------------------------------------------ #region Internal Fields internal System.Windows.Media.Composition.DUCE.MultiChannelResource _duceResource = new System.Windows.Media.Composition.DUCE.MultiChannelResource(); internal static Color s_Color = Colors.White; internal static Brush s_Brush = null; #endregion Internal Fields #region Constructors //------------------------------------------------------ // // Constructors // //------------------------------------------------------ static EmissiveMaterial() { // We check our static default fields which are of type Freezable // to make sure that they are not mutable, otherwise we will throw // if these get touched by more than one thread in the lifetime // of your app. Debug.Assert(s_Brush == null || s_Brush.IsFrozen, "Detected context bound default value EmissiveMaterial.s_Brush (See OS Bug #947272)."); // Initializations Type typeofThis = typeof(EmissiveMaterial); ColorProperty = RegisterProperty("Color", typeof(Color), typeofThis, Colors.White, new PropertyChangedCallback(ColorPropertyChanged), null, /* isIndependentlyAnimated = */ false, /* coerceValueCallback */ null); BrushProperty = RegisterProperty("Brush", typeof(Brush), typeofThis, null, new PropertyChangedCallback(BrushPropertyChanged), null, /* isIndependentlyAnimated = */ false, /* coerceValueCallback */ null); } #endregion Constructors } }
34.09375
157
0.52597
[ "MIT" ]
hongyuzhang1997/wpf
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/EmissiveMaterial.cs
13,092
C#
// Based on https://github.com/gaochundong/PracticeUnity/blob/master/Unity/Unity/Src/Utility/Guard.cs using System; namespace ExtraDomainEvent.Helpers { /// <summary> /// A static helper class that includes various parameter checking routines. /// </summary> public static class Guard { /// <summary> /// Throws <see cref="ArgumentNullException"/> if the given argument is null. /// </summary> /// <exception cref="ArgumentNullException"> if tested value if null.</exception> /// <param name="argumentValue">Argument value to test.</param> /// <param name="argumentName">Name of the argument being tested.</param> public static void ArgumentNotNull(object argumentValue, string argumentName) { if (argumentValue == null) throw new ArgumentNullException(argumentName); } /// <summary> /// Throws an exception if the tested string argument is null or the empty string. /// </summary> /// <exception cref="ArgumentNullException">Thrown if string value is null.</exception> /// <exception cref="ArgumentException">Thrown if the string is empty</exception> /// <param name="argumentValue">Argument value to check.</param> /// <param name="argumentName">Name of argument being checked.</param> public static void ArgumentNotNullOrEmpty(string argumentValue, string argumentName) { if (argumentValue == null) throw new ArgumentNullException(argumentName); if (argumentValue.Length == 0) throw new ArgumentException("The provided string argument must not be empty.", argumentName); } } }
44.487179
109
0.648991
[ "MIT" ]
abbasamiri/ExtraDomainEvent
src/ExtraDomainEvent/Helpers/Guard.cs
1,737
C#
using System; namespace CenterPodouble { class Program { static void Main(string[] args) { double coordinateX1 = double.Parse(Console.ReadLine()); double coordinateY1 = double.Parse(Console.ReadLine()); double coordinateX2 = double.Parse(Console.ReadLine()); double coordinateY2 = double.Parse(Console.ReadLine()); double diagonalX1Y1 = FindDiagonal(coordinateX1, coordinateY1); double diagonalX2Y2 = FindDiagonal(coordinateX2, coordinateY2); if (diagonalX1Y1 <= diagonalX2Y2) { Console.WriteLine($"({coordinateX1}, {coordinateY1})"); } else { Console.WriteLine($"({coordinateX2}, {coordinateY2})"); } } static double FindDiagonal(double coordinateX, double coordinateY) { double diagonal = (double)Math.Sqrt((coordinateX * coordinateX) + (coordinateY * coordinateY)); return diagonal; } } }
28.552632
107
0.560369
[ "MIT" ]
valkin88/Technologies-Fundamentals
Programming Fundamentals/Program Fundamentals - Methods. Debugging and Troubleshooting Code - Exercises/CenterPoint/CenterPoint/Program.cs
1,087
C#
using ExampleMod.Content.Items.Ammo; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace ExampleMod.Content.Items.Weapons { // This is an example showing how to create a weapon that fires custom ammunition // The most important property is "Item.useAmmo". It tells you which item to use as ammo. // You can see the description of other parameters in the ExampleGun class and at https://github.com/tModLoader/tModLoader/wiki/Item-Class-Documentation public class ExampleCustomAmmoGun : ModItem { public override void SetStaticDefaults() { Tooltip.SetDefault("Uses CustomAmmo as ammo and shooting HomingProjectiles"); } public override void SetDefaults() { Item.width = 42; // The width of item hitbox Item.height = 30; // The height of item hitbox Item.autoReuse = true; // Whether or not you can hold click to automatically use it again. Item.damage = 12; // Sets the item's damage. Note that projectiles shot by this weapon will use its and the used ammunition's damage added together. Item.DamageType = DamageClass.Ranged; // What type of damage does this item affect? Item.knockBack = 4f; // Sets the item's knockback. Note that projectiles shot by this weapon will use its and the used ammunition's knockback added together. Item.noMelee = true; // So the item's animation doesn't do damage. Item.rare = ItemRarityID.Yellow; // The color that the item's name will be in-game. Item.shootSpeed = 10f; // The speed of the projectile (measured in pixels per frame.) Item.useAnimation = 35; // The length of the item's use animation in ticks (60 ticks == 1 second.) Item.useTime = 35; // The item's use time in ticks (60 ticks == 1 second.) Item.UseSound = SoundID.Item11; // The sound that this item plays when used. Item.useStyle = ItemUseStyleID.Shoot; // How you use the item (swinging, holding out, shoot, etc.) Item.value = Item.buyPrice(gold: 1); //The value of the weapon in copper coins //Custom ammo and shooting homing projectiles Item.shoot = ModContent.ProjectileType<Projectiles.ExampleHomingProjectile>(); Item.useAmmo = ModContent.ItemType<ExampleCustomAmmo>(); //Restrict the type of ammo the weapon can use, so that the weapon cannot use other ammos } // Please see Content/ExampleRecipes.cs for a detailed explanation of recipe creation. public override void AddRecipes() { CreateRecipe() .AddIngredient<ExampleItem>() .AddTile<Tiles.Furniture.ExampleWorkbench>() .Register(); } } }
53.510638
160
0.740755
[ "MIT" ]
Yozzaxia1311/tModLoader
ExampleMod/Content/Items/Weapons/ExampleCustomAmmoGun.cs
2,517
C#
namespace UblTr.Common { [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.8.3928.0")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2")] [System.Xml.Serialization.XmlRootAttribute("Event", Namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2", IsNullable = false)] public partial class EventType { private IdentificationIDType identificationIDField; private OccurrenceDateType occurrenceDateField; private OccurrenceTimeType occurrenceTimeField; private TypeCodeType typeCodeField; private DescriptionType[] descriptionField; private CompletionIndicatorType completionIndicatorField; private StatusType[] currentStatusField; private ContactType[] contactField; private LocationType1 occurenceLocationField; /// <remarks/> [System.Xml.Serialization.XmlElementAttribute(Namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2")] public IdentificationIDType IdentificationID { get { return this.identificationIDField; } set { this.identificationIDField = value; } } /// <remarks/> [System.Xml.Serialization.XmlElementAttribute(Namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2")] public OccurrenceDateType OccurrenceDate { get { return this.occurrenceDateField; } set { this.occurrenceDateField = value; } } /// <remarks/> [System.Xml.Serialization.XmlElementAttribute(Namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2")] public OccurrenceTimeType OccurrenceTime { get { return this.occurrenceTimeField; } set { this.occurrenceTimeField = value; } } /// <remarks/> [System.Xml.Serialization.XmlElementAttribute(Namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2")] public TypeCodeType TypeCode { get { return this.typeCodeField; } set { this.typeCodeField = value; } } /// <remarks/> [System.Xml.Serialization.XmlElementAttribute("Description", Namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2")] public DescriptionType[] Description { get { return this.descriptionField; } set { this.descriptionField = value; } } /// <remarks/> [System.Xml.Serialization.XmlElementAttribute(Namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2")] public CompletionIndicatorType CompletionIndicator { get { return this.completionIndicatorField; } set { this.completionIndicatorField = value; } } /// <remarks/> [System.Xml.Serialization.XmlElementAttribute("CurrentStatus")] public StatusType[] CurrentStatus { get { return this.currentStatusField; } set { this.currentStatusField = value; } } /// <remarks/> [System.Xml.Serialization.XmlElementAttribute("Contact")] public ContactType[] Contact { get { return this.contactField; } set { this.contactField = value; } } /// <remarks/> public LocationType1 OccurenceLocation { get { return this.occurenceLocationField; } set { this.occurenceLocationField = value; } } } }
29.227273
164
0.551655
[ "MIT" ]
enisgurkann/UblTr
Ubl-Tr/Common/CommonAggregateComponents/EventType.cs
4,501
C#
using System.Text.Json.Serialization; namespace LinqToTwitter { public record TwitterUserTargetID { [JsonPropertyName("target_user_id")] public string? TargetUserID { get; init; } } }
21.3
50
0.685446
[ "Apache-2.0" ]
JoeMayo/LinqToTwitter
src/LinqToTwitter6/LinqToTwitter/User/TwitterUserTargetID.cs
215
C#
// // AnnotationAttribute.cs // // Author: Jeffrey Stedfast <jestedfa@microsoft.com> // // Copyright (c) 2013-2021 .NET Foundation and Contributors // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // using System; namespace MailKit { /// <summary> /// An annotation attribute. /// </summary> /// <remarks> /// <para>An annotation attribute.</para> /// <para>For more information about annotations, see /// <a href="https://tools.ietf.org/html/rfc5257">rfc5257</a>.</para> /// </remarks> public class AnnotationAttribute : IEquatable<AnnotationAttribute> { static readonly char[] Wildcards = { '*', '%' }; /// <summary> /// The annotation value. /// </summary> /// <remarks> /// Used to get or set both the private and shared values of an annotation. /// </remarks> public static readonly AnnotationAttribute Value = new AnnotationAttribute ("value", AnnotationScope.Both); /// <summary> /// The shared annotation value. /// </summary> /// <remarks> /// Used to get or set the shared value of an annotation. /// </remarks> public static readonly AnnotationAttribute SharedValue = new AnnotationAttribute ("value", AnnotationScope.Shared); /// <summary> /// The private annotation value. /// </summary> /// <remarks> /// Used to get or set the private value of an annotation. /// </remarks> public static readonly AnnotationAttribute PrivateValue = new AnnotationAttribute ("value", AnnotationScope.Private); /// <summary> /// The size of an annotation value. /// </summary> /// <remarks> /// Used to get the size of the both the private and shared annotation values. /// </remarks> public static readonly AnnotationAttribute Size = new AnnotationAttribute ("size", AnnotationScope.Both); /// <summary> /// The size of a shared annotation value. /// </summary> /// <remarks> /// Used to get the size of a shared annotation value. /// </remarks> public static readonly AnnotationAttribute SharedSize = new AnnotationAttribute ("size", AnnotationScope.Shared); /// <summary> /// The size of a private annotation value. /// </summary> /// <remarks> /// Used to get the size of a private annotation value. /// </remarks> public static readonly AnnotationAttribute PrivateSize = new AnnotationAttribute ("size", AnnotationScope.Private); AnnotationAttribute (string name, AnnotationScope scope) { switch (scope) { case AnnotationScope.Shared: Specifier = string.Format ("{0}.shared", name); break; case AnnotationScope.Private: Specifier = string.Format ("{0}.priv", name); break; default: Specifier = name; break; } Scope = scope; Name = name; } /// <summary> /// Initializes a new instance of the <see cref="MailKit.AnnotationAttribute"/> class. /// </summary> /// <param name="specifier">The annotation attribute specifier.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="specifier"/> is <c>null</c>. /// </exception> /// <exception cref="System.ArgumentException"> /// <paramref name="specifier"/> contains illegal characters. /// </exception> public AnnotationAttribute (string specifier) { if (specifier == null) throw new ArgumentNullException (nameof (specifier)); if (specifier.Length == 0) throw new ArgumentException ("Annotation attribute specifiers cannot be empty.", nameof (specifier)); // TODO: improve validation if (specifier.IndexOfAny (Wildcards) != -1) throw new ArgumentException ("Annotation attribute specifiers cannot contain '*' or '%'.", nameof (specifier)); Specifier = specifier; if (specifier.EndsWith (".shared", StringComparison.Ordinal)) { Name = specifier.Substring (0, specifier.Length - ".shared".Length); Scope = AnnotationScope.Shared; } else if (specifier.EndsWith (".priv", StringComparison.Ordinal)) { Name = specifier.Substring (0, specifier.Length - ".priv".Length); Scope = AnnotationScope.Private; } else { Scope = AnnotationScope.Both; Name = specifier; } } /// <summary> /// Get the name of the annotation attribute. /// </summary> /// <remarks> /// Gets the name of the annotation attribute. /// </remarks> public string Name { get; private set; } /// <summary> /// Get the scope of the annotation attribute. /// </summary> /// <remarks> /// Gets the scope of the annotation attribute. /// </remarks> public AnnotationScope Scope { get; private set; } /// <summary> /// Get the annotation attribute specifier. /// </summary> /// <remarks> /// Gets the annotation attribute specifier. /// </remarks> public string Specifier { get; private set; } #region IEquatable implementation /// <summary> /// Determines whether the specified <see cref="MailKit.AnnotationAttribute"/> is equal to the current <see cref="MailKit.AnnotationAttribute"/>. /// </summary> /// <remarks> /// Determines whether the specified <see cref="MailKit.AnnotationAttribute"/> is equal to the current <see cref="MailKit.AnnotationAttribute"/>. /// </remarks> /// <param name="other">The <see cref="MailKit.AnnotationAttribute"/> to compare with the current <see cref="MailKit.AnnotationAttribute"/>.</param> /// <returns><c>true</c> if the specified <see cref="MailKit.AnnotationAttribute"/> is equal to the current /// <see cref="MailKit.AnnotationAttribute"/>; otherwise, <c>false</c>.</returns> public bool Equals (AnnotationAttribute other) { return other?.Specifier == Specifier; } #endregion /// <summary> /// Determines whether two annotation attributes are equal. /// </summary> /// <remarks> /// Determines whether two annotation attributes are equal. /// </remarks> /// <returns><c>true</c> if <paramref name="attr1"/> and <paramref name="attr2"/> are equal; otherwise, <c>false</c>.</returns> /// <param name="attr1">The first annotation attribute to compare.</param> /// <param name="attr2">The second annotation attribute to compare.</param> public static bool operator == (AnnotationAttribute attr1, AnnotationAttribute attr2) { return attr1?.Specifier == attr2?.Specifier; } /// <summary> /// Determines whether two annotation attributes are not equal. /// </summary> /// <remarks> /// Determines whether two annotation attributes are not equal. /// </remarks> /// <returns><c>true</c> if <paramref name="attr1"/> and <paramref name="attr2"/> are not equal; otherwise, <c>false</c>.</returns> /// <param name="attr1">The first annotation attribute to compare.</param> /// <param name="attr2">The second annotation attribute to compare.</param> public static bool operator != (AnnotationAttribute attr1, AnnotationAttribute attr2) { return attr1?.Specifier != attr2?.Specifier; } /// <summary> /// Determine whether the specified <see cref="System.Object"/> is equal to the current <see cref="MailKit.AnnotationAttribute"/>. /// </summary> /// <remarks> /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="MailKit.AnnotationAttribute"/>. /// </remarks> /// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="MailKit.AnnotationAttribute"/>.</param> /// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current /// <see cref="MailKit.AnnotationAttribute"/>; otherwise, <c>false</c>.</returns> public override bool Equals (object obj) { return obj is AnnotationAttribute && ((AnnotationAttribute) obj).Specifier == Specifier; } /// <summary> /// Serves as a hash function for a <see cref="MailKit.AnnotationAttribute"/> object. /// </summary> /// <remarks> /// Serves as a hash function for a <see cref="MailKit.AnnotationAttribute"/> object. /// </remarks> /// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a hash table.</returns> public override int GetHashCode () { return Specifier.GetHashCode (); } /// <summary> /// Returns a <see cref="System.String"/> that represents the current <see cref="MailKit.AnnotationAttribute"/>. /// </summary> /// <remarks> /// Returns a <see cref="System.String"/> that represents the current <see cref="MailKit.AnnotationAttribute"/>. /// </remarks> /// <returns>A <see cref="System.String"/> that represents the current <see cref="MailKit.AnnotationAttribute"/>.</returns> public override string ToString () { return Specifier; } } }
38.071429
150
0.689806
[ "MIT" ]
AJenbo/MailKit
MailKit/AnnotationAttribute.cs
9,596
C#
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CreationError : MonoBehaviour { [Header("OBJECTS")] public Button welcomeButton; public Button passwordButton; public Button allrightButton; public Text firstnameText; public Text lastnameText; public Text passwordText; public Text securityQuestionText; public Text securityQuestionHintText; [Header("ERROR PANEL")] public Animator errorAnimator; public string fadeInAnimName; public Text errorTitleText; public Text errorDescriptionText; public string errorTitle; public string errorDescription; void Update () { if (firstnameText.text.Length <= 1 && lastnameText.text.Length <= 2) { welcomeButton.interactable = false; } else if (firstnameText.text.Length >= 2 && lastnameText.text.Length >= 3) { welcomeButton.interactable = true; } if (passwordText.text.Length <= 4 && securityQuestionText.text.Length <= 1 && securityQuestionHintText.text.Length <= 1) { passwordButton.interactable = false; } if (passwordText.text.Length >= 4 && securityQuestionText.text.Length >= 2 && securityQuestionHintText.text.Length >= 2) { passwordButton.interactable = true; } } public void ShowError () { if (firstnameText.text.Length <= 2 && lastnameText.text.Length <= 2) { errorTitle = "Oops!"; errorDescription = "You have to type at least 4 characters."; errorTitleText.text = errorTitle; errorDescriptionText.text = errorDescription; errorAnimator.Play (fadeInAnimName); } else if (passwordText.text.Length <= 4 && securityQuestionText.text.Length <= 4 && securityQuestionHintText.text.Length <= 4) { errorTitle = "Oops!"; errorDescription = "You have to type at least 4 characters."; errorTitleText.text = errorTitle; errorDescriptionText.text = errorDescription; errorAnimator.Play (fadeInAnimName); } } }
27.571429
128
0.732124
[ "MIT" ]
RobsonMaciel/glassos
Scripts/User/CreationError.cs
1,932
C#
using Microsoft.Build.Framework; using Microsoft.Build.Utilities; #nullable enable namespace GltfGenerator.Tasks { public class GenerateGltf : Task { [Required] public ITaskItem[]? Inputs { get; set; } [Required] public ITaskItem? GltfSchema { get; set; } [Output] public ITaskItem? Output { get; set; } public override bool Execute() { CodeGenerator generator = new CodeGenerator(GltfSchema!.ItemSpec); generator.ParseSchemas(); generator.ExpandSchemaReferences(); generator.EvaluateInheritance(); generator.PostProcessSchema(); generator.CSharpCodeGen(Output!.ItemSpec); return true; } } }
23.96875
78
0.604954
[ "MIT" ]
BAEK-Computer-Graphics/DirectX12GameEngine
Gltf/GltfGenerator/Tasks/GenerateGltf.cs
769
C#
using System; using System.Reflection; // ReSharper disable CheckNamespace namespace Microsoft.Extensions.DependencyInjection { // ReSharper restore CheckNamespace /// <summary> /// This class contains extensions methods for <see cref="IServiceCollection"/>. /// </summary> public static class ServiceCollectionExtensions { /// <summary> /// Adds all concrete implementation types that are assignable from the specified service type to the service collection. /// </summary> /// <typeparam name="T">The service type.</typeparam> /// <param name="services">The services.</param> /// <param name="lifetime">The lifetime.</param> public static void RegisterAllTypes<T>(this IServiceCollection services, ServiceLifetime lifetime) { Type type = typeof(T); RegisterAllTypes(services, type, lifetime); } /// <summary> /// Adds all concrete implementation types that are assignable from the specified service type to the service collection. /// </summary> /// <param name="services">The service collection.</param> /// <param name="type">The service type.</param> /// <param name="lifetime">The lifetime.</param> /// <remarks>In case the specified service type in an open generic type, first the concrete generic type is created based on the retrieved implementation type.</remarks> public static void RegisterAllTypes(this IServiceCollection services, Type type, ServiceLifetime lifetime) { Assembly assembly = Assembly.GetAssembly(type); var typesToRegister = type.GetAllConcreteAssignableTypes(assembly); foreach (var implementationType in typesToRegister) { Type typeToRegister = type; if (type.IsGenericTypeDefinition) { typeToRegister = GetTypeForGenericTypeDefinition(type, implementationType); } services.Add(new ServiceDescriptor(typeToRegister, implementationType, lifetime)); } } /// <summary> /// Gets the concrete generic type for the specified open generic type. /// </summary> /// <param name="openGenericType">The open generic type.</param> /// <param name="concreteType">The concrete type from which the generic parameter is retrieved.</param> /// <returns>The concrete generic type.</returns> /// <remarks> /// GenericType&lt;&gt; /// ConcreteType: GenericType&lt;T&gt; /// returns GenericType&lt;T&gt; /// </remarks> private static Type GetTypeForGenericTypeDefinition(Type openGenericType, Type concreteType) { foreach (Type type in concreteType.GetAllAssignableTypes()) { if (type.IsGenericType && type.GetGenericTypeDefinition() == openGenericType) { return type; } } return null; } } }
41.891892
177
0.62
[ "Apache-2.0" ]
commercetools/commercetools-dotnet-core-sdk
commercetools.Sdk/commercetools.Sdk.Registration/ServiceCollectionExtensions.cs
3,102
C#
#region Copyright & License // Copyright © 2012 - 2021 François Chabot // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #endregion namespace Be.Stateless.BizTalk.Activity.Tracking { /// <summary> /// Simple structure that holds the BAM activity identifiers of the various steps that were involved to build a batch /// envelope message, ranging from the aggregating steps to its release. /// </summary> internal class BatchTrackingContext { /// <summary> /// The identifiers of the BAM messaging step activities that aggregated the various parts of the batch envelope. /// </summary> internal string[] MessagingStepActivityIdList { get; set; } /// <summary> /// The identifier of the BAM process activity that triggered the release of the batch. /// </summary> internal string ProcessActivityId { get; set; } } }
35.473684
118
0.736647
[ "Apache-2.0" ]
emmanuelbenitez/Be.Stateless.BizTalk.Factory.Batching.Application
src/Be.Stateless.BizTalk.Batching/Activity/Tracking/BatchTrackingContext.cs
1,352
C#
using FluentAssertions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions; using SharedTestResources.Domain.TestAggregateRoot; using SharedTestResources.Infrastructure; using System; using Xunit; namespace Quicker.Infrastructure.EntityFramework.UnitTests.Extensions { public class OwnedNavigationBuilderExtensionTests : IDisposable { private readonly TestDbContext _Context; public OwnedNavigationBuilderExtensionTests() { _Context = TestDbContext.CreateContext(Guid.NewGuid().ToString()); } public void Dispose() { _Context.Database.EnsureDeleted(); _Context.Dispose(); } [Fact] public void ConfigureEntity_Success_Should_AddKeyConventionToBuilder() { var conventionSet = ConventionSet.CreateConventionSet(_Context); var modelBuilder = new ModelBuilder(conventionSet); var entityTypeBuilder = modelBuilder.Entity<TestAggregateRoot>(); var ownedBuilder = entityTypeBuilder.OwnsMany<TestEntity>(nameof(TestAggregateRoot.TestEntities)); ownedBuilder.ConfigureEntity<TestAggregateRoot, TestEntity, Guid>(); var idProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.Id)); idProperty.IsKey().Should().BeTrue(); } [Fact] public void ConfigureCreatedDate_OneGeneric_Success_Should_AddCreatedDateConventionToBuilder() { var conventionSet = ConventionSet.CreateConventionSet(_Context); var modelBuilder = new ModelBuilder(conventionSet); var entityTypeBuilder = modelBuilder.Entity<TestAggregateRoot>(); var ownedBuilder = entityTypeBuilder.OwnsMany<TestEntity>(nameof(TestAggregateRoot.TestEntities)); ownedBuilder.ConfigureCreatedDate<TestAggregateRoot, TestEntity, Guid?>(); var createdDateProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.CreatedDate)); createdDateProperty.IsNullable.Should().BeFalse(); } [Fact] public void ConfigureCreatedDate_TwoGeneric_Success_Should_AddCreatedDateAndCreatedByConventionToBuilder() { var conventionSet = ConventionSet.CreateConventionSet(_Context); var modelBuilder = new ModelBuilder(conventionSet); var entityTypeBuilder = modelBuilder.Entity<TestAggregateRoot>(); var ownedBuilder = entityTypeBuilder.OwnsMany<TestEntity>(nameof(TestAggregateRoot.TestEntities)); ownedBuilder.ConfigureCreatedDate<TestAggregateRoot, TestEntity, Guid?>(); var createdDateProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.CreatedDate)); createdDateProperty.IsNullable.Should().BeFalse(); var createdByProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.CreatedBy)); createdByProperty.IsNullable.Should().BeFalse(); } [Fact] public void ConfigureUpdatedDate_OneGeneric_Success_Should_AddUpdatedDateConventionToBuilder() { var conventionSet = ConventionSet.CreateConventionSet(_Context); var modelBuilder = new ModelBuilder(conventionSet); var entityTypeBuilder = modelBuilder.Entity<TestAggregateRoot>(); var ownedBuilder = entityTypeBuilder.OwnsMany<TestEntity>(nameof(TestAggregateRoot.TestEntities)); ownedBuilder.ConfigureUpdatedDate<TestAggregateRoot, TestEntity, Guid?>(); var updatedDateProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.UpdatedDate)); updatedDateProperty.IsNullable.Should().BeTrue(); } [Fact] public void ConfigureUpdatedDate_TwoGeneric_Success_Should_AddUpdatedDateAndUpdatedByConventionToBuilder() { var conventionSet = ConventionSet.CreateConventionSet(_Context); var modelBuilder = new ModelBuilder(conventionSet); var entityTypeBuilder = modelBuilder.Entity<TestAggregateRoot>(); var ownedBuilder = entityTypeBuilder.OwnsMany<TestEntity>(nameof(TestAggregateRoot.TestEntities)); ownedBuilder.ConfigureUpdatedDate<TestAggregateRoot, TestEntity, Guid?>(); var updatedDateProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.UpdatedDate)); updatedDateProperty.IsNullable.Should().BeTrue(); var updatedByProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.UpdatedBy)); updatedByProperty.IsNullable.Should().BeTrue(); } [Fact] public void ConfigureDeactivatedDate_OneGeneric_Success_Should_AddDeactivatedDateConventionToBuilder() { var conventionSet = ConventionSet.CreateConventionSet(_Context); var modelBuilder = new ModelBuilder(conventionSet); var entityTypeBuilder = modelBuilder.Entity<TestAggregateRoot>(); var ownedBuilder = entityTypeBuilder.OwnsMany<TestEntity>(nameof(TestAggregateRoot.TestEntities)); ownedBuilder.ConfigureDeactivatedDate<TestAggregateRoot, TestEntity, Guid?>(); var inactiveProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.Inactive)); inactiveProperty.IsNullable.Should().BeFalse(); var deactivatedDateProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.DeactivatedDate)); deactivatedDateProperty.IsNullable.Should().BeTrue(); } [Fact] public void ConfigureDeactivatedDate_TwoGeneric_Success_Should_AddDeactivatedDateAndDeactivatedByConventionToBuilder() { var conventionSet = ConventionSet.CreateConventionSet(_Context); var modelBuilder = new ModelBuilder(conventionSet); var entityTypeBuilder = modelBuilder.Entity<TestAggregateRoot>(); var ownedBuilder = entityTypeBuilder.OwnsMany<TestEntity>(nameof(TestAggregateRoot.TestEntities)); ownedBuilder.ConfigureDeactivatedDate<TestAggregateRoot, TestEntity, Guid?>(); var inactiveProperty = entityTypeBuilder.Metadata .FindDeclaredProperty(nameof(TestAggregateRoot.Inactive)); inactiveProperty.IsNullable.Should().BeFalse(); var deactivatedDateProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.DeactivatedDate)); deactivatedDateProperty.IsNullable.Should().BeTrue(); var deactivatedByProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.DeactivatedBy)); deactivatedByProperty.IsNullable.Should().BeTrue(); } [Fact] public void ConfigureReactivatedDate_OneGeneric_Success_Should_AddReactivatedDateConventionToBuilder() { var conventionSet = ConventionSet.CreateConventionSet(_Context); var modelBuilder = new ModelBuilder(conventionSet); var entityTypeBuilder = modelBuilder.Entity<TestAggregateRoot>(); var ownedBuilder = entityTypeBuilder.OwnsMany<TestEntity>(nameof(TestAggregateRoot.TestEntities)); ownedBuilder.ConfigureReactivatedDate<TestAggregateRoot, TestEntity, Guid?>(); var inactiveProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.Inactive)); inactiveProperty.IsNullable.Should().BeFalse(); var reactivatedDateProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.DeactivatedDate)); reactivatedDateProperty.IsNullable.Should().BeTrue(); var deactivatedDateProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.ReactivatedDate)); deactivatedDateProperty.IsNullable.Should().BeTrue(); } [Fact] public void ConfigureReactivatedDate_TwoGeneric_Success_Should_AddReactivatedDateAndReactivatedByConventionToBuilder() { var conventionSet = ConventionSet.CreateConventionSet(_Context); var modelBuilder = new ModelBuilder(conventionSet); var entityTypeBuilder = modelBuilder.Entity<TestAggregateRoot>(); var ownedBuilder = entityTypeBuilder.OwnsMany<TestEntity>(nameof(TestAggregateRoot.TestEntities)); ownedBuilder.ConfigureReactivatedDate<TestAggregateRoot, TestEntity, Guid?>(); var inactiveProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.Inactive)); inactiveProperty.IsNullable.Should().BeFalse(); var deactivatedDateProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.DeactivatedDate)); deactivatedDateProperty.IsNullable.Should().BeTrue(); var deactivatedByProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.DeactivatedBy)); deactivatedByProperty.IsNullable.Should().BeTrue(); var reactivatedDateProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.ReactivatedDate)); reactivatedDateProperty.IsNullable.Should().BeTrue(); var reactivatedByProperty = ownedBuilder.OwnedEntityType .FindDeclaredProperty(nameof(TestAggregateRoot.ReactivatedBy)); reactivatedByProperty.IsNullable.Should().BeTrue(); } } }
42.699153
126
0.705468
[ "MIT" ]
HernanFAR/Quicker
Quicker.Infrastructure.EntityFramework.UnitTests/Extensions/OwnedNavigationBuilderExtensionTests.cs
10,079
C#
using System; using System.Xml.Serialization; using System.Collections.Generic; using Top.Api; namespace DingTalk.Api.Response { /// <summary> /// OapiRoleAddRoleResponse. /// </summary> public class OapiRoleAddRoleResponse : DingTalkResponse { /// <summary> /// errcode /// </summary> [XmlElement("errcode")] public long Errcode { get; set; } /// <summary> /// errmsg /// </summary> [XmlElement("errmsg")] public string Errmsg { get; set; } /// <summary> /// roleId /// </summary> [XmlElement("roleId")] public long RoleId { get; set; } } }
20.909091
59
0.53913
[ "MIT" ]
lee890720/YiShaAdmin
YiSha.Util/YsSha.Dingtalk/DingTalk/Response/OapiRoleAddRoleResponse.cs
690
C#
using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace SmartMed.CodeChalenge { public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); } }
26.037037
70
0.648649
[ "Unlicense" ]
sergio23fsantos/SmartMedCodeChallenge
SmartMed.CodeChalenge/SmartMed.CodeChalenge/Program.cs
703
C#
// Generated by minBND 5.1.94.90 - © github.com/Alan-FGR using System; using System.Runtime.InteropServices; public static unsafe partial class minBND_pinvokes { [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor(physx.PxMat44* pvk_this); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor_PxIDENTITY_(physx.PxMat44* pvk_this, physx.PxIDENTITY pvk_r); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor_PxZERO_(physx.PxMat44* pvk_this, physx.PxZERO pvk_r); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor_PxVec4_PxVec4_PxVec4_PxVec4_(physx.PxMat44* pvk_this, physx.PxVec4* pvk_col0, physx.PxVec4* pvk_col1, physx.PxVec4* pvk_col2, physx.PxVec4* pvk_col3); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor_float_(physx.PxMat44* pvk_this, float pvk_r); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor_PxVec3_PxVec3_PxVec3_PxVec3_(physx.PxMat44* pvk_this, physx.PxVec3* pvk_col0, physx.PxVec3* pvk_col1, physx.PxVec3* pvk_col2, physx.PxVec3* pvk_col3); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor_PxQuat_(physx.PxMat44* pvk_this, physx.PxQuat* pvk_q); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor_PxVec4_(physx.PxMat44* pvk_this, physx.PxVec4* pvk_diagonal); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor_PxMat33_PxVec3_(physx.PxMat44* pvk_this, physx.PxMat33* pvk_axes, physx.PxVec3* pvk_position); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor_PxTransform_(physx.PxMat44* pvk_this, physx.PxTransform* pvk_t); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern bool bool_const_PxMat44_operator_Ptr_EqualEqual_PxMat44_(physx.PxMat44* pvk_lhs, physx.PxMat44* pvk_m); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_PxMat44Ptr_Ctor_PxMat44_(physx.PxMat44* pvk_this, physx.PxMat44* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern physx.PxMat44* PxMat44_PxMat44_operator_Ptr_Equal_PxMat44_(physx.PxMat44* pvk_lhs, physx.PxMat44* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxMat44_const_PxMat44_getTransposePtr(physx.PxMat44* pvk_RetRef, physx.PxMat44* pvk_this); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxMat44_const_PxMat44_operator_Ptr_Minus(physx.PxMat44* pvk_RetRef, physx.PxMat44* pvk_lhs); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxMat44_const_PxMat44_operator_Ptr_Plus_PxMat44_(physx.PxMat44* pvk_RetRef, physx.PxMat44* pvk_lhs, physx.PxMat44* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxMat44_const_PxMat44_operator_Ptr_Minus_PxMat44_(physx.PxMat44* pvk_RetRef, physx.PxMat44* pvk_lhs, physx.PxMat44* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxMat44_const_PxMat44_operator_Ptr_Star_float_(physx.PxMat44* pvk_RetRef, physx.PxMat44* pvk_lhs, float pvk_scalar); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxMat44_const_PxMat44_operator_Ptr_Star_PxMat44_(physx.PxMat44* pvk_RetRef, physx.PxMat44* pvk_lhs, physx.PxMat44* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern physx.PxMat44* PxMat44_PxMat44_operator_Ptr_PlusEqual_PxMat44_(physx.PxMat44* pvk_lhs, physx.PxMat44* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern physx.PxMat44* PxMat44_PxMat44_operator_Ptr_MinusEqual_PxMat44_(physx.PxMat44* pvk_lhs, physx.PxMat44* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern physx.PxMat44* PxMat44_PxMat44_operator_Ptr_StarEqual_float_(physx.PxMat44* pvk_lhs, float pvk_scalar); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern physx.PxMat44* PxMat44_PxMat44_operator_Ptr_StarEqual_PxMat44_(physx.PxMat44* pvk_lhs, physx.PxMat44* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern float float_const_PxMat44_operator_Ptr_Call_uint_uint_(physx.PxMat44* pvk_lhs, uint pvk_row, uint pvk_col); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern float* float_PxMat44_operator_Ptr_Call_uint_uint_(physx.PxMat44* pvk_lhs, uint pvk_row, uint pvk_col); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxVec4_const_PxMat44_transformPtr_PxVec4_(physx.PxVec4* pvk_RetRef, physx.PxMat44* pvk_this, physx.PxVec4* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxVec3_const_PxMat44_transformPtr_PxVec3_(physx.PxVec3* pvk_RetRef, physx.PxMat44* pvk_this, physx.PxVec3* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxVec4_const_PxMat44_rotatePtr_PxVec4_(physx.PxVec4* pvk_RetRef, physx.PxMat44* pvk_this, physx.PxVec4* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxVec3_const_PxMat44_rotatePtr_PxVec3_(physx.PxVec3* pvk_RetRef, physx.PxMat44* pvk_this, physx.PxVec3* pvk_other); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxVec3_const_PxMat44_getBasisPtr_int_(physx.PxVec3* pvk_RetRef, physx.PxMat44* pvk_this, int pvk_num); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxVec3_const_PxMat44_getPositionPtr(physx.PxVec3* pvk_RetRef, physx.PxMat44* pvk_this); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_setPositionPtr_PxVec3_(physx.PxMat44* pvk_this, physx.PxVec3* pvk_position); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern float* float_const_PxMat44_frontPtr(physx.PxMat44* pvk_this); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern physx.PxVec4* PxVec4_PxMat44_operator_Ptr_Subscript_uint_(physx.PxMat44* pvk_lhs, uint pvk_num); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern physx.PxVec4* PxVec4_const_PxMat44_operator_Ptr_Subscript_uint_(physx.PxMat44* pvk_lhs, uint pvk_num); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void void_PxMat44_scalePtr_PxVec4_(physx.PxMat44* pvk_this, physx.PxVec4* pvk_p); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern void PxMat44_const_PxMat44_inverseRTPtr(physx.PxMat44* pvk_RetRef, physx.PxMat44* pvk_this); [DllImport(SharpPhysX.Lib, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] internal static extern bool bool_const_PxMat44_isFinitePtr(physx.PxMat44* pvk_this); }
73.016529
207
0.837465
[ "MIT" ]
Alan-FGR/SharpPhysX
SharpPhysX/Generated/PxMat44.Pinvokes.cs
8,836
C#
namespace AccountingProject.Web.Controllers { using System; using System.Threading.Tasks; using AccountingProject.Common; using AccountingProject.Services.Data; using AccountingProject.Web.ViewModels.FixedAssets; using AccountingProject.Web.ViewModels.ViewComponents; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; [Authorize(Roles = GlobalConstants.AllAccountantsRoleNames)] public class FixedAssetsController : Controller { private readonly IMainAccountsService mainAccountsService; private readonly IFixedAssetsService fixedAssetsService; public FixedAssetsController( IMainAccountsService mainAccountsService, IFixedAssetsService fixedAssetsService) { this.mainAccountsService = mainAccountsService; this.fixedAssetsService = fixedAssetsService; } // FixedAssets/Create public IActionResult Create() { var viewModel = new CreateFixedAssetInputModel { AcquisitionDate = DateTime.UtcNow, }; return this.View(viewModel); } [HttpPost] public async Task<IActionResult> Create(CreateFixedAssetInputModel input) { if (!await this.fixedAssetsService.IsNameAvailableAsync(input.Name)) { this.ModelState.AddModelError(nameof(input.Name), GlobalConstants.ErrorMessageForExistingName); } if (!this.ModelState.IsValid) { return this.View(input); } await this.fixedAssetsService.CreateAsync(input); this.TempData["Message"] = $"Fixed asset \"{input.Name}\" has been added successfully."; return this.RedirectToAction(nameof(this.All)); } // FixedAssets/All public async Task<IActionResult> All() { var viewModel = new FixedAssetsListViewModel { FixedAssets = await this.fixedAssetsService .GetAllAsync<FixedAssetInListViewModel>(), }; return this.View(viewModel); } // FixedAssets/ById public async Task<IActionResult> ByIdAsync(int id) { var fixedAsset = await this.fixedAssetsService .GetByIdAsync<FixedAssetViewModel>(id); return this.View(fixedAsset); } // FixedAssets/Delete [HttpPost] public async Task<IActionResult> DeleteAsync(int id) { await this.fixedAssetsService.DeleteAsync(id); this.TempData["Message"] = $"Fixed asset has been deleted successfully."; return this.RedirectToAction(nameof(this.All)); } // FixedAssets/Edit public async Task<IActionResult> EditAsync(int id) { var viewModel = await this.fixedAssetsService .GetByIdAsync<EditFixedAssetInputModel>(id); return this.View(viewModel); } [HttpPost] public async Task<IActionResult> EditAsync(int id, EditFixedAssetInputModel input) { if (!this.ModelState.IsValid) { return this.View(input); } await this.fixedAssetsService.UpdateAsync(id, input); this.TempData["Message"] = $"Fixed asset \"{input.Name}\" has been edited successfully."; return this.RedirectToAction(nameof(this.All)); } // FixedAssets/ChooseAccount public IActionResult ChooseAccount() { var viewModel = new ListOfMainAccountsViewModel { }; viewModel.TypeOfAccount = "fixedAsset"; return this.View("~/Views/Shared/ChooseAccount.cshtml", viewModel); } [HttpPost] public IActionResult ChooseAccount(ListOfMainAccountsViewModel input) { if (!this.ModelState.IsValid) { return this.View("~/Views/Shared/ChooseAccount.cshtml", input); } return this.RedirectToAction(nameof(this.AllByAccount), new { mainAccountId = input.MainAccountId }); } // FixedAssets/AllByAccount public IActionResult AllByAccount(int mainAccountId) { var viewModel = new FixedAssetsListViewModel { FixedAssets = this.fixedAssetsService .GetAllByAccount<FixedAssetInListViewModel>(mainAccountId), }; return this.View(nameof(this.All), viewModel); } } }
34.095588
113
0.608367
[ "MIT" ]
StanislavaMiteva/Accounting
Web/AccountingProject.Web/Controllers/FixedAssetsController.cs
4,639
C#
using Newtonsoft.Json; using TauriApiWrapper.Converters; using TauriApiWrapper.Enums; namespace TauriApiWrapper.Objects.Responses.Arena { public sealed class ArenaTeamReportOpposingTeams : BaseApiResponse { [JsonProperty("realm"), JsonConverter(typeof(RealmNameConverter))] public Realm Realm { get; set; } [JsonProperty("team")] public ArenaTeam Team { get; set; } [JsonProperty("teamstats")] public ArenaTeamGameChartTeamstats TeamStats { get; set; } [JsonProperty("Season_start_time")] public int SeasonStartTime { get; set; } [JsonProperty("matchData")] public ArenaTeamReportOpposingTeamsMatchData MatchData { get; set; } } }
30.333333
76
0.690934
[ "Apache-2.0" ]
brues-code/TauriApiWrapper
TauriApiWrapper/Objects/Responses/Arena/ArenaTeamReportOpposingTeams.cs
730
C#
namespace MaterialCMS.Batching.Entities { public interface IHaveJobExecutionStatus { JobExecutionStatus Status { get; set; } } }
21.285714
47
0.697987
[ "MIT" ]
DucThanhNguyen/MaterialCMS
MaterialCMS/Batching/Entities/IHaveJobExecutionStatus.cs
151
C#
namespace P05_ShoppingSpree { using System; using System.Collections.Generic; public class Program { public static void Main() { var people = new List<Person>(); var products = new List<Product>(); var firstLine = Console.ReadLine().Split(';', StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < firstLine.Length; i++) { var currentPerson = firstLine[i].Split('='); string name = currentPerson[0]; int money = int.Parse(currentPerson[1]); var bag = new List<string>(); var person = new Person(name, money, bag); people.Add(person); } var secondLine = Console.ReadLine().Split(';', StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < secondLine.Length; i++) { var currentProduct = secondLine[i].Split('='); string name = currentProduct[0]; int price = int.Parse(currentProduct[1]); var product = new Product(name, price); products.Add(product); } while (true) { var command = Console.ReadLine().Split(); if (command[0] == "END") { foreach (var person in people) { if (person.Bag.Count == 0) { Console.WriteLine($"{person.Name} - Nothing bought"); } else { Console.WriteLine($"{person.Name} - {string.Join(", ", person.Bag)}"); } } break; } string personName = command[0]; string productName = command[1]; BuyProduct(personName, productName, people, products); } } public static void BuyProduct(string personName, string productName, List<Person> people, List<Product> products) { var person = people.Find(x => x.Name == personName); var product = products.Find(x => x.Name == productName); if (person.Money >= product.Price) { person.Money -= product.Price; person.Bag.Add(productName); Console.WriteLine($"{personName} bought {productName}"); } else { Console.WriteLine($"{personName} can't afford {productName}"); } } } public class Person { public string Name { get; set; } public int Money { get; set; } public List<string> Bag { get; set; } public Person(string name, int money, List<string> bag) { Name = name; Money = money; Bag = bag; } } public class Product { public string Name { get; set; } public int Price { get; set; } public Product(string name, int price) { Name = name; Price = price; } } }
28.310345
98
0.455847
[ "MIT" ]
MertYumer/Tech-Module-2018
07. Objects and Classes - More Exercises/P05-ShoppingSpree/Program.cs
3,286
C#
using Photon.Pun; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace lerisa { public class bukaInfografis : MonoBehaviour { [SerializeField] private GameObject bukabingkai; [SerializeField] private GameObject bukaObjek; Text statusInGame; public string TextStatusAktifitas = "TextStatusBawah"; void Start() { bukabingkai.SetActive(false); statusInGame = GameObject.Find(TextStatusAktifitas).GetComponent<Text>(); } private void OnTriggerEnter(Collider other) { if (other.gameObject.GetPhotonView().IsMine) { bukabingkai.SetActive(true); Debug.Log("in Infografis"); statusInGame.text = PhotonNetwork.NickName + " on Infographic Session"; // StartCoroutine(streamVideo()); } } private void OnTriggerExit(Collider other) { if (other.gameObject.GetPhotonView().IsMine) { // bukabingkai.SetActive(false); // panelBuka.SetActive(false); statusInGame.text = PhotonNetwork.NickName + " Exit Infographic Session"; } } // Update is called once per frame void Update() { } } }
25.327273
89
0.579325
[ "MIT" ]
heshost/GameLerisaUnity
Assets/Script/bukaInfografis.cs
1,395
C#
// Project: Daggerfall Tools For Unity // Copyright: Copyright (C) 2009-2020 Daggerfall Workshop // Web Site: http://www.dfworkshop.net // License: MIT License (http://www.opensource.org/licenses/mit-license.php) // Source Code: https://github.com/Interkarma/daggerfall-unity // Original Author: Gavin Clayton (interkarma@dfworkshop.net) // Contributors: Hazelnut // // Notes: // using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Unity.Collections; using DaggerfallConnect; using DaggerfallConnect.Arena2; using DaggerfallConnect.Utility; using DaggerfallWorkshop.Game.Entity; using DaggerfallWorkshop.Game.Questing; using DaggerfallWorkshop.Game.Items; namespace DaggerfallWorkshop { /// <summary> /// Index of a single Daggerfall texture. /// </summary> [Serializable] public struct DaggerfallTextureIndex { public int archive; public int record; public int frame; } /// <summary> /// Settings in for GetTexture methods. /// </summary> public struct GetTextureSettings { public int archive; // Texture archive index (e.g. 210 for TEXTURE.210) public int record; // Texture record index public int frame; // Texture frame index for animated textures public int alphaIndex; // Native index to receive transparent alpha (-1 to disable) public int emissionIndex; // Native index to become emissive on emission maps when enabled public int borderSize; // Number of pixels border to add around image public bool copyToOppositeBorder; // Copy texture edges to opposite border. Requires border, mutually exclusive with dilate public bool dilate; // Blend texture into surrounding empty pixels. Requires border public bool stayReadable; // Texture will remain in memory and can be read after creation public bool sharpen; // Sharpen image public bool createNormalMap; // Normal map will be created based on strength public bool createEmissionMap; // Emission map will also be created based on emissionIndex public float normalStrength; // Strength of generated normals public int atlasPadding; // Number of pixels padding around each sub-texture public int atlasMaxSize; // Max size of atlas public int atlasShrinkUVs; // Number of extra pixels to shrink UV rect public bool autoEmission; // Automatically create emission map for known textures public bool autoEmissionForWindows; // Automatically create emission map for window textures public TextureFile textureFile; // Provide an already open texture file to save time } /// <summary> /// Results out for GetTexture methods. /// </summary> public struct GetTextureResults { public Texture2D albedoMap; // Albedo texture out for all colour textures public Texture2D normalMap; // Normal texture out when normals are enabled public Texture2D emissionMap; // Emission texture out for emissive textures public List<int> atlasFrameCounts; // List of atlas frame counts for each texture public Rect singleRect; // Receives UV rect for texture inside border public List<Rect> atlasRects; // List of rects, one for each record sub-texture and frame public List<RecordIndex> atlasIndices; // List of record indices into rect array, accounting for animation frames public List<Vector2> atlasSizes; // List of sizes for each texture public List<Vector2> atlasScales; // List of scales for each texture public List<Vector2> atlasOffsets; // List of offsets for each texture public bool isWindow; // Flag is raised if this is a window texture, for single textures only public bool isEmissive; // Flag is raised is this texture is emissive public bool isAtlasAnimated; // Atlas texture has one or more animations public TextureFile textureFile; // Texture file used for last read operation. } /// <summary> /// Some information about a climate texture, returned by climate parser. /// </summary> [Serializable] public struct ClimateTextureInfo { public DFLocation.ClimateTextureGroup textureGroup; public DFLocation.ClimateTextureSet textureSet; public bool supportsWinter; public bool supportsRain; } /// <summary> /// Defines a single cached material and related properties. /// Marked as serializable but not currently serialized. /// </summary> [Serializable] public struct CachedMaterial { // Keys public int key; // Key of this material public int keyGroup; // Group of this material public float timeStamp; // Time in seconds from startup during last access // Textures public Texture2D albedoMap; // Albedo texture of material public Texture2D normalMap; // Normal texture of material public Texture2D emissionMap; // Emission texture of material // Material public Material material; // Shared material public Rect singleRect; // Rect for single material public Rect[] atlasRects; // Array of rects for atlased materials public RecordIndex[] atlasIndices; // Array of record indices into atlas rect array public FilterMode filterMode; // Filter mode of this material public int singleFrameCount; // Number of frames in single animated material public int[] atlasFrameCounts; // Array of frame counts for animated materials public int framesPerSecond; // Number of frames per second in single animated material // Windows public bool isWindow; // True if this is a window material public Color windowColor; // Colour of this window public float windowIntensity; // Intensity of this window // Size and scale public Vector2[] recordSizes; // Size of texture records public Vector2[] recordScales; // Scale of texture records public Vector2[] recordOffsets; // Offset of texture records } /// <summary> /// Data package returned by ImageHelper.GetImageData() methods. /// Supplied Texture2D will always be readable. /// </summary> public struct ImageData { public ImageTypes type; // Original type public string filename; // Original filename public int record; // Original record public int frame; // Original frame public bool hasAlpha; // Original loaded with alpha cutout public int alphaIndex; // Original alpha index (usually 0) public int width; // Original image width public int height; // Original image height public DFBitmap dfBitmap; // Original indexed bitmap public Texture2D texture; // Generated texture public Texture2D maskTexture; // Generated mask texture public Texture2D[] animatedTextures; // Array of animation frames if this is an animated texture public DFPosition offset; // Custom Daggerfall offset position for paper doll inventory, etc. public DFSize scale; // Custom Daggerfall size for scaling sprites public DFSize size; // Size of image } /// <summary> /// Defines animation setup for mobile enemies. /// </summary> [Serializable] public struct MobileAnimation { public int Record; // Index of this animation public int NumFrames; // Number of frames in this animation public int FramePerSecond; // Speed at which this animation plays public bool FlipLeftRight; // True if animation flipped left-to-right } /// <summary> /// Defines basic properties of mobile enemies. /// </summary> [Serializable] public struct MobileEnemy { public int ID; // ID of this mobile public string Name; // In-game name of this mobile public MobileBehaviour Behaviour; // Behaviour of mobile public MobileAffinity Affinity; // Affinity of mobile public MobileGender Gender; // Gender of mobile public MobileReactions Reactions; // Mobile reaction setting public MobileCombatFlags CombatFlags; // Mobile combat flags public int MaleTexture; // Texture archive index for male sprite public int FemaleTexture; // Texture archive index for female sprite public int CorpseTexture; // Corpse texture archive:record bits public bool HasIdle; // Has standard Idle animation group public bool HasRangedAttack1; // Has RangedAttack1 animation group public bool HasRangedAttack2; // Has RangedAttack2 animation group public bool CanOpenDoors; // Enemy can open doors to pursue player public bool PrefersRanged; // Enemy prefers ranged attacks and spells over melee public int BloodIndex; // Index in TEXTURE.380 for blood splash public int MoveSound; // Index of enemy "moving around" sound public int BarkSound; // Index of enemy "bark" or "shout" sound public int AttackSound; // Index of enemy "attack" sound public int SightModifier; // +/- range of vision for acute/impaired sight public int HearingModifier; // +/- range of hearing for acute/impaired hearing public WeaponMaterialTypes MinMetalToHit; // Minimum metal type required to hit enemy public int MinDamage; // Minimum damage per first hit of attack public int MaxDamage; // Maximum damage per first hit of attack public int MinDamage2; // Minimum damage per second hit of attack public int MaxDamage2; // Maximum damage per second hit of attack public int MinDamage3; // Minimum damage per third hit of attack public int MaxDamage3; // Maximum damage per third hit of attack public int MinHealth; // Minimum health public int MaxHealth; // Maximum health public int Level; // Level public int ArmorValue; // Armor value public bool ParrySounds; // Plays parry sounds when attacks against this enemy miss public int MapChance; // Chance of having a map public string LootTableKey; // Key to use when generating loot public int Weight; // Weight of this enemy. Affects chance of being knocked back by a hit. public bool CastsMagic; // Whether this enemy casts magic. Only used for enemy classes. public bool SeesThroughInvisibility; // Whether this enemy sees through the shade, chameleon and invisibility effects. public Color? GlowColor; // Emitted light color public bool NoShadow; // Casts no shadows public int SoulPts; // Number of enchantment points in a trapped soul of this enemy public int[] PrimaryAttackAnimFrames; // Animation sequence to play when doing primary attack public int ChanceForAttack2; // Chance to use PrimaryAttackAnimFrames2 for an attack public int[] PrimaryAttackAnimFrames2; // Alternate animation sequence to play when doing primary attack public int ChanceForAttack3; // Chance to use PrimaryAttackAnimFrames3 for an attack public int[] PrimaryAttackAnimFrames3; // Alternate animation sequence to play when doing primary attack public int ChanceForAttack4; // Chance to use PrimaryAttackAnimFrames3 for an attack public int[] PrimaryAttackAnimFrames4; // Alternate animation sequence to play when doing primary attack public int ChanceForAttack5; // Chance to use PrimaryAttackAnimFrames3 for an attack public int[] PrimaryAttackAnimFrames5; // Alternate animation sequence to play when doing primary attack public int[] RangedAttackAnimFrames; // Animation sequence to play when doing bow & arrow attack public bool HasSpellAnimation; // Whether or not this character has specific animations for casting spells public int[] SpellAnimFrames; // Animation sequence to play when doing a spell cast public MobileTeams Team; // Team that this enemy uses if enemy in-fighting is on } /// <summary> /// Defines a list of random encounters based on dungeon type (Crypt, Orc Stronghold, etc.). /// </summary> [Serializable] public struct RandomEncounterTable { public DFRegion.DungeonTypes DungeonType; public MobileTypes[] Enemies; } /// <summary> /// A record index for cached materials. /// Used to align indices in atlased textures. /// </summary> [Serializable] public struct RecordIndex { public int startIndex; // Index of first frame in atlas rect array public int frameCount; // Number of frames in this record public int width; // Width in pixels of this record, excluding border and padding public int height; // Height in pixels of this record, excluding border and padding } /// <summary> /// Defines model data. /// </summary> [Serializable] public struct ModelData { public DFMesh DFMesh; // Native ngon geometry as read from ARCH3D.BSA public Vector3[] Vertices; // Vector3 array containing position data public Vector3[] Normals; // Vector3 array containing normal data public Vector2[] UVs; // Vector2 array containing UV data public int[] Indices; // Index array describing the triangles of this mesh public SubMeshData[] SubMeshes; // Data for each SubMesh, grouped by texture public ModelDoor[] Doors; // Doors found in this model //public DFMesh.DFPlane[] DungeonFloors; // Dungeon floor planes in this model /// <summary> /// Defines submesh data. /// </summary> [Serializable] public struct SubMeshData { public int StartIndex; // Location in the index array at which to start reading vertices public int PrimitiveCount; // Number of primitives in this submesh public int TextureArchive; // Texture archive index public int TextureRecord; // Texture record index } } /// <summary> /// Defines a door found in model data. /// </summary> [Serializable] public struct ModelDoor { public int Index; // Index of this door in model data public DoorTypes Type; // Type of door found (building, dungeon, etc.) public Vector3 Vert0; // Vertex 0 public Vector3 Vert1; // Vertex 1 public Vector3 Vert2; // Vertex 2 public Vector3 Normal; // Normal facing away from door } /// <summary> /// Defines animation setup for weapons. /// </summary> [Serializable] public struct WeaponAnimation { public int Record; // Index of this animation public int NumFrames; // Number of frames in this animation public int FramePerSecond; // Speed at which this animation plays public WeaponAlignment Alignment; // Side of screen to align animation public float Offset; // Offset from edge of screen in 0-1 range, ignored for WeaponAlignment.Center public float Offsety; } /// <summary> /// Defines a static door for hit tests inside a scene. /// </summary> [Serializable] public struct StaticDoor { public int buildingKey; // Unique key of building this door will access public Vector3 ownerPosition; // World position of door owner public Quaternion ownerRotation; // Rotation of door owner public Matrix4x4 buildingMatrix; // Matrix of individual building owning this door public DoorTypes doorType; // Type of door public int blockIndex; // Block index in BLOCKS.BSA public int recordIndex; // Record index for interior public int doorIndex; // Door index for individual building/record (most buildings have only 1-2 doors) public Vector3 centre; // Door centre in model space public Vector3 size; // Door size in model space public Vector3 normal; // Normal pointing away from door } /// <summary> /// Defines a static building for hit tests inside scene. /// </summary> [Serializable] public struct StaticBuilding { public int buildingKey; // Building key unique to parent location public Matrix4x4 modelMatrix; // Matrix of individual model for this building public int recordIndex; // Record index for building public Vector3 centre; // Building centre in model space public Vector3 size; // Building size } /// <summary> /// Detailed information about a building for directory lookups. /// </summary> [Serializable] public struct BuildingSummary { public int buildingKey; // Building key unique to parent location public int NameSeed; // Name seed of building - not set at block level public int FactionId; // Faction ID of building public DFLocation.BuildingTypes BuildingType; // Type of building public int Quality; // Quality of building public Vector3 Position; // Position of building public Vector3 Rotation; // Rotation of building public Matrix4x4 Matrix; // Transform matrix of building public uint ModelID; // Numerical model ID of building in ARCH3D.BSA - 0 means no model found } /// <summary> /// Information about a single map pixel for streaming world. /// </summary> [Serializable] public struct MapPixelData { public bool inWorld; // True if map pixel is inside world area public int mapPixelX; // Map pixel X coordinate public int mapPixelY; // Map pixel Y coordinate public int worldHeight; // Height of this pixel (not scaled) public int worldClimate; // Climate of this pixel public int worldPolitic; // Politics of this pixel public bool hasLocation; // True if location present public int mapRegionIndex; // Map region index (if location present) public int mapLocationIndex; // Map location index (if location present) public int locationID; // Location ID (if location present) public string locationName; // Location name (if location present) public float averageHeight; // Average height of terrain for location placement public float maxHeight; // Max height of terrain for location placement public Rect locationRect; // Rect of location tiles in sample are [HideInInspector, NonSerialized] public byte[,] tilemapSamples; // Tilemap samples for terrain [HideInInspector, NonSerialized] public float[,] heightmapSamples; // Heightmap samples for terrain - indexed [y,x] for Terrain.SetHeights [HideInInspector, NonSerialized] public NativeArray<float> heightmapData; // Heightmap data for terrain jobs (unmanaged memory) [HideInInspector, NonSerialized] public NativeArray<byte> tilemapData; // Tilemap data for terrain jobs (unmanaged memory) [HideInInspector, NonSerialized] public NativeArray<Color32> tileMap; // Tilemap color data for shader (unmanaged memory) [HideInInspector, NonSerialized] public NativeArray<float> avgMaxHeight; // Average and max height of terrain for location placement (unmanaged memory) [HideInInspector, NonSerialized] public List<IDisposable> nativeArrayList; // List of temp working native arrays (unmanaged memory) for disposal when jobs complete } /// <summary> /// Full details of a quest site generated by Place resource. /// A site has different meanings based on type: /// * Town - Exterior arrangement of RMB blocks. Can be fixed or random. /// * Dungeon - Interior arrangement of RDB blocks. Can be fixed or random. /// * Building - Interior of a specific RMB block record. Random based on building type. /// /// NOTES: /// * All available quest Spawn and Item markers are stored in SiteDetails for lookups. /// * Only a single marker will be selected based on first resource placed to site and what markers are available. /// * If an Item resource is placed first it will select a random Item marker. /// * If a Foe or Person resource is placed first it will select a random Spawn marker. /// * Future placements will be added to selected marker. /// * If site has only a Spawn or Item marker available, the best available marker type will be used. /// * Will continue to refine this design as quest system progresses. /// </summary> [Serializable] public struct SiteDetails { public ulong questUID; // Quest who owns this site public SiteTypes siteType; // Type of site public int mapId; // MapID of this location public uint locationId; // LocationID of this location public string regionName; // Name of region containing this location public string locationName; // Name of exterior location itself public int buildingKey; // Key of building site in this location public string buildingName; // Name of target building, e.g. 'The Odd Blades' public QuestMarker[] questSpawnMarkers; // Array of quest spawn markers (Foe, Person resources) found in site, can be null or empty public QuestMarker[] questItemMarkers; // Array of quest item markers (Item resource) found in site, can be null or empty public int selectedQuestSpawnMarker; // [DEPRECATED] Quest spawn marker randomly chosen at time of site generation public int selectedQuestItemMarker; // [DEPRECATED] Quest item marker randomly chosen at time of site generation public QuestMarker selectedMarker; // The spawn/item marker to which future resources will be placed public int magicNumberIndex; // Static index specified by fixed places only (one-based) } /// <summary> /// Site links are reserved by "create npc at" action. /// Creates a bridge between world and quest markers for layout classes. /// For example, quest NPCs might need to be injected to a certain building or dungeon interior. /// The same mechanism is used to place quest items and foes for the player. /// SiteLink contains enough information for external classes to determine if they belong to that site. /// If layout classes find a matching SiteLink, they will deploy any assigned QuestMarkers assigned to site. /// </summary> [Serializable] public struct SiteLink { public ulong questUID; // Quest which reserved link public Symbol placeSymbol; // Symbol of Place/site target public SiteTypes siteType; // Type of site involved in quest public int mapId; // MapID of site location in world public int buildingKey; // Key for building site types public int magicNumberIndex; // Static index specified by fixed places only (one-based) } /// <summary> /// Describes a single quest marker for NPC, item, etc. /// These markers are used to place quest resources like Person, Foe, Item, etc. /// </summary> [Serializable] public struct QuestMarker { public ulong questUID; // Quest who owns this marker public Symbol placeSymbol; // Symbol of place who owns this marker public List<Symbol> targetResources; // Resources assigned to this marker, can be null or empty public MarkerTypes markerType; // Type of marker this represents public Vector3 flatPosition; // Position of marker flat in block layout public int dungeonX; // Dungeon block X position in location public int dungeonZ; // Dungeon block Z position in location public int buildingKey; // Building key if a building site public ulong markerID; // Marker ID for dungeon markers } /// <summary> /// Used to create matrix of chances by loot table key. /// </summary> public struct LootChanceMatrix { public string key; public int MinGold; public int MaxGold; public int P1; // PlantIngredients1 public int P2; // PlantIngredients2 public int C1; // CreatureIngredients1 public int C2; // CreatureIngredients2 public int C3; // CreatureIngredients3 public int M1; // MiscellaneousIngredients1 public int AM; // Armor public int WP; // Weapons public int MI; // Magic item public int CL; // Clothing public int BK; // Book public int M2; // MiscellaneousIngredients2 public int RL; // ReligiousItems } /// <summary> /// A single global variable. /// </summary> public struct GlobalVar { public int index; public string name; public bool value; } [Serializable] public struct FaceDetails { public ulong questUID; public Symbol targetPerson; public Symbol targetFoe; public Races targetRace; public Genders gender; public bool isChild; public int faceIndex; public int factionFaceIndex; } /// <summary> /// List of starting spells for a specific career. /// Custom careers use the same starting spells as Spellsword (CareerIndex=1) if any primary or major skills are a magic skill) /// </summary> [Serializable] public struct CareerStartingSpells { public int CareerIndex; // Career index of starting character - referenced by character creation public string CareerName; // Display name of career - only used to make file more human readable public StartingSpell[] SpellsList; // List of starting spells for this career } /// <summary> /// A single starting spell. /// </summary> [Serializable] public struct StartingSpell { public int SpellID; // ID of spell inside SPELLS.STD - used to reference spell itself public string SpellName; // Display name of spell - only used to make file more human readable } public struct Border<T> { public Border(T common) { Fill = Top = Bottom = Left = Right = TopLeft = TopRight = BottomLeft = BottomRight = common; } public T Fill; public T Top; public T Bottom; public T Left; public T Right; public T TopLeft; public T TopRight; public T BottomLeft; public T BottomRight; } }
54.696429
143
0.591185
[ "MIT" ]
communityus/CO-DF-Unity-10.23
Assets/Scripts/DaggerfallUnityStructs.cs
30,630
C#
/* * ============================================================================== * * FileName: TaskSchedulerServer.cs * Created: 2020/6/17 13:42:07 * Author: Meiam * Description:  * * ============================================================================== */ using Meiam.System.Interfaces; using Meiam.System.Model; using Quartz; using Quartz.Impl; using Quartz.Spi; using System; using System.Collections.Specialized; using System.Reflection; using System.Threading.Tasks; namespace Meiam.System.Tasks { /// <summary> /// 计划任务中心 /// </summary> public class TaskSchedulerServer : ITaskSchedulerServer { private Task<IScheduler> _scheduler; private readonly IJobFactory _jobFactory; public TaskSchedulerServer(IJobFactory jobFactory) { _scheduler = GetTaskSchedulerAsync(); _jobFactory = jobFactory; } /// <summary> /// 开启计划任务 /// </summary> /// <returns></returns> private Task<IScheduler> GetTaskSchedulerAsync() { if (_scheduler != null) { return _scheduler; } NameValueCollection collection = new NameValueCollection { { "quartz.serializer.type", "binary" } }; StdSchedulerFactory factory = new StdSchedulerFactory(collection); return _scheduler = factory.GetScheduler(); } public async Task<ApiResult<string>> StartTaskScheduleAsync() { try { _scheduler.Result.JobFactory = _jobFactory; if (_scheduler.Result.IsStarted) { return new ApiResult<string> { StatusCode = 500, Message = $"计划任务已经开启", }; } //等待任务运行完成 await _scheduler.Result.Start(); return new ApiResult<string> { StatusCode = 200, Message = $"计划任务开启成功", }; } catch (Exception) { throw; } } /// <summary> /// 停止计划任务 /// </summary> /// <returns></returns> public async Task<ApiResult<string>> StopTaskScheduleAsync() { try { if (_scheduler.Result.IsShutdown) { return new ApiResult<string> { StatusCode = 500, Message = $"计划任务已经停止", }; } await _scheduler.Result.Shutdown(); return new ApiResult<string> { StatusCode = 200, Message = $"计划任务已经停止", }; } catch (Exception) { throw; } } /// <summary> /// 添加一个计划任务 /// </summary> /// <param name="tasksQz"></param> /// <returns></returns> public async Task<ApiResult<string>> AddTaskScheduleAsync(Sys_TasksQz tasksQz) { try { JobKey jobKey = new JobKey(tasksQz.ID, tasksQz.JobGroup); if (await _scheduler.Result.CheckExists(jobKey)) { return new ApiResult<string> { StatusCode = 500, Message = $"该计划任务已经在执行:【{tasksQz.Name}】,请勿重复添加!", }; } #region 设置开始时间和结束时间 tasksQz.BeginTime = tasksQz.BeginTime == null ? DateTime.Now : tasksQz.BeginTime; tasksQz.EndTime = tasksQz.EndTime == null ? DateTime.MaxValue.AddDays(-1) : tasksQz.EndTime; DateTimeOffset starRunTime = DateBuilder.NextGivenSecondDate(tasksQz.BeginTime, 1);//设置开始时间 DateTimeOffset endRunTime = DateBuilder.NextGivenSecondDate(tasksQz.EndTime, 1);//设置暂停时间 #endregion #region 通过反射获取程序集类型和类 Assembly assembly = Assembly.Load(new AssemblyName(tasksQz.AssemblyName)); Type jobType = assembly.GetType(tasksQz.AssemblyName + "." + tasksQz.ClassName); #endregion //判断任务调度是否开启 if (!_scheduler.Result.IsStarted) { await StartTaskScheduleAsync(); } //传入反射出来的执行程序集 IJobDetail job = new JobDetailImpl(tasksQz.ID, tasksQz.JobGroup, jobType); job.JobDataMap.Add("JobParam", tasksQz.JobParams); ITrigger trigger; if (tasksQz.Cron != null && CronExpression.IsValidExpression(tasksQz.Cron) && tasksQz.TriggerType > 0) { trigger = CreateCronTrigger(tasksQz); } else { trigger = CreateSimpleTrigger(tasksQz); } // 告诉Quartz使用我们的触发器来安排作业 await _scheduler.Result.ScheduleJob(job, trigger); return new ApiResult<string> { StatusCode = 200, Message = $"启动计划任务:【{tasksQz.Name}】成功!", }; } catch (Exception) { throw; } } /// <summary> /// 暂停指定的计划任务 /// </summary> /// <param name="tasksQz"></param> /// <returns></returns> public async Task<ApiResult<string>> PauseTaskScheduleAsync(Sys_TasksQz tasksQz) { try { JobKey jobKey = new JobKey(tasksQz.ID, tasksQz.JobGroup); if (!await _scheduler.Result.CheckExists(jobKey)) { return new ApiResult<string> { StatusCode = 500, Message = $"未找计划任务:【{tasksQz.Name}】", }; } await _scheduler.Result.PauseJob(jobKey); return new ApiResult<string> { StatusCode = 200, Message = $"暂停计划任务:【{tasksQz.Name}】成功", }; } catch (Exception) { throw; } } /// <summary> /// 恢复指定计划任务 /// </summary> /// <param name="tasksQz"></param> /// <returns></returns> public async Task<ApiResult<string>> ResumeTaskScheduleAsync(Sys_TasksQz tasksQz) { try { JobKey jobKey = new JobKey(tasksQz.ID, tasksQz.JobGroup); if (!await _scheduler.Result.CheckExists(jobKey)) { return new ApiResult<string> { StatusCode = 500, Message = $"未找到计划任务:【{tasksQz.Name}】", }; } await _scheduler.Result.ResumeJob(jobKey); return new ApiResult<string> { StatusCode = 200, Message = $"恢复计划任务:【{tasksQz.Name}】成功", }; } catch (Exception) { throw; } } /// <summary> /// 删除指定计划任务 /// </summary> /// <param name="tasksQz"></param> /// <returns></returns> public async Task<ApiResult<string>> DeleteTaskScheduleAsync(Sys_TasksQz tasksQz) { try { JobKey jobKey = new JobKey(tasksQz.ID, tasksQz.JobGroup); await _scheduler.Result.DeleteJob(jobKey); return new ApiResult<string> { StatusCode = 200, Message = $"删除计划任务:【{tasksQz.Name}】成功", }; } catch (Exception) { throw; } } #region 创建触发器帮助方法 /// <summary> /// 创建SimpleTrigger触发器(简单触发器) /// </summary> /// <param name="tasksQz"></param> /// <returns></returns> private ITrigger CreateSimpleTrigger(Sys_TasksQz tasksQz) { if (tasksQz.RunTimes > 0) { ITrigger trigger = TriggerBuilder.Create() .WithIdentity(tasksQz.ID, tasksQz.JobGroup) .StartAt(tasksQz.BeginTime.Value) .EndAt(tasksQz.EndTime.Value) .WithSimpleSchedule(x => x.WithIntervalInSeconds(tasksQz.IntervalSecond) .WithRepeatCount(tasksQz.RunTimes)).ForJob(tasksQz.ID, tasksQz.JobGroup).Build(); return trigger; } else { ITrigger trigger = TriggerBuilder.Create() .WithIdentity(tasksQz.ID, tasksQz.JobGroup) .StartAt(tasksQz.BeginTime.Value) .EndAt(tasksQz.EndTime.Value) .WithSimpleSchedule(x => x.WithIntervalInSeconds(tasksQz.IntervalSecond) .RepeatForever()).ForJob(tasksQz.ID, tasksQz.JobGroup).Build(); return trigger; } // 触发作业立即运行,然后每10秒重复一次,无限循环 } /// <summary> /// 创建类型Cron的触发器 /// </summary> /// <param name="tasksQz"></param> /// <returns></returns> private ITrigger CreateCronTrigger(Sys_TasksQz tasksQz) { // 作业触发器 return TriggerBuilder.Create() .WithIdentity(tasksQz.ID, tasksQz.JobGroup) .StartAt(tasksQz.BeginTime.Value)//开始时间 .EndAt(tasksQz.EndTime.Value)//结束数据 .WithCronSchedule(tasksQz.Cron)//指定cron表达式 .ForJob(tasksQz.ID, tasksQz.JobGroup)//作业名称 .Build(); } #endregion } }
31.324159
118
0.45475
[ "Apache-2.0" ]
91270/Meiam.System
Meiam.System.Tasks/TaskSchedulerServer.cs
10,874
C#
using Microsoft.EntityFrameworkCore.Migrations; namespace SmartCarRentals.Data.Migrations { public partial class FreeParkingSlotsRename : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( name: "FreeParkingLots", table: "Parkings"); migrationBuilder.AddColumn<int>( name: "FreeParkingSlots", table: "Parkings", nullable: false, defaultValue: 0); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( name: "FreeParkingSlots", table: "Parkings"); migrationBuilder.AddColumn<int>( name: "FreeParkingLots", table: "Parkings", type: "int", nullable: false, defaultValue: 0); } } }
28.457143
71
0.541165
[ "MIT" ]
ulivegenov/SmartCarRentals
Data/SmartCarRentals.Data/Migrations/20200318224118_FreeParkingSlotsRename.cs
998
C#
namespace ModulesRegistry.Services.Extensions; public static class PaginationExtensions { public static int TotalPages<T>(this IEnumerable<T> me, int itemPerPage) => me is null ? 0 : me.Count() % itemPerPage == 0 ? me.Count() / itemPerPage : (me.Count() / itemPerPage) + 1; public static IEnumerable<T> Page<T>(this IEnumerable<T> me, int itemPerPage, int pageNumber) => pageNumber < 1 || pageNumber > me.TotalPages(itemPerPage) ? Array.Empty<T>() : me.Skip((pageNumber - 1) * itemPerPage).Take(itemPerPage); public static IEnumerable<IEnumerable<T>> ItemsPerPage<T>(this IEnumerable<T> me, int itemsPerPage) { var totalPages = me.TotalPages(itemsPerPage); return Enumerable.Range(1, totalPages).Select(page => me.Page(itemsPerPage, page)); } }
42.631579
115
0.68642
[ "MIT" ]
tellurianinteractive/Tellurian.Trains.ModulesRegistryApp
SourceCode/Services/Extensions/PaginationExtensions.cs
812
C#
namespace FarmersMarket.Web.Controllers { using FarmersMarket.Services.Interfaces; using Microsoft.AspNetCore.Mvc; using X.PagedList; [Route("farms")] public class FarmsController : BaseController { private readonly IFarmsService service; public FarmsController(IFarmsService service) { this.service = service; } [HttpGet] //[OutputCache(Duration = 60, Location = OutputCacheLocation.ServerAndClient)] public IActionResult All(int? page) { var farms = this.service.GetAllFarms(); int pageSize = 4; int pageNumber = (page ?? 1); return View(farms.ToPagedList(pageNumber, pageSize)); } } }
25.965517
86
0.612218
[ "MIT" ]
KonstantinKirchev/FarmersMarket-ASP.NET-Core
FarmersMarket/FarmersMarket.Web/Controllers/FarmsController.cs
755
C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections.ObjectModel; using System.ComponentModel; using Windows.UI.Xaml.Media; using kurema.FileExplorerControl.Models.IconProviders; using kurema.FileExplorerControl.Models.FileItems; namespace kurema.FileExplorerControl.ViewModels { public class FileItemViewModel:INotifyPropertyChanged { #region INotifyPropertyChanged protected bool SetProperty<T>(ref T backingStore, T value, [System.Runtime.CompilerServices.CallerMemberName]string propertyName = "", System.Action onChanged = null) { if (EqualityComparer<T>.Default.Equals(backingStore, value)) return false; backingStore = value; onChanged?.Invoke(); OnPropertyChanged(propertyName); return true; } public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = "") { PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } #endregion private IFileItem _Content; public IFileItem Content { get => _Content; set { SetProperty(ref _Content, value); _Children = null; OnPropertyChanged(nameof(Children)); OnPropertyChanged(nameof(Folders)); OnPropertyChanged(nameof(Files)); OnPropertyChanged(nameof(Title)); OnPropertyChanged(nameof(Path)); OnPropertyChanged(nameof(LastModified)); OnPropertyChanged(nameof(IsFolder)); OnPropertyChanged(nameof(Size)); DeleteCommand?.OnCanExecuteChanged(); //RenameCommand?.OnCanExecuteChanged(); } } public FileItemViewModel(IFileItem content) { Content = content ?? throw new ArgumentNullException(nameof(content)); } public FileItemViewModel[] Folders => Children?.Where(a => a.IsFolder).ToArray()?? new FileItemViewModel[0]; public FileItemViewModel[] Files => Children?.Where(a => !a.IsFolder).ToArray() ?? new FileItemViewModel[0]; private OrderStatus _Order = new OrderStatus(); public OrderStatus Order { get => _Order; set { SetProperty(ref _Order, value); OnPropertyChanged(nameof(Children)); OnPropertyChanged(nameof(Files)); OnPropertyChanged(nameof(Folders)); } } //public Helper.DelegateCommand RenameCommand { get; set; } private Helper.DelegateCommand _DeleteCommand; public Helper.DelegateCommand DeleteCommand => _DeleteCommand = _DeleteCommand ?? new Helper.DelegateCommand(async (parameter) => { async Task<(bool,bool)> checkDelete() { if (ParentContent?.DialogDelete != null) { var result = await ParentContent?.DialogDelete(this); if (result.delete == false) return (false, false); return (result.delete, result.completeDelete); } return (true, false); } if (Content?.DeleteCommand is Helper.DelegateAsyncCommand dc) { if (dc.CanExecute(parameter)) { var checkResult = await checkDelete(); if (checkResult.Item1) { await dc.ExecuteAsync(checkResult.Item2); await Parent?.UpdateChildren(); } } } else { if (Content?.DeleteCommand?.CanExecute(parameter) == true) { var checkResult = await checkDelete(); if (checkResult.Item1) { Content.DeleteCommand.Execute(checkResult.Item2); } } } }, a => Content?.DeleteCommand?.CanExecute(a) ?? false); private ContentViewModel _ParentContent; public ContentViewModel ParentContent { get => _ParentContent; set { SetProperty(ref _ParentContent, value); if (Children != null) foreach (var item in this.Children) { item.ParentContent = this.ParentContent; } } } public class OrderStatus:INotifyPropertyChanged { #region INotifyPropertyChanged protected bool SetProperty<T>(ref T backingStore, T value, [System.Runtime.CompilerServices.CallerMemberName]string propertyName = "", System.Action onChanged = null) { if (System.Collections.Generic.EqualityComparer<T>.Default.Equals(backingStore, value)) return false; backingStore = value; onChanged?.Invoke(); OnPropertyChanged(propertyName); return true; } public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = "") { PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } #endregion private string _Key; public string Key { get => _Key; set => SetProperty(ref _Key, value); } private bool _KeyIsAscending; public bool KeyIsAscending { get => _KeyIsAscending; set => SetProperty(ref _KeyIsAscending, value); } private Func<IEnumerable<FileItemViewModel>, IEnumerable<FileItemViewModel>> _OrderDelegate; public Func<IEnumerable<FileItemViewModel>, IEnumerable<FileItemViewModel>> OrderDelegate { get => _OrderDelegate; set { SetProperty(ref _OrderDelegate, value); OnPropertyChanged(nameof(IsEmpty)); } } public bool IsEmpty => _OrderDelegate == null; public OrderStatus GetBasicOrder(string key, bool isAscending) { var resultOrder = new OrderStatus(); void SetSortState<T>(Func<FileItemViewModel, T> func, bool isAscendingArg) { if (isAscendingArg) resultOrder.OrderDelegate = a => a.OrderBy(func); else resultOrder.OrderDelegate = a => a.OrderByDescending(func); } switch (key) { case "Title": SetSortState(b => b.Title, isAscending); break; case "Size": SetSortState(b => b.Size ?? 0, isAscending); break; case "Date": SetSortState(b => b.LastModified.Ticks, isAscending); break; default: return new OrderStatus(); } resultOrder.Key = key; resultOrder.KeyIsAscending = isAscending; return resultOrder; } public OrderStatus GetShiftedBasicOrder(string key) { if (Key == key) { if (KeyIsAscending) { return GetBasicOrder(key, false); } else { return new OrderStatus(); } } else { return GetBasicOrder(key, true); } } } private IEnumerable<FileItemViewModel> _Children; public IEnumerable<FileItemViewModel> Children { get { return Order?.OrderDelegate == null ? _Children : Order?.OrderDelegate(_Children); } private set { _Children = value; OnPropertyChanged(nameof(Children)); OnPropertyChanged(nameof(Files)); OnPropertyChanged(nameof(Folders)); } } private ObservableCollection<IIconProvider> _IconProviders = new ObservableCollection<IIconProvider>(new[] { new IconProviderDefault() }); public ObservableCollection<IIconProvider> IconProviders { get => _IconProviders; set { void IconUpdate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { OnPropertyChanged(nameof(IconSmall)); OnPropertyChanged(nameof(IconLarge)); } if (_IconProviders!=null) _IconProviders.CollectionChanged -= IconUpdate; SetProperty(ref _IconProviders, value); IconUpdate(this, null); if (_IconProviders != null) _IconProviders.CollectionChanged += IconUpdate; } } public async Task UpdateChildren() { var children = new List<FileItemViewModel>((await Content?.GetChildren())?.Select(f => new FileItemViewModel(f))); foreach (var item in children) { //(item.IconSmall, item.IconLarge) = IconProviderDefault.GetIcon(item.Content, IconProviders); item.IconProviders = this.IconProviders; item.Parent = this; item.ParentContent = this.ParentContent; } Children = children; } private FileItemViewModel _Parent; public FileItemViewModel Parent { get => _Parent; set => SetProperty(ref _Parent, value); } public string Title { get => _Content?.Name ?? ""; set { Rename(value?.ToString()); } } private async void Rename(string title) { if (title == Title) return; if (String.IsNullOrEmpty(title)) return; if (Content?.RenameCommand?.CanExecute(title) == true) { if (Content.RenameCommand is Helper.DelegateAsyncCommand renac) { try { await renac.ExecuteAsync(title); } catch { return; } } else { try { Content.RenameCommand.Execute(title); } catch { return; } } } OnPropertyChanged(nameof(Title)); } public string Path => _Content?.Path ?? ""; public DateTimeOffset LastModified => _Content?.DateCreated??new DateTimeOffset(); public bool IsFolder => _Content?.IsFolder ?? false; private ulong? _Size; public ulong? Size { get { if (_Size != null) return _Size; if (_Content == null) return null; if (this.IsFolder) { if (Children == null) return null; ulong result = 0; foreach(var item in Children) { if (item.Size == null) return null; else result += item.Size ?? 0; } return result; } else { UpdateSize(); return null; } } } private async void UpdateSize() { if (_Content == null) return; try { _Size = await _Content.GetSizeAsync(); OnPropertyChanged(nameof(Size)); } catch { } } private ImageSource _IconSmall; public ImageSource IconSmall { get { if (_IconSmall == null) (_IconSmall, _IconLarge) = IconProviderDefault.GetIcon(this.Content, IconProviders); return _IconSmall; } set { SetProperty(ref _IconSmall, value); } } private ImageSource _IconLarge; public ImageSource IconLarge { get { if (_IconLarge == null) (_IconSmall, _IconLarge) = IconProviderDefault.GetIcon(this.Content, IconProviders); return _IconLarge; } set { SetProperty(ref _IconLarge, value); } } } }
34.928947
146
0.513976
[ "MIT" ]
Manu99it/BookViewerApp3
FileExplorerControl/ViewModels/FileItemViewModel.cs
13,275
C#
using UnityEngine; using System.Collections; using EnhancedUI; using EnhancedUI.EnhancedScroller; namespace EnhancedScrollerDemos.RefreshDemo { /// <summary> /// Set up our demo script as a delegate for the scroller by inheriting from the IEnhancedScrollerDelegate interface /// /// EnhancedScroller delegates will handle telling the scroller: /// - How many cells it should allocate room for (GetNumberOfCells) /// - What each cell size is (GetCellSize) /// - What the cell at a given index should be (GetCell) /// </summary> public class Controller : MonoBehaviour, IEnhancedScrollerDelegate { /// <summary> /// Internal representation of our data. Note that the scroller will never see /// this, so it separates the data from the layout using MVC principles. /// </summary> private SmallList<Data> _data; /// <summary> /// This is our scroller we will be a delegate for /// </summary> public EnhancedScroller scroller; /// <summary> /// This will be the prefab of each cell in our scroller. Note that you can use more /// than one kind of cell, but this example just has the one type. /// </summary> public EnhancedScrollerCellView cellViewPrefab; /// <summary> /// Be sure to set up your references to the scroller after the Awake function. The /// scroller does some internal configuration in its own Awake function. If you need to /// do this in the Awake function, you can set up the script order through the Unity editor. /// In this case, be sure to set the EnhancedScroller's script before your delegate. /// /// In this example, we are calling our initializations in the delegate's Start function, /// but it could have been done later, perhaps in the Update function. /// </summary> void Start() { // tell the scroller that this script will be its delegate scroller.Delegate = this; // load in a large set of data LoadLargeData(); } void Update() { // update the data and refresh the active cells if (Input.GetKeyDown(KeyCode.R)) { // set up some new data for cells zero through five _data[0].someText = "This cell was updated"; _data[1].someText = "---"; _data[2].someText = "---"; _data[3].someText = "---"; _data[4].someText = "---"; _data[5].someText = "This cell was also updated"; // refresh the active cells scroller.RefreshActiveCellViews(); } } /// <summary> /// Populates the data with a lot of records /// </summary> private void LoadLargeData() { // set up some simple data _data = new SmallList<Data>(); for (var i = 0; i < 1000; i++) _data.Add(new Data() { someText = "Cell Data Index " + i.ToString() }); // tell the scroller to reload now that we have the data scroller.ReloadData(); } /// <summary> /// Populates the data with a small set of records /// </summary> private void LoadSmallData() { // set up some simple data _data = new SmallList<Data>(); _data.Add(new Data() { someText = "A" }); _data.Add(new Data() { someText = "B" }); _data.Add(new Data() { someText = "C" }); // tell the scroller to reload now that we have the data scroller.ReloadData(); } #region UI Handlers /// <summary> /// Button handler for the large data loader /// </summary> public void LoadLargeDataButton_OnClick() { LoadLargeData(); } /// <summary> /// Button handler for the small data loader /// </summary> public void LoadSmallDataButton_OnClick() { LoadSmallData(); } #endregion #region EnhancedScroller Handlers /// <summary> /// This tells the scroller the number of cells that should have room allocated. This should be the length of your data array. /// </summary> /// <param name="scroller">The scroller that is requesting the data size</param> /// <returns>The number of cells</returns> public int GetNumberOfCells(EnhancedScroller scroller) { // in this example, we just pass the number of our data elements return _data.Count; } /// <summary> /// This tells the scroller what the size of a given cell will be. Cells can be any size and do not have /// to be uniform. For vertical scrollers the cell size will be the height. For horizontal scrollers the /// cell size will be the width. /// </summary> /// <param name="scroller">The scroller requesting the cell size</param> /// <param name="dataIndex">The index of the data that the scroller is requesting</param> /// <returns>The size of the cell</returns> public float GetCellViewSize(EnhancedScroller scroller, int dataIndex) { // in this example, even numbered cells are 30 pixels tall, odd numbered cells are 100 pixels tall return (dataIndex % 2 == 0 ? 30f : 100f); } /// <summary> /// Gets the cell to be displayed. You can have numerous cell types, allowing variety in your list. /// Some examples of this would be headers, footers, and other grouping cells. /// </summary> /// <param name="scroller">The scroller requesting the cell</param> /// <param name="dataIndex">The index of the data that the scroller is requesting</param> /// <param name="cellIndex">The index of the list. This will likely be different from the dataIndex if the scroller is looping</param> /// <returns>The cell for the scroller to use</returns> public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex) { // first, we get a cell from the scroller by passing a prefab. // if the scroller finds one it can recycle it will do so, otherwise // it will create a new cell. CellView cellView = scroller.GetCellView(cellViewPrefab) as CellView; // set the name of the game object to the cell's data index. // this is optional, but it helps up debug the objects in // the scene hierarchy. cellView.name = "Cell " + dataIndex.ToString(); // in this example, we just pass the data to our cell's view which will update its UI cellView.SetData(_data[dataIndex]); // return the cell to the scroller return cellView; } #endregion } }
39.516667
142
0.588359
[ "BSD-3-Clause" ]
bac0264/LuaTest
Assets/EnhancedScroller v2/Demos/07 Refreshing/Controller.cs
7,115
C#
using System; namespace FileManipulator { public interface ITaskErrorEventArgs { Exception Exception { get; } } }
15
40
0.666667
[ "MIT" ]
mateuszokroj1/FileManipulator
Sources/Core/Events/ITaskErrorEventArgs.cs
137
C#
using System; using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Linq; using System.Numerics; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using Merkator.Tools; namespace Merkator.BitCoin { // Implements https://en.bitcoin.it/wiki/Base58Check_encoding public static class Base58Encoding { public const int CheckSumSizeInBytes = 4; public static byte[] AddCheckSum(byte[] data) { Contract.Requires<ArgumentNullException>(data != null); Contract.Ensures(Contract.Result<byte[]>().Length == data.Length + CheckSumSizeInBytes); byte[] checkSum = GetCheckSum(data); byte[] dataWithCheckSum = ArrayHelpers.ConcatArrays(data, checkSum); return dataWithCheckSum; } //Returns null if the checksum is invalid public static byte[] VerifyAndRemoveCheckSum(byte[] data) { Contract.Requires<ArgumentNullException>(data != null); Contract.Ensures(Contract.Result<byte[]>() == null || Contract.Result<byte[]>().Length + CheckSumSizeInBytes == data.Length); byte[] result = ArrayHelpers.SubArray(data, 0, data.Length - CheckSumSizeInBytes); byte[] givenCheckSum = ArrayHelpers.SubArray(data, data.Length - CheckSumSizeInBytes); byte[] correctCheckSum = GetCheckSum(result); if (givenCheckSum.SequenceEqual(correctCheckSum)) return result; else return null; } private const string Digits = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; public static string Encode(byte[] data) { //Contract.Requires<ArgumentNullException>(data != null); //Contract.Ensures(Contract.Result<string>() != null); // Decode byte[] to BigInteger BigInteger intData = 0; for (int i = 0; i < data.Length; i++) { intData = intData * 256 + data[i]; } // Encode BigInteger to Base58 string string result = ""; while (intData > 0) { int remainder = (int)(intData % 58); intData /= 58; result = Digits[remainder] + result; } // Append `1` for each leading 0 byte for (int i = 0; i < data.Length && data[i] == 0; i++) { result = '1' + result; } return result; } public static string EncodeWithCheckSum(byte[] data) { Contract.Requires<ArgumentNullException>(data != null); Contract.Ensures(Contract.Result<string>() != null); return Encode(AddCheckSum(data)); } public static byte[] Decode(string s) { //Contract.Requires<ArgumentNullException>(s != null); //Contract.Ensures(Contract.Result<byte[]>() != null); // Decode Base58 string to BigInteger BigInteger intData = 0; for (int i = 0; i < s.Length; i++) { int digit = Digits.IndexOf(s[i]); //Slow if (digit < 0) throw new FormatException(string.Format("Invalid Base58 character `{0}` at position {1}", s[i], i)); intData = intData * 58 + digit; } // Encode BigInteger to byte[] // Leading zero bytes get encoded as leading `1` characters int leadingZeroCount = s.TakeWhile(c => c == '1').Count(); var leadingZeros = Enumerable.Repeat((byte)0, leadingZeroCount); var bytesWithoutLeadingZeros = intData.ToByteArray() .Reverse()// to big endian .SkipWhile(b => b == 0);//strip sign byte var result = leadingZeros.Concat(bytesWithoutLeadingZeros).ToArray(); return result; } // Throws `FormatException` if s is not a valid Base58 string, or the checksum is invalid public static byte[] DecodeWithCheckSum(string s) { Contract.Requires<ArgumentNullException>(s != null); Contract.Ensures(Contract.Result<byte[]>() != null); var dataWithCheckSum = Decode(s); var dataWithoutCheckSum = VerifyAndRemoveCheckSum(dataWithCheckSum); if (dataWithoutCheckSum == null) throw new FormatException("Base58 checksum is invalid"); return dataWithoutCheckSum; } private static byte[] GetCheckSum(byte[] data) { Contract.Requires<ArgumentNullException>(data != null); Contract.Ensures(Contract.Result<byte[]>() != null); SHA256 sha256 = new SHA256Managed(); byte[] hash1 = sha256.ComputeHash(data); byte[] hash2 = sha256.ComputeHash(hash1); var result = new byte[CheckSumSizeInBytes]; Buffer.BlockCopy(hash2, 0, result, 0, result.Length); return result; } } }
31.924812
128
0.694536
[ "MIT" ]
CEO-NextMindCoin/unity-solana-wallet
Runtime/codebase/utility/Base58Encoding.cs
4,248
C#
using System; using R5T.T0039.T002; namespace R5T.T0086 { /// <summary> /// Base for extensions ... /// </summary> [ExtensionMethodBaseMarker] public interface ILogger { } }
13.6
31
0.602941
[ "MIT" ]
SafetyCone/R5T.T0086
source/R5T.T0086/Code/Bases/Interfaces/ILogger.cs
204
C#
using ReactNative; using System; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; using Windows.UI.Core; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; namespace VideoPlayer { /// <summary> /// Provides application-specific behavior to supplement the default Application class. /// </summary> sealed partial class App : Application { private readonly ReactPage _reactPage; /// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; this.Resuming += OnResuming; _reactPage = new MainPage(); } /// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { _reactPage.OnResume(Exit); #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { _reactPage.OnCreate(e.Arguments); // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Content = _reactPage; } // Ensure the current window is active Window.Current.Activate(); } /// <summary> /// Invoked when Navigation to a certain page fails /// </summary> /// <param name="sender">The Frame which failed navigation</param> /// <param name="e">Details about the navigation failure</param> void OnNavigationFailed(object sender, NavigationFailedEventArgs e) { throw new Exception("Failed to load Page " + e.SourcePageType.FullName); } /// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private void OnSuspending(object sender, SuspendingEventArgs e) { _reactPage.OnSuspend(); } /// <summary> /// Invoked when application execution is being resumed. /// </summary> /// <param name="sender">The source of the resume request.</param> /// <param name="e">Details about the resume request.</param> private void OnResuming(object sender, object e) { _reactPage.OnResume(Exit); } } }
36.141593
99
0.605534
[ "MIT" ]
24i/react-native-video
examples/basic/windows/VideoPlayer/App.xaml.cs
4,084
C#
#if ALE_STRIP_UGUI #define OBSOLETE #endif #if OBSOLETE && !UNITY_EDITOR #define STRIP #endif #if !STRIP using System; using TMPro; using UnityEngine; using UnityEngine.Events; namespace Hertzole.ALE { #if UNITY_EDITOR [DisallowMultipleComponent] #if !OBSOLETE [AddComponentMenu("ALE/UI/uGUI/Fields/Number Field", 200)] #else [System.Obsolete("LevelEditorNumberField has been stripped and will be removed on build.", true)] #endif #endif public class LevelEditorNumberField : LevelEditorInspectorField { [Serializable] public class SByteEvent : UnityEvent<sbyte> { } [Serializable] public class ByteEvent : UnityEvent<byte> { } [Serializable] public class ShortEvent : UnityEvent<short> { } [Serializable] public class UShortEvent : UnityEvent<ushort> { } [Serializable] public class IntEvent : UnityEvent<int> { } [Serializable] public class UIntEvent : UnityEvent<uint> { } [Serializable] public class LongEvent : UnityEvent<long> { } [Serializable] public class ULongEvent : UnityEvent<ulong> { } [Serializable] public class FloatEvent : UnityEvent<float> { } [Serializable] public class DoubleEvent : UnityEvent<double> { } [Serializable] public class DecimalEvent : UnityEvent<decimal> { } [SerializeField] private TMP_InputField textField = null; [SerializeField] private bool placeholderAsName = true; [SerializeField] private SByteEvent onSByteValueChanged = new SByteEvent(); [SerializeField] private SByteEvent onSByteEndEdit = new SByteEvent(); [SerializeField] private ByteEvent onByteValueChanged = new ByteEvent(); [SerializeField] private ByteEvent onByteEndEdit = new ByteEvent(); [SerializeField] private ShortEvent onShortValueChanged = new ShortEvent(); [SerializeField] private ShortEvent onShortEndEdit = new ShortEvent(); [SerializeField] private UShortEvent onUShortValueChanged = new UShortEvent(); [SerializeField] private UShortEvent onUShortEndEdit = new UShortEvent(); [SerializeField] private IntEvent onIntValueChanged = new IntEvent(); [SerializeField] private IntEvent onIntEndEdit = new IntEvent(); [SerializeField] private UIntEvent onUIntValueChanged = new UIntEvent(); [SerializeField] private UIntEvent onUIntEndEdit = new UIntEvent(); [SerializeField] private LongEvent onLongValueChanged = new LongEvent(); [SerializeField] private LongEvent onLongEndEdit = new LongEvent(); [SerializeField] private ULongEvent onULongValueChanged = new ULongEvent(); [SerializeField] private ULongEvent onULongEndEdit = new ULongEvent(); [SerializeField] private FloatEvent onFloatValueChanged = new FloatEvent(); [SerializeField] private FloatEvent onFloatEndEdit = new FloatEvent(); [SerializeField] private DoubleEvent onDoubleValueChanged = new DoubleEvent(); [SerializeField] private DoubleEvent onDoubleEndEdit = new DoubleEvent(); [SerializeField] private DecimalEvent onDecimalValueChanged = new DecimalEvent(); [SerializeField] private DecimalEvent onDecimalEndEdit = new DecimalEvent(); private enum NumberType : ushort { Sbyte, Byte, Short, UShort, Int, UInt, Long, ULong, Float, Double, Decimal } private bool editing; private NumberType currentType; public SByteEvent OnSByteValueChanged { get { return onSByteValueChanged; } } public ByteEvent OnByteValueChanged { get { return onByteValueChanged; } } public ShortEvent OnShortValueChanged { get { return onShortValueChanged; } } public UShortEvent OnUShortValueChanged { get { return onUShortValueChanged; } } public IntEvent OnIntValueChanged { get { return onIntValueChanged; } } public UIntEvent OnUIntValueChanged { get { return onUIntValueChanged; } } public LongEvent OnLongValueChanged { get { return onLongValueChanged; } } public ULongEvent OnULongValueChanged { get { return onULongValueChanged; } } public FloatEvent OnFloatValueChanged { get { return onFloatValueChanged; } } public DoubleEvent OnDoubleValueChanged { get { return onDoubleValueChanged; } } public DecimalEvent OnDecimalValueChanged { get { return onDecimalValueChanged; } } public SByteEvent OnSByteEndEdit { get { return onSByteEndEdit; } } public ByteEvent OnByteEndEdit { get { return onByteEndEdit; } } public ShortEvent OnShortEndEdit { get { return onShortEndEdit; } } public UShortEvent OnUShortEndEdit { get { return onUShortEndEdit; } } public IntEvent OnIntEndEdit { get { return onIntEndEdit; } } public UIntEvent OnUIntEndEdit { get { return onUIntEndEdit; } } public LongEvent OnLongEndEdit { get { return onLongEndEdit; } } public ULongEvent OnULongEndEdit { get { return onULongEndEdit; } } public FloatEvent OnFloatEndEdit { get { return onFloatEndEdit; } } public DoubleEvent OnDoubleEndEdit { get { return onDoubleEndEdit; } } public DecimalEvent OnDecimalEndEdit { get { return onDecimalEndEdit; } } private const int CHARACTER_LIMIT_BYTE = 3; private const int CHARACTER_LIMIT_SHORT = 5; private const int CHARACTER_LIMIT_INT = 10; private const int CHARACTER_LIMIT_LONG = 18; private const int CHARACTER_LIMIT_FLOAT = 8; private const int CHARACTER_LIMIT_DOUBLE = 18; private const int CHARACTER_LIMIT_DECIMAL = 29; protected override void OnAwake() { this.LogIfStripped(); textField.contentType = TMP_InputField.ContentType.IntegerNumber; textField.onSelect.AddListener(x => BeginEdit()); textField.onValueChanged.AddListener(x => OnValueChanged(x, false)); textField.onEndEdit.AddListener(x => OnValueChanged(x, true)); } public override bool SupportsType(Type type, bool isArray) { if (type.IsArray || isArray) { return false; } return type == typeof(sbyte) || type == typeof(byte) || type == typeof(short) || type == typeof(ushort) || type == typeof(int) || type == typeof(uint) || type == typeof(long) || type == typeof(ulong) || type == typeof(float) || type == typeof(double) || type == typeof(decimal); } protected override void OnBound(ExposedField property, IExposedToLevelEditor exposed) { editing = false; if (property.Type == typeof(sbyte)) { currentType = NumberType.Sbyte; } else if (property.Type == typeof(byte)) { currentType = NumberType.Byte; } else if (property.Type == typeof(short)) { currentType = NumberType.Short; } else if (property.Type == typeof(ushort)) { currentType = NumberType.UShort; } else if (property.Type == typeof(int)) { currentType = NumberType.Int; } else if (property.Type == typeof(uint)) { currentType = NumberType.UInt; } else if (property.Type == typeof(long)) { currentType = NumberType.Long; } else if (property.Type == typeof(ulong)) { currentType = NumberType.ULong; } else if (property.Type == typeof(float)) { currentType = NumberType.Float; } else if (property.Type == typeof(double)) { currentType = NumberType.Double; } else { currentType = NumberType.Decimal; } switch (currentType) { case NumberType.Sbyte: textField.contentType = TMP_InputField.ContentType.IntegerNumber; break; case NumberType.Byte: textField.contentType = TMP_InputField.ContentType.IntegerNumber; break; case NumberType.Short: textField.contentType = TMP_InputField.ContentType.IntegerNumber; break; case NumberType.UShort: textField.contentType = TMP_InputField.ContentType.IntegerNumber; break; case NumberType.Int: textField.contentType = TMP_InputField.ContentType.IntegerNumber; break; case NumberType.UInt: textField.contentType = TMP_InputField.ContentType.IntegerNumber; break; case NumberType.Long: case NumberType.ULong: textField.contentType = TMP_InputField.ContentType.IntegerNumber; break; case NumberType.Float: textField.contentType = TMP_InputField.ContentType.DecimalNumber; break; case NumberType.Double: textField.contentType = TMP_InputField.ContentType.DecimalNumber; break; case NumberType.Decimal: textField.contentType = TMP_InputField.ContentType.DecimalNumber; break; } if (placeholderAsName && textField.placeholder is TextMeshProUGUI placeholder) { placeholder.text = property.Name; } } private void OnValueChanged(string stringValue, bool endEdit) { editing = !endEdit; switch (currentType) { case NumberType.Sbyte: ParseValue<sbyte, long>(stringValue, sbyte.MinValue, sbyte.MaxValue, CHARACTER_LIMIT_BYTE, endEdit, LongParse); break; case NumberType.Byte: ParseValue<byte, ulong>(stringValue, byte.MinValue, byte.MaxValue, CHARACTER_LIMIT_BYTE, endEdit, ULongParse); break; case NumberType.Short: ParseValue<short, long>(stringValue, short.MinValue, short.MaxValue, CHARACTER_LIMIT_SHORT, endEdit, LongParse); break; case NumberType.UShort: ParseValue<ushort, ulong>(stringValue, ushort.MinValue, ushort.MaxValue, CHARACTER_LIMIT_SHORT, endEdit, ULongParse); break; case NumberType.Int: ParseValue<int, long>(stringValue, int.MinValue, int.MaxValue, CHARACTER_LIMIT_INT, endEdit, LongParse); break; case NumberType.UInt: ParseValue<uint, ulong>(stringValue, uint.MinValue, uint.MaxValue, CHARACTER_LIMIT_INT, endEdit, ULongParse); break; case NumberType.Long: ParseValue<long, long>(stringValue, long.MinValue, long.MaxValue, CHARACTER_LIMIT_LONG, endEdit, LongParse); break; case NumberType.ULong: ParseValue<ulong, ulong>(stringValue, ulong.MinValue, ulong.MaxValue, CHARACTER_LIMIT_LONG, endEdit, ULongParse); break; case NumberType.Float: ParseValue<float, float>(stringValue, float.MinValue, float.MaxValue, CHARACTER_LIMIT_FLOAT, endEdit, x => { bool canParse = float.TryParse(x, out float result); return (canParse, result); }); break; case NumberType.Double: ParseValue<double, double>(stringValue, double.MinValue, double.MaxValue, CHARACTER_LIMIT_DOUBLE, endEdit, x => { bool canParse = double.TryParse(x, out double result); return (canParse, result); }); break; case NumberType.Decimal: ParseValue<decimal, decimal>(stringValue, decimal.MinValue, decimal.MaxValue, CHARACTER_LIMIT_DECIMAL, endEdit, x => { bool canParse = decimal.TryParse(x, out decimal result); return (canParse, result); }); break; default: ModifyPropertyValue(0, true); break; } static (bool, long) LongParse(string x) { bool canParse = long.TryParse(x, out long result); return (canParse, result); } static (bool, ulong) ULongParse(string x) { bool canParse = ulong.TryParse(x, out ulong result); return (canParse, result); } } private void ParseValue<TValue, TConverter>(string value, TConverter min, TConverter max, int maxCharacters, bool endEdit, Func<string, ValueTuple<bool, TConverter>> parse) where TValue : IConvertible, IComparable<TValue> where TConverter : IConvertible, IComparable<TConverter> { // If the value starts with - add one extra to the max characters to fit that in. textField.characterLimit = !string.IsNullOrWhiteSpace(value) && value.StartsWith("-") ? maxCharacters + 1 : maxCharacters; TValue convertedValue; if (string.IsNullOrWhiteSpace(value)) { convertedValue = (TValue)Convert.ChangeType(0, typeof(TValue)); ModifyPropertyValue(0, true); if (endEdit) { textField.SetTextWithoutNotify("0"); InvokeEndEdit(convertedValue); EndEdit(); } else { InvokeValueChanged(convertedValue); } return; } (bool canParse, TConverter result) = parse.Invoke(value); LevelEditorLogger.Log($"Can Parse: {canParse} | Result: {result} | Min: {min} | Max: {max} | Compare min: {result.CompareTo(min)} | Compare max: {result.CompareTo(max)}"); if (canParse) { // Make sure the result is within the ranges. if (result.CompareTo(min) < 0) { result = min; } else if (result.CompareTo(max) > 0) { result = max; } // Convert the value to what we want and set the property value. convertedValue = (TValue) Convert.ChangeType(result, typeof(TValue)); ModifyPropertyValue(convertedValue, true); // If the user is leaving the text field, it's safe to update the text field to the actual result. // Otherwise we just leave it be and invoke the value changed event. if (endEdit) { textField.SetTextWithoutNotify(result.ToString()); InvokeEndEdit(convertedValue); EndEdit(); } else { InvokeValueChanged(convertedValue); } } else if (endEdit) { convertedValue = (TValue) Convert.ChangeType(0, typeof(TValue)); textField.SetTextWithoutNotify(convertedValue.ToString()); ModifyPropertyValue(convertedValue, true); InvokeEndEdit(convertedValue); EndEdit(); } } private void InvokeValueChanged(object value) { switch (currentType) { case NumberType.Sbyte: onSByteValueChanged.Invoke((sbyte)value); break; case NumberType.Byte: onByteValueChanged.Invoke((byte)value); break; case NumberType.Short: onShortValueChanged.Invoke((short)value); break; case NumberType.UShort: onUShortValueChanged.Invoke((ushort)value); break; case NumberType.Int: onIntValueChanged.Invoke((int)value); break; case NumberType.UInt: onUIntValueChanged.Invoke((uint)value); break; case NumberType.Long: onLongValueChanged.Invoke((long)value); break; case NumberType.ULong: onULongValueChanged.Invoke((ulong)value); break; case NumberType.Float: onFloatValueChanged.Invoke((float)value); break; case NumberType.Double: onDoubleValueChanged.Invoke((double)value); break; case NumberType.Decimal: onDecimalValueChanged.Invoke((decimal)value); break; default: break; } } private void InvokeEndEdit(object value) { switch (currentType) { case NumberType.Sbyte: onSByteEndEdit.Invoke((sbyte)value); break; case NumberType.Byte: onByteEndEdit.Invoke((byte)value); break; case NumberType.Short: onShortEndEdit.Invoke((short)value); break; case NumberType.UShort: onUShortEndEdit.Invoke((ushort)value); break; case NumberType.Int: onIntEndEdit.Invoke((int)value); break; case NumberType.UInt: onUIntEndEdit.Invoke((uint)value); break; case NumberType.Long: onLongEndEdit.Invoke((long)value); break; case NumberType.ULong: onULongEndEdit.Invoke((ulong)value); break; case NumberType.Float: onFloatEndEdit.Invoke((float)value); break; case NumberType.Double: onDoubleEndEdit.Invoke((double)value); break; case NumberType.Decimal: onDecimalEndEdit.Invoke((decimal)value); break; default: break; } } protected override void SetFieldValue(object value) { // If the field is currently being edited, we don't want to update it. if (editing) { return; } textField.SetTextWithoutNotify(value.ToString()); } } } #endif
41.068465
183
0.548573
[ "MIT" ]
Hertzole/advanced-level-editor
Packages/se.hertzole.ale/Runtime/UI/Inspector/Fields/LevelEditorNumberField.cs
19,797
C#
using Gtk; namespace FloydPink.Flickr.Downloadr.UI.Helpers { public class MessageBox { public static ResponseType Show(Window window, string message, ButtonsType buttons, MessageType type) { var md = new MessageDialog(window, DialogFlags.DestroyWithParent, type, buttons, false, message); var result = (ResponseType) md.Run(); md.Destroy(); return result; } } }
25.375
105
0.694581
[ "MIT" ]
Dr4co/flickr-downloadr-gtk
source/FloydPink.Flickr.Downloadr.UI/Helpers/MessageBox.cs
408
C#
using Microsoft.AspNetCore.Html; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Rendering; namespace SexyColor.CommonComponents { public interface ICaptchaManager { /// <summary> /// 产生验证码 /// </summary> /// <param name="htmlHelper"></param> /// <param name="showCaptchaImage"></param> /// <returns></returns> IHtmlContent GenerateCaptcha<T>(IHtmlHelper<T> htmlHelper, bool showCaptchaImage = false); /// <summary> /// 验证码是否输入正确 /// </summary> /// <param name="filterContext"></param> /// <param name="captchaInputName">输入框名称</param> /// <returns></returns> bool IsCaptchaValid(ActionExecutingContext filterContext); } }
29.692308
98
0.61658
[ "Apache-2.0" ]
lxkbest/SexyColor.Net
SexyColor.CommonComponents/Mvc/Utlity/Captcha/ICaptchaManager.cs
812
C#
/* * Farseer Physics Engine: * Copyright (c) 2012 Ian Qvist * * Original source Box2D: * Copyright (c) 2006-2011 Erin Catto http://www.box2d.org * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ using FarseerPhysics.Collision; using FarseerPhysics.Controllers; using FarseerPhysics.Dynamics.Contacts; using FarseerPhysics.Dynamics.Joints; namespace FarseerPhysics.Dynamics { /// <summary> /// This delegate is called when a contact is deleted /// </summary> public delegate void EndContactDelegate( Contact contact ); /// <summary> /// This delegate is called when a contact is created /// </summary> public delegate bool BeginContactDelegate( Contact contact ); public delegate void PreSolveDelegate( Contact contact, ref Manifold oldManifold ); public delegate void PostSolveDelegate( Contact contact, ContactVelocityConstraint impulse ); public delegate void FixtureDelegate( Fixture fixture ); public delegate void JointDelegate( Joint joint ); public delegate void BodyDelegate( Body body ); public delegate void ControllerDelegate( Controller controller ); public delegate bool CollisionFilterDelegate( Fixture fixtureA, Fixture fixtureB ); public delegate void BroadphaseDelegate( ref FixtureProxy proxyA, ref FixtureProxy proxyB ); public delegate bool BeforeCollisionEventHandler( Fixture fixtureA, Fixture fixtureB ); public delegate bool OnCollisionEventHandler( Fixture fixtureA, Fixture fixtureB, Contact contact ); public delegate void AfterCollisionEventHandler( Fixture fixtureA, Fixture fixtureB, Contact contact, ContactVelocityConstraint impulse ); public delegate void OnSeparationEventHandler( Fixture fixtureA, Fixture fixtureB ); }
38.369231
139
0.785084
[ "MIT" ]
AlmostBearded/monogame-platformer
Platformer/Nez/Nez.FarseerPhysics/Farseer/Dynamics/WorldCallbacks.cs
2,496
C#
/* * Copyright (C) Alibaba Cloud Computing * All rights reserved. * * 版权所有 (C)阿里云计算有限公司 */ using System; using System.Collections.Generic; using Aliyun.OpenServices.Properties; using Aliyun.OpenServices.OpenStorageService.Utilities; using Aliyun.OpenServices.Domain; namespace Aliyun.OpenServices.OpenStorageService { /// <summary> /// 获取List Multipart Upload的请求结果. /// </summary> public class MultipartUploadListing { private readonly IList<MultipartUpload> _multipartUploads = new List<MultipartUpload>(); private readonly IList<string> _commonPrefixes = new List<string>(); /// <summary> /// 获取Object所在的<see cref="Bucket" />的名称。 /// </summary> public string BucketName { get; internal set; } /// <summary> /// 获取请求参数<see cref="P:ListMultipartUploadsRequest.KeyMarker" />的值。 /// </summary> public string KeyMarker { get; internal set; } /// <summary> /// 获取请求参数<see cref="P:ListMultipartUploadsRequest.Delimiter" />的值。 /// </summary> public string Delimiter { get; internal set; } /// <summary> /// 获取请求参数<see cref="P:ListMultipartUploadsRequest.Prefix" />的值。 /// </summary> public string Prefix { get; internal set; } /// <summary> /// 获取请求参数<see cref="P:ListMultipartUploadsRequest.UploadIdMarker" />的值。 /// </summary> public string UploadIdMarker { get; internal set; } /// <summary> /// 获取请求参数<see cref="P:ListMultipartUploadsRequest.MaxUploads" />的值。 /// </summary> public int MaxUploads { get; internal set; } /// <summary> /// 标明是否本次返回的Multipart Upload结果列表被截断。 /// “true”表示本次没有返回全部结果; /// “false”表示本次已经返回了全部结果。 /// </summary> public bool IsTruncated { get; internal set; } /// <summary> /// 列表的起始Object位置。 /// </summary> public string NextKeyMarker { get; internal set; } /// <summary> /// 如果本次没有返回全部结果,响应请求中将包含NextUploadMarker元素,用于标明接下来请求的UploadMarker值。 /// </summary> public string NextUploadIdMarker { get; internal set; } /// <summary> /// 所有Multipart Upload事件 /// </summary> public IEnumerable<MultipartUpload> MultipartUploads { get { return _multipartUploads; } } /// <summary> /// 获取返回结果中的CommonPrefixes部分。 /// </summary> public IEnumerable<string> CommonPrefixes { get { return _commonPrefixes; } } public MultipartUploadListing(string bucketName) { if (string.IsNullOrEmpty(bucketName)) throw new ArgumentException(Resources.ExceptionIfArgumentStringIsNullOrEmpty, "bucketName"); if (!OssUtils.IsBucketNameValid(bucketName)) throw new ArgumentException(OssResources.BucketNameInvalid, "bucketName"); BucketName = bucketName; } internal void AddMultipartUpload(MultipartUpload multipartUpload) { _multipartUploads.Add(multipartUpload); } internal void AddCommonPrefix(string prefix) { _commonPrefixes.Add(prefix); } } }
32.425926
109
0.567105
[ "Apache-2.0" ]
chenxihoho/FirstFrame
007.FileIO/aliyun_dotnet_sdk_20150115/FileIO_ALIYUN/src/Domain/MultipartUploadListing.cs
3,870
C#
using System.Threading.Tasks; namespace OrchardCore.DisplayManagement.Liquid { public class LiquidPage : Razor.RazorPage<dynamic> { public override Task ExecuteAsync() => LiquidViewTemplate.RenderAsync(this); } }
23.4
84
0.739316
[ "BSD-3-Clause" ]
1051324354/OrchardCore
src/OrchardCore/OrchardCore.DisplayManagement.Liquid/LiquidPage.cs
234
C#
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.SignatureHelp { internal partial class Controller { internal override void OnTextViewBufferPostChanged(object sender, EventArgs args) { Retrigger(); } } }
28.882353
89
0.718941
[ "Apache-2.0" ]
HenrikWM/roslyn
src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Controller_OnTextViewBufferPostChanged.cs
493
C#
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using TerraExplorerX; using System.Xml.Linq; using System.IO; namespace skyline { public partial class Form1 : Form { private SGWorld65 sgworld; public Form1() { InitializeComponent(); sgworld = new SGWorld65(); } private void Form1_Load(object sender, EventArgs e) { } private void myScanTree() { try { var root = sgworld.ProjectTree.GetNextItem(string.Empty, ItemCode.ROOT); string a = sgworld.ProjectTree.GetItemName(root); string b = sgworld.ProjectTree.HiddenGroupName; BuildTreeRecursive(null, root); } catch (Exception ex) { MessageBox.Show("错误信息:" + ex.Message); } } private void BuildTreeRecursive(TreeNode node, String current) { while (String.IsNullOrEmpty(current)==false) { if (sgworld.ProjectTree.IsGroup(current)) { TreeNode groupnode = new TreeNode(); string gname = sgworld.ProjectTree.GetItemName(current); groupnode.Text = gname; if (node != null) { node.Nodes.Add(groupnode); } else { treeView1.Nodes.Add(groupnode); } var child = sgworld.ProjectTree.GetNextItem(current, ItemCode.CHILD); BuildTreeRecursive(groupnode, child); } else { var currentName = sgworld.ProjectTree.GetItemName(current); if (node == null) { treeView1.Nodes.Add(currentName); } else { node.Nodes.Add(currentName); } } current = sgworld.ProjectTree.GetNextItem(current, ItemCode.NEXT); } } private void buttonGetTree_Click(object sender, EventArgs e) { myScanTree(); } private void button2_Click(object sender, EventArgs e) { TreeNode node = treeView1.SelectedNode; if (node == null) { MessageBox.Show("请选择节点"); return; } String nodeName = node.Text; IFeatureLayer65 layer = sgworld.ProjectTree.GetLayerByName(nodeName); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "XML files(*.xml)|*.xml"; saveFileDialog.DefaultExt = "xml"; DialogResult result = saveFileDialog.ShowDialog(); if (result == DialogResult.OK) { XElement element = new XElement("Layer", new object[] { new XAttribute("Name", layer.TreeItem.Name), new XAttribute("IgnoreZ", layer.IgnoreZ), new XAttribute("Reproject", layer.Reproject), new XAttribute("Streaming", layer.Streaming) }); if (layer.FeatureGroups.Polygon != null) { XElement content = layer.FeatureGroups.Polygon.WriteXmlSchema(); content.Add(new XAttribute("Name", "Polygon")); element.Add(content); } if (layer.FeatureGroups.Annotation != null) { XElement content = layer.FeatureGroups.Annotation.WriteXmlSchema(); content.Add(new XAttribute("Name", "Annotation")); element.Add(content); } if (layer.FeatureGroups.Polyline != null) { XElement content = layer.FeatureGroups.Polyline.WriteXmlSchema(); content.Add(new XAttribute("Name", "Polyline")); element.Add(content); } if (layer.FeatureGroups.Point != null) { XElement content = layer.FeatureGroups.Point.WriteXmlSchema(); content.Add(new XAttribute("Name", "Point")); element.Add(content); } element.Save(saveFileDialog.FileName); } } private void ToolStripMenuItem2_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Filter = "FLY文件(*.fly)|*.fly"; DialogResult result = open.ShowDialog(); if (result == DialogResult.OK) { sgworld.Project.Open(open.FileName, true); } } private void ToolStripMenuItem3_Click(object sender, EventArgs e) { sgworld.Project.Close(); } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { sgworld.Project.Save(); } private void button3_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Filter = "SHP文件(*.shp)|*.shp"; DialogResult result = open.ShowDialog(); if (result == DialogResult.OK) { shpPath.Text = open.FileName; } } private void button4_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Filter = "XML文件(*.xml)|*.xml"; DialogResult result = open.ShowDialog(); if (result == DialogResult.OK) { XMLPath.Text = open.FileName; } } private void button5_Click(object sender, EventArgs e) { string spath = shpPath.Text; string xpath = XMLPath.Text; if (!File.Exists(spath)) { MessageBox.Show("shp文件不存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!File.Exists(xpath)) { MessageBox.Show("XML文件不存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string gid = sgworld.ProjectTree.FindOrCreateGroup("demo"); string tConnectionString = String.Format("FileName={0};TEPlugName=OGR;", spath); IFeatureLayer65 featurelayer = sgworld.Creator.CreateFeatureLayer(Path.GetFileNameWithoutExtension(spath), tConnectionString, gid); //featurelayer.Streaming = false; featurelayer.DataSourceInfo.Attributes.ImportAll = true; //featurelayer.Refresh(); string config = xpath; if (radioYes.Checked) { featurelayer.Annotation = true; } if (radioNo.Checked) { featurelayer.Annotation = false; } featurelayer.ReadXmlSchema(config); featurelayer.Refresh(); // ISGWorldExtentions.sgWorld.Navigate.FlyToGuiZhou(); } } }
33.738739
253
0.51215
[ "Apache-2.0" ]
xiangjg/vsskyline
skyline/Form1.cs
7,552
C#
namespace LinqPadless { using System; // Credit Stuart Lang and source: // https://stu.dev/defer-with-csharp8/ static class DeferDisposable { public static DeferDisposable<T> Defer<T>(T arg, Action<T> action) => new DeferDisposable<T>(arg, action); } readonly struct DeferDisposable<T> : IDisposable { readonly Action<T> _action; readonly T _arg; public DeferDisposable(T arg, Action<T> action) => (_action, _arg) = (action, arg); public void Dispose() => _action.Invoke(_arg); } }
24.416667
77
0.607509
[ "Apache-2.0" ]
atifaziz/LinqPadless
src/DeferDisposable.cs
586
C#
using $ext_safeprojectname$.Common; using $ext_safeprojectname$.Dependencies; using $safeprojectname$.Services; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.OpenApi.Models; namespace $safeprojectname$ { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSingleton<IPathAccessor, PathAccessor>(); services.AddLogging(); services.AddModuleDependencies(); services.AddMediatR(); services.AddAutoMapper(); services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "$safeprojectname$", Version = "v1" }); }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "$safeprojectname$ v1")); } app.AddExceptionHandlerMiddlewares(); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } }
30.390625
109
0.615424
[ "Unlicense", "MIT" ]
cedric-gruber/CQRS-Template
src/WebApp/Startup.cs
1,945
C#
//----------------------------------------------------------------------------- // Copyright : (c) Chris Moore, 2020 // License : MIT //----------------------------------------------------------------------------- namespace Z0 { using System; using System.Runtime.CompilerServices; using static Root; /// <summary> /// Defines a datatype that represents a rational number /// </summary> public struct Rational<T> : IRational<Rational<T>,T> { public T Over {get;} public T Under {get;} [MethodImpl(Inline)] public Rational(T over, T under) { Over = over; Under = under; } [MethodImpl(Inline)] public string Format() => string.Format($"{Over}/{Under}"); public override string ToString() => Format(); [MethodImpl(Inline)] public static implicit operator Rational<T>((T over, T under) src) => new Rational<T>(src.over, src.under); [MethodImpl(Inline)] public static implicit operator Rational<T>(Pair<T> src) => new Rational<T>(src.Left, src.Right); public static Rational<T> Undefined => default; public static Rational<T> Zero => (default(T), Numeric.force<T>(1)); } }
27.285714
79
0.483919
[ "BSD-3-Clause" ]
0xCM/z0
src/core/src/numeric/RationalT.cs
1,337
C#
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; using Windows.Storage; using Windows.UI.Xaml.Controls; namespace HoloLensCommander { /// <summary> /// Delegate defining the method signature for handling the AppInstalled event. /// </summary> /// <param name="sender">The object sending the event.</param> public delegate void AppInstalledEventHandler(DeviceMonitorControl sender); /// <summary> /// Delegate defining the method signature for handling the AppUninstalled event. /// </summary> /// <param name="sender">The object sending the event.</param> public delegate void AppUninstalledEventHandler(DeviceMonitorControl sender); /// <summary> /// Delegate defining the method signature for handling the DeviceDisconnected event. /// </summary> /// <param name="sender">The object sending the event.</param> public delegate void DeviceDisconnectedEventHandler(DeviceMonitorControl sender); /// <summary> /// Delegate defining the method signature for handling the IsSelectedChanged event. /// </summary> /// <param name="sender">The object sending the event.</param> public delegate void IsSelectionChangedEventHander(DeviceMonitorControl sender); /// <summary> /// Delegate defining the method signature for handling the TagChanged event. /// </summary> /// <param name="sender">The object sending the event.</param> public delegate void TagChangedEventHandler(DeviceMonitorControl sender); /// <summary> /// The class that implements the custom xaml control used to monitor a connected device. /// </summary> public sealed partial class DeviceMonitorControl : Page, IDisposable { /// <summary> /// Event that is sent when an application install has completed. /// </summary> public event AppInstalledEventHandler AppInstalled; /// <summary> /// Event that is sent when an application uninstall has completed. /// </summary> public event AppUninstalledEventHandler AppUninstalled; /// <summary> /// Event that is sent when the device has been disconnected. /// </summary> public event DeviceDisconnectedEventHandler DeviceDisconnected; /// <summary> /// Event that is sent when the device's selection state has been changed. /// </summary> public event IsSelectionChangedEventHander SelectedChanged; /// <summary> /// Event that is sent when the data tagged to the device has been changed. /// </summary> public event TagChangedEventHandler TagChanged; /// <summary> /// Gets this page's DataContext as the underlying object's type. /// </summary> internal DeviceMonitorControlViewModel ViewModel { get { return this.DataContext as DeviceMonitorControlViewModel; } } /// <summary> /// Initializes a new instance of the <see cref="DeviceMonitorControl" /> class. /// </summary> /// <param name="monitor">The DeviceMonitor that is responsible for communication with the device.</param> public DeviceMonitorControl( DeviceMonitor monitor) { this.DataContext = new DeviceMonitorControlViewModel( this, monitor); this.InitializeComponent(); } /// <summary> /// Finalizer so that we are assured we clean up all encapsulated resources. /// </summary> /// <remarks>Call Dispose on this object to avoid running the finalizer.</remarks> ~DeviceMonitorControl() { this.Dispose(); } /// <summary> /// Cleans up objects managed by the DeviceMonitorControl. /// </summary> /// <remarks> /// Failure to call this method will result in the object not being collected until /// finalization occurs. /// </remarks> public void Dispose() { try { this.ViewModel.Dispose(); } catch { // TODO: Investigate what causes this.DataContext to throw. } GC.SuppressFinalize(this); } /// <summary> /// Closes all applications running on this device. /// </summary> /// <returns>Task object used for tracking method completion.</returns> internal async Task CloseAllAppsAsync() { await this.ViewModel.CloseAllAppsAsync(); } /// <summary> /// Disconnect from this device. /// </summary> internal void Disconnect() { this.ViewModel.Disconnect(); } /// <summary> /// Queries the device for the names of all installed applications. /// </summary> /// <returns>List of application names.</returns> internal async Task<List<string>> GetInstalledAppNamesAsync() { return await this.ViewModel.GetInstalledAppNamesAsync(); } /// <summary> /// Downloads the mixed reality capture files on the device. /// </summary> /// <param name="parentFolder">The name of the folder in which to download the files.</param> /// <param name="deleteAfterDownload">True to remove the downloaded files from the device.</param> /// <returns>Task object used for tracking method completion.</returns> internal async Task GetMixedRealityFilesAsync( StorageFolder parentFolder, bool deleteAfterDownload) { await this.ViewModel.GetMixedRealityFilesAsync( parentFolder, deleteAfterDownload); } /// <summary> /// Installs an application on this device. /// </summary> /// <param name="installFiles">Object describing the file(s) required to install an application.</param> /// <returns>Task object used for tracking method completion.</returns> internal async Task InstallAppAsync(AppInstallFiles installFiles) { await this.ViewModel.InstallAppAsync(installFiles); } /// <summary> /// Launches an application on this device. /// </summary> /// <param name="appName">The name of the application to launch.</param> /// <returns>The process identifier of the running application.</returns> internal async Task<int> LaunchAppAsync(string appName) { return await this.ViewModel.LaunchAppAsync(appName); } /// <summary> /// Sends the AppIninstalled event to registered handlers. /// </summary> internal void NotifyAppInstall() { this.AppInstalled?.Invoke(this); } /// <summary> /// Sends the AppUninstalled event to registered handlers. /// </summary> internal void NotifyAppUninstall() { this.AppUninstalled?.Invoke(this); } /// <summary> /// Sends the Disconnected event to registered handlers. /// </summary> internal void NotifyDisconnected() { this.DeviceDisconnected?.Invoke(this); } /// <summary> /// Sends the SelectedChanged event to registered handlers. /// </summary> internal void NotifySelectedChanged() { this.SelectedChanged?.Invoke(this); } /// <summary> /// Sends the TagChanged event to registered handlers. /// </summary> internal void NotifyTagChanged() { this.TagChanged?.Invoke(this); } /// <summary> /// Reboots this device. /// </summary> /// <returns>Task object used for tracking method completion.</returns> internal async Task RebootAsync() { await this.ViewModel.RebootAsync(); } /// <summary> /// Shuts down this device. /// </summary> /// <returns>Task object used for tracking method completion.</returns> internal async Task ShutdownAsync() { await this.ViewModel.ShutdownAsync(); } /// <summary> /// Starts recording a mixed reality video on this device. /// </summary> /// <returns>Task object used for tracking method completion.</returns> internal async Task StartMixedRealityRecordingAsync() { await this.ViewModel.StartMixedRealityRecordingAsync(); } /// <summary> /// Stops thea mixed reality recording on this device. /// </summary> /// <returns>Task object used for tracking method completion.</returns> internal async Task StopMixedRealityRecordingAsync() { await this.ViewModel.StopMixedRealityRecordingAsync(); } /// <summary> /// Uninstalls an application on this device. /// </summary> /// <param name="appName">The name of the application to uninstall.</param> /// <returns>Task object used for tracking method completion.</returns> internal async Task UninstallAppAsync(string appName) { await this.ViewModel.UninstallAppAsync(appName); } /// <summary> /// Wipes camera roll contents on this device. /// </summary> /// <returns></returns> internal async Task WipeCameraRollAsync() { await this.ViewModel.WipeCameraRollAsync(); } /// <summary> /// Uninstalls all side loaded applications of this device. /// </summary> /// <returns></returns> internal async Task UninstallAllAppsAsync() { await this.ViewModel.UninstallAllAppsAsync(); } } }
34.955479
114
0.601156
[ "MIT" ]
OrangeLV/HoloLensCompanionKit
HoloLensCommander/HoloLensCommander/Controls/DeviceMonitorControl.xaml.cs
10,209
C#
using System; #if !NETFX_CORE namespace HelixToolkit.Wpf.SharpDX #else #if CORE namespace HelixToolkit.SharpDX.Core #else namespace HelixToolkit.UWP #endif #endif { using System.IO; using Utilities; using Model; public interface ITextureResourceManager : IDisposable { int Count { get; } /// <summary> /// Registers the specified texture stream. This creates mipmaps automatically /// </summary> /// <param name="textureStream">The texture stream.</param> /// <returns></returns> ShaderResourceViewProxy Register(TextureModel textureStream); /// <summary> /// Registers the specified texture stream. /// </summary> /// <param name="textureStream">The texture stream.</param> /// <param name="enableAutoGenMipMap">if set to <c>false</c> [disable automatic gen mip map].</param> /// <returns></returns> ShaderResourceViewProxy Register(TextureModel textureStream, bool enableAutoGenMipMap); } }
28.621622
109
0.641171
[ "MIT" ]
JeremyAnsel/helix-toolkit
Source/HelixToolkit.SharpDX.Shared/Interface/ITextureResourceManager.cs
1,061
C#
using System; using System.Collections.Generic; namespace DataRepository.Models.ELD.Prod { public partial class BrokerMaster { public BrokerMaster() { AcctTrans = new HashSet<AcctTrans>(); ArTrans = new HashSet<ArTrans>(); BrokerContact = new HashSet<BrokerContact>(); } public int BrokerId { get; set; } public int HouseId { get; set; } public string BrokerNo { get; set; } public string Link { get; set; } public string BrokerRegion { get; set; } public string VisitedRegion { get; set; } public string BrokerType { get; set; } public string BrokerName { get; set; } public string BrokerCity { get; set; } public string BrokerSta { get; set; } public string BrokerAddress { get; set; } public string BrokerAddress2 { get; set; } public string BrokerZip { get; set; } public string BrokerRank { get; set; } public double CommissionPct { get; set; } public string BillMethod { get; set; } public DateTime? SurplusLicExpDate { get; set; } public string SurplusApplied { get; set; } public DateTime? BrokerAssignedDate { get; set; } public DateTime? BrokerAgreementDate { get; set; } public bool? BrokerAgreementReceived { get; set; } public DateTime? LastAppReceived { get; set; } public string BrokerTaxId { get; set; } public string BrokerMasterPhone { get; set; } public string MarketingNotes { get; set; } public bool? Merged { get; set; } public bool? Hide { get; set; } public DateTime? LastChangedDate { get; set; } public string LastChangedId { get; set; } public byte[] RowVersion { get; set; } public long? PrmNo { get; set; } public string SlLicNo { get; set; } public string RelationshipManager { get; set; } public bool? IsTemporary { get; set; } public string Website { get; set; } public bool? IsHouse { get; set; } public string SalesForceLinkId { get; set; } public string EntryMethod { get; set; } public ICollection<AcctTrans> AcctTrans { get; set; } public ICollection<ArTrans> ArTrans { get; set; } public ICollection<BrokerContact> BrokerContact { get; set; } } }
41.474576
70
0.59338
[ "MIT" ]
nsiddiqui25/newAngProj
DataRepository-AffiliateInfo/Models/ELD/Prod/BrokerMaster.cs
2,449
C#
using System; using System.Collections.Generic; using GraphQL.Types; using Newtonsoft.Json.Linq; namespace GraphQL.Dynamic.Tests.Schemas { public class DynamicSampleRemoteSchema : Schema { public static string GithubMoniker = "github"; public DynamicSampleRemoteSchema(IEnumerable<Type> remoteTypes) { Query = new SampleRemoteSchemaRoot(remoteTypes); } public class SampleRemoteSchemaRoot : ObjectGraphType { public SampleRemoteSchemaRoot(IEnumerable<Type> remoteTypes) { this.RemoteField(remoteTypes, GithubMoniker, "GithubAPI", "githubDynamic", resolve: ctx => { // This is where we'd hypothetically return a JObject result from the remote server return JObject.FromObject(new { user = new { login = "foo@bar.com", id = 12, company = "some company", repos = new[] { new { id = 22, name = "qux" }, new { id = 52, name = "baz" } } } }); }); } } } }
32.173077
106
0.380753
[ "MIT" ]
elauffenburger/graphql-dotnet
src/GraphQL.Dynamic.Tests/Schemas/DynamicSampleRemoteSchema.cs
1,673
C#
using System; using System.Linq; using UnityEngine; using Vexe.Editor.Helpers; using Vexe.Editor.Windows; using Vexe.Editor.Types; using Vexe.Runtime.Extensions; using Vexe.Runtime.Types; using UnityObject = UnityEngine.Object; namespace Vexe.Editor.Drawers { public class SelectObjDrawer : AttributeDrawer<UnityObject, SelectObjAttribute> { public override void OnGUI() { using (gui.Horizontal()) { bool isNull = member.IsNull(); bool isObjectField = prefs[id]; gui.Text(displayText, isNull ? "null" : memberValue.name + " (" + memberTypeName + ")"); var fieldRect = gui.LastRect; { GUIHelper.PingField(fieldRect, memberValue, !isNull && isObjectField); } if (gui.SelectionButton("object")) { Func<UnityObject[], string, Tab> newTab = (values, title) => new Tab<UnityObject>( @getValues : () => values, @getCurrent : member.As<UnityObject>, @setTarget : member.Set, @getValueName : obj => obj.name, @title : title ); bool isGo = memberType == typeof(GameObject); SelectionWindow.Show("Select a " + memberTypeName, newTab(UnityObject.FindObjectsOfType(memberType), "All"), newTab(isGo ? (UnityObject[])gameObject.GetChildren() : gameObject.GetComponentsInChildren(memberType), "Children"), newTab(isGo ? (UnityObject[])gameObject.GetParents() : gameObject.GetComponentsInParent(memberType), "Parents"), newTab(isGo ? PrefabHelper.GetGameObjectPrefabs().ToArray() : PrefabHelper.GetComponentPrefabs(memberType).Cast<UnityObject>().ToArray(), "Prefabs") ); } } } } }
30.381818
94
0.661879
[ "MIT" ]
DanielPotter/VFW
Assets/VFW Deprecated/Editor/Drawers/SelectObjDrawer.cs
1,673
C#
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("SharpDB.Engine.Specs")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SharpDB.Engine.Specs")] [assembly: AssemblyCopyright("Copyright © 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("c50fd293-3157-4280-961e-cbb6bf5b0f4f")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
38.189189
84
0.745223
[ "MIT" ]
Polyhaze/SharpDB
src/SharpDB.Engine.Specs/Properties/AssemblyInfo.cs
1,416
C#
// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Linq; namespace Microsoft.Dnx.Runtime.Common.CommandLine { internal class CommandArgument { public CommandArgument() { Values = new List<string>(); } public string Name { get; set; } public string Description { get; set; } public List<string> Values { get; private set; } public bool MultipleValues { get; set; } public string Value { get { return Values.FirstOrDefault(); } } } }
26.566667
112
0.574655
[ "MIT" ]
sourcegraph/srclib-csharp
3rdparty/Microsoft.Framework.CommandLineUtils.Sources/1.0.0-rc1-15779/shared/CommandArgument.cs
797
C#
using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; using System.Text.RegularExpressions; using Microsoft.Recognizers.Definitions.English; namespace Microsoft.Recognizers.Text.Number.English { public class OrdinalExtractor : BaseNumberExtractor { private static readonly ConcurrentDictionary<string, OrdinalExtractor> Instances = new ConcurrentDictionary<string, OrdinalExtractor>(); private OrdinalExtractor() { var regexes = new Dictionary<Regex, TypeTag> { { new Regex(NumbersDefinitions.OrdinalSuffixRegex, RegexOptions.Singleline), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.NUMBER_SUFFIX) }, { new Regex(NumbersDefinitions.OrdinalNumericRegex, RegexOptions.Singleline), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.NUMBER_SUFFIX) }, { new Regex(NumbersDefinitions.OrdinalEnglishRegex, RegexOptions.Singleline), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.ENGLISH) }, { new Regex(NumbersDefinitions.OrdinalRoundNumberRegex, RegexOptions.Singleline), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.ENGLISH) }, }; Regexes = regexes.ToImmutableDictionary(); } internal sealed override ImmutableDictionary<Regex, TypeTag> Regexes { get; } protected sealed override string ExtractType { get; } = Constants.SYS_NUM_ORDINAL; // "Ordinal"; public static OrdinalExtractor GetInstance(string placeholder = "") { if (!Instances.ContainsKey(placeholder)) { var instance = new OrdinalExtractor(); Instances.TryAdd(placeholder, instance); } return Instances[placeholder]; } } }
40.054545
106
0.615978
[ "MIT" ]
ParadoxARG/Recognizers-Text
.NET/Microsoft.Recognizers.Text.Number/English/Extractors/OrdinalExtractor.cs
2,205
C#
using System; using System.Collections.Generic; using System.Linq; using KitchenPC.DB.Models; using KitchenPC.Ingredients; using KitchenPC.NLP; using NHibernate.Criterion; namespace KitchenPC.DB { public class IngredientLoader : ISynonymLoader<IngredientNode> { readonly DatabaseAdapter adapter; public IngredientLoader(DatabaseAdapter adapter) { this.adapter = adapter; } public IEnumerable<IngredientNode> LoadSynonyms() { using (var session = adapter.GetStatelessSession()) { var nodes = new Dictionary<Guid, IngredientNode>(); var ingsForNlp = session.QueryOver<Models.Ingredients>().List(); var pairingMap = session.QueryOver<NlpDefaultPairings>() .Fetch(prop => prop.WeightForm).Eager() .Fetch(prop => prop.VolumeForm).Eager() .Fetch(prop => prop.UnitForm).Eager() .List() .ToDictionary(p => p.Ingredient.IngredientId); foreach (var ing in ingsForNlp) { var ingId = ing.IngredientId; var name = ing.DisplayName; var convType = ing.ConversionType; Weight unitWeight = ing.UnitWeight; var pairings = new DefaultPairings(); NlpDefaultPairings defaultPairing; if (pairingMap.TryGetValue(ingId, out defaultPairing)) { if (defaultPairing.WeightForm != null) { var wfAmount = new Amount(defaultPairing.WeightForm.FormAmount, defaultPairing.WeightForm.FormUnit); pairings.Weight = new IngredientForm(defaultPairing.WeightForm.IngredientFormId, ingId, Units.Ounce, null, null, defaultPairing.WeightForm.ConvMultiplier, wfAmount); } if (defaultPairing.VolumeForm != null) { var vfAmount = new Amount(defaultPairing.VolumeForm.FormAmount, defaultPairing.VolumeForm.FormUnit); pairings.Volume = new IngredientForm(defaultPairing.VolumeForm.IngredientFormId, ingId, Units.Cup, null, null, defaultPairing.VolumeForm.ConvMultiplier, vfAmount); } if (defaultPairing.UnitForm != null) { var ufAmount = new Amount(defaultPairing.UnitForm.FormAmount, defaultPairing.UnitForm.FormUnit); pairings.Unit = new IngredientForm(defaultPairing.UnitForm.IngredientFormId, ingId, Units.Unit, null, null, defaultPairing.UnitForm.ConvMultiplier, ufAmount); } } if (nodes.ContainsKey(ingId)) { Parser.Log.ErrorFormat("[NLP Loader] Duplicate ingredient key due to bad DB data: {0} ({1})", name, ingId); } else { nodes.Add(ingId, new IngredientNode(ingId, name, convType, unitWeight, pairings)); } } //Load synonyms var ingSynonyms = session.QueryOver<NlpIngredientSynonyms>().List(); var ret = new List<IngredientNode>(); foreach (var syn in ingSynonyms) { var ingId = syn.Ingredient.IngredientId; var alias = syn.Alias; var prepnote = syn.Prepnote; IngredientNode node; if (nodes.TryGetValue(ingId, out node)) //TODO: If this fails, maybe throw an exception? { ret.Add(new IngredientNode(node, alias, prepnote)); } } ret.AddRange(nodes.Values); return ret; } } public Pairings LoadFormPairings() { throw new NotImplementedException(); } } }
38.813725
187
0.558727
[ "MIT" ]
KitchenPC/core
src/DB/NLP/IngredientLoader.cs
3,959
C#
/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections; using System.Collections.Generic; using MongoDB.Bson.IO; using MongoDB.Bson.Serialization.Options; namespace MongoDB.Bson.Serialization.Serializers { /// <summary> /// Represents a serializer for dictionaries. /// </summary> /// <typeparam name="TDictionary">The type of the dictionary.</typeparam> public abstract class DictionarySerializerBase<TDictionary> : ClassSerializerBase<TDictionary>, IBsonDocumentSerializer, IBsonDictionarySerializer where TDictionary : class, IDictionary { // private constants private static class Flags { public const long Key = 1; public const long Value = 2; } // private fields private readonly DictionaryRepresentation _dictionaryRepresentation; private readonly SerializerHelper _helper; private readonly IBsonSerializer _keySerializer; private readonly IBsonSerializer _valueSerializer; // constructors /// <summary> /// Initializes a new instance of the <see cref="DictionarySerializerBase{TDictionary}"/> class. /// </summary> public DictionarySerializerBase() : this(DictionaryRepresentation.Document) { } /// <summary> /// Initializes a new instance of the <see cref="DictionarySerializerBase{TDictionary}"/> class. /// </summary> /// <param name="dictionaryRepresentation">The dictionary representation.</param> public DictionarySerializerBase(DictionaryRepresentation dictionaryRepresentation) : this(dictionaryRepresentation, new ObjectSerializer(), new ObjectSerializer()) { } /// <summary> /// Initializes a new instance of the <see cref="DictionarySerializerBase{TDictionary}"/> class. /// </summary> /// <param name="dictionaryRepresentation">The dictionary representation.</param> /// <param name="keySerializer">The key serializer.</param> /// <param name="valueSerializer">The value serializer.</param> public DictionarySerializerBase(DictionaryRepresentation dictionaryRepresentation, IBsonSerializer keySerializer, IBsonSerializer valueSerializer) { _dictionaryRepresentation = dictionaryRepresentation; _keySerializer = keySerializer; _valueSerializer = valueSerializer; _helper = new SerializerHelper ( new SerializerHelper.Member("k", Flags.Key), new SerializerHelper.Member("v", Flags.Value) ); } // public properties /// <summary> /// Gets the dictionary representation. /// </summary> /// <value> /// The dictionary representation. /// </value> public DictionaryRepresentation DictionaryRepresentation { get { return _dictionaryRepresentation; } } /// <summary> /// Gets the key serializer. /// </summary> /// <value> /// The key serializer. /// </value> public IBsonSerializer KeySerializer { get { return _keySerializer; } } /// <summary> /// Gets the value serializer. /// </summary> /// <value> /// The value serializer. /// </value> public IBsonSerializer ValueSerializer { get { return _valueSerializer; } } // public methods /// <inheritdoc/> public bool TryGetMemberSerializationInfo(string memberName, out BsonSerializationInfo serializationInfo) { if (_dictionaryRepresentation != DictionaryRepresentation.Document) { serializationInfo = null; return false; } serializationInfo = new BsonSerializationInfo( memberName, _valueSerializer, _valueSerializer.ValueType); return true; } // protected methods /// <summary> /// Deserializes a value. /// </summary> /// <param name="context">The deserialization context.</param> /// <param name="args">The deserialization args.</param> /// <returns>A deserialized value.</returns> protected override TDictionary DeserializeValue(BsonDeserializationContext context, BsonDeserializationArgs args) { var bsonReader = context.Reader; var bsonType = bsonReader.GetCurrentBsonType(); switch (bsonType) { case BsonType.Array: return DeserializeArrayRepresentation(context); case BsonType.Document: return DeserializeDocumentRepresentation(context); default: throw CreateCannotDeserializeFromBsonTypeException(bsonType); } } /// <summary> /// Serializes a value. /// </summary> /// <param name="context">The serialization context.</param> /// <param name="args">The serialization args.</param> /// <param name="value">The object.</param> protected override void SerializeValue(BsonSerializationContext context, BsonSerializationArgs args, TDictionary value) { var bsonWriter = context.Writer; switch (_dictionaryRepresentation) { case DictionaryRepresentation.Document: SerializeDocumentRepresentation(context, value); break; case DictionaryRepresentation.ArrayOfArrays: SerializeArrayOfArraysRepresentation(context, value); break; case DictionaryRepresentation.ArrayOfDocuments: SerializeArrayOfDocumentsRepresentation(context, value); break; default: var message = string.Format("'{0}' is not a valid IDictionary representation.", _dictionaryRepresentation); throw new BsonSerializationException(message); } } // protected methods /// <summary> /// Creates the instance. /// </summary> /// <returns>The instance.</returns> protected abstract TDictionary CreateInstance(); // private methods private TDictionary DeserializeArrayRepresentation(BsonDeserializationContext context) { var dictionary = CreateInstance(); var bsonReader = context.Reader; bsonReader.ReadStartArray(); while (bsonReader.ReadBsonType() != BsonType.EndOfDocument) { object key; object value; var bsonType = bsonReader.GetCurrentBsonType(); switch (bsonType) { case BsonType.Array: bsonReader.ReadStartArray(); key = _keySerializer.Deserialize(context); value = _valueSerializer.Deserialize(context); bsonReader.ReadEndArray(); break; case BsonType.Document: key = null; value = null; _helper.DeserializeMembers(context, (elementName, flag) => { switch (flag) { case Flags.Key: key = _keySerializer.Deserialize(context); break; case Flags.Value: value = _valueSerializer.Deserialize(context); break; } }); break; default: throw CreateCannotDeserializeFromBsonTypeException(bsonType); } dictionary.Add(key, value); } bsonReader.ReadEndArray(); return dictionary; } private TDictionary DeserializeDocumentRepresentation(BsonDeserializationContext context) { var dictionary = CreateInstance(); var bsonReader = context.Reader; bsonReader.ReadStartDocument(); while (bsonReader.ReadBsonType() != BsonType.EndOfDocument) { var key = DeserializeKeyString(bsonReader.ReadName()); var value = _valueSerializer.Deserialize(context); dictionary.Add(key, value); } bsonReader.ReadEndDocument(); return dictionary; } private object DeserializeKeyString(string keyString) { var keyDocument = new BsonDocument("k", keyString); using (var keyReader = new BsonDocumentReader(keyDocument)) { var context = BsonDeserializationContext.CreateRoot(keyReader); keyReader.ReadStartDocument(); keyReader.ReadName("k"); var key = _keySerializer.Deserialize(context); keyReader.ReadEndDocument(); return key; } } private void SerializeArrayOfArraysRepresentation(BsonSerializationContext context, TDictionary value) { var bsonWriter = context.Writer; bsonWriter.WriteStartArray(); foreach (DictionaryEntry dictionaryEntry in value) { bsonWriter.WriteStartArray(); _keySerializer.Serialize(context, dictionaryEntry.Key); _valueSerializer.Serialize(context, dictionaryEntry.Value); bsonWriter.WriteEndArray(); } bsonWriter.WriteEndArray(); } private void SerializeArrayOfDocumentsRepresentation(BsonSerializationContext context, TDictionary value) { var bsonWriter = context.Writer; bsonWriter.WriteStartArray(); foreach (DictionaryEntry dictionaryEntry in value) { bsonWriter.WriteStartDocument(); bsonWriter.WriteName("k"); _keySerializer.Serialize(context, dictionaryEntry.Key); bsonWriter.WriteName("v"); _valueSerializer.Serialize(context, dictionaryEntry.Value); bsonWriter.WriteEndDocument(); } bsonWriter.WriteEndArray(); } private void SerializeDocumentRepresentation(BsonSerializationContext context, TDictionary value) { var bsonWriter = context.Writer; bsonWriter.WriteStartDocument(); foreach (DictionaryEntry dictionaryEntry in value) { bsonWriter.WriteName(SerializeKeyString(dictionaryEntry.Key)); _valueSerializer.Serialize(context, dictionaryEntry.Value); } bsonWriter.WriteEndDocument(); } private string SerializeKeyString(object key) { var keyDocument = new BsonDocument(); using (var keyWriter = new BsonDocumentWriter(keyDocument)) { var context = BsonSerializationContext.CreateRoot(keyWriter); keyWriter.WriteStartDocument(); keyWriter.WriteName("k"); _keySerializer.Serialize(context, key); keyWriter.WriteEndDocument(); } var keyValue = keyDocument["k"]; if (keyValue.BsonType != BsonType.String) { throw new BsonSerializationException("When using DictionaryRepresentation.Document key values must serialize as strings."); } return (string)keyValue; } } /// <summary> /// Represents a serializer for dictionaries. /// </summary> /// <typeparam name="TDictionary">The type of the dictionary.</typeparam> /// <typeparam name="TKey">The type of the keys.</typeparam> /// <typeparam name="TValue">The type of the values.</typeparam> public abstract class DictionarySerializerBase<TDictionary, TKey, TValue> : ClassSerializerBase<TDictionary>, IBsonArraySerializer, IBsonDocumentSerializer, IBsonDictionarySerializer where TDictionary : class, IEnumerable<KeyValuePair<TKey, TValue>> { // private constants private static class Flags { public const long Key = 1; public const long Value = 2; } // private fields private readonly DictionaryRepresentation _dictionaryRepresentation; private readonly SerializerHelper _helper; private readonly Lazy<IBsonSerializer<TKey>> _lazyKeySerializer; private readonly Lazy<IBsonSerializer<TValue>> _lazyValueSerializer; // constructors /// <summary> /// Initializes a new instance of the <see cref="DictionarySerializerBase{TDictionary, TKey, TValue}"/> class. /// </summary> public DictionarySerializerBase() : this(DictionaryRepresentation.Document) { } /// <summary> /// Initializes a new instance of the <see cref="DictionarySerializerBase{TDictionary, TKey, TValue}" /> class. /// </summary> /// <param name="dictionaryRepresentation">The dictionary representation.</param> public DictionarySerializerBase(DictionaryRepresentation dictionaryRepresentation) : this(dictionaryRepresentation, BsonSerializer.SerializerRegistry) { } /// <summary> /// Initializes a new instance of the <see cref="DictionarySerializerBase{TDictionary, TKey, TValue}" /> class. /// </summary> /// <param name="dictionaryRepresentation">The dictionary representation.</param> /// <param name="keySerializer">The key serializer.</param> /// <param name="valueSerializer">The value serializer.</param> public DictionarySerializerBase(DictionaryRepresentation dictionaryRepresentation, IBsonSerializer<TKey> keySerializer, IBsonSerializer<TValue> valueSerializer) : this( dictionaryRepresentation, new Lazy<IBsonSerializer<TKey>>(() => keySerializer), new Lazy<IBsonSerializer<TValue>>(() => valueSerializer)) { if (keySerializer == null) { throw new ArgumentNullException("keySerializer"); } if (valueSerializer == null) { throw new ArgumentNullException("valueSerializer"); } } /// <summary> /// Initializes a new instance of the <see cref="DictionarySerializerBase{TDictionary, TKey, TValue}" /> class. /// </summary> /// <param name="dictionaryRepresentation">The dictionary representation.</param> /// <param name="serializerRegistry">The serializer registry.</param> public DictionarySerializerBase(DictionaryRepresentation dictionaryRepresentation, IBsonSerializerRegistry serializerRegistry) : this( dictionaryRepresentation, new Lazy<IBsonSerializer<TKey>>(() => serializerRegistry.GetSerializer<TKey>()), new Lazy<IBsonSerializer<TValue>>(() => serializerRegistry.GetSerializer<TValue>())) { if (serializerRegistry == null) { throw new ArgumentNullException("serializerRegistry"); } } private DictionarySerializerBase( DictionaryRepresentation dictionaryRepresentation, Lazy<IBsonSerializer<TKey>> lazyKeySerializer, Lazy<IBsonSerializer<TValue>> lazyValueSerializer) { _dictionaryRepresentation = dictionaryRepresentation; _lazyKeySerializer = lazyKeySerializer; _lazyValueSerializer = lazyValueSerializer; _helper = new SerializerHelper ( new SerializerHelper.Member("k", Flags.Key), new SerializerHelper.Member("v", Flags.Value) ); } // public properties /// <summary> /// Gets the dictionary representation. /// </summary> /// <value> /// The dictionary representation. /// </value> public DictionaryRepresentation DictionaryRepresentation { get { return _dictionaryRepresentation; } } /// <summary> /// Gets the key serializer. /// </summary> /// <value> /// The key serializer. /// </value> public IBsonSerializer<TKey> KeySerializer { get { return _lazyKeySerializer.Value; } } /// <summary> /// Gets the value serializer. /// </summary> /// <value> /// The value serializer. /// </value> public IBsonSerializer<TValue> ValueSerializer { get { return _lazyValueSerializer.Value; } } // public methods /// <inheritdoc/> public bool TryGetItemSerializationInfo(out BsonSerializationInfo serializationInfo) { if (_dictionaryRepresentation != DictionaryRepresentation.ArrayOfDocuments) { serializationInfo = null; return false; } var serializer = new KeyValuePairSerializer<TKey, TValue>( BsonType.Document, _lazyKeySerializer.Value, _lazyValueSerializer.Value); serializationInfo = new BsonSerializationInfo( null, serializer, serializer.ValueType); return true; } /// <inheritdoc/> public bool TryGetMemberSerializationInfo(string memberName, out BsonSerializationInfo serializationInfo) { if (_dictionaryRepresentation != DictionaryRepresentation.Document) { serializationInfo = null; return false; } serializationInfo = new BsonSerializationInfo( memberName, _lazyValueSerializer.Value, _lazyValueSerializer.Value.ValueType); return true; } // protected methods /// <summary> /// Deserializes a value. /// </summary> /// <param name="context">The deserialization context.</param> /// <param name="args">The deserialization args.</param> /// <returns>A deserialized value.</returns> protected override TDictionary DeserializeValue(BsonDeserializationContext context, BsonDeserializationArgs args) { var bsonReader = context.Reader; var bsonType = bsonReader.GetCurrentBsonType(); switch (bsonType) { case BsonType.Array: return DeserializeArrayRepresentation(context); case BsonType.Document: return DeserializeDocumentRepresentation(context); default: throw CreateCannotDeserializeFromBsonTypeException(bsonType); } } /// <summary> /// Serializes a value. /// </summary> /// <param name="context">The serialization context.</param> /// <param name="args">The serialization args.</param> /// <param name="value">The object.</param> protected override void SerializeValue(BsonSerializationContext context, BsonSerializationArgs args, TDictionary value) { var bsonWriter = context.Writer; switch (_dictionaryRepresentation) { case DictionaryRepresentation.Document: SerializeDocumentRepresentation(context, value); break; case DictionaryRepresentation.ArrayOfArrays: SerializeArrayOfArraysRepresentation(context, value); break; case DictionaryRepresentation.ArrayOfDocuments: SerializeArrayOfDocumentsRepresentation(context, value); break; default: var message = string.Format("'{0}' is not a valid IDictionary<{1}, {2}> representation.", _dictionaryRepresentation, BsonUtils.GetFriendlyTypeName(typeof(TKey)), BsonUtils.GetFriendlyTypeName(typeof(TValue))); throw new BsonSerializationException(message); } } // protected methods /// <summary> /// Creates an accumulator. /// </summary> /// <returns>The accumulator.</returns> protected virtual ICollection<KeyValuePair<TKey, TValue>> CreateAccumulator() { #pragma warning disable 618 return (ICollection<KeyValuePair<TKey, TValue>>)CreateInstance(); #pragma warning restore 618 } // protected methods /// <summary> /// Creates the instance. /// </summary> /// <returns>The instance.</returns> [Obsolete("CreateInstance is deprecated. Please use CreateAccumulator instead.")] protected virtual TDictionary CreateInstance() { throw new NotImplementedException(); } /// <summary> /// Finalizes an accumulator. /// </summary> /// <param name="accumulator">The accumulator to finalize</param> /// <returns>The instance.</returns> protected virtual TDictionary FinalizeAccumulator(ICollection<KeyValuePair<TKey, TValue>> accumulator) { return (TDictionary)accumulator; } // private methods private TDictionary DeserializeArrayRepresentation(BsonDeserializationContext context) { var accumulator = CreateAccumulator(); var bsonReader = context.Reader; bsonReader.ReadStartArray(); while (bsonReader.ReadBsonType() != BsonType.EndOfDocument) { TKey key; TValue value; var bsonType = bsonReader.GetCurrentBsonType(); switch (bsonType) { case BsonType.Array: bsonReader.ReadStartArray(); key = _lazyKeySerializer.Value.Deserialize(context); value = _lazyValueSerializer.Value.Deserialize(context); bsonReader.ReadEndArray(); break; case BsonType.Document: key = default(TKey); value = default(TValue); _helper.DeserializeMembers(context, (elementName, flag) => { switch (flag) { case Flags.Key: key = _lazyKeySerializer.Value.Deserialize(context); break; case Flags.Value: value = _lazyValueSerializer.Value.Deserialize(context); break; } }); break; default: throw CreateCannotDeserializeFromBsonTypeException(bsonType); } accumulator.Add(new KeyValuePair<TKey, TValue>(key, value)); } bsonReader.ReadEndArray(); return FinalizeAccumulator(accumulator); } private TDictionary DeserializeDocumentRepresentation(BsonDeserializationContext context) { var accumulator = CreateAccumulator(); var bsonReader = context.Reader; bsonReader.ReadStartDocument(); while (bsonReader.ReadBsonType() != BsonType.EndOfDocument) { var key = DeserializeKeyString(bsonReader.ReadName()); var value = _lazyValueSerializer.Value.Deserialize(context); accumulator.Add(new KeyValuePair<TKey, TValue>(key, value)); } bsonReader.ReadEndDocument(); return FinalizeAccumulator(accumulator); } private TKey DeserializeKeyString(string keyString) { var keyDocument = new BsonDocument("k", keyString); using (var keyReader = new BsonDocumentReader(keyDocument)) { var context = BsonDeserializationContext.CreateRoot(keyReader); keyReader.ReadStartDocument(); keyReader.ReadName("k"); var key = _lazyKeySerializer.Value.Deserialize(context); keyReader.ReadEndDocument(); return key; } } private void SerializeArrayOfArraysRepresentation(BsonSerializationContext context, TDictionary value) { var bsonWriter = context.Writer; bsonWriter.WriteStartArray(); foreach (var keyValuePair in value) { bsonWriter.WriteStartArray(); _lazyKeySerializer.Value.Serialize(context, keyValuePair.Key); _lazyValueSerializer.Value.Serialize(context, keyValuePair.Value); bsonWriter.WriteEndArray(); } bsonWriter.WriteEndArray(); } private void SerializeArrayOfDocumentsRepresentation(BsonSerializationContext context, TDictionary value) { var bsonWriter = context.Writer; bsonWriter.WriteStartArray(); foreach (var keyValuePair in value) { bsonWriter.WriteStartDocument(); bsonWriter.WriteName("k"); _lazyKeySerializer.Value.Serialize(context, keyValuePair.Key); bsonWriter.WriteName("v"); _lazyValueSerializer.Value.Serialize(context, keyValuePair.Value); bsonWriter.WriteEndDocument(); } bsonWriter.WriteEndArray(); } private void SerializeDocumentRepresentation(BsonSerializationContext context, TDictionary value) { var bsonWriter = context.Writer; bsonWriter.WriteStartDocument(); foreach (var keyValuePair in value) { bsonWriter.WriteName(SerializeKeyString(keyValuePair.Key)); _lazyValueSerializer.Value.Serialize(context, keyValuePair.Value); } bsonWriter.WriteEndDocument(); } private string SerializeKeyString(TKey key) { var keyDocument = new BsonDocument(); using (var keyWriter = new BsonDocumentWriter(keyDocument)) { var context = BsonSerializationContext.CreateRoot(keyWriter); keyWriter.WriteStartDocument(); keyWriter.WriteName("k"); _lazyKeySerializer.Value.Serialize(context, key); keyWriter.WriteEndDocument(); } var keyValue = keyDocument["k"]; if (keyValue.BsonType != BsonType.String) { throw new BsonSerializationException("When using DictionaryRepresentation.Document key values must serialize as strings."); } return (string)keyValue; } // explicit interface implementations IBsonSerializer IBsonDictionarySerializer.KeySerializer { get { return KeySerializer; } } IBsonSerializer IBsonDictionarySerializer.ValueSerializer { get { return ValueSerializer; } } } }
38.349462
168
0.580822
[ "MIT" ]
AlianBlank/DCET
Unity/Packages/MongoDB/Runtime/MongoDB.Bson/Serialization/Serializers/DictionarySerializerBase.cs
28,534
C#
using MiCake.Core.Util.Collections; using System; using System.Collections.Generic; using System.Linq; using Xunit; namespace MiCake.Core.Tests.Util { public class ListExtension_Tests { public ListExtension_Tests() { } [Fact] public void ListExchangeOrderUsePredicate_ShouldRightOrder() { List<string> strList = new List<string>() { "A", "B", "C" }; strList.ExchangeOrder(s => s.Equals("B"), strList.Count - 1); Assert.Equal("B", strList.Last()); } [Fact] public void ListExchangeOrder_ShouldRightOrder() { List<string> strList = new List<string>() { "A", "B", "C" }; strList.ExchangeOrder("B", strList.Count - 1); Assert.Equal("B", strList.Last()); } [Fact] public void ListExchangeOrder_WrongPredictShoudError() { List<string> strList = new List<string>() { "A", "B", "C" }; Assert.Throws<ArgumentException>(() => { strList.ExchangeOrder(s => s.Equals("D"), strList.Count - 1); }); } } }
24.354167
77
0.540633
[ "MIT" ]
wrsxinlang/MiCake
src/tests/MiCake.Core.Util.Tests/ListExtension_Tests.cs
1,171
C#
using BookingsApi.Contract.Requests.Enums; namespace BookingsApi.Contract.Requests { public class UpdateBookingStatusRequest { /// <summary> /// The user requesting to update the status /// </summary> public string UpdatedBy { get; set; } /// <summary> /// New status of the hearing /// </summary> public UpdateBookingStatus Status { get; set; } /// <summary> /// The reason for cancelling the video hearing /// </summary> public string CancelReason { get; set; } } }
23.48
55
0.575809
[ "MIT" ]
hmcts/vh-bookings-api
BookingsApi/BookingsApi.Contract/Requests/UpdateBookingStatusRequest.cs
589
C#
using System; using System.Collections.Generic; using System.Text; namespace OxfordDictionariesAPI.Models { public class Metadata { public string Provider { get; set; } } public class GrammaticalFeature { public string Text { get; set; } public string Type { get; set; } } public class Example { public string Text { get; set; } } public class Subsense { public string[] Definitions { get; set; } public string[] Examples { get; set; } public string Id { get; set; } public string[] Domains { get; set; } public string[] Regions { get; set; } public string[] Registers { get; set; } } public class Sense { public string[] Definitions { get; set; } public string[] Domains { get; set; } public string[] Examples { get; set; } public string Id { get; set; } public Subsense[] Subsenses { get; set; } public string[] Registers { get; set; } } public class Entry { public GrammaticalFeature[] GrammaticalFeatures { get; set; } public string HomographNumber { get; set; } public Sense[] Senses { get; set; } public string[] Etymologies { get; set; } } public class Pronunciation { public string AudioFile { get; set; } public string[] Dialects { get; set; } public string PhoneticNotation { get; set; } public string PhoneticSpelling { get; set; } } public class LexicalEntry { public Entry[] Entries { get; set; } public string Language { get; set; } public string LexicalCategory { get; set; } public Pronunciation[] Pronunciations { get; set; } public string Text { get; set; } } public class Result { public string Id { get; set; } public string Language { get; set; } public LexicalEntry[] LexicalEntries { get; set; } public string Type { get; set; } public string Word { get; set; } } public class SearchResult { public Metadata Metadata { get; set; } public Result[] Results { get; set; } } }
26.686747
69
0.575621
[ "MIT" ]
witoong623/OxfordDictionariesAPI
OxfordDictionariesAPI/Models/Models.cs
2,217
C#
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace SimpleToDo.Data.Migrations { public partial class CreateIdentitySchema : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column<string>(nullable: false), ConcurrencyStamp = table.Column<string>(nullable: true), Name = table.Column<string>(maxLength: 256, nullable: true), NormalizedName = table.Column<string>(maxLength: 256, nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column<string>(nullable: false), LoginProvider = table.Column<string>(nullable: false), Name = table.Column<string>(nullable: false), Value = table.Column<string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); }); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column<string>(nullable: false), AccessFailedCount = table.Column<int>(nullable: false), ConcurrencyStamp = table.Column<string>(nullable: true), Email = table.Column<string>(maxLength: 256, nullable: true), EmailConfirmed = table.Column<bool>(nullable: false), LockoutEnabled = table.Column<bool>(nullable: false), LockoutEnd = table.Column<DateTimeOffset>(nullable: true), NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true), NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true), PasswordHash = table.Column<string>(nullable: true), PhoneNumber = table.Column<string>(nullable: true), PhoneNumberConfirmed = table.Column<bool>(nullable: false), SecurityStamp = table.Column<string>(nullable: true), TwoFactorEnabled = table.Column<bool>(nullable: false), UserName = table.Column<string>(maxLength: 256, nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column<int>(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), ClaimType = table.Column<string>(nullable: true), ClaimValue = table.Column<string>(nullable: true), RoleId = table.Column<string>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column<int>(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), ClaimType = table.Column<string>(nullable: true), ClaimValue = table.Column<string>(nullable: true), UserId = table.Column<string>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column<string>(nullable: false), ProviderKey = table.Column<string>(nullable: false), ProviderDisplayName = table.Column<string>(nullable: true), UserId = table.Column<string>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column<string>(nullable: false), RoleId = table.Column<string>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName"); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_UserId", table: "AspNetUserRoles", column: "UserId"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "AspNetUsers", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", unique: true); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AspNetRoleClaims"); migrationBuilder.DropTable( name: "AspNetUserClaims"); migrationBuilder.DropTable( name: "AspNetUserLogins"); migrationBuilder.DropTable( name: "AspNetUserRoles"); migrationBuilder.DropTable( name: "AspNetUserTokens"); migrationBuilder.DropTable( name: "AspNetRoles"); migrationBuilder.DropTable( name: "AspNetUsers"); } } }
42.018182
122
0.501731
[ "MIT" ]
RipplerEs/SimpleToDo
src/SimpleToDo/Data/Migrations/00000000000000_CreateIdentitySchema.cs
9,246
C#
using System; using lm.Comol.Core.DomainModel; using lm.Comol.Core.Authentication; namespace lm.Comol.Core.BaseModules.AuthenticationManagement.Presentation { public interface IViewUserLogout : IViewBaseAuthenticationPages { lm.Comol.Core.DomainModel.Helpers.dtoLoginCookie UserAccessInfo { get; } Boolean IsShibbolethSessionActive(string key); void LoadInternalLoginPage(); void LoadExternalProviderPage(String url); void LoadLogoutMessage( LogoutMode mode,AuthenticationProviderType type, String destinationUrl); //void LoadOldAuthenticationPage(int idAuthenticationType); void GoToDefaultPage(); void LoadLanguage(Language language); } }
42.176471
104
0.758717
[ "MIT" ]
EdutechSRL/Adevico
3-Business/3-Modules/lm.Comol.Core.BaseModules/AuthenticationManagement/Presentation/Access/View/IViewUserLogout.cs
719
C#
// Copyright (c) Xenko contributors (https://xenko.com) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) // Distributed under the MIT license. See the LICENSE.md file in the project root for more information. using Xenko.Core.Assets; using Xenko.Core.Assets.Compiler; using Xenko.Animations; using Xenko.Assets.Models; namespace Xenko.Editor.Preview { [AssetCompiler(typeof(AnimationAsset), typeof(EditorGameCompilationContext))] public class AnimationAssetEditorGameCompiler : AssetCompilerBase { protected override void Prepare(AssetCompilerContext context, AssetItem assetItem, string targetUrlInStorage, AssetCompilerResult result) { result.BuildSteps.Add(new DummyAssetCommand<AnimationAsset, AnimationClip>(assetItem)); } } }
41.842105
145
0.76478
[ "MIT" ]
Aminator/xenko
sources/editor/Xenko.Editor/Preview/AnimationAssetEditorGameCompiler.cs
795
C#
using Easy_Password_Validator.Interfaces; using Easy_Password_Validator.Models; using Easy_Password_Validator.Properties; using System; using System.Collections.Generic; using System.Linq; namespace Easy_Password_Validator.Tests { /// <summary> /// Checks to see whether a password meets the maximum neighboring characters requirements /// </summary> public class TestPattern : IPasswordTest { /// <summary> /// Prepares test for use and allows using custom pattern /// </summary> /// <param name="passwordRequirements">Object containing current settings</param> /// <param name="map">An optional custom pattern mapping to check</param> public TestPattern(IPasswordRequirements passwordRequirements, List<PatternMapItem> map = null) { Settings = passwordRequirements; PatternMap = map ?? PatternMapService.QwertyMap; } /// <inheritdoc/> public int ScoreModifier { get; set; } /// <inheritdoc/> public string FailureMessage { get; set; } /// <inheritdoc/> public IPasswordRequirements Settings { get; set; } /// <inheritdoc/> public IEnumerable<string> BadList { get; set; } /// <inheritdoc/> public List<PatternMapItem> PatternMap { get; set; } /// <inheritdoc/> public bool TestAndScore(string password) { // Reset FailureMessage = null; ScoreModifier = 0; // Check for inactive if (Settings.MaxNeighboringCharacter < 1) return true; // Do work var patterns = PatternMapService.GetPatterns(password, PatternMap); // Adjust score ScoreModifier = patterns.Sum(x => -(int)Math.Pow(2, x.Length)); // Return result var pass = patterns.Any(x => x.Length > Settings.MaxNeighboringCharacter) == false; if (pass == false) FailureMessage = string.Format(Resources.FailedPattern, Settings.MaxNeighboringCharacter); return pass; } } }
31.728571
107
0.592076
[ "MIT" ]
thirstyape/Easy-Password-Validator
Tests/TestPattern.cs
2,223
C#
using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace Lykke.Job.SlackNotifications.Services { internal sealed class HttpRequestClient { private static readonly HttpClient _instance = new HttpClient(); // Explicit static constructor to tell C# compiler // not to mark type as beforefieldinit static HttpRequestClient() { _instance.DefaultRequestHeaders.Accept.Clear(); _instance.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } HttpRequestClient(){} public static async Task<string> PostRequest(string json, string url) { var content = new StringContent(json, Encoding.UTF8, "application/json"); var response = await _instance.PostAsync(url, content); return await response.Content.ReadAsStringAsync(); } } }
32.266667
112
0.676653
[ "MIT" ]
LykkeCity/Lykke.Job.SlackNotifications
src/Lykke.Job.SlackNotifications.Services/HttpRequestClient.cs
970
C#
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Web; using System.Web.Mvc; using System.Web.Optimization; using System.Web.Routing; using StackExchange.Exceptional; using StackExchange.Profiling; using StackExchange.Opserver.Helpers; using StackExchange.Profiling.Mvc; namespace StackExchange.Opserver { public class GlobalApplication : HttpApplication { /// <summary> /// The time this application was spun up. /// </summary> public static readonly DateTime StartDate = DateTime.UtcNow; public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" }); // any controller methods that are decorated with our attribute will be registered RouteAttribute.MapDecoratedRoutes(routes); // MUST be the last route as a catch-all! routes.MapRoute("", "{*url}", new { controller = "Error", action = "PageNotFound" }); } private static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/scripts/plugins.js").IncludeDirectory("~/Content/js/plugins", "*.js")); bundles.Add(new ScriptBundle("~/scripts/scripts.js").Include("~/Content/js/Scripts*")); } protected void Application_Start() { // disable the X-AspNetMvc-Version: header MvcHandler.DisableMvcResponseHeader = true; AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); RegisterBundles(BundleTable.Bundles); //BundleTable.EnableOptimizations = true; SetupMiniProfiler(); ErrorStore.GetCustomData = GetCustomErrorData; TaskScheduler.UnobservedTaskException += (sender, args) => Current.LogException(args.Exception); // enable custom model binder ModelBinders.Binders.DefaultBinder = new ProfiledModelBinder(); } private static void SetupMiniProfiler() { MiniProfiler.Settings.RouteBasePath = "~/profiler/"; MiniProfiler.Settings.PopupRenderPosition = RenderPosition.Left; var paths = MiniProfiler.Settings.IgnoredPaths.ToList(); paths.Add("/graph/"); paths.Add("/login"); MiniProfiler.Settings.IgnoredPaths = paths.ToArray(); MiniProfiler.Settings.PopupMaxTracesToShow = 5; var copy = ViewEngines.Engines.ToList(); ViewEngines.Engines.Clear(); foreach (var item in copy) { ViewEngines.Engines.Add(new ProfilingViewEngine(item)); } } protected void Application_BeginRequest() { Current.LogRequest(); if (ShouldProfile()) MiniProfiler.Start(); } protected void Application_EndRequest() { if (ShouldProfile()) MiniProfiler.Stop(); } public override string GetVaryByCustomString(HttpContext context, string arg) { if (arg.ToLower() == "highDPI") { return Current.IsHighDPI.ToString(); } return base.GetVaryByCustomString(context, arg); } private static void GetCustomErrorData(Exception ex, HttpContext context, Dictionary<string, string> data) { // everything below needs a context if (Current.Context != null) { data.Add("User", Current.User.AccountName); data.Add("Roles", Current.User.RawRoles.ToString()); } if (ex == null) return; foreach (DictionaryEntry de in ex.Data) { var key = de.Key as string; if (key.HasValue() && key.StartsWith(ExtensionMethods.ExceptionLogPrefix)) { data.Add(key.Replace(ExtensionMethods.ExceptionLogPrefix, ""), de.Value != null ? de.Value.ToString() : ""); } } } private static bool ShouldProfile() { switch (SiteSettings.ProfilingMode) { case SiteSettings.ProfilingModes.Enabled: return true; case SiteSettings.ProfilingModes.LocalOnly: return HttpContext.Current.Request.IsLocal; case SiteSettings.ProfilingModes.AdminOnly: return Current.User != null && Current.User.IsGlobalAdmin; default: return false; } } } }
35.154412
128
0.585861
[ "MIT" ]
SeanKilleen/Opserver
Opserver/Global.asax.cs
4,783
C#
using System; using System.IO; using Xunit; using Prism.Modularity; namespace Prism.Wpf.Tests.Modularity { public class AssemblyResolverFixture : IDisposable { private const string ModulesDirectory1 = @".\DynamicModules\MocksModulesAssemblyResolve"; public AssemblyResolverFixture() { CleanUpDirectories(); } private void CleanUpDirectories() { CompilerHelper.CleanUpDirectory(ModulesDirectory1); } [Fact] public void ShouldThrowOnInvalidAssemblyFilePath() { bool exceptionThrown = false; using (var resolver = new AssemblyResolver()) { try { resolver.LoadAssemblyFrom(null); } catch (ArgumentException) { exceptionThrown = true; } Assert.True(exceptionThrown); try { resolver.LoadAssemblyFrom("file://InexistentFile.dll"); exceptionThrown = false; } catch (FileNotFoundException) { exceptionThrown = true; } Assert.True(exceptionThrown); try { resolver.LoadAssemblyFrom("InvalidUri.dll"); exceptionThrown = false; } catch (ArgumentException) { exceptionThrown = true; } Assert.True(exceptionThrown); } } [Fact] public void ShouldResolveTypeFromAbsoluteUriToAssembly() { string assemblyPath = CompilerHelper.GenerateDynamicModule("ModuleInLoadedFromContext1", "Module", ModulesDirectory1 + @"\ModuleInLoadedFromContext1.dll"); var uriBuilder = new UriBuilder { Host = String.Empty, Scheme = Uri.UriSchemeFile, Path = Path.GetFullPath(assemblyPath) }; var assemblyUri = uriBuilder.Uri; using (var resolver = new AssemblyResolver()) { Type resolvedType = Type.GetType( "TestModules.ModuleInLoadedFromContext1Class, ModuleInLoadedFromContext1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); Assert.Null(resolvedType); resolver.LoadAssemblyFrom(assemblyUri.ToString()); resolvedType = Type.GetType( "TestModules.ModuleInLoadedFromContext1Class, ModuleInLoadedFromContext1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); Assert.NotNull(resolvedType); } } [Fact] public void ShouldResolvePartialAssemblyName() { string assemblyPath = CompilerHelper.GenerateDynamicModule("ModuleInLoadedFromContext2", "Module", ModulesDirectory1 + @"\ModuleInLoadedFromContext2.dll"); var uriBuilder = new UriBuilder { Host = String.Empty, Scheme = Uri.UriSchemeFile, Path = Path.GetFullPath(assemblyPath) }; var assemblyUri = uriBuilder.Uri; using (var resolver = new AssemblyResolver()) { resolver.LoadAssemblyFrom(assemblyUri.ToString()); Type resolvedType = Type.GetType("TestModules.ModuleInLoadedFromContext2Class, ModuleInLoadedFromContext2"); Assert.NotNull(resolvedType); resolvedType = Type.GetType("TestModules.ModuleInLoadedFromContext2Class, ModuleInLoadedFromContext2, Version=0.0.0.0"); Assert.NotNull(resolvedType); resolvedType = Type.GetType("TestModules.ModuleInLoadedFromContext2Class, ModuleInLoadedFromContext2, Version=0.0.0.0, Culture=neutral"); Assert.NotNull(resolvedType); } } public void Dispose() { CleanUpDirectories(); } } }
33.362963
167
0.511545
[ "MIT" ]
Algorithman/Prism
tests/Wpf/Prism.Wpf.Tests/Modularity/AssemblyResolverFixture.Desktop.cs
4,504
C#
using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using System.Linq; using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; using wize.content.data; using wize.content.data.v1.Models; using wize.content.data.v1.Interfaces; using wize.common.use.paging.Models; using wize.common.use.repository.Operators; using wize.common.use.paging.Interfaces; using wize.common.use.repository.Extensions; using wize.common.use.repository.Models; namespace wize.content.data.v1.Repositories { public class FileRepository : RepositoryBase<int, File>, IFileRepository { public FileRepository(ILogger<IFileRepository> logger, WizeContext context) : base(logger, context) { context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; } } }
30.571429
107
0.778037
[ "MIT" ]
brandonkorous/wize.content
src/wize.content.data/V1/Repositories/FileRepository.cs
858
C#
// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. Project-level // suppressions either have no target or are given a specific target // and scoped to a namespace, type, member, etc. // // To add a suppression to this file, right-click the message in the // Error List, point to "Suppress Message(s)", and click "In Project // Suppression File". You do not need to add suppressions to this // file manually. [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "NuGet.Dialog.Providers")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "NuGet.Dialog.ToolsOptionsUI")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "XamlGeneratedNamespace")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "NuGet.OutputWindowConsole")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "ps", Scope = "resource", Target = "NuGet.Dialog.Resources.resources", Justification = "ps is a well-known extension.")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Multi", Scope = "type", Target = "NuGet.Dialog.PackageManagerUI.MultiNullToVisibilityConverter")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi", Scope = "type", Target = "NuGet.Dialog.PackageManagerUI.MultiNullToVisibilityConverter")]
107.736842
262
0.791891
[ "ECL-2.0", "Apache-2.0" ]
Barsonax/NuGet2
src/DialogServices/GlobalSuppressions.cs
2,047
C#
namespace XlsxStream { public class WorksheetSettings { public int DefaultRowHeight { get; set; } public static WorksheetSettings Default { get { return new WorksheetSettings { DefaultRowHeight = 15 }; } } } }
21.058824
49
0.449721
[ "Apache-2.0" ]
stewart-r/XlsxStream
XlsxStream/WorksheetSettings.cs
360
C#
using System; using Xunit; using Cronos; namespace CronosTests { public class DateRangeTests { [Fact] public void Constructor_01() { var now = DateTime.Now; var sp = new DateRange(now, now.AddHours(1)); Assert.Equal(now, sp.Start); Assert.Equal(now.AddHours(1), sp.End); } [Fact] public void Constructor_Throws_01() { var now = DateTime.Now; Assert.Throws<ArgumentOutOfRangeException>(() => new DateRange(now, now)); } [Fact] public void Constructor_Throws_02() { var now = DateTime.Now; Assert.Throws<ArgumentOutOfRangeException>(() => new DateRange(now, now.AddHours(-1))); } [Fact] public void Size() { var now = DateTime.Now; var sp = new DateRange(now.AddHours(2), now.AddHours(5)); Assert.Equal(new TimeSpan(3,0,0), sp.Size); } [Fact] public void Intersects_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(2)); var sp2 = new DateRange(now.AddHours(1), now.AddHours(3)); Assert.True(sp1.Intersects(sp2)); } [Fact] public void Intersects_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(2)); var sp2 = new DateRange(now.AddHours(-1), now.AddHours(1)); Assert.True(sp1.Intersects(sp2)); } [Fact] public void Intersects_03() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(2)); var sp2 = new DateRange(now.AddHours(-1), now.AddHours(3)); Assert.True(sp1.Intersects(sp2)); } [Fact] public void Intersects_04() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(1), now.AddHours(2)); Assert.True(sp1.Intersects(sp2)); } [Fact] public void Intersects_05() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(5), now.AddHours(7)); Assert.False(sp1.Intersects(sp2)); } [Fact] public void Intersects_06() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(-5), now.AddHours(-1)); Assert.False(sp1.Intersects(sp2)); } [Fact] public void Intersects_07() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(3)); Assert.True(sp1.Intersects(sp2)); } [Fact] public void Adjacent_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(3), now.AddHours(5)); Assert.True(sp1.Adjacent(sp2)); } [Fact] public void Adjacent_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(-3), now); Assert.True(sp1.Adjacent(sp2)); } [Fact] public void Adjacent_03() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(3)); Assert.False(sp1.Adjacent(sp2)); } [Fact] public void Adjacent_04() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(4), now.AddHours(7)); Assert.False(sp1.Adjacent(sp2)); } [Fact] public void Adjacent_05() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(2), now.AddHours(5)); Assert.False(sp1.Adjacent(sp2)); } [Fact] public void Adjacent_06() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(-5), now.AddHours(-1)); Assert.False(sp1.Adjacent(sp2)); } [Fact] public void Union_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(1), now.AddHours(2)); var result = sp1.Union(sp2); Assert.Equal(now, result.Start); Assert.Equal(now.AddHours(3), result.End); } [Fact] public void Union_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(1), now.AddHours(4)); var result = sp1.Union(sp2); Assert.Equal(now, result.Start); Assert.Equal(now.AddHours(4), result.End); } [Fact] public void Union_03() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(-1), now.AddHours(2)); var result = sp1.Union(sp2); Assert.Equal(now.AddHours(-1), result.Start); Assert.Equal(now.AddHours(3), result.End); } [Fact] public void Union_04() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(-1), now.AddHours(5)); var result = sp1.Union(sp2); Assert.Equal(now.AddHours(-1), result.Start); Assert.Equal(now.AddHours(5), result.End); } [Fact] public void Union_05() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(3), now.AddHours(5)); var result = sp1.Union(sp2); Assert.Equal(now, result.Start); Assert.Equal(now.AddHours(5), result.End); } [Fact] public void Union_Throws_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(5), now.AddHours(7)); Assert.Throws<ArgumentOutOfRangeException>(() => sp1.Union(sp2)); } [Fact] public void Union_Throws_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(-5), now.AddHours(-1)); Assert.Throws<ArgumentOutOfRangeException>(() => sp1.Union(sp2)); } [Fact] public void Intersection_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(-1), now.AddHours(2)); var result = sp1.Intersection(sp2); Assert.Equal(now, result.Start); Assert.Equal(now.AddHours(2), result.End); } [Fact] public void Intersection_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(1), now.AddHours(5)); var result = sp1.Intersection(sp2); Assert.Equal(now.AddHours(1), result.Start); Assert.Equal(now.AddHours(3), result.End); } [Fact] public void Intersection_Throws_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(4), now.AddHours(7)); Assert.Throws<ArgumentOutOfRangeException>(() => sp1.Intersection(sp2)); } [Fact] public void Intersection_Throws_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(-4), now.AddHours(-2)); Assert.Throws<ArgumentOutOfRangeException>(() => sp1.Intersection(sp2)); } [Fact] public void Operator_eq_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(5)); var sp2 = new DateRange(now, now.AddHours(5)); Assert.True(sp1 == sp2); } [Fact] public void Operator_eq_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(5)); var sp2 = new DateRange(now, now.AddHours(3)); Assert.False(sp1 == sp2); } [Fact] public void Operator_eq_03() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(5)); Assert.False(sp1 == sp2); } [Fact] public void Operator_eq_04() { var now = DateTime.Now; var sp1 = new DateRange(now.AddHours(1), now.AddHours(5)); var sp2 = new DateRange(now.AddHours(2), now.AddHours(5)); Assert.False(sp1 == sp2); } [Fact] public void Operator_eq_05() { var now = DateTime.Now; var sp1 = new DateRange(now.AddHours(2), now.AddHours(5)); var sp2 = new DateRange(now.AddHours(1), now.AddHours(5)); Assert.False(sp1 == sp2); } [Fact] public void Operator_neq_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(5)); var sp2 = new DateRange(now, now.AddHours(5)); Assert.False(sp1 != sp2); } [Fact] public void Operator_neq_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(5)); var sp2 = new DateRange(now, now.AddHours(3)); Assert.True(sp1 != sp2); } [Fact] public void Operator_neq_03() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(5)); Assert.True(sp1 != sp2); } [Fact] public void Operator_neq_04() { var now = DateTime.Now; var sp1 = new DateRange(now.AddHours(1), now.AddHours(5)); var sp2 = new DateRange(now.AddHours(2), now.AddHours(5)); Assert.True(sp1 != sp2); } [Fact] public void Operator_neq_05() { var now = DateTime.Now; var sp1 = new DateRange(now.AddHours(2), now.AddHours(5)); var sp2 = new DateRange(now.AddHours(1), now.AddHours(5)); Assert.True(sp1 != sp2); } [Fact] public void Operator_lt_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(5), now.AddHours(7)); Assert.True(sp1 < sp2); Assert.False(sp2 < sp1); } [Fact] public void Operator_lt_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(-5), now.AddHours(-2)); Assert.False(sp1 < sp2); Assert.True(sp2 < sp1); } [Fact] public void Operator_lt_03() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(3)); Assert.False(sp1 < sp2); } [Fact] public void Operator_lt_04() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(2)); Assert.False(sp1 < sp2); Assert.True(sp2 < sp1); } [Fact] public void Operator_lt_05() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(5)); Assert.True(sp1 < sp2); Assert.False(sp2 < sp1); } [Fact] public void Operator_gt_01() { var now = DateTime.Now; var sp1 = new DateRange(now.AddHours(3), now.AddHours(5)); var sp2 = new DateRange(now.AddHours(1), now.AddHours(2)); Assert.True(sp1 > sp2); Assert.False(sp2 > sp1); } [Fact] public void Operator_gt_02() { var now = DateTime.Now; var sp1 = new DateRange(now.AddHours(2), now.AddHours(3)); var sp2 = new DateRange(now.AddHours(4), now.AddHours(6)); Assert.False(sp1 > sp2); Assert.True(sp2 > sp1); } [Fact] public void Operator_gt_03() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(3)); Assert.False(sp1 > sp2); } [Fact] public void Operator_gt_04() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(2)); var sp2 = new DateRange(now, now.AddHours(3)); Assert.False(sp1 > sp2); Assert.True(sp2 > sp1); } [Fact] public void Operator_gt_05() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(5)); var sp2 = new DateRange(now, now.AddHours(3)); Assert.True(sp1 > sp2); Assert.False(sp2 > sp1); } [Fact] public void Operator_lt_eq_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(5), now.AddHours(7)); Assert.True(sp1 <= sp2); Assert.False(sp2 <= sp1); } [Fact] public void Operator_lt_eq_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(3)); Assert.True(sp1 <= sp2); } [Fact] public void Operator_lt_eq_03() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(2)); Assert.False(sp1 <= sp2); Assert.True(sp2 <= sp1); } [Fact] public void Operator_lt_eq_04() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(5)); Assert.True(sp1 <= sp2); Assert.False(sp2 <= sp1); } [Fact] public void Operator_mt_eq_01() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now.AddHours(5), now.AddHours(7)); Assert.False(sp1 >= sp2); Assert.True(sp2 >= sp1); } [Fact] public void Operator_mt_eq_02() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(3)); Assert.True(sp1 >= sp2); } [Fact] public void Operator_mt_eq_03() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(2)); Assert.True(sp1 >= sp2); Assert.False(sp2 >= sp1); } [Fact] public void Operator_mt_eq_04() { var now = DateTime.Now; var sp1 = new DateRange(now, now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(5)); Assert.False(sp1 >= sp2); Assert.True(sp2 >= sp1); } [Fact] public void Operator_OR_01() { var now = DateTime.Now; var sp1 = new DateRange(now.AddHours(1), now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(5)); Assert.Equal(sp1.Union(sp2), sp1 | sp2); } [Fact] public void Operator_AND_01() { var now = DateTime.Now; var sp1 = new DateRange(now.AddHours(1), now.AddHours(3)); var sp2 = new DateRange(now, now.AddHours(5)); Assert.Equal(sp1.Intersection(sp2), sp1 & sp2); } } }
31.257194
99
0.503999
[ "MIT" ]
polterguy/cronos
CronosTests/DateRangeTests.cs
17,379
C#
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.Toolkit.Uwp.UI.Lottie.Animatables; namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData { /// <summary> /// Copies shapes and applies a transform to the copies. /// </summary> #if PUBLIC_LottieData public #endif sealed class Repeater : ShapeLayerContent { public Repeater( in ShapeLayerContentArgs args, Animatable<double> count, Animatable<double> offset, RepeaterTransform transform) : base(in args) { Count = count; Offset = offset; Transform = transform; } /// <summary> /// Gets the number of copies to make. /// </summary> public Animatable<double> Count { get; } /// <summary> /// Gets the offset of each copy. /// </summary> public Animatable<double> Offset { get; } /// <summary> /// Gets the transform to apply. The transform is applied n times to the n-th copy. /// </summary> public RepeaterTransform Transform { get; } /// <inheritdoc/> public override ShapeContentType ContentType => ShapeContentType.Repeater; public override ShapeLayerContent WithTimeOffset(double offset) { return new Repeater( CopyArgs(), Count.WithTimeOffset(offset), Offset.WithTimeOffset(offset), (RepeaterTransform)Transform.WithTimeOffset(offset) ); } } }
30.137931
91
0.590389
[ "MIT" ]
CommunityToolkit/Lottie-Windows
source/LottieData/Repeater.cs
1,748
C#
using UnityEngine; using System.Collections; public class GrappleGuideParent : MonoBehaviour { // Use this for initialization void Start() { } // Update is called once per frame void Update() { transform.LookAt(transform.position + transform.parent.rigidbody.velocity); } }
14.75
77
0.722034
[ "BSD-2-Clause" ]
Pillowdrift/StellarSwingClassic
Assets/Scripts/GrappleGuideParent.cs
295
C#
namespace Sandbox { using System; using System.Diagnostics; using System.IO; using System.Threading.Tasks; using CommandLine; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using SoManyBooksSoLittleTime.Data; using SoManyBooksSoLittleTime.Data.Common; using SoManyBooksSoLittleTime.Data.Common.Repositories; using SoManyBooksSoLittleTime.Data.Models; using SoManyBooksSoLittleTime.Data.Repositories; using SoManyBooksSoLittleTime.Data.Seeding; using SoManyBooksSoLittleTime.Services.Messaging; public static class Program { public static int Main(string[] args) { Console.WriteLine($"{typeof(Program).Namespace} ({string.Join(" ", args)}) starts working..."); var serviceCollection = new ServiceCollection(); ConfigureServices(serviceCollection); IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider(true); // Seed data on application startup using (var serviceScope = serviceProvider.CreateScope()) { var dbContext = serviceScope.ServiceProvider.GetRequiredService<ApplicationDbContext>(); dbContext.Database.Migrate(); new ApplicationDbContextSeeder().SeedAsync(dbContext, serviceScope.ServiceProvider).GetAwaiter().GetResult(); } using (var serviceScope = serviceProvider.CreateScope()) { serviceProvider = serviceScope.ServiceProvider; return Parser.Default.ParseArguments<SandboxOptions>(args).MapResult( opts => SandboxCode(opts, serviceProvider).GetAwaiter().GetResult(), _ => 255); } } private static async Task<int> SandboxCode(SandboxOptions options, IServiceProvider serviceProvider) { var sw = Stopwatch.StartNew(); Console.WriteLine(sw.Elapsed); return await Task.FromResult(0); } private static void ConfigureServices(ServiceCollection services) { var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", false, true) .AddEnvironmentVariables() .Build(); services.AddSingleton<IConfiguration>(configuration); services.AddDbContext<ApplicationDbContext>( options => options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")) .UseLoggerFactory(new LoggerFactory())); services.AddDefaultIdentity<ApplicationUser>(IdentityOptionsProvider.GetIdentityOptions) .AddRoles<ApplicationRole>().AddEntityFrameworkStores<ApplicationDbContext>(); services.AddScoped(typeof(IDeletableEntityRepository<>), typeof(EfDeletableEntityRepository<>)); services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>)); services.AddScoped<IDbQueryRunner, DbQueryRunner>(); // Application services services.AddTransient<IEmailSender, NullMessageSender>(); } } }
41.65
125
0.666267
[ "MIT" ]
RadostinaPetrova/SoManyBooksSoLittleTime
Tests/Sandbox/Program.cs
3,334
C#
// // Copyright (c) Microsoft and contributors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // limitations under the License. // // Warning: This code was generated by a tool. // // Changes to this file may cause incorrect behavior and will be lost if the // code is regenerated. using System; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.WindowsAzure.Management.Network.Models; namespace Microsoft.WindowsAzure.Management.Network { /// <summary> /// The Network Management API includes operations for managing the static /// IPs for your subscription. /// </summary> public partial interface IStaticIPOperations { /// <summary> /// The Check Static IP operation retrieves the details for the /// availability of static IP addresses for the given virtual network. /// </summary> /// <param name='networkName'> /// The name of the virtual network. /// </param> /// <param name='ipAddress'> /// The address of the static IP. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// A response that indicates the availability of a static IP address, /// and if not, provides a list of suggestions. /// </returns> Task<NetworkStaticIPAvailabilityResponse> CheckAsync(string networkName, string ipAddress, CancellationToken cancellationToken); } }
36
136
0.677579
[ "Apache-2.0" ]
CerebralMischief/azure-sdk-for-net
src/ServiceManagement/Network/NetworkManagement/Generated/IStaticIPOperations.cs
2,016
C#
#region BSD License /* * * Original BSD 3-Clause License (https://github.com/ComponentFactory/Krypton/blob/master/LICENSE) * © Component Factory Pty Ltd, 2006 - 2016, All rights reserved. * * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2022. All rights reserved. * */ #endregion namespace Krypton.Toolkit { /// <summary> /// Provides the Blue color scheme variant of the Office 2010 palette. /// </summary> public class PaletteOffice2010BlueLightMode : PaletteOffice2010BlueLightModeBase { #region Static Fields private static readonly ImageList _checkBoxList; private static readonly ImageList _galleryButtonList; private static readonly Image[] _radioButtonArray; private static readonly Image _blueDropDownButton = Office2010Arrows._2010BlueDropDownButton; private static readonly Image _contextMenuSubMenu = Office2010Arrows._2010BlueContextMenuSub; private static readonly Image _formCloseNormal = Office2010ControlBoxResources.Office2010BlueCloseNormal_25_x_23; private static readonly Image _formCloseDisabled = Office2010ControlBoxResources.Office2010BlueCloseDisabled_25_x_23; private static readonly Image _formCloseHover = Office2010ControlBoxResources.Office2010BlueCloseHover_25_x_23; private static readonly Image _formMaximiseNormal = Office2010ControlBoxResources.Office2010BlueMaximiseNormal_25_x_23; private static readonly Image _formMaximiseDisabled = Office2010ControlBoxResources.Office2010BlueMaximiseDisabled_25_x_23; private static readonly Image _formMaximiseHover = Office2010ControlBoxResources.Office2010BlueMaximiseHover_25_x_23; private static readonly Image _formMinimiseNormal = Office2010ControlBoxResources.Office2010BlueMinimiseNormal_25_x_23; private static readonly Image _formMinimiseHover = Office2010ControlBoxResources.Office2010BlueMinimiseHover_25_x_23; private static readonly Image _formMinimiseDisabled = Office2010ControlBoxResources.Office2010BlueMinimiseDisabled_25_x_23; private static readonly Image _formRestoreNormal = Office2010ControlBoxResources.Office2010BlueRestoreNormal_25_x_23; private static readonly Image _formRestoreDisabled = Office2010ControlBoxResources.Office2010BlueRestoreDisabled_25_x_23; private static readonly Image _formRestoreHover = Office2010ControlBoxResources.Office2010BlueRestoreHover_25_x_23; private static readonly Image _formHelpNormal = HelpIconResources.GenericOffice2010HelpIconBlue; private static readonly Image _formHelpHover = HelpIconResources.GenericOffice2010HelpIconHover; private static readonly Image _formHelpDisabled = HelpIconResources.GenericOffice2010HelpIconDisabled; private static readonly Color[] _trackBarColors = { Color.FromArgb(116, 150, 194), // Tick marks Color.FromArgb(116, 150, 194), // Top track Color.FromArgb(152, 190, 241), // Bottom track Color.FromArgb(142, 180, 231), // Fill track Color.FromArgb(64, Color.White), // Outside position Color.FromArgb(63, 101, 152) // Border (normal) position }; private static readonly Color[] _schemeColors = { Color.FromArgb( 30, 57, 91), // TextLabelControl Color.FromArgb( 30, 57, 91), // TextButtonNormal Color.Black, // TextButtonChecked Color.FromArgb(171, 186, 208), // ButtonNormalBorder Color.FromArgb(117, 144, 175), // ButtonNormalDefaultBorder Color.FromArgb(225, 237, 250), // ButtonNormalBack1 Color.FromArgb(208, 223, 238), // ButtonNormalBack2 Color.FromArgb(255, 255, 255), // ButtonNormalDefaultBack1 Color.FromArgb(210, 229, 250), // ButtonNormalDefaultBack2 Color.FromArgb(174, 194, 219), // ButtonNormalNavigatorBack1 Color.FromArgb(174, 194, 219), // ButtonNormalNavigatorBack2 Color.FromArgb(187, 206, 230), // PanelClient Color.FromArgb(174, 194, 219), // PanelAlternative Color.FromArgb(133, 158, 191), // ControlBorder Color.FromArgb(239, 245, 255), // SeparatorHighBorder1 Color.FromArgb(200, 217, 239), // SeparatorHighBorder2 Color.FromArgb(207, 221, 238), // HeaderPrimaryBack1 Color.FromArgb(174, 194, 219), // HeaderPrimaryBack2 Color.FromArgb(239, 246, 253), // HeaderSecondaryBack1 Color.FromArgb(216, 228, 242), // HeaderSecondaryBack2 Color.FromArgb( 30, 57, 91), // HeaderText Color.FromArgb( 30, 57, 91), // StatusStripText Color.FromArgb(236, 199, 87), // ButtonBorder Color.FromArgb(245, 249, 255), // SeparatorLight Color.FromArgb(120, 141, 165), // SeparatorDark Color.FromArgb(212, 225, 241), // GripLight Color.FromArgb(132, 157, 189), // GripDark Color.FromArgb(187, 206, 230), // ToolStripBack Color.FromArgb(220, 232, 246), // StatusStripLight Color.FromArgb(179, 196, 216), // StatusStripDark Color.White, // ImageMargin Color.FromArgb(220, 232, 246), // ToolStripBegin Color.FromArgb(179, 196, 216), // ToolStripMiddle Color.FromArgb(179, 196, 216), // ToolStripEnd Color.FromArgb(132, 157, 189), // OverflowBegin Color.FromArgb(132, 157, 189), // OverflowMiddle Color.FromArgb(132, 157, 189), // OverflowEnd Color.FromArgb(132, 157, 189), // ToolStripBorder Color.FromArgb(144, 154, 166), // FormBorderActive Color.FromArgb(162, 173, 185), // FormBorderInactive Color.FromArgb(187, 206, 230), // FormBorderActiveLight Color.FromArgb(212, 230, 245), // FormBorderActiveDark Color.FromArgb(223, 235, 247), // FormBorderInactiveLight Color.FromArgb(223, 235, 247), // FormBorderInactiveDark Color.FromArgb(144, 154, 166), // FormBorderHeaderActive Color.FromArgb(162, 173, 185), // FormBorderHeaderInactive Color.FromArgb(193, 212, 236), // FormBorderHeaderActive1 Color.FromArgb(187, 206, 230), // FormBorderHeaderActive2 Color.FromArgb(223, 235, 247), // FormBorderHeaderInctive1 Color.FromArgb(223, 235, 247), // FormBorderHeaderInctive2 Color.FromArgb( 30, 57, 91), // FormHeaderShortActive Color.FromArgb(106, 128, 168), // FormHeaderShortInactive Color.FromArgb( 30, 57, 91), // FormHeaderLongActive Color.FromArgb(106, 128, 168), // FormHeaderLongInactive Color.FromArgb(143, 165, 191), // FormButtonBorderTrack Color.FromArgb(214, 234, 255), // FormButtonBack1Track Color.FromArgb(188, 207, 231), // FormButtonBack2Track Color.FromArgb(143, 165, 191), // FormButtonBorderPressed Color.FromArgb(187, 206, 230), // FormButtonBack1Pressed Color.FromArgb(166, 182, 213), // FormButtonBack2Pressed Color.FromArgb( 21, 66, 139), // TextButtonFormNormal Color.FromArgb( 21, 66, 139), // TextButtonFormTracking Color.FromArgb( 21, 66, 139), // TextButtonFormPressed Color.Blue, // LinkNotVisitedOverrideControl Color.Purple, // LinkVisitedOverrideControl Color.Red, // LinkPressedOverrideControl Color.Blue, // LinkNotVisitedOverridePanel Color.Purple, // LinkVisitedOverridePanel Color.Red, // LinkPressedOverridePanel Color.FromArgb( 30, 57, 91), // TextLabelPanel Color.FromArgb( 30, 57, 91), // RibbonTabTextNormal Color.FromArgb( 30, 57, 91), // RibbonTabTextChecked Color.FromArgb(159, 178, 199), // RibbonTabSelected1 Color.FromArgb(245, 250, 255), // RibbonTabSelected2 Color.FromArgb(239, 246, 253), // RibbonTabSelected3 Color.FromArgb(239, 246, 253), // RibbonTabSelected4 Color.FromArgb(239, 246, 253), // RibbonTabSelected5 Color.FromArgb(159, 178, 199), // RibbonTabTracking1 Color.FromArgb(237, 241, 247), // RibbonTabTracking2 Color.FromArgb(159, 178, 199), // RibbonTabHighlight1 Color.FromArgb(245, 250, 255), // RibbonTabHighlight2 Color.FromArgb(239, 246, 253), // RibbonTabHighlight3 Color.FromArgb(239, 246, 253), // RibbonTabHighlight4 Color.FromArgb(239, 246, 253), // RibbonTabHighlight5 Color.FromArgb(182, 186, 191), // RibbonTabSeparatorColor Color.FromArgb(159, 178, 199), // RibbonGroupsArea1 Color.FromArgb(114, 142, 173), // RibbonGroupsArea2 Color.FromArgb(239, 246, 253), // RibbonGroupsArea3 Color.FromArgb(221, 234, 247), // RibbonGroupsArea4 Color.FromArgb(216, 228, 242), // RibbonGroupsArea5 Color.FromArgb(235, 240, 246), // RibbonGroupBorder1 Color.FromArgb(240, 246, 252), // RibbonGroupBorder2 Color.Empty, // RibbonGroupTitle1 Color.Empty, // RibbonGroupTitle2 Color.Empty, // RibbonGroupBorderContext1 Color.Empty, // RibbonGroupBorderContext2 Color.Empty, // RibbonGroupTitleContext1 Color.Empty, // RibbonGroupTitleContext2 Color.FromArgb(135, 142, 152), // RibbonGroupDialogDark Color.FromArgb(165, 174, 183), // RibbonGroupDialogLight Color.Empty, // RibbonGroupTitleTracking1 Color.Empty, // RibbonGroupTitleTracking2 Color.FromArgb(139, 160, 188), // RibbonMinimizeBarDark Color.FromArgb(198, 218, 240), // RibbonMinimizeBarLight Color.Empty, // RibbonGroupCollapsedBorder1 Color.Empty, // RibbonGroupCollapsedBorder2 Color.Empty, // RibbonGroupCollapsedBorder3 Color.Empty, // RibbonGroupCollapsedBorder4 Color.Empty, // RibbonGroupCollapsedBack1 Color.Empty, // RibbonGroupCollapsedBack2 Color.Empty, // RibbonGroupCollapsedBack3 Color.Empty, // RibbonGroupCollapsedBack4 Color.Empty, // RibbonGroupCollapsedBorderT1 Color.Empty, // RibbonGroupCollapsedBorderT2 Color.Empty, // RibbonGroupCollapsedBorderT3 Color.Empty, // RibbonGroupCollapsedBorderT4 Color.Empty, // RibbonGroupCollapsedBackT1 Color.Empty, // RibbonGroupCollapsedBackT2 Color.Empty, // RibbonGroupCollapsedBackT3 Color.Empty, // RibbonGroupCollapsedBackT4 Color.FromArgb(189, 203, 218), // RibbonGroupFrameBorder1 Color.FromArgb(184, 199, 216), // RibbonGroupFrameBorder2 Color.FromArgb(233, 241, 250), // RibbonGroupFrameInside1 Color.FromArgb(222, 233, 246), // RibbonGroupFrameInside2 Color.Empty, // RibbonGroupFrameInside3 Color.Empty, // RibbonGroupFrameInside4 Color.FromArgb( 30, 57, 91), // RibbonGroupCollapsedText Color.FromArgb(118, 153, 200), // AlternatePressedBack1 Color.FromArgb(184, 215, 253), // AlternatePressedBack2 Color.FromArgb(135, 156, 175), // AlternatePressedBorder1 Color.FromArgb(177, 198, 216), // AlternatePressedBorder2 Color.FromArgb(150, 194, 239), // FormButtonBack1Checked Color.FromArgb(210, 228, 254), // FormButtonBack2Checked Color.FromArgb(158, 193, 241), // FormButtonBorderCheck Color.FromArgb(140, 184, 229), // FormButtonBack1CheckTrack Color.FromArgb(225, 241, 255), // FormButtonBack2CheckTrack Color.FromArgb(154, 179, 213), // RibbonQATMini1 Color.FromArgb(219, 231, 247), // RibbonQATMini2 Color.FromArgb(195, 213, 236), // RibbonQATMini3 Color.FromArgb(128, Color.White), // RibbonQATMini4 Color.FromArgb(72, Color.White), // RibbonQATMini5 Color.FromArgb(153, 176, 206), // RibbonQATMini1I Color.FromArgb(226, 233, 241), // RibbonQATMini2I Color.FromArgb(198, 210, 226), // RibbonQATMini3I Color.FromArgb(128, Color.White), // RibbonQATMini4I Color.FromArgb(72, Color.White), // RibbonQATMini5I Color.FromArgb(213, 232, 254), // RibbonQATFullbar1 Color.FromArgb(205, 223, 245), // RibbonQATFullbar2 Color.FromArgb(114, 142, 173), // RibbonQATFullbar3 Color.FromArgb( 90, 90, 90), // RibbonQATButtonDark Color.FromArgb(207, 214, 224), // RibbonQATButtonLight Color.FromArgb(222, 236, 252), // RibbonQATOverflow1 Color.FromArgb(123, 139, 156), // RibbonQATOverflow2 Color.FromArgb(145, 166, 194), // RibbonGroupSeparatorDark Color.FromArgb(239, 245, 250), // RibbonGroupSeparatorLight Color.FromArgb(192, 212, 241), // ButtonClusterButtonBack1 Color.FromArgb(200, 219, 238), // ButtonClusterButtonBack2 Color.FromArgb(155, 183, 224), // ButtonClusterButtonBorder1 Color.FromArgb(117, 150, 191), // ButtonClusterButtonBorder2 Color.FromArgb(213, 228, 242), // NavigatorMiniBackColor Color.FromArgb(244, 249, 255), // GridListNormal1 Color.FromArgb(218, 231, 245), // GridListNormal2 Color.FromArgb(198, 211, 225), // GridListPressed1 Color.FromArgb(244, 249, 255), // GridListPressed2 Color.FromArgb(160, 185, 230), // GridListSelected Color.FromArgb(233, 246, 255), // GridSheetColNormal1 Color.FromArgb(213, 226, 240), // GridSheetColNormal2 Color.FromArgb(255, 223, 107), // GridSheetColPressed1 Color.FromArgb(255, 252, 230), // GridSheetColPressed2 Color.FromArgb(255, 211, 89), // GridSheetColSelected1 Color.FromArgb(255, 239, 113), // GridSheetColSelected2 Color.FromArgb(218, 231, 245), // GridSheetRowNormal Color.FromArgb(255, 223, 107), // GridSheetRowPressed Color.FromArgb(245, 210, 87), // GridSheetRowSelected Color.FromArgb(218, 220, 221), // GridDataCellBorder Color.FromArgb(183, 219, 255), // GridDataCellSelected Color.FromArgb( 30, 57, 91), // InputControlTextNormal Color.FromArgb(168, 168, 168), // InputControlTextDisabled Color.FromArgb(177, 192, 214), // InputControlBorderNormal Color.FromArgb(177, 187, 198), // InputControlBorderDisabled Color.FromArgb(201, 222, 245), // InputControlBackNormal Color.FromArgb(240, 240, 240), // InputControlBackDisabled Color.FromArgb(237, 245, 253), // InputControlBackInactive Color.Black, // InputDropDownNormal1 Color.Transparent, // InputDropDownNormal2 Color.FromArgb(172, 168, 153), // InputDropDownDisabled1 Color.Transparent, // InputDropDownDisabled2 Color.FromArgb(240, 242, 245), // ContextMenuHeadingBack Color.FromArgb( 30, 57, 91), // ContextMenuHeadingText Color.White, // ContextMenuImageColumn Color.FromArgb(195, 212, 235), // AppButtonBack1 Color.FromArgb(195, 212, 235), // AppButtonBack2 Color.FromArgb(114, 142, 173), // AppButtonBorder Color.FromArgb(195, 212, 235), // AppButtonOuter1 Color.FromArgb(195, 212, 235), // AppButtonOuter2 Color.FromArgb(195, 212, 235), // AppButtonOuter3 Color.Empty, // AppButtonInner1 Color.FromArgb(114, 142, 173), // AppButtonInner2 Color.White, // AppButtonMenuDocs Color.Black, // AppButtonMenuDocsText Color.FromArgb(239, 245, 255), // SeparatorHighInternalBorder1 Color.FromArgb(200, 217, 239), // SeparatorHighInternalBorder2 Color.FromArgb(177, 192, 214), // RibbonGalleryBorder Color.FromArgb(237, 245, 253), // RibbonGalleryBackNormal Color.FromArgb(242, 247, 252), // RibbonGalleryBackTracking Color.FromArgb(237, 245, 253), // RibbonGalleryBack1 Color.FromArgb(206, 221, 237), // RibbonGalleryBack2 Color.FromArgb(214, 222, 234), // RibbonTabTracking3 Color.FromArgb(200, 215, 233), // RibbonTabTracking4 Color.FromArgb(147, 167, 195), // RibbonGroupBorder3 Color.FromArgb(226, 236, 247), // RibbonGroupBorder4 Color.FromArgb(251, 251, 252), // RibbonGroupBorder5 Color.FromArgb( 56, 78, 115), // RibbonGroupTitleText Color.FromArgb(151, 156, 163), // RibbonDropArrowLight Color.FromArgb( 39, 49, 60), // RibbonDropArrowDark Color.FromArgb(208, 226, 248), // HeaderDockInactiveBack1 Color.FromArgb(178, 196, 218), // HeaderDockInactiveBack2 Color.FromArgb(133, 158, 191), // ButtonNavigatorBorder Color.FromArgb( 0, 25, 56), // ButtonNavigatorText Color.FromArgb(177, 198, 224), // ButtonNavigatorTrack1 Color.FromArgb(211, 224, 240), // ButtonNavigatorTrack2 Color.FromArgb(148, 174, 205), // ButtonNavigatorPressed1 Color.FromArgb(198, 214, 231), // ButtonNavigatorPressed2 Color.FromArgb(200, 219, 240), // ButtonNavigatorChecked1 Color.FromArgb(177, 201, 228), // ButtonNavigatorChecked2 Color.FromArgb(201, 217, 239) // ToolTipBottom }; #endregion #region Identity static PaletteOffice2010BlueLightMode() { _checkBoxList = new ImageList { ImageSize = new Size(13, 13), ColorDepth = ColorDepth.Depth24Bit }; _checkBoxList.Images.AddStrip(CheckBoxStripResources.CheckBoxStrip2010Blue); _galleryButtonList = new ImageList { ImageSize = new Size(13, 7), ColorDepth = ColorDepth.Depth24Bit, TransparentColor = Color.Magenta }; _galleryButtonList.Images.AddStrip(GalleryImageResources.Gallery2010); _radioButtonArray = new Image[]{Office2010BlueRadioButtonResources.RadioButton2010BlueD, Office2010BlueRadioButtonResources.RadioButton2010BlueN, Office2010BlueRadioButtonResources.RadioButton2010BlueT, Office2010BlueRadioButtonResources.RadioButton2010BlueP, Office2010BlueRadioButtonResources.RadioButton2010BlueDC, Office2010BlueRadioButtonResources.RadioButton2010BlueNC, Office2010BlueRadioButtonResources.RadioButton2010BlueTC, Office2010BlueRadioButtonResources.RadioButton2010BluePC}; } /// <summary> /// Initialize a new instance of the PaletteOffice2010Blue class. /// </summary> public PaletteOffice2010BlueLightMode() : base(_schemeColors, _checkBoxList, _galleryButtonList, _radioButtonArray, _trackBarColors) { } #endregion #region Images /// <summary> /// Gets a drop down button image appropriate for the provided state. /// </summary> /// <param name="state">PaletteState for which image is required.</param> public override Image GetDropDownButtonImage(PaletteState state) => state != PaletteState.Disabled ? _blueDropDownButton : base.GetDropDownButtonImage(state); /// <summary> /// Gets an image indicating a sub-menu on a context menu item. /// </summary> /// <returns>Appropriate image for drawing; otherwise null.</returns> public override Image GetContextMenuSubMenuImage() => _contextMenuSubMenu; #endregion #region ButtonSpec /// <summary> /// Gets the image to display for the button. /// </summary> /// <param name="style">Style of button spec.</param> /// <param name="state">State for which image is required.</param> /// <returns>Image value.</returns> public override Image GetButtonSpecImage(PaletteButtonSpecStyle style, PaletteState state) { return style switch { PaletteButtonSpecStyle.FormClose => state switch { PaletteState.Tracking => _formCloseHover, PaletteState.Normal => _formCloseNormal, _ => _formCloseDisabled }, PaletteButtonSpecStyle.FormMin => state switch { PaletteState.Normal => _formMinimiseNormal, PaletteState.Tracking => _formMinimiseHover, _ => _formMinimiseDisabled }, PaletteButtonSpecStyle.FormMax => state switch { PaletteState.Normal => _formMaximiseNormal, PaletteState.Tracking => _formMaximiseHover, _ => _formMaximiseDisabled }, PaletteButtonSpecStyle.FormRestore => state switch { PaletteState.Normal => _formRestoreNormal, PaletteState.Tracking => _formRestoreHover, _ => _formRestoreDisabled }, PaletteButtonSpecStyle.FormHelp => state switch { PaletteState.Tracking => _formHelpHover, PaletteState.Normal => _formHelpNormal, _ => _formHelpDisabled }, _ => base.GetButtonSpecImage(style, state) }; } #endregion } #region Class: PaletteOffice2010BlueLightModeBase /// <summary> /// Provides a base for Office 2010 palettes. /// </summary> public abstract class PaletteOffice2010BlueLightModeBase : PaletteBase { #region Static Fields private static readonly Padding _contentPaddingGrid = new(2, 1, 2, 1); private static readonly Padding _contentPaddingHeader1 = new(2, 1, 2, 1); private static readonly Padding _contentPaddingHeader2 = new(2, 1, 2, 1); private static readonly Padding _contentPaddingDock = new(2, 2, 2, 1); private static readonly Padding _contentPaddingCalendar = new(2); private static readonly Padding _contentPaddingHeaderForm = new(10, 6, 3, 0); // 10 is from the RealWindowFrameSize +1 private static readonly Padding _contentPaddingLabel = new(3, 1, 3, 1); private static readonly Padding _contentPaddingLabel2 = new(8, 2, 8, 2); private static readonly Padding _contentPaddingButtonInputControl = new(0); private static readonly Padding _contentPaddingButton12 = new(1); private static readonly Padding _contentPaddingButton3 = new(1, 0, 1, 0); private static readonly Padding _contentPaddingButton4 = new(4, 3, 4, 3); private static readonly Padding _contentPaddingButton5 = new(3, 3, 3, 2); private static readonly Padding _contentPaddingButton6 = new(3); private static readonly Padding _contentPaddingButton7 = new(1, 1, 0, 1); private static readonly Padding _contentPaddingButtonForm = new(0); private static readonly Padding _contentPaddingButtonGallery = new(1, 0, 1, 0); private static readonly Padding _contentPaddingButtonListItem = new(0, -1, 0, -1); private static readonly Padding _contentPaddingToolTip = new(2); private static readonly Padding _contentPaddingSuperTip = new(4); private static readonly Padding _contentPaddingKeyTip = new(0, -1, 0, -3); private static readonly Padding _contentPaddingContextMenuHeading = new(8, 2, 8, 0); private static readonly Padding _contentPaddingContextMenuImage = new(0); private static readonly Padding _contentPaddingContextMenuItemText = new(9, 1, 7, 0); private static readonly Padding _contentPaddingContextMenuItemTextAlt = new(7, 1, 6, 0); private static readonly Padding _contentPaddingContextMenuItemShortcutText = new(3, 1, 4, 0); private static readonly Padding _metricPaddingRibbon = new(0, 1, 1, 1); private static readonly Padding _metricPaddingRibbonAppButton = new(3, 0, 3, 0); private static readonly Padding _metricPaddingHeader = new(0, 3, 1, 3); private static readonly Padding _metricPaddingHeaderForm = new(0, 3, 0, -3); // Move the Maximised Form buttons down a bit private static readonly Padding _metricPaddingInputControl = new(0, 1, 0, 1); private static readonly Padding _metricPaddingBarInside = new(3); private static readonly Padding _metricPaddingBarTabs = new(0); private static readonly Padding _metricPaddingBarOutside = new(0, 0, 0, 3); private static readonly Padding _metricPaddingPageButtons = new(1, 3, 1, 3); private static readonly Image _treeExpandWhite = TreeItemImageResources.TreeExpandWhite; private static readonly Image _treeCollapseBlack = TreeItemImageResources.TreeCollapseBlack; private static readonly Image _disabledDropDown = DropDownArrowImageResources.DisabledDropDownButton; private static readonly Image _buttonSpecClose = ProfessionalButtonSpecResources.ProfessionalCloseButton; private static readonly Image _buttonSpecContext = GenericProfessionalImageResources.ProfessionalContextButton; private static readonly Image _buttonSpecNext = GenericProfessionalImageResources.ProfessionalNextButton; private static readonly Image _buttonSpecPrevious = GenericProfessionalImageResources.ProfessionalPreviousButton; private static readonly Image _buttonSpecArrowLeft = GenericProfessionalImageResources.ProfessionalArrowLeftButton; private static readonly Image _buttonSpecArrowRight = GenericProfessionalImageResources.ProfessionalArrowRightButton; private static readonly Image _buttonSpecArrowUp = GenericProfessionalImageResources.ProfessionalArrowUpButton; private static readonly Image _buttonSpecArrowDown = GenericProfessionalImageResources.ProfessionalArrowDownButton; private static readonly Image _buttonSpecDropDown = GenericProfessionalImageResources.ProfessionalDropDownButton; private static readonly Image _buttonSpecPinVertical = ProfessionalPinImageResources.ProfessionalPinVerticalButton; private static readonly Image _buttonSpecPinHorizontal = ProfessionalPinImageResources.ProfessionalPinHorizontalButton; private static readonly Image _buttonSpecPendantClose = Office2010ControlBoxResources._2010ButtonMDIClose; private static readonly Image _buttonSpecPendantMin = Office2010ControlBoxResources._2010ButtonMDIMin; private static readonly Image _buttonSpecPendantRestore = Office2010ControlBoxResources._2010ButtonMDIRestore; private static readonly Image _buttonSpecWorkspaceMaximize = GenericProfessionalImageResources.ProfessionalMaximize; private static readonly Image _buttonSpecWorkspaceRestore = GenericProfessionalImageResources.ProfessionalRestore; private static readonly Image _buttonSpecRibbonMinimize = RibbonArrowImageResources.RibbonUp2010; private static readonly Image _buttonSpecRibbonExpand = RibbonArrowImageResources.RibbonDown2010; private static readonly Image _contextMenuChecked = GenericOffice2007ImageResources.Office2007Checked; private static readonly Image _contextMenuIndeterminate = GenericOffice2007ImageResources.Office2007Indeterminate; private static readonly Color _gridTextColor = Color.Black; private static readonly Color _disabledText2 = Color.FromArgb(128, 128, 128); private static readonly Color _disabledText = Color.FromArgb(167, 167, 167); private static readonly Color _disabledBack = Color.FromArgb(235, 235, 235); private static readonly Color _disabledBorder = Color.FromArgb(212, 212, 212); private static readonly Color _disabledGlyphDark = Color.FromArgb(183, 183, 183); private static readonly Color _disabledGlyphLight = Color.FromArgb(237, 237, 237); private static readonly Color _contextCheckedTabBorder1 = Color.FromArgb(223, 119, 0); private static readonly Color _contextCheckedTabBorder2 = Color.FromArgb(230, 190, 129); private static readonly Color _contextCheckedTabBorder3 = Color.FromArgb(220, 202, 171); private static readonly Color _contextCheckedTabBorder4 = Color.FromArgb(255, 252, 247); private static readonly Color _contextTabSeparator = Color.White; private static readonly Color _contextTextColor = Color.White; private static readonly Color _todayBorder = Color.FromArgb(187, 85, 3); private static readonly Color _toolTipBack1 = Color.FromArgb(255, 255, 255); private static readonly Color _toolTipBack2 = Color.FromArgb(201, 217, 239); private static readonly Color _toolTipBorder = Color.FromArgb(118, 118, 118); private static readonly Color _toolTipText = Color.FromArgb(76, 76, 76); private static readonly Color _contextMenuBack = Color.White; private static readonly Color _contextMenuBorder = Color.FromArgb(134, 134, 134); private static readonly Color _contextMenuHeadingBorder = Color.FromArgb(197, 197, 197); private static readonly Color _contextMenuImageBackChecked = Color.FromArgb(252, 241, 194); private static readonly Color _contextMenuImageBorderChecked = Color.FromArgb(242, 149, 54); private static readonly Color _formCloseBorderTracking = Color.FromArgb(155, 61, 61); private static readonly Color _formCloseBorderPressed = Color.FromArgb(155, 61, 61); private static readonly Color _formCloseBorderCheckedNormal = Color.FromArgb(155, 61, 61); private static readonly Color _formCloseTracking1 = Color.FromArgb(255, 132, 130); private static readonly Color _formCloseTracking2 = Color.FromArgb(227, 97, 98); private static readonly Color _formClosePressed1 = Color.FromArgb(242, 119, 118); private static readonly Color _formClosePressed2 = Color.FromArgb(206, 85, 84); private static readonly Color _formCloseChecked1 = Color.FromArgb(255, 132, 130); private static readonly Color _formCloseChecked2 = Color.FromArgb(255, 132, 130); private static readonly Color _formCloseCheckedTracking1 = Color.FromArgb(255, 132, 130); private static readonly Color _formCloseCheckedTracking2 = Color.FromArgb(255, 132, 130); private static readonly Color _controlCustom3Color = Color.FromArgb(201, 222, 245); private static readonly Color[] _appButtonNormal = { Color.FromArgb(243, 245, 248), Color.FromArgb(214, 220, 231), Color.FromArgb(188, 198, 211), Color.FromArgb(254, 254, 255), Color.FromArgb(206, 213, 225) }; private static readonly Color[] _appButtonTrack = { Color.FromArgb(255, 251, 230), Color.FromArgb(248, 230, 143), Color.FromArgb(238, 213, 126), Color.FromArgb(254, 247, 129), Color.FromArgb(240, 201, 41) }; private static readonly Color[] _appButtonPressed = { Color.FromArgb(235, 227, 196), Color.FromArgb(228, 198, 149), Color.FromArgb(166, 97, 7), Color.FromArgb(242, 155, 57), Color.FromArgb(236, 136, 9) }; private static readonly Color[] _buttonBorderColors = { Color.FromArgb(180, 180, 180), // Button, Disabled, Border Color.FromArgb(237, 201, 88), // Button, Tracking, Border 1 Color.FromArgb(243, 213, 73), // Button, Tracking, Border 2 Color.FromArgb(194, 118, 43), // Button, Pressed, Border 1 Color.FromArgb(194, 158, 71), // Button, Pressed, Border 2 Color.FromArgb(194, 138, 48), // Button, Checked, Border 1 Color.FromArgb(194, 164, 77) // Button, Checked, Border 2 }; private static readonly Color[] _buttonBackColors = { Color.FromArgb(250, 250, 250), // Button, Disabled, Back 1 Color.FromArgb(250, 250, 250), // Button, Disabled, Back 2 Color.FromArgb(248, 225, 135), // Button, Tracking, Back 1 Color.FromArgb(251, 248, 224), // Button, Tracking, Back 2 Color.FromArgb(255, 228, 138), // Button, Pressed, Back 1 Color.FromArgb(194, 118, 43), // Button, Pressed, Back 2 Color.FromArgb(255, 216, 108), // Button, Checked, Back 1 Color.FromArgb(255, 244, 128), // Button, Checked, Back 2 Color.FromArgb(255, 225, 104), // Button, Checked Tracking, Back 1 Color.FromArgb(255, 249, 196) // Button, Checked Tracking, Back 2 }; #endregion #region Instance Fields private KryptonColorTable2010 _table; private readonly Color[] _ribbonColors; private readonly Color[] _trackBarColors; private readonly ImageList _checkBoxList; private readonly ImageList _galleryButtonList; private readonly Image[] _radioButtonArray; private Font _header1ShortFont; private Font _header2ShortFont; private Font _header1LongFont; private Font _header2LongFont; private Font _superToolFont; private Font _headerFormFont; private Font _buttonFont; private Font _buttonFontNavigatorStack; private Font _buttonFontNavigatorMini; private Font _tabFontNormal; private Font _tabFontSelected; private Font _ribbonTabFont; private Font _ribbonTabContextFont; private Font _gridFont; private Font _calendarFont; private Font _calendarBoldFont; private Font _boldFont; private Font _italicFont; private string _baseFontName; #endregion #region Identity /// <summary> /// Initialize a new instance of the PaletteOffice2010BlueLightModeBase class. /// </summary> /// <param name="schemeColors">Array of palette specific colors.</param> /// <param name="checkBoxList">List of images for check box.</param> /// <param name="galleryButtonList">List of images for gallery buttons.</param> /// <param name="radioButtonArray">Array of images for radio button.</param> /// <param name="trackBarColors">Array of track bar specific colors.</param> public PaletteOffice2010BlueLightModeBase(Color[] schemeColors, ImageList checkBoxList, ImageList galleryButtonList, Image[] radioButtonArray, Color[] trackBarColors) { Debug.Assert(schemeColors != null); Debug.Assert(checkBoxList != null); Debug.Assert(galleryButtonList != null); Debug.Assert(radioButtonArray != null); // Remember incoming sets of values _ribbonColors = schemeColors; _checkBoxList = checkBoxList; _galleryButtonList = galleryButtonList; _radioButtonArray = radioButtonArray; _trackBarColors = trackBarColors; // Get the font settings from the system DefineFonts(); } #endregion #region AllowFormChrome /// <summary> /// Gets a value indicating if KryptonForm instances should show custom chrome. /// </summary> /// <returns>InheritBool value.</returns> public override InheritBool GetAllowFormChrome() => InheritBool.True; #endregion #region Renderer /// <summary> /// Gets the renderer to use for this palette. /// </summary> /// <returns>Renderer to use for drawing palette settings.</returns> public override IRenderer GetRenderer() => // We always want the professional renderer KryptonManager.RenderOffice2010; #endregion #region Back /// <summary> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteBackStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return InheritBool.Inherit; } return style switch { PaletteBackStyle.SeparatorLowProfile or PaletteBackStyle.SeparatorCustom1 or PaletteBackStyle.SeparatorCustom2 or PaletteBackStyle.SeparatorCustom3 => InheritBool.False, PaletteBackStyle.ButtonLowProfile or PaletteBackStyle.ButtonBreadCrumb or PaletteBackStyle.ButtonListItem or PaletteBackStyle.ButtonCommand or PaletteBackStyle.ButtonButtonSpec or PaletteBackStyle.ButtonCalendarDay or PaletteBackStyle.ButtonNavigatorOverflow or PaletteBackStyle.ButtonForm or PaletteBackStyle.ButtonFormClose => state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride => InheritBool.False, _ => InheritBool.True }, PaletteBackStyle.ContextMenuItemImage or PaletteBackStyle.ContextMenuItemHighlight => state switch { PaletteState.Normal or PaletteState.NormalDefaultOverride => InheritBool.False, _ => InheritBool.True }, PaletteBackStyle.ButtonInputControl => state is PaletteState.Disabled or PaletteState.Normal ? InheritBool.False : InheritBool.True, _ => InheritBool.True // Default to drawing the background }; } /// <summary> /// Gets the graphics drawing hint for the background. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteGraphicsHint value.</returns> public override PaletteGraphicsHint GetBackGraphicsHint(PaletteBackStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteGraphicsHint.Inherit; } return style switch { PaletteBackStyle.TabHighProfile or PaletteBackStyle.TabStandardProfile or PaletteBackStyle.TabLowProfile or PaletteBackStyle.TabOneNote or PaletteBackStyle.TabDock or PaletteBackStyle.TabDockAutoHidden or PaletteBackStyle.TabCustom1 or PaletteBackStyle.TabCustom2 or PaletteBackStyle.TabCustom3 or PaletteBackStyle.PanelClient or PaletteBackStyle.PanelRibbonInactive or PaletteBackStyle.PanelAlternate or PaletteBackStyle.PanelCustom1 or PaletteBackStyle.PanelCustom2 or PaletteBackStyle.PanelCustom3 or PaletteBackStyle.SeparatorHighInternalProfile or PaletteBackStyle.SeparatorHighProfile or PaletteBackStyle.SeparatorLowProfile or PaletteBackStyle.SeparatorCustom1 or PaletteBackStyle.SeparatorCustom2 or PaletteBackStyle.SeparatorCustom3 or PaletteBackStyle.ControlClient or PaletteBackStyle.ControlAlternate or PaletteBackStyle.ControlGroupBox or PaletteBackStyle.ControlToolTip or PaletteBackStyle.ControlRibbon or PaletteBackStyle.ControlRibbonAppMenu or PaletteBackStyle.ControlCustom1 or PaletteBackStyle.ControlCustom2 or PaletteBackStyle.ControlCustom3 or PaletteBackStyle.ContextMenuOuter or PaletteBackStyle.ContextMenuInner or PaletteBackStyle.ContextMenuHeading or PaletteBackStyle.ContextMenuSeparator or PaletteBackStyle.ContextMenuItemSplit or PaletteBackStyle.ContextMenuItemImageColumn or PaletteBackStyle.ContextMenuItemImage or PaletteBackStyle.ContextMenuItemHighlight or PaletteBackStyle.InputControlStandalone or PaletteBackStyle.InputControlRibbon or PaletteBackStyle.InputControlCustom1 or PaletteBackStyle.InputControlCustom2 or PaletteBackStyle.InputControlCustom3 or PaletteBackStyle.FormMain or PaletteBackStyle.FormCustom1 or PaletteBackStyle.FormCustom2 or PaletteBackStyle.FormCustom3 or PaletteBackStyle.HeaderPrimary or PaletteBackStyle.HeaderDockInactive or PaletteBackStyle.HeaderDockActive or PaletteBackStyle.HeaderSecondary or PaletteBackStyle.HeaderForm or PaletteBackStyle.HeaderCalendar or PaletteBackStyle.HeaderCustom1 or PaletteBackStyle.HeaderCustom2 or PaletteBackStyle.HeaderCustom3 or PaletteBackStyle.ButtonStandalone or PaletteBackStyle.ButtonGallery or PaletteBackStyle.ButtonAlternate or PaletteBackStyle.ButtonLowProfile or PaletteBackStyle.ButtonBreadCrumb or PaletteBackStyle.ButtonListItem or PaletteBackStyle.ButtonCommand or PaletteBackStyle.ButtonCalendarDay or PaletteBackStyle.ButtonButtonSpec or PaletteBackStyle.ButtonCluster or PaletteBackStyle.ButtonNavigatorStack or PaletteBackStyle.ButtonNavigatorOverflow or PaletteBackStyle.ButtonNavigatorMini or PaletteBackStyle.ButtonForm or PaletteBackStyle.ButtonFormClose or PaletteBackStyle.ButtonCustom1 or PaletteBackStyle.ButtonCustom2 or PaletteBackStyle.ButtonCustom3 or PaletteBackStyle.ButtonInputControl or PaletteBackStyle.GridBackgroundList or PaletteBackStyle.GridBackgroundSheet or PaletteBackStyle.GridBackgroundCustom1 or PaletteBackStyle.GridHeaderColumnList or PaletteBackStyle.GridHeaderColumnSheet or PaletteBackStyle.GridHeaderColumnCustom1 or PaletteBackStyle.GridHeaderColumnCustom2 or PaletteBackStyle.GridHeaderColumnCustom3 or PaletteBackStyle.GridHeaderRowList or PaletteBackStyle.GridHeaderRowSheet or PaletteBackStyle.GridHeaderRowCustom1 or PaletteBackStyle.GridHeaderRowCustom2 or PaletteBackStyle.GridHeaderRowCustom3 or PaletteBackStyle.GridDataCellList or PaletteBackStyle.GridDataCellSheet or PaletteBackStyle.GridDataCellCustom1 or PaletteBackStyle.GridDataCellCustom2 or PaletteBackStyle.GridDataCellCustom3 => PaletteGraphicsHint.None, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the first background color. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetBackColor1(PaletteBackStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideStateExclude(state, PaletteState.NormalDefaultOverride)) { return Color.Empty; } switch (style) { case PaletteBackStyle.GridHeaderColumnList: case PaletteBackStyle.GridHeaderColumnCustom1: case PaletteBackStyle.GridHeaderColumnCustom2: case PaletteBackStyle.GridHeaderColumnCustom3: case PaletteBackStyle.GridHeaderRowList: case PaletteBackStyle.GridHeaderRowCustom1: case PaletteBackStyle.GridHeaderRowCustom2: case PaletteBackStyle.GridHeaderRowCustom3: return state switch { PaletteState.Disabled => _disabledBack, PaletteState.Pressed => _ribbonColors[(int)SchemeOfficeColors.GridListPressed1], PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.GridListSelected], _ => _ribbonColors[(int)SchemeOfficeColors.GridListNormal1] }; case PaletteBackStyle.GridHeaderColumnSheet: return state switch { PaletteState.Disabled => _disabledBack, PaletteState.Tracking or PaletteState.Pressed => _ribbonColors[(int)SchemeOfficeColors.GridSheetColPressed1], PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.GridSheetColSelected1], _ => _ribbonColors[(int)SchemeOfficeColors.GridSheetColNormal1] }; case PaletteBackStyle.GridHeaderRowSheet: return state switch { PaletteState.Disabled => _disabledBack, PaletteState.Tracking or PaletteState.Pressed => _ribbonColors[(int)SchemeOfficeColors.GridSheetRowPressed], PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.GridSheetRowSelected], _ => _ribbonColors[(int)SchemeOfficeColors.GridSheetRowNormal] }; case PaletteBackStyle.GridDataCellList: case PaletteBackStyle.GridDataCellCustom1: case PaletteBackStyle.GridDataCellCustom2: case PaletteBackStyle.GridDataCellCustom3: return state == PaletteState.CheckedNormal ? _ribbonColors[(int)SchemeOfficeColors.GridDataCellSelected] : SystemColors.Window; case PaletteBackStyle.GridDataCellSheet: return state == PaletteState.CheckedNormal ? _buttonBackColors[6] : SystemColors.Window; case PaletteBackStyle.TabHighProfile: case PaletteBackStyle.TabStandardProfile: case PaletteBackStyle.TabLowProfile: case PaletteBackStyle.TabOneNote: case PaletteBackStyle.TabCustom1: case PaletteBackStyle.TabCustom2: case PaletteBackStyle.TabCustom3: switch (state) { case PaletteState.Disabled: return style == PaletteBackStyle.TabLowProfile ? Color.Empty : _disabledBack; case PaletteState.Normal: return style == PaletteBackStyle.TabLowProfile ? Color.Empty : SystemColors.Window; case PaletteState.Pressed: case PaletteState.Tracking: return style switch { PaletteBackStyle.TabLowProfile => Color.Empty, PaletteBackStyle.TabHighProfile => state == PaletteState.Tracking ? _buttonBackColors[2] : _buttonBackColors[4], _ => SystemColors.Window }; case PaletteState.CheckedNormal: case PaletteState.CheckedPressed: case PaletteState.CheckedTracking: if (style == PaletteBackStyle.TabHighProfile) { return state switch { PaletteState.CheckedNormal => _buttonBackColors[6], PaletteState.CheckedPressed => _buttonBackColors[4], _ => _buttonBackColors[8] }; } else { return SystemColors.Window; } default: throw new ArgumentOutOfRangeException(nameof(state)); } case PaletteBackStyle.TabDock: case PaletteBackStyle.TabDockAutoHidden: return state switch { PaletteState.Disabled => _disabledBack, PaletteState.Normal or PaletteState.CheckedNormal or PaletteState.CheckedPressed or PaletteState.CheckedTracking or PaletteState.Pressed or PaletteState.Tracking => SystemColors.Window, _ => throw new ArgumentOutOfRangeException(nameof(state)) }; case PaletteBackStyle.HeaderForm: return state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormBorderHeaderInactive1] : _ribbonColors[(int)SchemeOfficeColors.FormBorderHeaderActive1]; case PaletteBackStyle.HeaderCalendar: return state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.HeaderPrimaryBack1] : _ribbonColors[(int)SchemeOfficeColors.HeaderPrimaryBack2]; case PaletteBackStyle.HeaderPrimary: case PaletteBackStyle.HeaderCustom1: case PaletteBackStyle.HeaderCustom2: case PaletteBackStyle.HeaderCustom3: return state == PaletteState.Disabled ? _disabledBack : _ribbonColors[(int)SchemeOfficeColors.HeaderPrimaryBack1]; case PaletteBackStyle.HeaderDockInactive: return state == PaletteState.Disabled ? _disabledBack : _ribbonColors[(int)SchemeOfficeColors.HeaderDockInactiveBack1]; case PaletteBackStyle.HeaderDockActive: return state == PaletteState.Disabled ? _disabledBack : _buttonBackColors[6]; case PaletteBackStyle.HeaderSecondary: return state == PaletteState.Disabled ? _disabledBack : _ribbonColors[(int)SchemeOfficeColors.HeaderSecondaryBack1]; case PaletteBackStyle.SeparatorHighInternalProfile: return state == PaletteState.Disabled ? _disabledBack : _ribbonColors[(int)SchemeOfficeColors.SeparatorHighInternalBorder1]; case PaletteBackStyle.SeparatorHighProfile: return state == PaletteState.Disabled ? _disabledBack : _ribbonColors[(int)SchemeOfficeColors.SeparatorHighBorder1]; case PaletteBackStyle.SeparatorLowProfile: case PaletteBackStyle.SeparatorCustom1: case PaletteBackStyle.SeparatorCustom2: case PaletteBackStyle.SeparatorCustom3: case PaletteBackStyle.PanelClient: case PaletteBackStyle.PanelCustom1: case PaletteBackStyle.PanelCustom2: case PaletteBackStyle.PanelCustom3: case PaletteBackStyle.ControlGroupBox: case PaletteBackStyle.GridBackgroundList: case PaletteBackStyle.GridBackgroundSheet: case PaletteBackStyle.GridBackgroundCustom1: return _ribbonColors[(int)SchemeOfficeColors.PanelClient]; case PaletteBackStyle.PanelAlternate: return _ribbonColors[(int)SchemeOfficeColors.PanelAlternative]; case PaletteBackStyle.PanelRibbonInactive: return _ribbonColors[(int)SchemeOfficeColors.FormBorderInactiveLight]; case PaletteBackStyle.FormMain: case PaletteBackStyle.FormCustom1: case PaletteBackStyle.FormCustom2: case PaletteBackStyle.FormCustom3: return state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormBorderInactiveLight] : _ribbonColors[(int)SchemeOfficeColors.FormBorderActiveLight]; case PaletteBackStyle.ControlClient: case PaletteBackStyle.ControlAlternate: case PaletteBackStyle.ControlCustom1: case PaletteBackStyle.ControlCustom2: case PaletteBackStyle.ControlCustom3: return _controlCustom3Color; case PaletteBackStyle.InputControlStandalone: case PaletteBackStyle.InputControlRibbon: case PaletteBackStyle.InputControlCustom1: case PaletteBackStyle.InputControlCustom2: case PaletteBackStyle.InputControlCustom3: if (state == PaletteState.Disabled) { return _ribbonColors[(int)SchemeOfficeColors.InputControlBackDisabled]; } else { return (state == PaletteState.Tracking) || (style == PaletteBackStyle.InputControlStandalone) ? _ribbonColors[(int)SchemeOfficeColors.InputControlBackNormal] : _ribbonColors[(int)SchemeOfficeColors.InputControlBackInactive]; } case PaletteBackStyle.ControlRibbon: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabSelected4]; case PaletteBackStyle.ControlRibbonAppMenu: return _ribbonColors[(int)SchemeOfficeColors.AppButtonBack1]; case PaletteBackStyle.ControlToolTip: return _toolTipBack1; case PaletteBackStyle.ContextMenuOuter: return _contextMenuBack; case PaletteBackStyle.ContextMenuSeparator: case PaletteBackStyle.ContextMenuItemSplit: return state switch { PaletteState.Tracking => _buttonBackColors[2], _ => _contextMenuBack }; case PaletteBackStyle.ContextMenuInner: return _contextMenuBack; case PaletteBackStyle.ContextMenuHeading: return _ribbonColors[(int)SchemeOfficeColors.ContextMenuHeadingBack]; case PaletteBackStyle.ContextMenuItemImageColumn: return _ribbonColors[(int)SchemeOfficeColors.ContextMenuImageColumn]; case PaletteBackStyle.ContextMenuItemImage: return _contextMenuImageBackChecked; case PaletteBackStyle.ButtonForm: return state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride => Color.Empty, PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.FormButtonBack1Checked], PaletteState.Tracking => _ribbonColors[(int)SchemeOfficeColors.FormButtonBack1Track], PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.FormButtonBack1CheckTrack], PaletteState.Pressed or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.FormButtonBack1Pressed], _ => throw new ArgumentOutOfRangeException(nameof(state)) }; case PaletteBackStyle.ButtonFormClose: return state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride => Color.Empty, PaletteState.CheckedNormal => _formCloseChecked1, PaletteState.Tracking => _formCloseTracking1, PaletteState.CheckedTracking => _formCloseCheckedTracking1, PaletteState.Pressed or PaletteState.CheckedPressed => _formClosePressed1, _ => throw new ArgumentOutOfRangeException(nameof(state)) }; case PaletteBackStyle.ButtonStandalone: case PaletteBackStyle.ButtonGallery: case PaletteBackStyle.ButtonAlternate: case PaletteBackStyle.ButtonLowProfile: case PaletteBackStyle.ButtonBreadCrumb: case PaletteBackStyle.ButtonListItem: case PaletteBackStyle.ButtonCommand: case PaletteBackStyle.ButtonButtonSpec: case PaletteBackStyle.ButtonCalendarDay: case PaletteBackStyle.ButtonCluster: case PaletteBackStyle.ButtonCustom1: case PaletteBackStyle.ButtonCustom2: case PaletteBackStyle.ButtonCustom3: case PaletteBackStyle.ButtonInputControl: case PaletteBackStyle.ContextMenuItemHighlight: return state switch { PaletteState.Disabled => style == PaletteBackStyle.ButtonGallery ? _ribbonColors[(int)SchemeOfficeColors.RibbonGalleryBack1] : _disabledBack, PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1], PaletteState.NormalDefaultOverride => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalDefaultBack1], PaletteState.CheckedNormal => style == PaletteBackStyle.ButtonInputControl ? _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1] : _buttonBackColors[6], PaletteState.Tracking => _buttonBackColors[2], PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBackColors[4], PaletteState.CheckedTracking => style == PaletteBackStyle.ButtonInputControl ? _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1] : _buttonBackColors[8], _ => throw new ArgumentOutOfRangeException(nameof(state)) }; case PaletteBackStyle.ButtonNavigatorStack: case PaletteBackStyle.ButtonNavigatorOverflow: case PaletteBackStyle.ButtonNavigatorMini: return state switch { PaletteState.Disabled => _buttonBackColors[1], PaletteState.Tracking => _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorTrack1], PaletteState.Pressed => _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorPressed1], PaletteState.CheckedNormal or PaletteState.CheckedTracking or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorChecked1], _ => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalNavigatorBack1] }; default: throw new ArgumentOutOfRangeException(nameof(style)); } } /// <summary> /// Gets the second back color. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetBackColor2(PaletteBackStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideStateExclude(state, PaletteState.NormalDefaultOverride)) { return Color.Empty; } switch (style) { case PaletteBackStyle.GridHeaderColumnList: case PaletteBackStyle.GridHeaderColumnCustom1: case PaletteBackStyle.GridHeaderColumnCustom2: case PaletteBackStyle.GridHeaderColumnCustom3: case PaletteBackStyle.GridHeaderRowList: case PaletteBackStyle.GridHeaderRowCustom1: case PaletteBackStyle.GridHeaderRowCustom2: case PaletteBackStyle.GridHeaderRowCustom3: return state switch { PaletteState.Disabled => _disabledBack, PaletteState.Pressed => _ribbonColors[(int)SchemeOfficeColors.GridListPressed2], PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.GridListSelected], _ => _ribbonColors[(int)SchemeOfficeColors.GridListNormal2] }; case PaletteBackStyle.GridHeaderColumnSheet: return state switch { PaletteState.Disabled => _disabledBack, PaletteState.Tracking or PaletteState.Pressed => _ribbonColors[(int)SchemeOfficeColors.GridSheetColPressed2], PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.GridSheetColSelected2], _ => _ribbonColors[(int)SchemeOfficeColors.GridSheetColNormal2] }; case PaletteBackStyle.GridHeaderRowSheet: return state switch { PaletteState.Disabled => _disabledBack, PaletteState.Tracking or PaletteState.Pressed => _ribbonColors[(int)SchemeOfficeColors.GridSheetRowPressed], PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.GridSheetRowSelected], _ => _ribbonColors[(int)SchemeOfficeColors.GridSheetRowNormal] }; case PaletteBackStyle.GridDataCellList: case PaletteBackStyle.GridDataCellCustom1: case PaletteBackStyle.GridDataCellCustom2: case PaletteBackStyle.GridDataCellCustom3: return state == PaletteState.CheckedNormal ? _ribbonColors[(int)SchemeOfficeColors.GridDataCellSelected] : SystemColors.Window; case PaletteBackStyle.GridDataCellSheet: return state == PaletteState.CheckedNormal ? _buttonBackColors[7] : SystemColors.Window; case PaletteBackStyle.TabHighProfile: case PaletteBackStyle.TabStandardProfile: case PaletteBackStyle.TabLowProfile: case PaletteBackStyle.TabOneNote: case PaletteBackStyle.TabCustom1: case PaletteBackStyle.TabCustom2: case PaletteBackStyle.TabCustom3: return state switch { PaletteState.Disabled => style == PaletteBackStyle.TabLowProfile ? Color.Empty : _disabledBack, PaletteState.Normal => style == PaletteBackStyle.TabLowProfile ? Color.Empty : _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack2], PaletteState.Tracking or PaletteState.Pressed => style == PaletteBackStyle.TabLowProfile ? Color.Empty : SystemColors.Window, PaletteState.CheckedNormal or PaletteState.CheckedPressed or PaletteState.CheckedTracking => SystemColors.Window, _ => throw new ArgumentOutOfRangeException(nameof(state)) }; case PaletteBackStyle.TabDock: return state switch { PaletteState.Disabled => _disabledBack, PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.HeaderDockInactiveBack1], PaletteState.Tracking or PaletteState.Pressed => _buttonBackColors[4], PaletteState.CheckedNormal or PaletteState.CheckedPressed or PaletteState.CheckedTracking => SystemColors.Window, _ => throw new ArgumentOutOfRangeException(nameof(state)) }; case PaletteBackStyle.TabDockAutoHidden: return state switch { PaletteState.Disabled => _disabledBack, PaletteState.Normal or PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.HeaderDockInactiveBack1], PaletteState.Tracking or PaletteState.CheckedTracking or PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBackColors[4], _ => throw new ArgumentOutOfRangeException(nameof(state)) }; case PaletteBackStyle.HeaderForm: return state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormBorderHeaderInactive2] : _ribbonColors[(int)SchemeOfficeColors.FormBorderHeaderActive2]; case PaletteBackStyle.HeaderCalendar: return state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.HeaderPrimaryBack1] : _ribbonColors[(int)SchemeOfficeColors.HeaderPrimaryBack2]; case PaletteBackStyle.HeaderPrimary: case PaletteBackStyle.HeaderCustom1: case PaletteBackStyle.HeaderCustom2: case PaletteBackStyle.HeaderCustom3: return state == PaletteState.Disabled ? _disabledBack : _ribbonColors[(int)SchemeOfficeColors.HeaderPrimaryBack2]; case PaletteBackStyle.HeaderDockInactive: return state == PaletteState.Disabled ? _disabledBack : _ribbonColors[(int)SchemeOfficeColors.HeaderDockInactiveBack2]; case PaletteBackStyle.HeaderDockActive: return state == PaletteState.Disabled ? _disabledBack : _buttonBackColors[7]; case PaletteBackStyle.HeaderSecondary: return state == PaletteState.Disabled ? _disabledBack : _ribbonColors[(int)SchemeOfficeColors.HeaderSecondaryBack2]; case PaletteBackStyle.SeparatorHighInternalProfile: return state == PaletteState.Disabled ? _disabledBack : _ribbonColors[(int)SchemeOfficeColors.SeparatorHighInternalBorder2]; case PaletteBackStyle.SeparatorHighProfile: return state == PaletteState.Disabled ? _disabledBack : _ribbonColors[(int)SchemeOfficeColors.SeparatorHighBorder2]; case PaletteBackStyle.SeparatorLowProfile: case PaletteBackStyle.SeparatorCustom1: case PaletteBackStyle.SeparatorCustom2: case PaletteBackStyle.SeparatorCustom3: case PaletteBackStyle.PanelClient: case PaletteBackStyle.PanelCustom1: case PaletteBackStyle.PanelCustom2: case PaletteBackStyle.PanelCustom3: case PaletteBackStyle.ControlGroupBox: case PaletteBackStyle.GridBackgroundList: case PaletteBackStyle.GridBackgroundSheet: case PaletteBackStyle.GridBackgroundCustom1: return _ribbonColors[(int)SchemeOfficeColors.PanelClient]; case PaletteBackStyle.PanelAlternate: return _ribbonColors[(int)SchemeOfficeColors.PanelAlternative]; case PaletteBackStyle.PanelRibbonInactive: return _ribbonColors[(int)SchemeOfficeColors.FormBorderInactiveDark]; case PaletteBackStyle.FormMain: case PaletteBackStyle.FormCustom1: case PaletteBackStyle.FormCustom2: case PaletteBackStyle.FormCustom3: return state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormBorderInactiveDark] : _ribbonColors[(int)SchemeOfficeColors.FormBorderActiveDark]; case PaletteBackStyle.ControlClient: case PaletteBackStyle.ControlAlternate: case PaletteBackStyle.ControlCustom1: case PaletteBackStyle.ControlCustom2: case PaletteBackStyle.ControlCustom3: return SystemColors.Window; case PaletteBackStyle.InputControlStandalone: case PaletteBackStyle.InputControlRibbon: case PaletteBackStyle.InputControlCustom1: case PaletteBackStyle.InputControlCustom2: case PaletteBackStyle.InputControlCustom3: if (state == PaletteState.Disabled) { return _ribbonColors[(int)SchemeOfficeColors.InputControlBackDisabled]; } else { return (state == PaletteState.Tracking) || (style == PaletteBackStyle.InputControlStandalone) ? _ribbonColors[(int)SchemeOfficeColors.InputControlBackNormal] : _ribbonColors[(int)SchemeOfficeColors.InputControlBackInactive]; } case PaletteBackStyle.ControlRibbon: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabSelected4]; case PaletteBackStyle.ControlRibbonAppMenu: return _ribbonColors[(int)SchemeOfficeColors.AppButtonBack2]; case PaletteBackStyle.ControlToolTip: return _ribbonColors[(int)SchemeOfficeColors.ToolTipBottom]; case PaletteBackStyle.ContextMenuOuter: return _contextMenuBack; case PaletteBackStyle.ContextMenuSeparator: case PaletteBackStyle.ContextMenuItemSplit: return state switch { PaletteState.Tracking => _buttonBackColors[3], _ => _contextMenuBack }; case PaletteBackStyle.ContextMenuInner: return _contextMenuBack; case PaletteBackStyle.ContextMenuHeading: return _ribbonColors[(int)SchemeOfficeColors.ContextMenuHeadingBack]; case PaletteBackStyle.ContextMenuItemImageColumn: return _ribbonColors[(int)SchemeOfficeColors.ContextMenuImageColumn]; case PaletteBackStyle.ContextMenuItemImage: return _contextMenuImageBackChecked; case PaletteBackStyle.ButtonForm: return state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride => Color.Empty, PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.FormButtonBack2Checked], PaletteState.Tracking => _ribbonColors[(int)SchemeOfficeColors.FormButtonBack2Track], PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.FormButtonBack2CheckTrack], PaletteState.Pressed or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.FormButtonBack2Pressed], _ => throw new ArgumentOutOfRangeException(nameof(state)) }; case PaletteBackStyle.ButtonFormClose: return state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride => Color.Empty, PaletteState.CheckedNormal => _formCloseChecked2, PaletteState.Tracking => _formCloseTracking2, PaletteState.CheckedTracking => _formCloseCheckedTracking2, PaletteState.Pressed or PaletteState.CheckedPressed => _formClosePressed2, _ => throw new ArgumentOutOfRangeException(nameof(state)) }; case PaletteBackStyle.ButtonStandalone: case PaletteBackStyle.ButtonGallery: case PaletteBackStyle.ButtonAlternate: case PaletteBackStyle.ButtonLowProfile: case PaletteBackStyle.ButtonBreadCrumb: case PaletteBackStyle.ButtonListItem: case PaletteBackStyle.ButtonCommand: case PaletteBackStyle.ButtonButtonSpec: case PaletteBackStyle.ButtonCalendarDay: case PaletteBackStyle.ButtonCluster: case PaletteBackStyle.ButtonCustom1: case PaletteBackStyle.ButtonCustom2: case PaletteBackStyle.ButtonCustom3: case PaletteBackStyle.ButtonInputControl: case PaletteBackStyle.ContextMenuItemHighlight: return state switch { PaletteState.Disabled => style == PaletteBackStyle.ButtonGallery ? _ribbonColors[(int)SchemeOfficeColors.RibbonGalleryBack1] : _buttonBackColors[1], PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack2], PaletteState.NormalDefaultOverride => style is PaletteBackStyle.ButtonLowProfile or PaletteBackStyle.ButtonBreadCrumb or PaletteBackStyle.ButtonListItem or PaletteBackStyle.ButtonCommand or PaletteBackStyle.ButtonButtonSpec or PaletteBackStyle.ContextMenuItemHighlight ? Color.Empty : _ribbonColors[(int)SchemeOfficeColors.ButtonNormalDefaultBack2], PaletteState.CheckedNormal => style == PaletteBackStyle.ButtonInputControl ? _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack2] : _buttonBackColors[7], PaletteState.Tracking => _buttonBackColors[3], PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBackColors[5], PaletteState.CheckedTracking => style == PaletteBackStyle.ButtonInputControl ? _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1] : _buttonBackColors[9], _ => throw new ArgumentOutOfRangeException(nameof(state)) }; case PaletteBackStyle.ButtonNavigatorStack: case PaletteBackStyle.ButtonNavigatorOverflow: case PaletteBackStyle.ButtonNavigatorMini: return state switch { PaletteState.Disabled => _buttonBackColors[1], PaletteState.Tracking => _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorTrack2], PaletteState.Pressed => _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorPressed2], PaletteState.CheckedNormal or PaletteState.CheckedTracking or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorChecked2], _ => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalNavigatorBack2] }; default: throw new ArgumentOutOfRangeException(nameof(style)); } } /// <summary> /// Gets the color background drawing style. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color drawing style.</returns> public override PaletteColorStyle GetBackColorStyle(PaletteBackStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteColorStyle.Inherit; } return style switch { PaletteBackStyle.HeaderForm => PaletteColorStyle.Rounding5, PaletteBackStyle.GridHeaderColumnList or PaletteBackStyle.GridHeaderColumnCustom1 or PaletteBackStyle.GridHeaderColumnCustom2 or PaletteBackStyle.GridHeaderColumnCustom3 => PaletteColorStyle.Rounded, PaletteBackStyle.GridHeaderRowList or PaletteBackStyle.GridHeaderRowCustom1 or PaletteBackStyle.GridHeaderRowCustom2 or PaletteBackStyle.GridHeaderRowCustom3 => PaletteColorStyle.Linear, PaletteBackStyle.GridHeaderColumnSheet or PaletteBackStyle.GridHeaderRowSheet => PaletteColorStyle.Linear, PaletteBackStyle.GridDataCellList or PaletteBackStyle.GridDataCellCustom1 or PaletteBackStyle.GridDataCellCustom2 or PaletteBackStyle.GridDataCellCustom3 => PaletteColorStyle.Solid, PaletteBackStyle.GridDataCellSheet => PaletteColorStyle.ExpertChecked, PaletteBackStyle.TabHighProfile or PaletteBackStyle.TabCustom1 or PaletteBackStyle.TabCustom2 or PaletteBackStyle.TabCustom3 => state switch { PaletteState.Tracking or PaletteState.Pressed or PaletteState.CheckedNormal or PaletteState.CheckedTracking or PaletteState.CheckedPressed => PaletteColorStyle.GlassFade, _ => PaletteColorStyle.QuarterPhase }, PaletteBackStyle.TabStandardProfile => state switch { PaletteState.CheckedNormal or PaletteState.CheckedTracking or PaletteState.CheckedPressed => PaletteColorStyle.Solid, PaletteState.Tracking or PaletteState.Pressed => PaletteColorStyle.GlassFade, _ => PaletteColorStyle.QuarterPhase }, PaletteBackStyle.TabLowProfile => PaletteColorStyle.Solid, PaletteBackStyle.TabOneNote or PaletteBackStyle.TabDock or PaletteBackStyle.TabDockAutoHidden => PaletteColorStyle.Linear, PaletteBackStyle.PanelClient or PaletteBackStyle.PanelRibbonInactive or PaletteBackStyle.PanelAlternate or PaletteBackStyle.PanelCustom1 or PaletteBackStyle.PanelCustom2 or PaletteBackStyle.PanelCustom3 or PaletteBackStyle.SeparatorLowProfile or PaletteBackStyle.SeparatorCustom1 or PaletteBackStyle.SeparatorCustom2 or PaletteBackStyle.SeparatorCustom3 or PaletteBackStyle.ControlClient or PaletteBackStyle.ControlAlternate or PaletteBackStyle.ControlGroupBox or PaletteBackStyle.ControlRibbon or PaletteBackStyle.ContextMenuOuter or PaletteBackStyle.ContextMenuInner or PaletteBackStyle.ControlCustom1 or PaletteBackStyle.ControlCustom2 or PaletteBackStyle.ControlCustom3 or PaletteBackStyle.ContextMenuHeading or PaletteBackStyle.ContextMenuItemImageColumn or PaletteBackStyle.InputControlStandalone or PaletteBackStyle.InputControlRibbon or PaletteBackStyle.InputControlCustom1 or PaletteBackStyle.InputControlCustom2 or PaletteBackStyle.InputControlCustom3 or PaletteBackStyle.GridBackgroundList or PaletteBackStyle.GridBackgroundSheet or PaletteBackStyle.GridBackgroundCustom1 or PaletteBackStyle.HeaderCalendar or PaletteBackStyle.ButtonCalendarDay => PaletteColorStyle.Solid, PaletteBackStyle.ControlRibbonAppMenu => PaletteColorStyle.Switch90, PaletteBackStyle.ContextMenuSeparator or PaletteBackStyle.ContextMenuItemSplit => state == PaletteState.Tracking ? PaletteColorStyle.GlassTrackingFull : PaletteColorStyle.Solid, PaletteBackStyle.ControlToolTip => PaletteColorStyle.Linear, PaletteBackStyle.FormMain or PaletteBackStyle.FormCustom1 or PaletteBackStyle.FormCustom2 or PaletteBackStyle.FormCustom3 => PaletteColorStyle.SolidAllLine, PaletteBackStyle.SeparatorHighProfile => PaletteColorStyle.RoundedTopLight, PaletteBackStyle.SeparatorHighInternalProfile => PaletteColorStyle.Linear, PaletteBackStyle.HeaderPrimary or PaletteBackStyle.HeaderDockInactive or PaletteBackStyle.HeaderSecondary or PaletteBackStyle.HeaderCustom1 or PaletteBackStyle.HeaderCustom2 or PaletteBackStyle.HeaderCustom3 or PaletteBackStyle.HeaderDockActive => PaletteColorStyle.Rounded, PaletteBackStyle.ButtonForm or PaletteBackStyle.ButtonFormClose => state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride or PaletteState.CheckedNormal or PaletteState.Tracking or PaletteState.CheckedTracking => PaletteColorStyle.Linear, PaletteState.Pressed or PaletteState.CheckedPressed => PaletteColorStyle.LinearShadow, _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBackStyle.ButtonAlternate or PaletteBackStyle.ButtonStandalone or PaletteBackStyle.ButtonLowProfile or PaletteBackStyle.ButtonBreadCrumb or PaletteBackStyle.ButtonListItem or PaletteBackStyle.ButtonCommand or PaletteBackStyle.ButtonButtonSpec or PaletteBackStyle.ButtonCluster or PaletteBackStyle.ButtonGallery or PaletteBackStyle.ButtonCustom1 or PaletteBackStyle.ButtonCustom2 or PaletteBackStyle.ButtonCustom3 or PaletteBackStyle.ButtonInputControl or PaletteBackStyle.ContextMenuItemHighlight => state switch { PaletteState.Disabled => PaletteColorStyle.Solid, PaletteState.Normal => PaletteColorStyle.Linear, PaletteState.Tracking => PaletteColorStyle.ExpertTracking, PaletteState.Pressed or PaletteState.CheckedPressed => PaletteColorStyle.ExpertPressed, PaletteState.CheckedNormal => PaletteColorStyle.ExpertChecked, PaletteState.CheckedTracking => PaletteColorStyle.ExpertCheckedTracking, _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBackStyle.ContextMenuItemImage => PaletteColorStyle.Solid, PaletteBackStyle.ButtonNavigatorStack or PaletteBackStyle.ButtonNavigatorOverflow or PaletteBackStyle.ButtonNavigatorMini => state switch { PaletteState.Tracking or PaletteState.Pressed => PaletteColorStyle.SolidAllLine, PaletteState.CheckedNormal or PaletteState.CheckedTracking or PaletteState.CheckedPressed => PaletteColorStyle.ExpertSquareHighlight, _ => PaletteColorStyle.Solid }, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color alignment. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color alignment style.</returns> public override PaletteRectangleAlign GetBackColorAlign(PaletteBackStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRectangleAlign.Inherit; } return style switch { PaletteBackStyle.ControlClient or PaletteBackStyle.ControlAlternate or PaletteBackStyle.ControlGroupBox or PaletteBackStyle.ControlRibbon or PaletteBackStyle.ControlRibbonAppMenu or PaletteBackStyle.ControlCustom1 or PaletteBackStyle.ControlCustom2 or PaletteBackStyle.ControlCustom3 or PaletteBackStyle.InputControlStandalone or PaletteBackStyle.InputControlRibbon or PaletteBackStyle.InputControlCustom1 or PaletteBackStyle.InputControlCustom2 or PaletteBackStyle.InputControlCustom3 or PaletteBackStyle.FormMain or PaletteBackStyle.FormCustom1 or PaletteBackStyle.FormCustom2 or PaletteBackStyle.FormCustom3 or PaletteBackStyle.PanelClient or PaletteBackStyle.PanelRibbonInactive or PaletteBackStyle.PanelAlternate or PaletteBackStyle.PanelCustom1 or PaletteBackStyle.PanelCustom2 or PaletteBackStyle.PanelCustom3 or PaletteBackStyle.GridBackgroundList or PaletteBackStyle.GridBackgroundSheet or PaletteBackStyle.GridBackgroundCustom1 => PaletteRectangleAlign.Control, PaletteBackStyle.ControlToolTip or PaletteBackStyle.SeparatorLowProfile or PaletteBackStyle.SeparatorHighInternalProfile or PaletteBackStyle.SeparatorHighProfile or PaletteBackStyle.SeparatorCustom1 or PaletteBackStyle.SeparatorCustom2 or PaletteBackStyle.SeparatorCustom3 or PaletteBackStyle.HeaderPrimary or PaletteBackStyle.HeaderDockInactive or PaletteBackStyle.HeaderDockActive or PaletteBackStyle.HeaderCalendar or PaletteBackStyle.HeaderSecondary or PaletteBackStyle.HeaderForm or PaletteBackStyle.HeaderCustom1 or PaletteBackStyle.HeaderCustom2 or PaletteBackStyle.HeaderCustom3 or PaletteBackStyle.TabHighProfile or PaletteBackStyle.TabStandardProfile or PaletteBackStyle.TabLowProfile or PaletteBackStyle.TabOneNote or PaletteBackStyle.TabDock or PaletteBackStyle.TabDockAutoHidden or PaletteBackStyle.TabCustom1 or PaletteBackStyle.TabCustom2 or PaletteBackStyle.TabCustom3 or PaletteBackStyle.ButtonStandalone or PaletteBackStyle.ButtonGallery or PaletteBackStyle.ButtonAlternate or PaletteBackStyle.ButtonLowProfile or PaletteBackStyle.ButtonBreadCrumb or PaletteBackStyle.ButtonListItem or PaletteBackStyle.ButtonCommand or PaletteBackStyle.ButtonButtonSpec or PaletteBackStyle.ButtonCalendarDay or PaletteBackStyle.ButtonCluster or PaletteBackStyle.ButtonNavigatorStack or PaletteBackStyle.ButtonNavigatorOverflow or PaletteBackStyle.ButtonNavigatorMini or PaletteBackStyle.ButtonForm or PaletteBackStyle.ButtonFormClose or PaletteBackStyle.ButtonCustom1 or PaletteBackStyle.ButtonCustom2 or PaletteBackStyle.ButtonCustom3 or PaletteBackStyle.ButtonInputControl or PaletteBackStyle.GridHeaderColumnList or PaletteBackStyle.GridHeaderColumnSheet or PaletteBackStyle.GridHeaderColumnCustom1 or PaletteBackStyle.GridHeaderColumnCustom2 or PaletteBackStyle.GridHeaderColumnCustom3 or PaletteBackStyle.GridHeaderRowList or PaletteBackStyle.GridHeaderRowSheet or PaletteBackStyle.GridHeaderRowCustom1 or PaletteBackStyle.GridHeaderRowCustom2 or PaletteBackStyle.GridHeaderRowCustom3 or PaletteBackStyle.GridDataCellList or PaletteBackStyle.GridDataCellSheet or PaletteBackStyle.GridDataCellCustom1 or PaletteBackStyle.GridDataCellCustom2 or PaletteBackStyle.GridDataCellCustom3 or PaletteBackStyle.ContextMenuItemImage or PaletteBackStyle.ContextMenuItemHighlight or PaletteBackStyle.ContextMenuOuter or PaletteBackStyle.ContextMenuInner or PaletteBackStyle.ContextMenuHeading or PaletteBackStyle.ContextMenuSeparator or PaletteBackStyle.ContextMenuItemSplit or PaletteBackStyle.ContextMenuItemImageColumn => PaletteRectangleAlign.Local, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color background angle. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Angle used for color drawing.</returns> public override float GetBackColorAngle(PaletteBackStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return -1f; } return style switch { PaletteBackStyle.PanelClient or PaletteBackStyle.PanelRibbonInactive or PaletteBackStyle.PanelAlternate or PaletteBackStyle.PanelCustom1 or PaletteBackStyle.PanelCustom2 or PaletteBackStyle.PanelCustom3 or PaletteBackStyle.SeparatorLowProfile or PaletteBackStyle.SeparatorHighInternalProfile or PaletteBackStyle.SeparatorHighProfile or PaletteBackStyle.SeparatorCustom1 or PaletteBackStyle.SeparatorCustom2 or PaletteBackStyle.SeparatorCustom3 or PaletteBackStyle.ControlClient or PaletteBackStyle.ControlAlternate or PaletteBackStyle.ControlGroupBox or PaletteBackStyle.ControlToolTip or PaletteBackStyle.ControlRibbon or PaletteBackStyle.ControlRibbonAppMenu or PaletteBackStyle.ControlCustom1 or PaletteBackStyle.ControlCustom2 or PaletteBackStyle.ControlCustom3 or PaletteBackStyle.ContextMenuOuter or PaletteBackStyle.ContextMenuInner or PaletteBackStyle.ContextMenuHeading or PaletteBackStyle.ContextMenuSeparator or PaletteBackStyle.ContextMenuItemSplit or PaletteBackStyle.ContextMenuItemImageColumn or PaletteBackStyle.InputControlStandalone or PaletteBackStyle.InputControlRibbon or PaletteBackStyle.InputControlCustom1 or PaletteBackStyle.InputControlCustom2 or PaletteBackStyle.InputControlCustom3 or PaletteBackStyle.FormMain or PaletteBackStyle.FormCustom1 or PaletteBackStyle.FormCustom2 or PaletteBackStyle.FormCustom3 or PaletteBackStyle.HeaderPrimary or PaletteBackStyle.HeaderDockInactive or PaletteBackStyle.HeaderDockActive or PaletteBackStyle.HeaderCalendar or PaletteBackStyle.HeaderSecondary or PaletteBackStyle.HeaderForm or PaletteBackStyle.HeaderCustom1 or PaletteBackStyle.HeaderCustom2 or PaletteBackStyle.HeaderCustom3 or PaletteBackStyle.TabHighProfile or PaletteBackStyle.TabStandardProfile or PaletteBackStyle.TabLowProfile or PaletteBackStyle.TabOneNote or PaletteBackStyle.TabDock or PaletteBackStyle.TabDockAutoHidden or PaletteBackStyle.TabCustom1 or PaletteBackStyle.TabCustom2 or PaletteBackStyle.TabCustom3 or PaletteBackStyle.ButtonStandalone or PaletteBackStyle.ButtonGallery or PaletteBackStyle.ButtonAlternate or PaletteBackStyle.ButtonLowProfile or PaletteBackStyle.ButtonBreadCrumb or PaletteBackStyle.ButtonListItem or PaletteBackStyle.ButtonCommand or PaletteBackStyle.ButtonButtonSpec or PaletteBackStyle.ButtonCalendarDay or PaletteBackStyle.ButtonCluster or PaletteBackStyle.ButtonNavigatorStack or PaletteBackStyle.ButtonNavigatorOverflow or PaletteBackStyle.ButtonNavigatorMini or PaletteBackStyle.ButtonForm or PaletteBackStyle.ButtonFormClose or PaletteBackStyle.ButtonCustom1 or PaletteBackStyle.ButtonCustom2 or PaletteBackStyle.ButtonCustom3 or PaletteBackStyle.ButtonInputControl or PaletteBackStyle.ContextMenuItemImage or PaletteBackStyle.ContextMenuItemHighlight or PaletteBackStyle.GridBackgroundList or PaletteBackStyle.GridBackgroundSheet or PaletteBackStyle.GridBackgroundCustom1 or PaletteBackStyle.GridHeaderColumnList or PaletteBackStyle.GridHeaderColumnSheet or PaletteBackStyle.GridHeaderColumnCustom1 or PaletteBackStyle.GridHeaderColumnCustom2 or PaletteBackStyle.GridHeaderColumnCustom3 or PaletteBackStyle.GridHeaderRowList or PaletteBackStyle.GridHeaderRowSheet or PaletteBackStyle.GridHeaderRowCustom1 or PaletteBackStyle.GridHeaderRowCustom2 or PaletteBackStyle.GridHeaderRowCustom3 or PaletteBackStyle.GridDataCellList or PaletteBackStyle.GridDataCellSheet or PaletteBackStyle.GridDataCellCustom1 or PaletteBackStyle.GridDataCellCustom2 or PaletteBackStyle.GridDataCellCustom3 => 90f, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets a background image. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image instance.</returns> public override Image GetBackImage(PaletteBackStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return null; } return style switch { PaletteBackStyle.PanelClient or PaletteBackStyle.PanelRibbonInactive or PaletteBackStyle.PanelAlternate or PaletteBackStyle.PanelCustom1 or PaletteBackStyle.PanelCustom2 or PaletteBackStyle.PanelCustom3 or PaletteBackStyle.SeparatorLowProfile or PaletteBackStyle.SeparatorHighInternalProfile or PaletteBackStyle.SeparatorHighProfile or PaletteBackStyle.SeparatorCustom1 or PaletteBackStyle.SeparatorCustom2 or PaletteBackStyle.SeparatorCustom3 or PaletteBackStyle.ControlClient or PaletteBackStyle.ControlAlternate or PaletteBackStyle.ControlGroupBox or PaletteBackStyle.ControlToolTip or PaletteBackStyle.ControlRibbon or PaletteBackStyle.ControlRibbonAppMenu or PaletteBackStyle.ControlCustom1 or PaletteBackStyle.ControlCustom2 or PaletteBackStyle.ControlCustom3 or PaletteBackStyle.ContextMenuOuter or PaletteBackStyle.ContextMenuInner or PaletteBackStyle.ContextMenuHeading or PaletteBackStyle.ContextMenuSeparator or PaletteBackStyle.ContextMenuItemSplit or PaletteBackStyle.ContextMenuItemImageColumn or PaletteBackStyle.InputControlStandalone or PaletteBackStyle.InputControlRibbon or PaletteBackStyle.InputControlCustom1 or PaletteBackStyle.InputControlCustom2 or PaletteBackStyle.InputControlCustom3 or PaletteBackStyle.FormMain or PaletteBackStyle.FormCustom1 or PaletteBackStyle.FormCustom2 or PaletteBackStyle.FormCustom3 or PaletteBackStyle.HeaderPrimary or PaletteBackStyle.HeaderDockInactive or PaletteBackStyle.HeaderDockActive or PaletteBackStyle.HeaderCalendar or PaletteBackStyle.HeaderSecondary or PaletteBackStyle.HeaderForm or PaletteBackStyle.HeaderCustom1 or PaletteBackStyle.HeaderCustom2 or PaletteBackStyle.HeaderCustom3 or PaletteBackStyle.TabHighProfile or PaletteBackStyle.TabStandardProfile or PaletteBackStyle.TabLowProfile or PaletteBackStyle.TabOneNote or PaletteBackStyle.TabDock or PaletteBackStyle.TabDockAutoHidden or PaletteBackStyle.TabCustom1 or PaletteBackStyle.TabCustom2 or PaletteBackStyle.TabCustom3 or PaletteBackStyle.ButtonStandalone or PaletteBackStyle.ButtonGallery or PaletteBackStyle.ButtonAlternate or PaletteBackStyle.ButtonLowProfile or PaletteBackStyle.ButtonBreadCrumb or PaletteBackStyle.ButtonListItem or PaletteBackStyle.ButtonCommand or PaletteBackStyle.ButtonButtonSpec or PaletteBackStyle.ButtonCalendarDay or PaletteBackStyle.ButtonCluster or PaletteBackStyle.ButtonNavigatorStack or PaletteBackStyle.ButtonNavigatorOverflow or PaletteBackStyle.ButtonNavigatorMini or PaletteBackStyle.ButtonForm or PaletteBackStyle.ButtonFormClose or PaletteBackStyle.ButtonCustom1 or PaletteBackStyle.ButtonCustom2 or PaletteBackStyle.ButtonCustom3 or PaletteBackStyle.ButtonInputControl or PaletteBackStyle.ContextMenuItemImage or PaletteBackStyle.ContextMenuItemHighlight or PaletteBackStyle.GridBackgroundList or PaletteBackStyle.GridBackgroundSheet or PaletteBackStyle.GridBackgroundCustom1 or PaletteBackStyle.GridHeaderColumnList or PaletteBackStyle.GridHeaderColumnSheet or PaletteBackStyle.GridHeaderColumnCustom1 or PaletteBackStyle.GridHeaderColumnCustom2 or PaletteBackStyle.GridHeaderColumnCustom3 or PaletteBackStyle.GridHeaderRowList or PaletteBackStyle.GridHeaderRowSheet or PaletteBackStyle.GridHeaderRowCustom1 or PaletteBackStyle.GridHeaderRowCustom2 or PaletteBackStyle.GridHeaderRowCustom3 or PaletteBackStyle.GridDataCellList or PaletteBackStyle.GridDataCellSheet or PaletteBackStyle.GridDataCellCustom1 or PaletteBackStyle.GridDataCellCustom2 or PaletteBackStyle.GridDataCellCustom3 => null, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the background image style. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image style value.</returns> public override PaletteImageStyle GetBackImageStyle(PaletteBackStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteImageStyle.Inherit; } return style switch { PaletteBackStyle.PanelClient or PaletteBackStyle.PanelRibbonInactive or PaletteBackStyle.PanelAlternate or PaletteBackStyle.PanelCustom1 or PaletteBackStyle.PanelCustom2 or PaletteBackStyle.PanelCustom3 or PaletteBackStyle.SeparatorLowProfile or PaletteBackStyle.SeparatorHighInternalProfile or PaletteBackStyle.SeparatorHighProfile or PaletteBackStyle.SeparatorCustom1 or PaletteBackStyle.SeparatorCustom2 or PaletteBackStyle.SeparatorCustom3 or PaletteBackStyle.ControlClient or PaletteBackStyle.ControlAlternate or PaletteBackStyle.ControlGroupBox or PaletteBackStyle.ControlToolTip or PaletteBackStyle.ControlRibbon or PaletteBackStyle.ControlRibbonAppMenu or PaletteBackStyle.ControlCustom1 or PaletteBackStyle.ControlCustom2 or PaletteBackStyle.ControlCustom3 or PaletteBackStyle.ContextMenuOuter or PaletteBackStyle.ContextMenuInner or PaletteBackStyle.ContextMenuHeading or PaletteBackStyle.ContextMenuSeparator or PaletteBackStyle.ContextMenuItemSplit or PaletteBackStyle.ContextMenuItemImageColumn or PaletteBackStyle.InputControlStandalone or PaletteBackStyle.InputControlRibbon or PaletteBackStyle.InputControlCustom1 or PaletteBackStyle.InputControlCustom2 or PaletteBackStyle.InputControlCustom3 or PaletteBackStyle.FormMain or PaletteBackStyle.FormCustom1 or PaletteBackStyle.FormCustom2 or PaletteBackStyle.FormCustom3 or PaletteBackStyle.HeaderPrimary or PaletteBackStyle.HeaderDockInactive or PaletteBackStyle.HeaderDockActive or PaletteBackStyle.HeaderCalendar or PaletteBackStyle.HeaderSecondary or PaletteBackStyle.HeaderForm or PaletteBackStyle.HeaderCustom1 or PaletteBackStyle.HeaderCustom2 or PaletteBackStyle.HeaderCustom3 or PaletteBackStyle.TabHighProfile or PaletteBackStyle.TabStandardProfile or PaletteBackStyle.TabLowProfile or PaletteBackStyle.TabOneNote or PaletteBackStyle.TabDock or PaletteBackStyle.TabDockAutoHidden or PaletteBackStyle.TabCustom1 or PaletteBackStyle.TabCustom2 or PaletteBackStyle.TabCustom3 or PaletteBackStyle.ButtonStandalone or PaletteBackStyle.ButtonGallery or PaletteBackStyle.ButtonAlternate or PaletteBackStyle.ButtonLowProfile or PaletteBackStyle.ButtonBreadCrumb or PaletteBackStyle.ButtonListItem or PaletteBackStyle.ButtonCommand or PaletteBackStyle.ButtonButtonSpec or PaletteBackStyle.ButtonCalendarDay or PaletteBackStyle.ButtonCluster or PaletteBackStyle.ButtonNavigatorStack or PaletteBackStyle.ButtonNavigatorOverflow or PaletteBackStyle.ButtonNavigatorMini or PaletteBackStyle.ButtonForm or PaletteBackStyle.ButtonFormClose or PaletteBackStyle.ButtonCustom1 or PaletteBackStyle.ButtonCustom2 or PaletteBackStyle.ButtonCustom3 or PaletteBackStyle.ButtonInputControl or PaletteBackStyle.ContextMenuItemImage or PaletteBackStyle.ContextMenuItemHighlight or PaletteBackStyle.GridBackgroundList or PaletteBackStyle.GridBackgroundSheet or PaletteBackStyle.GridBackgroundCustom1 or PaletteBackStyle.GridHeaderColumnList or PaletteBackStyle.GridHeaderColumnSheet or PaletteBackStyle.GridHeaderColumnCustom1 or PaletteBackStyle.GridHeaderColumnCustom2 or PaletteBackStyle.GridHeaderColumnCustom3 or PaletteBackStyle.GridHeaderRowList or PaletteBackStyle.GridHeaderRowSheet or PaletteBackStyle.GridHeaderRowCustom1 or PaletteBackStyle.GridHeaderRowCustom2 or PaletteBackStyle.GridHeaderRowCustom3 or PaletteBackStyle.GridDataCellList or PaletteBackStyle.GridDataCellSheet or PaletteBackStyle.GridDataCellCustom1 or PaletteBackStyle.GridDataCellCustom2 or PaletteBackStyle.GridDataCellCustom3 => PaletteImageStyle.Tile, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the image alignment. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image alignment style.</returns> public override PaletteRectangleAlign GetBackImageAlign(PaletteBackStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRectangleAlign.Inherit; } return style switch { PaletteBackStyle.PanelClient or PaletteBackStyle.PanelRibbonInactive or PaletteBackStyle.PanelAlternate or PaletteBackStyle.PanelCustom1 or PaletteBackStyle.PanelCustom2 or PaletteBackStyle.PanelCustom3 or PaletteBackStyle.SeparatorLowProfile or PaletteBackStyle.SeparatorHighInternalProfile or PaletteBackStyle.SeparatorHighProfile or PaletteBackStyle.SeparatorCustom1 or PaletteBackStyle.SeparatorCustom2 or PaletteBackStyle.SeparatorCustom3 or PaletteBackStyle.ControlClient or PaletteBackStyle.ControlAlternate or PaletteBackStyle.ControlGroupBox or PaletteBackStyle.ControlToolTip or PaletteBackStyle.ControlRibbon or PaletteBackStyle.ControlRibbonAppMenu or PaletteBackStyle.ControlCustom1 or PaletteBackStyle.ControlCustom2 or PaletteBackStyle.ControlCustom3 or PaletteBackStyle.ContextMenuOuter or PaletteBackStyle.ContextMenuInner or PaletteBackStyle.ContextMenuHeading or PaletteBackStyle.ContextMenuSeparator or PaletteBackStyle.ContextMenuItemSplit or PaletteBackStyle.ContextMenuItemImageColumn or PaletteBackStyle.InputControlStandalone or PaletteBackStyle.InputControlRibbon or PaletteBackStyle.InputControlCustom1 or PaletteBackStyle.InputControlCustom2 or PaletteBackStyle.InputControlCustom3 or PaletteBackStyle.FormMain or PaletteBackStyle.FormCustom1 or PaletteBackStyle.FormCustom2 or PaletteBackStyle.FormCustom3 or PaletteBackStyle.HeaderPrimary or PaletteBackStyle.HeaderDockInactive or PaletteBackStyle.HeaderDockActive or PaletteBackStyle.HeaderCalendar or PaletteBackStyle.HeaderSecondary or PaletteBackStyle.HeaderForm or PaletteBackStyle.HeaderCustom1 or PaletteBackStyle.HeaderCustom2 or PaletteBackStyle.HeaderCustom3 or PaletteBackStyle.TabHighProfile or PaletteBackStyle.TabStandardProfile or PaletteBackStyle.TabLowProfile or PaletteBackStyle.TabOneNote or PaletteBackStyle.TabDock or PaletteBackStyle.TabDockAutoHidden or PaletteBackStyle.TabCustom1 or PaletteBackStyle.TabCustom2 or PaletteBackStyle.TabCustom3 or PaletteBackStyle.ButtonStandalone or PaletteBackStyle.ButtonGallery or PaletteBackStyle.ButtonAlternate or PaletteBackStyle.ButtonLowProfile or PaletteBackStyle.ButtonBreadCrumb or PaletteBackStyle.ButtonListItem or PaletteBackStyle.ButtonCommand or PaletteBackStyle.ButtonButtonSpec or PaletteBackStyle.ButtonCalendarDay or PaletteBackStyle.ButtonCluster or PaletteBackStyle.ButtonNavigatorStack or PaletteBackStyle.ButtonNavigatorOverflow or PaletteBackStyle.ButtonNavigatorMini or PaletteBackStyle.ButtonForm or PaletteBackStyle.ButtonFormClose or PaletteBackStyle.ButtonCustom1 or PaletteBackStyle.ButtonCustom2 or PaletteBackStyle.ButtonCustom3 or PaletteBackStyle.ButtonInputControl or PaletteBackStyle.ContextMenuItemImage or PaletteBackStyle.ContextMenuItemHighlight or PaletteBackStyle.GridBackgroundList or PaletteBackStyle.GridBackgroundSheet or PaletteBackStyle.GridBackgroundCustom1 or PaletteBackStyle.GridHeaderColumnList or PaletteBackStyle.GridHeaderColumnSheet or PaletteBackStyle.GridHeaderColumnCustom1 or PaletteBackStyle.GridHeaderColumnCustom2 or PaletteBackStyle.GridHeaderColumnCustom3 or PaletteBackStyle.GridHeaderRowList or PaletteBackStyle.GridHeaderRowSheet or PaletteBackStyle.GridHeaderRowCustom1 or PaletteBackStyle.GridHeaderRowCustom2 or PaletteBackStyle.GridHeaderRowCustom3 or PaletteBackStyle.GridDataCellList or PaletteBackStyle.GridDataCellSheet or PaletteBackStyle.GridDataCellCustom1 or PaletteBackStyle.GridDataCellCustom2 or PaletteBackStyle.GridDataCellCustom3 => PaletteRectangleAlign.Local, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } #endregion #region Border /// <summary> /// Gets a value indicating if border should be drawn. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBorderDraw(PaletteBorderStyle style, PaletteState state) { // Check for the calendar day today override if (state == PaletteState.TodayOverride) { if (style == PaletteBorderStyle.ButtonCalendarDay) { return InheritBool.True; } } // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return InheritBool.Inherit; } return style switch { PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.ButtonNavigatorMini or PaletteBorderStyle.ContextMenuInner => InheritBool.False, PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit or PaletteBorderStyle.ContextMenuItemImageColumn or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.HeaderForm or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabDock or PaletteBorderStyle.TabDockAutoHidden or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 => InheritBool.True, PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCalendarDay or PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose or PaletteBorderStyle.ButtonInputControl => state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride => InheritBool.False, _ => InheritBool.True }, PaletteBorderStyle.ContextMenuItemImage or PaletteBorderStyle.ContextMenuItemHighlight => state switch { PaletteState.Normal or PaletteState.NormalDefaultOverride => InheritBool.False, _ => InheritBool.True }, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets a value indicating which borders to draw. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteDrawBorders value.</returns> public override PaletteDrawBorders GetBorderDrawBorders(PaletteBorderStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteDrawBorders.Inherit; } return style switch { PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCalendarDay or PaletteBorderStyle.ButtonInputControl or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ContextMenuItemImage or PaletteBorderStyle.ContextMenuItemHighlight or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 => PaletteDrawBorders.All, PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabDock or PaletteBorderStyle.TabDockAutoHidden or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 => PaletteDrawBorders.All, PaletteBorderStyle.ContextMenuHeading => PaletteDrawBorders.Bottom, PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit => PaletteDrawBorders.Top, PaletteBorderStyle.ContextMenuItemImageColumn => PaletteDrawBorders.Right, PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini or PaletteBorderStyle.ContextMenuInner => PaletteDrawBorders.None, PaletteBorderStyle.HeaderForm => PaletteDrawBorders.TopLeftRight, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the graphics drawing hint for the border. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteGraphicsHint value.</returns> public override PaletteGraphicsHint GetBorderGraphicsHint(PaletteBorderStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteGraphicsHint.Inherit; } return style switch { PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabDock or PaletteBorderStyle.TabDockAutoHidden or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 or PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.ContextMenuInner or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit or PaletteBorderStyle.ContextMenuItemImageColumn or PaletteBorderStyle.ContextMenuItemImage or PaletteBorderStyle.ContextMenuItemHighlight or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderForm or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCalendarDay or PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini or PaletteBorderStyle.ButtonInputControl or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 => PaletteGraphicsHint.AntiAlias, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the first border color. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetBorderColor1(PaletteBorderStyle style, PaletteState state) { if (CommonHelper.IsOverrideStateExclude(state, PaletteState.NormalDefaultOverride)) { // Check for the calendar day today override if (state == PaletteState.TodayOverride) { if (style == PaletteBorderStyle.ButtonCalendarDay) { return state == PaletteState.Disabled ? _disabledBorder : _todayBorder; } } return Color.Empty; } return style switch { PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 => state switch { PaletteState.Disabled => style == PaletteBorderStyle.TabLowProfile ? Color.Empty : _disabledBorder, PaletteState.Normal or PaletteState.Tracking or PaletteState.Pressed => style == PaletteBorderStyle.TabLowProfile ? Color.Empty : _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.CheckedNormal or PaletteState.CheckedPressed or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.ControlBorder], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.TabDock => state switch { PaletteState.Disabled => _disabledBorder, PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.Tracking or PaletteState.Pressed => _buttonBorderColors[2], PaletteState.CheckedNormal or PaletteState.CheckedPressed or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.ControlBorder], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.TabDockAutoHidden => state switch { PaletteState.Disabled => _disabledBorder, PaletteState.Normal or PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.Tracking or PaletteState.CheckedTracking or PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBorderColors[2], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.HeaderCalendar => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.HeaderPrimaryBack1] : _ribbonColors[(int)SchemeOfficeColors.HeaderPrimaryBack2], PaletteBorderStyle.HeaderForm => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormBorderHeaderInactive] : _ribbonColors[(int)SchemeOfficeColors.FormBorderHeaderActive], PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 => state == PaletteState.Disabled ? _disabledBorder : _ribbonColors[(int)SchemeOfficeColors.ControlBorder], PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuItemImageColumn => _contextMenuHeadingBorder, PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit => state switch { PaletteState.Disabled => _buttonBorderColors[0], PaletteState.Tracking => _buttonBorderColors[1], _ => _contextMenuHeadingBorder }, PaletteBorderStyle.ContextMenuItemImage => _contextMenuImageBorderChecked, PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.InputControlBorderDisabled] : _ribbonColors[(int)SchemeOfficeColors.InputControlBorderNormal], PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 => state == PaletteState.Disabled ? _disabledBorder : _ribbonColors[(int)SchemeOfficeColors.GridDataCellBorder], PaletteBorderStyle.ControlRibbon => state == PaletteState.Disabled ? _disabledBorder : _ribbonColors[(int)SchemeOfficeColors.RibbonGroupsArea1], PaletteBorderStyle.ControlRibbonAppMenu => state == PaletteState.Disabled ? _disabledBorder : _ribbonColors[(int)SchemeOfficeColors.AppButtonBorder], PaletteBorderStyle.ContextMenuOuter => _contextMenuBorder, PaletteBorderStyle.ContextMenuInner => _contextMenuBack, PaletteBorderStyle.ControlToolTip => state == PaletteState.Disabled ? _disabledBorder : _toolTipBorder, PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormBorderInactive] : _ribbonColors[(int)SchemeOfficeColors.FormBorderActive], PaletteBorderStyle.ButtonForm => state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride => Color.Empty, PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.FormButtonBorderCheck], PaletteState.Tracking or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.FormButtonBorderTrack], PaletteState.Pressed or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.FormButtonBorderPressed], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.ButtonFormClose => state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride => Color.Empty, PaletteState.CheckedNormal => _formCloseBorderCheckedNormal, PaletteState.Tracking or PaletteState.CheckedTracking => _formCloseBorderTracking, PaletteState.Pressed or PaletteState.CheckedPressed => _formCloseBorderPressed, _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ContextMenuItemHighlight => state switch { PaletteState.Disabled => style == PaletteBorderStyle.ButtonGallery ? _ribbonColors[(int)SchemeOfficeColors.RibbonGalleryBack2] : _buttonBorderColors[0], PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.NormalDefaultOverride => style is PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ContextMenuItemHighlight ? Color.Empty : _ribbonColors[(int)SchemeOfficeColors.ButtonNormalDefaultBorder], PaletteState.CheckedNormal => _buttonBorderColors[5], PaletteState.Tracking => _buttonBorderColors[1], PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBorderColors[3], PaletteState.CheckedTracking => _buttonBorderColors[3], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.ButtonInputControl => state switch { PaletteState.Disabled => _buttonBorderColors[0], PaletteState.Normal or PaletteState.CheckedNormal or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.Tracking => _buttonBorderColors[1], PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBorderColors[3], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.ButtonCalendarDay => state switch { PaletteState.Disabled => _disabledBack, PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1], PaletteState.NormalDefaultOverride => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalDefaultBack1], PaletteState.CheckedNormal => _buttonBackColors[6], PaletteState.Tracking => _buttonBackColors[2], PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBackColors[4], PaletteState.CheckedTracking => _buttonBackColors[8], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini => _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorBorder], _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the second border color. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetBorderColor2(PaletteBorderStyle style, PaletteState state) { if (CommonHelper.IsOverrideState(state)) { // Check for the calendar day today override if (state == PaletteState.TodayOverride) { if (style == PaletteBorderStyle.ButtonCalendarDay) { return state == PaletteState.Disabled ? _disabledBorder : _todayBorder; } } return Color.Empty; } return style switch { PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 => state switch { PaletteState.Disabled => style == PaletteBorderStyle.TabLowProfile ? Color.Empty : _disabledBorder, PaletteState.Normal or PaletteState.Tracking or PaletteState.Pressed => style == PaletteBorderStyle.TabLowProfile ? Color.Empty : _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.CheckedNormal or PaletteState.CheckedPressed or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.ControlBorder], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.TabDock => state switch { PaletteState.Disabled => _disabledBorder, PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.Tracking or PaletteState.Pressed => _buttonBorderColors[2], PaletteState.CheckedNormal or PaletteState.CheckedPressed or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.ControlBorder], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.TabDockAutoHidden => state switch { PaletteState.Disabled => _disabledBorder, PaletteState.Normal or PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.Tracking or PaletteState.CheckedTracking or PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBorderColors[2], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.HeaderForm => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormBorderHeaderInactive] : _ribbonColors[(int)SchemeOfficeColors.FormBorderHeaderActive], PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 => state == PaletteState.Disabled ? _disabledBorder : _ribbonColors[(int)SchemeOfficeColors.ControlBorder], PaletteBorderStyle.HeaderCalendar => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.HeaderPrimaryBack1] : _ribbonColors[(int)SchemeOfficeColors.HeaderPrimaryBack2], PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuItemImageColumn => _contextMenuHeadingBorder, PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit => state switch { PaletteState.Disabled => _buttonBorderColors[0], PaletteState.Tracking => _buttonBorderColors[2], _ => _contextMenuHeadingBorder }, PaletteBorderStyle.ContextMenuItemImage => _contextMenuImageBorderChecked, PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.InputControlBorderDisabled] : _ribbonColors[(int)SchemeOfficeColors.InputControlBorderNormal], PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 => state == PaletteState.Disabled ? _disabledBorder : _ribbonColors[(int)SchemeOfficeColors.GridDataCellBorder], PaletteBorderStyle.ControlRibbon => state == PaletteState.Disabled ? _disabledBorder : _ribbonColors[(int)SchemeOfficeColors.RibbonGroupsArea1], PaletteBorderStyle.ControlRibbonAppMenu => state == PaletteState.Disabled ? _disabledBorder : _ribbonColors[(int)SchemeOfficeColors.AppButtonBorder], PaletteBorderStyle.ContextMenuOuter => _contextMenuBorder, PaletteBorderStyle.ContextMenuInner => _contextMenuBack, PaletteBorderStyle.ControlToolTip => state == PaletteState.Disabled ? _disabledBorder : _toolTipBorder, PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormBorderInactive] : _ribbonColors[(int)SchemeOfficeColors.FormBorderActive], PaletteBorderStyle.ButtonForm => state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride => Color.Empty, PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.FormButtonBorderCheck], PaletteState.Tracking or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.FormButtonBorderTrack], PaletteState.Pressed or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.FormButtonBorderPressed], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.ButtonFormClose => state switch { PaletteState.Disabled or PaletteState.Normal or PaletteState.NormalDefaultOverride => Color.Empty, PaletteState.CheckedNormal => _formCloseBorderCheckedNormal, PaletteState.Tracking or PaletteState.CheckedTracking => _formCloseBorderTracking, PaletteState.Pressed or PaletteState.CheckedPressed => _formCloseBorderPressed, _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ContextMenuItemHighlight => state switch { PaletteState.Disabled => style == PaletteBorderStyle.ButtonGallery ? _ribbonColors[(int)SchemeOfficeColors.RibbonGalleryBack2] : _buttonBorderColors[0], PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.NormalDefaultOverride => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalDefaultBorder], PaletteState.CheckedNormal => _buttonBorderColors[6], PaletteState.Tracking => _buttonBorderColors[2], PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBorderColors[4], PaletteState.CheckedTracking => _buttonBorderColors[4], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.ButtonInputControl => state switch { PaletteState.Disabled => _buttonBorderColors[0], PaletteState.Normal or PaletteState.CheckedNormal or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.Tracking => _buttonBorderColors[2], PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBorderColors[4], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.ButtonCalendarDay => state switch { PaletteState.Disabled => _disabledBack, PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1], PaletteState.NormalDefaultOverride => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalDefaultBack1], PaletteState.CheckedNormal => _buttonBackColors[6], PaletteState.Tracking => _buttonBackColors[2], PaletteState.Pressed or PaletteState.CheckedPressed => _buttonBackColors[4], PaletteState.CheckedTracking => _buttonBackColors[8], _ => throw new ArgumentOutOfRangeException(nameof(state)) }, PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini => _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorBorder], _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color border drawing style. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color drawing style.</returns> public override PaletteColorStyle GetBorderColorStyle(PaletteBorderStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideStateExclude(state, PaletteState.NormalDefaultOverride)) { return PaletteColorStyle.Inherit; } return style switch { PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 => PaletteColorStyle.Sigma, PaletteBorderStyle.TabDock => state switch { PaletteState.Tracking or PaletteState.Pressed => PaletteColorStyle.Solid, _ => PaletteColorStyle.Sigma }, PaletteBorderStyle.TabDockAutoHidden => state switch { PaletteState.Tracking or PaletteState.CheckedTracking or PaletteState.Pressed or PaletteState.CheckedPressed => PaletteColorStyle.Solid, _ => PaletteColorStyle.Sigma }, PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.ContextMenuInner or PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuItemImageColumn or PaletteBorderStyle.ContextMenuItemImage or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 or PaletteBorderStyle.HeaderForm or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.ButtonCalendarDay => PaletteColorStyle.Solid, PaletteBorderStyle.ContextMenuItemSplit => state == PaletteState.Tracking ? PaletteColorStyle.Sigma : PaletteColorStyle.Solid, PaletteBorderStyle.ContextMenuSeparator => PaletteColorStyle.Dashed, PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ButtonInputControl or PaletteBorderStyle.ContextMenuItemHighlight => state switch { PaletteState.Normal => PaletteColorStyle.Solid, PaletteState.Disabled or PaletteState.NormalDefaultOverride => PaletteColorStyle.Solid, _ => PaletteColorStyle.Linear }, PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose => PaletteColorStyle.Solid, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color border alignment. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color alignment style.</returns> public override PaletteRectangleAlign GetBorderColorAlign(PaletteBorderStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRectangleAlign.Inherit; } return style switch { PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 => PaletteRectangleAlign.Control, PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderForm or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabDock or PaletteBorderStyle.TabDockAutoHidden or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCalendarDay or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini or PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ButtonInputControl or PaletteBorderStyle.ContextMenuItemImage or PaletteBorderStyle.ContextMenuItemHighlight or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.ContextMenuInner or PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuItemImageColumn or PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit => PaletteRectangleAlign.Local, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color border angle. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Angle used for color drawing.</returns> public override float GetBorderColorAngle(PaletteBorderStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return -1f; } return style switch { PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.ContextMenuInner or PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit or PaletteBorderStyle.ContextMenuItemImageColumn or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderForm or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabDock or PaletteBorderStyle.TabDockAutoHidden or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCalendarDay or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini or PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ButtonInputControl or PaletteBorderStyle.ContextMenuItemImage or PaletteBorderStyle.ContextMenuItemHighlight or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 => 90f, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the border width. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Integer width.</returns> public override int GetBorderWidth(PaletteBorderStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return -1; } return style switch { PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.ContextMenuInner => 0, PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit or PaletteBorderStyle.ContextMenuItemImageColumn or PaletteBorderStyle.ContextMenuItemImage or PaletteBorderStyle.ContextMenuItemHighlight or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderForm or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabDock or PaletteBorderStyle.TabDockAutoHidden or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCalendarDay or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonInputControl or PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini or PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 => 1, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the border corner rounding. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Float rounding.</returns> public override float GetBorderRounding(PaletteBorderStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return GlobalStaticValues.PRIMARY_CORNER_ROUNDING_VALUE; } return style switch { PaletteBorderStyle.ButtonInputControl or PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.ContextMenuInner or PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit or PaletteBorderStyle.ContextMenuItemImageColumn or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderForm or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabDock or PaletteBorderStyle.TabDockAutoHidden or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 or PaletteBorderStyle.ButtonCalendarDay or PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini => 0, PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ContextMenuItemImage => 1, PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.ContextMenuItemHighlight => 2, PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlGroupBox => 3, PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 => 5, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets a border image. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image instance.</returns> public override Image GetBorderImage(PaletteBorderStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return null; } return style switch { PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.ContextMenuInner or PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit or PaletteBorderStyle.ContextMenuItemImageColumn or PaletteBorderStyle.ContextMenuItemImage or PaletteBorderStyle.ContextMenuItemHighlight or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderForm or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabDock or PaletteBorderStyle.TabDockAutoHidden or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCalendarDay or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini or PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ButtonInputControl or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 => null, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the border image style. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image style value.</returns> public override PaletteImageStyle GetBorderImageStyle(PaletteBorderStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteImageStyle.Inherit; } return style switch { PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.ContextMenuInner or PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit or PaletteBorderStyle.ContextMenuItemImage or PaletteBorderStyle.ContextMenuItemImageColumn or PaletteBorderStyle.ContextMenuItemHighlight or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderForm or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabDock or PaletteBorderStyle.TabDockAutoHidden or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCalendarDay or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini or PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ButtonInputControl or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 => PaletteImageStyle.Tile, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the image border alignment. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image alignment style.</returns> public override PaletteRectangleAlign GetBorderImageAlign(PaletteBorderStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRectangleAlign.Inherit; } return style switch { PaletteBorderStyle.SeparatorLowProfile or PaletteBorderStyle.SeparatorHighInternalProfile or PaletteBorderStyle.SeparatorHighProfile or PaletteBorderStyle.SeparatorCustom1 or PaletteBorderStyle.SeparatorCustom2 or PaletteBorderStyle.SeparatorCustom3 or PaletteBorderStyle.ControlClient or PaletteBorderStyle.ControlAlternate or PaletteBorderStyle.ControlGroupBox or PaletteBorderStyle.ControlToolTip or PaletteBorderStyle.ControlRibbon or PaletteBorderStyle.ControlRibbonAppMenu or PaletteBorderStyle.ControlCustom1 or PaletteBorderStyle.ControlCustom2 or PaletteBorderStyle.ControlCustom3 or PaletteBorderStyle.ContextMenuOuter or PaletteBorderStyle.ContextMenuInner or PaletteBorderStyle.ContextMenuHeading or PaletteBorderStyle.ContextMenuSeparator or PaletteBorderStyle.ContextMenuItemSplit or PaletteBorderStyle.ContextMenuItemImage or PaletteBorderStyle.ContextMenuItemImageColumn or PaletteBorderStyle.ContextMenuItemHighlight or PaletteBorderStyle.InputControlStandalone or PaletteBorderStyle.InputControlRibbon or PaletteBorderStyle.InputControlCustom1 or PaletteBorderStyle.InputControlCustom2 or PaletteBorderStyle.InputControlCustom3 or PaletteBorderStyle.FormMain or PaletteBorderStyle.FormCustom1 or PaletteBorderStyle.FormCustom2 or PaletteBorderStyle.FormCustom3 or PaletteBorderStyle.HeaderPrimary or PaletteBorderStyle.HeaderDockInactive or PaletteBorderStyle.HeaderDockActive or PaletteBorderStyle.HeaderCalendar or PaletteBorderStyle.HeaderSecondary or PaletteBorderStyle.HeaderForm or PaletteBorderStyle.HeaderCustom1 or PaletteBorderStyle.HeaderCustom2 or PaletteBorderStyle.HeaderCustom3 or PaletteBorderStyle.TabHighProfile or PaletteBorderStyle.TabStandardProfile or PaletteBorderStyle.TabLowProfile or PaletteBorderStyle.TabOneNote or PaletteBorderStyle.TabDock or PaletteBorderStyle.TabDockAutoHidden or PaletteBorderStyle.TabCustom1 or PaletteBorderStyle.TabCustom2 or PaletteBorderStyle.TabCustom3 or PaletteBorderStyle.ButtonStandalone or PaletteBorderStyle.ButtonGallery or PaletteBorderStyle.ButtonAlternate or PaletteBorderStyle.ButtonLowProfile or PaletteBorderStyle.ButtonBreadCrumb or PaletteBorderStyle.ButtonListItem or PaletteBorderStyle.ButtonCommand or PaletteBorderStyle.ButtonButtonSpec or PaletteBorderStyle.ButtonCalendarDay or PaletteBorderStyle.ButtonCluster or PaletteBorderStyle.ButtonNavigatorStack or PaletteBorderStyle.ButtonNavigatorOverflow or PaletteBorderStyle.ButtonNavigatorMini or PaletteBorderStyle.ButtonForm or PaletteBorderStyle.ButtonFormClose or PaletteBorderStyle.ButtonCustom1 or PaletteBorderStyle.ButtonCustom2 or PaletteBorderStyle.ButtonCustom3 or PaletteBorderStyle.ButtonInputControl or PaletteBorderStyle.GridHeaderColumnList or PaletteBorderStyle.GridHeaderColumnSheet or PaletteBorderStyle.GridHeaderColumnCustom1 or PaletteBorderStyle.GridHeaderColumnCustom2 or PaletteBorderStyle.GridHeaderColumnCustom3 or PaletteBorderStyle.GridHeaderRowList or PaletteBorderStyle.GridHeaderRowSheet or PaletteBorderStyle.GridHeaderRowCustom1 or PaletteBorderStyle.GridHeaderRowCustom2 or PaletteBorderStyle.GridHeaderRowCustom3 or PaletteBorderStyle.GridDataCellList or PaletteBorderStyle.GridDataCellSheet or PaletteBorderStyle.GridDataCellCustom1 or PaletteBorderStyle.GridDataCellCustom2 or PaletteBorderStyle.GridDataCellCustom3 => PaletteRectangleAlign.Local, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } #endregion #region Content /// <summary> /// Gets a value indicating if content should be drawn. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetContentDraw(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return InheritBool.Inherit; } // Always draw everything return InheritBool.True; } /// <summary> /// Gets a value indicating if content should be drawn with focus indication. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetContentDrawFocus(PaletteContentStyle style, PaletteState state) { // By default the focus override shows the focus! if (state == PaletteState.FocusOverride) { return InheritBool.True; } // We do not override the other override states if (CommonHelper.IsOverrideState(state)) { return InheritBool.Inherit; } // By default, never show the focus indication, we let individual controls // override this functionality as required by the controls requirements return InheritBool.False; } /// <summary> /// Gets the horizontal relative alignment of the image. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentImageH(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRelativeAlign.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRelativeAlign.Near, PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText => PaletteRelativeAlign.Center, PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl => PaletteRelativeAlign.Center, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the vertical relative alignment of the image. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentImageV(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRelativeAlign.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRelativeAlign.Center, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the effect applied to drawing of the image. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteImageEffect value.</returns> public override PaletteImageEffect GetContentImageEffect(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteImageEffect.Inherit; } return style switch { PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => state == PaletteState.Disabled ? PaletteImageEffect.Disabled : PaletteImageEffect.Normal, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the image color to remap into another color. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentImageColorMap(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => Color.Empty, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color to use in place of the image map color. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentImageColorTo(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => Color.Empty, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the image color that should be transparent. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentImageColorTransparent(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => Color.Empty, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the font for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Font value.</returns> public override Font GetContentShortTextFont(PaletteContentStyle style, PaletteState state) { if (CommonHelper.IsOverrideState(state)) { return (state == PaletteState.BoldedOverride) && (style == PaletteContentStyle.ButtonCalendarDay) ? _calendarBoldFont : null; } return style switch { PaletteContentStyle.HeaderForm => _headerFormFont, PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.ButtonCommand => _header1ShortFont, PaletteContentStyle.LabelSuperTip or PaletteContentStyle.ContextMenuHeading => _superToolFont, PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemShortcutText => _header2ShortFont, PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelBoldPanel => _boldFont, PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelItalicControl => _italicFont, PaletteContentStyle.ContextMenuItemTextAlternate => _superToolFont, PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden => _tabFontNormal, PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 => state switch { PaletteState.CheckedNormal or PaletteState.CheckedPressed or PaletteState.CheckedTracking => _tabFontSelected, _ => _tabFontNormal }, PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl => _buttonFont, PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow => _buttonFontNavigatorStack, PaletteContentStyle.ButtonNavigatorMini => _buttonFontNavigatorMini, PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 or PaletteContentStyle.HeaderCalendar => _gridFont, PaletteContentStyle.ButtonCalendarDay => _calendarFont, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the font for the short text by generating a new font instance. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Font value.</returns> public override Font GetContentShortTextNewFont(PaletteContentStyle style, PaletteState state) { DefineFonts(); return GetContentShortTextFont(style, state); } /// <summary> /// Gets the rendering hint for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteTextHint value.</returns> public override PaletteTextHint GetContentShortTextHint(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteTextHint.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteTextHint.ClearTypeGridFit, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the prefix drawing setting for short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteTextPrefix value.</returns> public override PaletteTextHotkeyPrefix GetContentShortTextPrefix(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteTextHotkeyPrefix.Inherit; } return style switch { PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.HeaderForm => PaletteTextHotkeyPrefix.Show, PaletteContentStyle.ButtonListItem or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemShortcutText => PaletteTextHotkeyPrefix.None, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the flag indicating if multiline text is allowed for short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetContentShortTextMultiLine(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return InheritBool.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => InheritBool.True, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the text trimming to use for short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteTextTrim value.</returns> public override PaletteTextTrim GetContentShortTextTrim(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteTextTrim.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteTextTrim.EllipsisCharacter, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the horizontal relative alignment of the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentShortTextH(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRelativeAlign.Inherit; } return style switch { PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRelativeAlign.Near, PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.HeaderCalendar => PaletteRelativeAlign.Center, PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl => PaletteRelativeAlign.Center, PaletteContentStyle.ContextMenuItemShortcutText => PaletteRelativeAlign.Far, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the vertical relative alignment of the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentShortTextV(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRelativeAlign.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRelativeAlign.Center, PaletteContentStyle.LabelSuperTip => PaletteRelativeAlign.Near, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the horizontal relative alignment of multiline short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentShortTextMultiLineH(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRelativeAlign.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRelativeAlign.Near, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the first back color for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentShortTextColor1(PaletteContentStyle style, PaletteState state) { // Always work out value for an override state if (CommonHelper.IsOverrideState(state)) { return style switch { PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl => state switch { PaletteState.LinkNotVisitedOverride => _ribbonColors[ (int)SchemeOfficeColors.LinkNotVisitedOverrideControl], PaletteState.LinkVisitedOverride => _ribbonColors[ (int)SchemeOfficeColors.LinkVisitedOverrideControl], PaletteState.LinkPressedOverride => _ribbonColors[ (int)SchemeOfficeColors.LinkPressedOverrideControl], _ => Color.Empty }, PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption => state switch { PaletteState.LinkNotVisitedOverride => _ribbonColors[ (int)SchemeOfficeColors.LinkNotVisitedOverridePanel], PaletteState.LinkVisitedOverride => _ribbonColors[ (int)SchemeOfficeColors.LinkVisitedOverridePanel], PaletteState.LinkPressedOverride => _ribbonColors[ (int)SchemeOfficeColors.LinkPressedOverridePanel], _ => Color.Empty }, _ => Color.Empty }; } switch (style) { case PaletteContentStyle.HeaderForm: return state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormHeaderShortInactive] : _ribbonColors[(int)SchemeOfficeColors.FormHeaderShortActive]; } if ((state == PaletteState.Disabled) && (style != PaletteContentStyle.LabelToolTip) && (style != PaletteContentStyle.LabelSuperTip) && (style != PaletteContentStyle.LabelKeyTip) && (style != PaletteContentStyle.InputControlStandalone) && (style != PaletteContentStyle.InputControlRibbon) && (style != PaletteContentStyle.InputControlCustom1) && (style != PaletteContentStyle.InputControlCustom2) && (style != PaletteContentStyle.InputControlCustom3) && (style != PaletteContentStyle.ButtonInputControl) && (style != PaletteContentStyle.ButtonCalendarDay)) { return _disabledText; } return style switch { PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 or PaletteContentStyle.HeaderCalendar => _gridTextColor, PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 => _ribbonColors[(int)SchemeOfficeColors.HeaderText], PaletteContentStyle.HeaderDockActive => Color.Black, PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.InputControlTextDisabled] : _ribbonColors[(int)SchemeOfficeColors.InputControlTextNormal], PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption => _ribbonColors[(int)SchemeOfficeColors.TextLabelPanel], PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.ContextMenuItemTextAlternate => _ribbonColors[(int)SchemeOfficeColors.TextLabelControl], PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip => _toolTipText, PaletteContentStyle.ContextMenuHeading => _ribbonColors[(int)SchemeOfficeColors.ContextMenuHeadingText], PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 => state != PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.TextButtonChecked] : _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], PaletteContentStyle.TabDockAutoHidden => _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], PaletteContentStyle.ButtonCalendarDay => state == PaletteState.Disabled ? _disabledText2 : Color.Black, PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonButtonSpec => state switch { PaletteState.Normal => style == PaletteContentStyle.ButtonListItem ? _ribbonColors[(int)SchemeOfficeColors.TextLabelControl] : _ribbonColors[(int)SchemeOfficeColors.TextLabelPanel], PaletteState.CheckedNormal or PaletteState.CheckedTracking or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.TextButtonChecked], _ => _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal] }, PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose => state switch { PaletteState.Tracking or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormTracking], PaletteState.Pressed or PaletteState.CheckedPressed or PaletteState.CheckedNormal => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormPressed], _ => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormNormal] }, PaletteContentStyle.ButtonInputControl => state != PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.InputDropDownNormal1] : _ribbonColors[(int)SchemeOfficeColors.InputDropDownDisabled1], PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow => state != PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorText] : _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the second back color for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentShortTextColor2(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } switch (style) { case PaletteContentStyle.HeaderForm: return state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormHeaderShortInactive] : _ribbonColors[(int)SchemeOfficeColors.FormHeaderShortActive]; } if ((state == PaletteState.Disabled) && (style != PaletteContentStyle.LabelToolTip) && (style != PaletteContentStyle.LabelSuperTip) && (style != PaletteContentStyle.LabelKeyTip) && (style != PaletteContentStyle.InputControlStandalone) && (style != PaletteContentStyle.InputControlRibbon) && (style != PaletteContentStyle.InputControlCustom1) && (style != PaletteContentStyle.InputControlCustom2) && (style != PaletteContentStyle.InputControlCustom3) && (style != PaletteContentStyle.ButtonInputControl) && (style != PaletteContentStyle.ButtonCalendarDay)) { return _disabledText; } return style switch { PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 or PaletteContentStyle.HeaderCalendar => _gridTextColor, PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 => _ribbonColors[(int)SchemeOfficeColors.HeaderText], PaletteContentStyle.HeaderDockActive => Color.Black, PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.InputControlTextDisabled] : _ribbonColors[(int)SchemeOfficeColors.InputControlTextNormal], PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption => _ribbonColors[(int)SchemeOfficeColors.TextLabelPanel], PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText => _ribbonColors[(int)SchemeOfficeColors.TextLabelControl], PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip => _toolTipText, PaletteContentStyle.ContextMenuHeading => _ribbonColors[(int)SchemeOfficeColors.ContextMenuHeadingText], PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 => state != PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.TextButtonChecked] : _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], PaletteContentStyle.TabDockAutoHidden => _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], PaletteContentStyle.ButtonCalendarDay => state == PaletteState.Disabled ? _disabledText2 : Color.Black, PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonButtonSpec => state switch { PaletteState.Normal => style == PaletteContentStyle.ButtonListItem ? _ribbonColors[(int)SchemeOfficeColors.TextLabelControl] : _ribbonColors[(int)SchemeOfficeColors.TextLabelPanel], PaletteState.CheckedNormal or PaletteState.CheckedTracking or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.TextButtonChecked], _ => _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal] }, PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose => state switch { PaletteState.Tracking or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormTracking], PaletteState.Pressed or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormPressed], _ => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormNormal] }, PaletteContentStyle.ButtonInputControl => state != PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.InputDropDownNormal2] : _ribbonColors[(int)SchemeOfficeColors.InputDropDownDisabled2], PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow => state != PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorText] : _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color drawing style for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color drawing style.</returns> public override PaletteColorStyle GetContentShortTextColorStyle(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteColorStyle.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteColorStyle.Solid, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color alignment for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color alignment style.</returns> public override PaletteRectangleAlign GetContentShortTextColorAlign(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRectangleAlign.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRectangleAlign.Local, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color background angle for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Angle used for color drawing.</returns> public override float GetContentShortTextColorAngle(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return -1f; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => 90f, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets a background image for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image instance.</returns> public override Image GetContentShortTextImage(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return null; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => null, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the background image style. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image style value.</returns> public override PaletteImageStyle GetContentShortTextImageStyle(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteImageStyle.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteImageStyle.TileFlipXY, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the image alignment for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image alignment style.</returns> public override PaletteRectangleAlign GetContentShortTextImageAlign(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRectangleAlign.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRectangleAlign.Local, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the font for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Font value.</returns> public override Font GetContentLongTextFont(PaletteContentStyle style, PaletteState state) { if (CommonHelper.IsOverrideState(state)) { return (state == PaletteState.BoldedOverride) && (style == PaletteContentStyle.ButtonCalendarDay) ? _calendarBoldFont : null; } return style switch { PaletteContentStyle.ButtonCalendarDay => _calendarFont, PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 or PaletteContentStyle.HeaderCalendar => _gridFont, PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 => _header1LongFont, PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.HeaderSecondary => _header2LongFont, PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden => _tabFontNormal, PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 => state switch { PaletteState.CheckedNormal or PaletteState.CheckedPressed or PaletteState.CheckedTracking => _tabFontSelected, _ => _tabFontNormal }, PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl => _buttonFont, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the font for the long text by generating a new font instance. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Font value.</returns> public override Font GetContentLongTextNewFont(PaletteContentStyle style, PaletteState state) { DefineFonts(); return GetContentLongTextFont(style, state); } /// <summary> /// Gets the rendering hint for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteTextHint value.</returns> public override PaletteTextHint GetContentLongTextHint(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteTextHint.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteTextHint.ClearTypeGridFit, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the flag indicating if multiline text is allowed for long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetContentLongTextMultiLine(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return InheritBool.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => InheritBool.True, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the text trimming to use for long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteTextTrim value.</returns> public override PaletteTextTrim GetContentLongTextTrim(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteTextTrim.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteTextTrim.EllipsisCharacter, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the prefix drawing setting for long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteTextPrefix value.</returns> public override PaletteTextHotkeyPrefix GetContentLongTextPrefix(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteTextHotkeyPrefix.Inherit; } return style switch { PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl => PaletteTextHotkeyPrefix.Show, PaletteContentStyle.ButtonListItem or PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteTextHotkeyPrefix.None, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the horizontal relative alignment of the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentLongTextH(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRelativeAlign.Inherit; } return style switch { PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.ContextMenuItemTextAlternate => PaletteRelativeAlign.Near, PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRelativeAlign.Far, PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl => PaletteRelativeAlign.Center, PaletteContentStyle.ButtonCalendarDay => PaletteRelativeAlign.Far, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the vertical relative alignment of the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentLongTextV(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRelativeAlign.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRelativeAlign.Center, PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.ContextMenuItemTextAlternate => PaletteRelativeAlign.Far, PaletteContentStyle.LabelSuperTip => PaletteRelativeAlign.Center, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the horizontal relative alignment of multiline long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentLongTextMultiLineH(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRelativeAlign.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRelativeAlign.Center, PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ButtonCommand => PaletteRelativeAlign.Near, PaletteContentStyle.ContextMenuItemShortcutText => PaletteRelativeAlign.Far, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the first back color for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentLongTextColor1(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } switch (style) { case PaletteContentStyle.HeaderForm: return state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormHeaderLongInactive] : _ribbonColors[(int)SchemeOfficeColors.FormHeaderLongActive]; } if ((state == PaletteState.Disabled) && (style != PaletteContentStyle.LabelToolTip) && (style != PaletteContentStyle.LabelSuperTip) && (style != PaletteContentStyle.LabelKeyTip) && (style != PaletteContentStyle.InputControlStandalone) && (style != PaletteContentStyle.InputControlRibbon) && (style != PaletteContentStyle.InputControlCustom1) && (style != PaletteContentStyle.InputControlCustom2) && (style != PaletteContentStyle.InputControlCustom3) && (style != PaletteContentStyle.ButtonInputControl)) { return _disabledText; } return style switch { PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 or PaletteContentStyle.HeaderCalendar => _gridTextColor, PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 => _ribbonColors[(int)SchemeOfficeColors.HeaderText], PaletteContentStyle.HeaderDockActive => Color.Black, PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.InputControlTextDisabled] : _ribbonColors[(int)SchemeOfficeColors.InputControlTextNormal], PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption => _ribbonColors[(int)SchemeOfficeColors.TextLabelPanel], PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.ContextMenuItemTextAlternate => _ribbonColors[(int)SchemeOfficeColors.TextLabelControl], PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip => _toolTipText, PaletteContentStyle.ContextMenuHeading => _ribbonColors[(int)SchemeOfficeColors.ContextMenuHeadingText], PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 => state != PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.TextButtonChecked] : _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], PaletteContentStyle.TabDockAutoHidden => _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay => state switch { PaletteState.Normal => style == PaletteContentStyle.ButtonListItem ? _ribbonColors[(int)SchemeOfficeColors.TextLabelControl] : _ribbonColors[(int)SchemeOfficeColors.TextLabelPanel], PaletteState.CheckedNormal or PaletteState.CheckedTracking or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.TextButtonChecked], _ => _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal] }, PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose => state switch { PaletteState.Tracking or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormTracking], PaletteState.Pressed or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormPressed], _ => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormNormal] }, PaletteContentStyle.ButtonInputControl => state != PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.InputDropDownNormal1] : _ribbonColors[(int)SchemeOfficeColors.InputDropDownDisabled1], PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow => state != PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorText] : _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the second back color for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentLongTextColor2(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } switch (style) { case PaletteContentStyle.HeaderForm: return state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.FormHeaderLongInactive] : _ribbonColors[(int)SchemeOfficeColors.FormHeaderLongActive]; } if ((state == PaletteState.Disabled) && (style != PaletteContentStyle.LabelToolTip) && (style != PaletteContentStyle.LabelSuperTip) && (style != PaletteContentStyle.LabelKeyTip) && (style != PaletteContentStyle.InputControlStandalone) && (style != PaletteContentStyle.InputControlRibbon) && (style != PaletteContentStyle.InputControlCustom1) && (style != PaletteContentStyle.InputControlCustom2) && (style != PaletteContentStyle.InputControlCustom3) && (style != PaletteContentStyle.ButtonInputControl)) { return _disabledText; } return style switch { PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 or PaletteContentStyle.HeaderCalendar => _gridTextColor, PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 => _ribbonColors[(int)SchemeOfficeColors.HeaderText], PaletteContentStyle.HeaderDockActive => Color.Black, PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 => state == PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.InputControlTextDisabled] : _ribbonColors[(int)SchemeOfficeColors.InputControlTextNormal], PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption => _ribbonColors[(int)SchemeOfficeColors.TextLabelPanel], PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText => _ribbonColors[(int)SchemeOfficeColors.TextLabelControl], PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip => _toolTipText, PaletteContentStyle.ContextMenuHeading => _ribbonColors[(int)SchemeOfficeColors.ContextMenuHeadingText], PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 => state != PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.TextButtonChecked] : _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], PaletteContentStyle.TabDockAutoHidden => _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay => state switch { PaletteState.Normal => style == PaletteContentStyle.ButtonListItem ? _ribbonColors[(int)SchemeOfficeColors.TextLabelControl] : _ribbonColors[(int)SchemeOfficeColors.TextLabelPanel], PaletteState.CheckedNormal or PaletteState.CheckedTracking or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.TextButtonChecked], _ => _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal] }, PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose => state switch { PaletteState.Tracking or PaletteState.CheckedTracking => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormTracking], PaletteState.Pressed or PaletteState.CheckedPressed => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormPressed], _ => _ribbonColors[(int)SchemeOfficeColors.TextButtonFormNormal] }, PaletteContentStyle.ButtonInputControl => state != PaletteState.Disabled ? _ribbonColors[(int)SchemeOfficeColors.InputDropDownNormal2] : _ribbonColors[(int)SchemeOfficeColors.InputDropDownDisabled2], PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow => state != PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.ButtonNavigatorText] : _ribbonColors[(int)SchemeOfficeColors.TextButtonNormal], _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color drawing style for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color drawing style.</returns> public override PaletteColorStyle GetContentLongTextColorStyle(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteColorStyle.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteColorStyle.Solid, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color alignment for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color alignment style.</returns> public override PaletteRectangleAlign GetContentLongTextColorAlign(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRectangleAlign.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRectangleAlign.Local, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the color background angle for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Angle used for color drawing.</returns> public override float GetContentLongTextColorAngle(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return -1f; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => 90f, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets a background image for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image instance.</returns> public override Image GetContentLongTextImage(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return null; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => null, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the background image style for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image style value.</returns> public override PaletteImageStyle GetContentLongTextImageStyle(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteImageStyle.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteImageStyle.TileFlipXY, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the image alignment for the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image alignment style.</returns> public override PaletteRectangleAlign GetContentLongTextImageAlign(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return PaletteRectangleAlign.Inherit; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelSuperTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => PaletteRectangleAlign.Local, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the padding between the border and content drawing. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Padding value.</returns> public override Padding GetContentPadding(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return CommonHelper.InheritPadding; } return style switch { PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => _contentPaddingGrid, PaletteContentStyle.HeaderForm => _contentPaddingHeaderForm, PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 => _contentPaddingHeader1, PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive => _contentPaddingDock, PaletteContentStyle.HeaderSecondary => _contentPaddingHeader2, PaletteContentStyle.HeaderCalendar => _contentPaddingCalendar, PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 => _contentPaddingLabel, PaletteContentStyle.LabelGroupBoxCaption => _contentPaddingLabel2, PaletteContentStyle.ContextMenuItemTextStandard => _contentPaddingContextMenuItemText, PaletteContentStyle.ContextMenuItemTextAlternate => _contentPaddingContextMenuItemTextAlt, PaletteContentStyle.ContextMenuItemShortcutText => _contentPaddingContextMenuItemShortcutText, PaletteContentStyle.ContextMenuItemImage => _contentPaddingContextMenuImage, PaletteContentStyle.LabelToolTip => _contentPaddingToolTip, PaletteContentStyle.LabelSuperTip => _contentPaddingSuperTip, PaletteContentStyle.LabelKeyTip => _contentPaddingKeyTip, PaletteContentStyle.ContextMenuHeading => _contentPaddingContextMenuHeading, PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 => InputControlPadding, PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 => _contentPaddingButton12, PaletteContentStyle.ButtonInputControl or PaletteContentStyle.ButtonCalendarDay => _contentPaddingButtonInputControl, PaletteContentStyle.ButtonButtonSpec => _contentPaddingButton3, PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow => _contentPaddingButton4, PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose => _contentPaddingButtonForm, PaletteContentStyle.ButtonGallery => _contentPaddingButtonGallery, PaletteContentStyle.ButtonListItem => _contentPaddingButtonListItem, PaletteContentStyle.ButtonBreadCrumb => _contentPaddingButton6, PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 => _contentPaddingButton5, PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden => _contentPaddingButton7, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } /// <summary> /// Gets the padding between adjacent content items. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Integer value.</returns> public override int GetContentAdjacentGap(PaletteContentStyle style, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return -1; } return style switch { PaletteContentStyle.HeaderPrimary or PaletteContentStyle.HeaderDockInactive or PaletteContentStyle.HeaderDockActive or PaletteContentStyle.HeaderCalendar or PaletteContentStyle.HeaderSecondary or PaletteContentStyle.HeaderForm or PaletteContentStyle.HeaderCustom1 or PaletteContentStyle.HeaderCustom2 or PaletteContentStyle.HeaderCustom3 or PaletteContentStyle.LabelNormalControl or PaletteContentStyle.LabelBoldControl or PaletteContentStyle.LabelItalicControl or PaletteContentStyle.LabelTitleControl or PaletteContentStyle.LabelNormalPanel or PaletteContentStyle.LabelBoldPanel or PaletteContentStyle.LabelItalicPanel or PaletteContentStyle.LabelTitlePanel or PaletteContentStyle.LabelGroupBoxCaption or PaletteContentStyle.LabelToolTip or PaletteContentStyle.LabelKeyTip or PaletteContentStyle.LabelCustom1 or PaletteContentStyle.LabelCustom2 or PaletteContentStyle.LabelCustom3 or PaletteContentStyle.ContextMenuHeading or PaletteContentStyle.ContextMenuItemImage or PaletteContentStyle.ContextMenuItemTextStandard or PaletteContentStyle.ContextMenuItemTextAlternate or PaletteContentStyle.ContextMenuItemShortcutText or PaletteContentStyle.InputControlStandalone or PaletteContentStyle.InputControlRibbon or PaletteContentStyle.InputControlCustom1 or PaletteContentStyle.InputControlCustom2 or PaletteContentStyle.InputControlCustom3 or PaletteContentStyle.TabHighProfile or PaletteContentStyle.TabStandardProfile or PaletteContentStyle.TabLowProfile or PaletteContentStyle.TabOneNote or PaletteContentStyle.TabDock or PaletteContentStyle.TabDockAutoHidden or PaletteContentStyle.TabCustom1 or PaletteContentStyle.TabCustom2 or PaletteContentStyle.TabCustom3 or PaletteContentStyle.ButtonStandalone or PaletteContentStyle.ButtonGallery or PaletteContentStyle.ButtonAlternate or PaletteContentStyle.ButtonLowProfile or PaletteContentStyle.ButtonBreadCrumb or PaletteContentStyle.ButtonListItem or PaletteContentStyle.ButtonCommand or PaletteContentStyle.ButtonButtonSpec or PaletteContentStyle.ButtonCalendarDay or PaletteContentStyle.ButtonCluster or PaletteContentStyle.ButtonNavigatorMini or PaletteContentStyle.ButtonNavigatorStack or PaletteContentStyle.ButtonNavigatorOverflow or PaletteContentStyle.ButtonForm or PaletteContentStyle.ButtonFormClose or PaletteContentStyle.ButtonCustom1 or PaletteContentStyle.ButtonCustom2 or PaletteContentStyle.ButtonCustom3 or PaletteContentStyle.ButtonInputControl or PaletteContentStyle.GridHeaderColumnList or PaletteContentStyle.GridHeaderColumnSheet or PaletteContentStyle.GridHeaderColumnCustom1 or PaletteContentStyle.GridHeaderColumnCustom2 or PaletteContentStyle.GridHeaderColumnCustom3 or PaletteContentStyle.GridHeaderRowList or PaletteContentStyle.GridHeaderRowSheet or PaletteContentStyle.GridHeaderRowCustom1 or PaletteContentStyle.GridHeaderRowCustom2 or PaletteContentStyle.GridHeaderRowCustom3 or PaletteContentStyle.GridDataCellList or PaletteContentStyle.GridDataCellSheet or PaletteContentStyle.GridDataCellCustom1 or PaletteContentStyle.GridDataCellCustom2 or PaletteContentStyle.GridDataCellCustom3 => 1, PaletteContentStyle.LabelSuperTip => 5, _ => throw new ArgumentOutOfRangeException(nameof(style)) }; } #endregion #region Metric /// <summary> /// Gets an integer metric value. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <param name="metric">Requested metric.</param> /// <returns>Integer value.</returns> public override int GetMetricInt(PaletteState state, PaletteMetricInt metric) { switch (metric) { case PaletteMetricInt.PageButtonInset: case PaletteMetricInt.RibbonTabGap: case PaletteMetricInt.HeaderButtonEdgeInsetCalendar: return 2; case PaletteMetricInt.CheckButtonGap: return 5; case PaletteMetricInt.HeaderButtonEdgeInsetForm: return 9; // Needs to be the RealWindowBorderWidth Offset - No idea how to get it at this point case PaletteMetricInt.HeaderButtonEdgeInsetInputControl: return 1; case PaletteMetricInt.HeaderButtonEdgeInsetPrimary: case PaletteMetricInt.HeaderButtonEdgeInsetSecondary: case PaletteMetricInt.HeaderButtonEdgeInsetDockInactive: case PaletteMetricInt.HeaderButtonEdgeInsetDockActive: case PaletteMetricInt.HeaderButtonEdgeInsetCustom1: case PaletteMetricInt.HeaderButtonEdgeInsetCustom2: case PaletteMetricInt.HeaderButtonEdgeInsetCustom3: case PaletteMetricInt.BarButtonEdgeOutside: case PaletteMetricInt.BarButtonEdgeInside: return 3; case PaletteMetricInt.None: return 0; default: // Should never happen! Debug.Assert(false); break; } return -1; } /// <summary> /// Gets a boolean metric value. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <param name="metric">Requested metric.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetMetricBool(PaletteState state, PaletteMetricBool metric) { switch (metric) { case PaletteMetricBool.HeaderGroupOverlay: case PaletteMetricBool.SplitWithFading: case PaletteMetricBool.RibbonTabsSpareCaption: return InheritBool.True; case PaletteMetricBool.TreeViewLines: return InheritBool.False; default: // Should never happen! Debug.Assert(false); break; } return InheritBool.Inherit; } /// <summary> /// Gets a padding metric value. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <param name="metric">Requested metric.</param> /// <returns>Padding value.</returns> public override Padding GetMetricPadding(PaletteState state, PaletteMetricPadding metric) { switch (metric) { case PaletteMetricPadding.PageButtonPadding: return _metricPaddingPageButtons; case PaletteMetricPadding.BarPaddingTabs: return _metricPaddingBarTabs; case PaletteMetricPadding.BarPaddingInside: case PaletteMetricPadding.BarPaddingOnly: return _metricPaddingBarInside; case PaletteMetricPadding.BarPaddingOutside: return _metricPaddingBarOutside; case PaletteMetricPadding.HeaderButtonPaddingForm: return _metricPaddingHeaderForm; case PaletteMetricPadding.RibbonButtonPadding: return _metricPaddingRibbon; case PaletteMetricPadding.RibbonAppButton: return _metricPaddingRibbonAppButton; case PaletteMetricPadding.HeaderButtonPaddingInputControl: return _metricPaddingInputControl; case PaletteMetricPadding.HeaderButtonPaddingPrimary: case PaletteMetricPadding.HeaderButtonPaddingSecondary: case PaletteMetricPadding.HeaderButtonPaddingDockInactive: case PaletteMetricPadding.HeaderButtonPaddingDockActive: case PaletteMetricPadding.HeaderButtonPaddingCustom1: case PaletteMetricPadding.HeaderButtonPaddingCustom2: case PaletteMetricPadding.HeaderButtonPaddingCustom3: case PaletteMetricPadding.HeaderButtonPaddingCalendar: case PaletteMetricPadding.BarButtonPadding: return _metricPaddingHeader; case PaletteMetricPadding.HeaderGroupPaddingPrimary: case PaletteMetricPadding.HeaderGroupPaddingSecondary: case PaletteMetricPadding.HeaderGroupPaddingDockInactive: case PaletteMetricPadding.HeaderGroupPaddingDockActive: case PaletteMetricPadding.SeparatorPaddingLowProfile: case PaletteMetricPadding.SeparatorPaddingHighInternalProfile: case PaletteMetricPadding.SeparatorPaddingHighProfile: case PaletteMetricPadding.SeparatorPaddingCustom1: case PaletteMetricPadding.SeparatorPaddingCustom2: case PaletteMetricPadding.SeparatorPaddingCustom3: case PaletteMetricPadding.ContextMenuItemHighlight: case PaletteMetricPadding.ContextMenuItemsCollection: case PaletteMetricPadding.ContextMenuItemOuter: return Padding.Empty; default: // Should never happen! Debug.Assert(false); break; } return Padding.Empty; } #endregion #region Images /// <summary> /// Gets a tree view image appropriate for the provided state. /// </summary> /// <param name="expanded">Is the node expanded</param> /// <returns>Appropriate image for drawing; otherwise null.</returns> public override Image GetTreeViewImage(bool expanded) => expanded ? _treeCollapseBlack : _treeExpandWhite; /// <summary> /// Gets a check box image appropriate for the provided state. /// </summary> /// <param name="enabled">Is the check box enabled.</param> /// <param name="checkState">Is the check box checked/unchecked/indeterminate.</param> /// <param name="tracking">Is the check box being hot tracked.</param> /// <param name="pressed">Is the check box being pressed.</param> /// <returns>Appropriate image for drawing; otherwise null.</returns> public override Image GetCheckBoxImage(bool enabled, CheckState checkState, bool tracking, bool pressed) { switch (checkState) { default: case CheckState.Unchecked: if (!enabled) { return _checkBoxList.Images[0]; } else if (pressed) { return _checkBoxList.Images[3]; } else { return tracking ? _checkBoxList.Images[2] : _checkBoxList.Images[1]; } case CheckState.Checked: if (!enabled) { return _checkBoxList.Images[4]; } else if (pressed) { return _checkBoxList.Images[7]; } else { return tracking ? _checkBoxList.Images[6] : _checkBoxList.Images[5]; } case CheckState.Indeterminate: if (!enabled) { return _checkBoxList.Images[8]; } else if (pressed) { return _checkBoxList.Images[11]; } else { return tracking ? _checkBoxList.Images[10] : _checkBoxList.Images[9]; } } } /// <summary> /// Gets a check box image appropriate for the provided state. /// </summary> /// <param name="enabled">Is the radio button enabled.</param> /// <param name="checkState">Is the radio button checked.</param> /// <param name="tracking">Is the radio button being hot tracked.</param> /// <param name="pressed">Is the radio button being pressed.</param> /// <returns>Appropriate image for drawing; otherwise null.</returns> public override Image GetRadioButtonImage(bool enabled, bool checkState, bool tracking, bool pressed) { if (!checkState) { if (!enabled) { return _radioButtonArray[0]; } else if (pressed) { return _radioButtonArray[3]; } else { return tracking ? _radioButtonArray[2] : _radioButtonArray[1]; } } else { if (!enabled) { return _radioButtonArray[4]; } else if (pressed) { return _radioButtonArray[7]; } else { return tracking ? _radioButtonArray[6] : _radioButtonArray[5]; } } } /// <summary> /// Gets a drop down button image appropriate for the provided state. /// </summary> /// <param name="state">PaletteState for which image is required.</param> public override Image GetDropDownButtonImage(PaletteState state) => _disabledDropDown; /// <summary> /// Gets a checked image appropriate for a context menu item. /// </summary> /// <returns>Appropriate image for drawing; otherwise null.</returns> public override Image GetContextMenuCheckedImage() => _contextMenuChecked; /// <summary> /// Gets a indeterminate image appropriate for a context menu item. /// </summary> /// <returns>Appropriate image for drawing; otherwise null.</returns> public override Image GetContextMenuIndeterminateImage() => _contextMenuIndeterminate; /// <summary> /// Gets a check box image appropriate for the provided state. /// </summary> /// <param name="button">Enum of the button to fetch.</param> /// <param name="state">State of the button to fetch.</param> /// <returns>Appropriate image for drawing; otherwise null.</returns> public override Image GetGalleryButtonImage(PaletteRibbonGalleryButton button, PaletteState state) { return button switch { PaletteRibbonGalleryButton.Up => _galleryButtonList.Images[1], PaletteRibbonGalleryButton.DropDown => _galleryButtonList.Images[2], _ => _galleryButtonList.Images[0] }; } #endregion #region ButtonSpec /// <summary> /// Gets the icon to display for the button. /// </summary> /// <param name="style">Style of button spec.</param> /// <returns>Icon value.</returns> public override Icon GetButtonSpecIcon(PaletteButtonSpecStyle style) { switch (style) { case PaletteButtonSpecStyle.Generic: case PaletteButtonSpecStyle.Close: case PaletteButtonSpecStyle.Context: case PaletteButtonSpecStyle.Next: case PaletteButtonSpecStyle.Previous: case PaletteButtonSpecStyle.ArrowLeft: case PaletteButtonSpecStyle.ArrowRight: case PaletteButtonSpecStyle.ArrowUp: case PaletteButtonSpecStyle.ArrowDown: case PaletteButtonSpecStyle.DropDown: case PaletteButtonSpecStyle.PinVertical: case PaletteButtonSpecStyle.PinHorizontal: case PaletteButtonSpecStyle.FormClose: case PaletteButtonSpecStyle.FormMin: case PaletteButtonSpecStyle.FormMax: case PaletteButtonSpecStyle.FormRestore: case PaletteButtonSpecStyle.FormHelp: case PaletteButtonSpecStyle.PendantClose: case PaletteButtonSpecStyle.PendantMin: case PaletteButtonSpecStyle.PendantRestore: case PaletteButtonSpecStyle.WorkspaceMaximize: case PaletteButtonSpecStyle.WorkspaceRestore: case PaletteButtonSpecStyle.RibbonMinimize: case PaletteButtonSpecStyle.RibbonExpand: return null; default: // Should never happen! Debug.Assert(false); return null; } } /// <summary> /// Gets the image to display for the button. /// </summary> /// <param name="style">Style of button spec.</param> /// <param name="state">State for which image is required.</param> /// <returns>Image value.</returns> public override Image GetButtonSpecImage(PaletteButtonSpecStyle style, PaletteState state) { switch (style) { case PaletteButtonSpecStyle.Close: return _buttonSpecClose; case PaletteButtonSpecStyle.Context: return _buttonSpecContext; case PaletteButtonSpecStyle.Next: return _buttonSpecNext; case PaletteButtonSpecStyle.Previous: return _buttonSpecPrevious; case PaletteButtonSpecStyle.ArrowLeft: return _buttonSpecArrowLeft; case PaletteButtonSpecStyle.ArrowRight: return _buttonSpecArrowRight; case PaletteButtonSpecStyle.ArrowUp: return _buttonSpecArrowUp; case PaletteButtonSpecStyle.ArrowDown: return _buttonSpecArrowDown; case PaletteButtonSpecStyle.DropDown: return _buttonSpecDropDown; case PaletteButtonSpecStyle.PinVertical: return _buttonSpecPinVertical; case PaletteButtonSpecStyle.PinHorizontal: return _buttonSpecPinHorizontal; case PaletteButtonSpecStyle.PendantClose: return _buttonSpecPendantClose; case PaletteButtonSpecStyle.PendantMin: return _buttonSpecPendantMin; case PaletteButtonSpecStyle.PendantRestore: return _buttonSpecPendantRestore; case PaletteButtonSpecStyle.WorkspaceMaximize: return _buttonSpecWorkspaceMaximize; case PaletteButtonSpecStyle.WorkspaceRestore: return _buttonSpecWorkspaceRestore; case PaletteButtonSpecStyle.RibbonMinimize: return _buttonSpecRibbonMinimize; case PaletteButtonSpecStyle.RibbonExpand: return _buttonSpecRibbonExpand; case PaletteButtonSpecStyle.Generic: return null; default: // Should never happen! Debug.Assert(false); return null; } } /// <summary> /// Gets the image transparent color. /// </summary> /// <param name="style">Style of button spec.</param> /// <returns>Color value.</returns> public override Color GetButtonSpecImageTransparentColor(PaletteButtonSpecStyle style) { switch (style) { case PaletteButtonSpecStyle.Generic: return Color.Empty; case PaletteButtonSpecStyle.Close: case PaletteButtonSpecStyle.Context: case PaletteButtonSpecStyle.Next: case PaletteButtonSpecStyle.Previous: case PaletteButtonSpecStyle.ArrowLeft: case PaletteButtonSpecStyle.ArrowRight: case PaletteButtonSpecStyle.ArrowUp: case PaletteButtonSpecStyle.ArrowDown: case PaletteButtonSpecStyle.DropDown: case PaletteButtonSpecStyle.PinVertical: case PaletteButtonSpecStyle.PinHorizontal: case PaletteButtonSpecStyle.FormClose: case PaletteButtonSpecStyle.FormMin: case PaletteButtonSpecStyle.FormMax: case PaletteButtonSpecStyle.FormRestore: case PaletteButtonSpecStyle.FormHelp: case PaletteButtonSpecStyle.PendantClose: case PaletteButtonSpecStyle.PendantMin: case PaletteButtonSpecStyle.PendantRestore: case PaletteButtonSpecStyle.WorkspaceMaximize: case PaletteButtonSpecStyle.WorkspaceRestore: case PaletteButtonSpecStyle.RibbonMinimize: case PaletteButtonSpecStyle.RibbonExpand: return Color.Magenta; default: // Should never happen! Debug.Assert(false); return Color.Empty; } } /// <summary> /// Gets the short text to display for the button. /// </summary> /// <param name="style">Style of button spec.</param> /// <returns>String value.</returns> public override string GetButtonSpecShortText(PaletteButtonSpecStyle style) { switch (style) { case PaletteButtonSpecStyle.Generic: case PaletteButtonSpecStyle.Close: case PaletteButtonSpecStyle.Context: case PaletteButtonSpecStyle.Next: case PaletteButtonSpecStyle.Previous: case PaletteButtonSpecStyle.ArrowLeft: case PaletteButtonSpecStyle.ArrowRight: case PaletteButtonSpecStyle.ArrowUp: case PaletteButtonSpecStyle.ArrowDown: case PaletteButtonSpecStyle.DropDown: case PaletteButtonSpecStyle.PinVertical: case PaletteButtonSpecStyle.PinHorizontal: case PaletteButtonSpecStyle.FormClose: case PaletteButtonSpecStyle.FormMin: case PaletteButtonSpecStyle.FormMax: case PaletteButtonSpecStyle.FormRestore: case PaletteButtonSpecStyle.FormHelp: case PaletteButtonSpecStyle.PendantClose: case PaletteButtonSpecStyle.PendantMin: case PaletteButtonSpecStyle.PendantRestore: case PaletteButtonSpecStyle.WorkspaceMaximize: case PaletteButtonSpecStyle.WorkspaceRestore: case PaletteButtonSpecStyle.RibbonMinimize: case PaletteButtonSpecStyle.RibbonExpand: return string.Empty; default: // Should never happen! Debug.Assert(false); return null; } } /// <summary> /// Gets the long text to display for the button. /// </summary> /// <param name="style">Style of button spec.</param> /// <returns>String value.</returns> public override string GetButtonSpecLongText(PaletteButtonSpecStyle style) { switch (style) { case PaletteButtonSpecStyle.Generic: case PaletteButtonSpecStyle.Close: case PaletteButtonSpecStyle.Context: case PaletteButtonSpecStyle.Next: case PaletteButtonSpecStyle.Previous: case PaletteButtonSpecStyle.ArrowLeft: case PaletteButtonSpecStyle.ArrowRight: case PaletteButtonSpecStyle.ArrowUp: case PaletteButtonSpecStyle.ArrowDown: case PaletteButtonSpecStyle.DropDown: case PaletteButtonSpecStyle.PinVertical: case PaletteButtonSpecStyle.PinHorizontal: case PaletteButtonSpecStyle.FormClose: case PaletteButtonSpecStyle.FormMin: case PaletteButtonSpecStyle.FormMax: case PaletteButtonSpecStyle.FormRestore: case PaletteButtonSpecStyle.FormHelp: case PaletteButtonSpecStyle.PendantClose: case PaletteButtonSpecStyle.PendantMin: case PaletteButtonSpecStyle.PendantRestore: case PaletteButtonSpecStyle.WorkspaceMaximize: case PaletteButtonSpecStyle.WorkspaceRestore: case PaletteButtonSpecStyle.RibbonMinimize: case PaletteButtonSpecStyle.RibbonExpand: return string.Empty; default: // Should never happen! Debug.Assert(false); return null; } } /// <summary> /// Gets the color to remap from the image to the container foreground. /// </summary> /// <param name="style">Style of button spec.</param> /// <returns>Color value.</returns> public override Color GetButtonSpecColorMap(PaletteButtonSpecStyle style) { switch (style) { case PaletteButtonSpecStyle.FormClose: case PaletteButtonSpecStyle.FormMin: case PaletteButtonSpecStyle.FormMax: case PaletteButtonSpecStyle.FormRestore: case PaletteButtonSpecStyle.FormHelp: case PaletteButtonSpecStyle.PendantClose: case PaletteButtonSpecStyle.PendantMin: case PaletteButtonSpecStyle.PendantRestore: case PaletteButtonSpecStyle.Generic: return Color.Empty; case PaletteButtonSpecStyle.Close: case PaletteButtonSpecStyle.Context: case PaletteButtonSpecStyle.Next: case PaletteButtonSpecStyle.Previous: case PaletteButtonSpecStyle.ArrowLeft: case PaletteButtonSpecStyle.ArrowRight: case PaletteButtonSpecStyle.ArrowUp: case PaletteButtonSpecStyle.ArrowDown: case PaletteButtonSpecStyle.DropDown: case PaletteButtonSpecStyle.PinVertical: case PaletteButtonSpecStyle.PinHorizontal: case PaletteButtonSpecStyle.WorkspaceMaximize: case PaletteButtonSpecStyle.WorkspaceRestore: case PaletteButtonSpecStyle.RibbonMinimize: case PaletteButtonSpecStyle.RibbonExpand: return Color.Black; default: // Should never happen! Debug.Assert(false); return Color.Empty; } } /// <summary> /// Gets the color to remap to transparent. /// </summary> /// <param name="style">Style of button spec.</param> /// <returns>Color value.</returns> public override Color GetButtonSpecColorTransparent(PaletteButtonSpecStyle style) { switch (style) { case PaletteButtonSpecStyle.Generic: return Color.Empty; case PaletteButtonSpecStyle.Close: case PaletteButtonSpecStyle.Context: case PaletteButtonSpecStyle.Next: case PaletteButtonSpecStyle.Previous: case PaletteButtonSpecStyle.ArrowLeft: case PaletteButtonSpecStyle.ArrowRight: case PaletteButtonSpecStyle.ArrowUp: case PaletteButtonSpecStyle.DropDown: case PaletteButtonSpecStyle.PinVertical: case PaletteButtonSpecStyle.PinHorizontal: case PaletteButtonSpecStyle.FormClose: case PaletteButtonSpecStyle.FormMin: case PaletteButtonSpecStyle.FormMax: case PaletteButtonSpecStyle.FormRestore: case PaletteButtonSpecStyle.FormHelp: case PaletteButtonSpecStyle.PendantClose: case PaletteButtonSpecStyle.PendantMin: case PaletteButtonSpecStyle.PendantRestore: case PaletteButtonSpecStyle.WorkspaceMaximize: case PaletteButtonSpecStyle.WorkspaceRestore: case PaletteButtonSpecStyle.RibbonMinimize: case PaletteButtonSpecStyle.RibbonExpand: return Color.Magenta; default: // Should never happen! Debug.Assert(false); return Color.Empty; } } /// <summary> /// Gets the button style used for drawing the button. /// </summary> /// <param name="style">Style of button spec.</param> /// <returns>PaletteButtonStyle value.</returns> public override PaletteButtonStyle GetButtonSpecStyle(PaletteButtonSpecStyle style) { switch (style) { case PaletteButtonSpecStyle.FormMin: case PaletteButtonSpecStyle.FormMax: case PaletteButtonSpecStyle.FormRestore: case PaletteButtonSpecStyle.FormHelp: return PaletteButtonStyle.Form; case PaletteButtonSpecStyle.FormClose: return PaletteButtonStyle.FormClose; case PaletteButtonSpecStyle.Generic: case PaletteButtonSpecStyle.Close: case PaletteButtonSpecStyle.Context: case PaletteButtonSpecStyle.Next: case PaletteButtonSpecStyle.Previous: case PaletteButtonSpecStyle.ArrowLeft: case PaletteButtonSpecStyle.ArrowRight: case PaletteButtonSpecStyle.ArrowUp: case PaletteButtonSpecStyle.ArrowDown: case PaletteButtonSpecStyle.DropDown: case PaletteButtonSpecStyle.PinVertical: case PaletteButtonSpecStyle.PinHorizontal: case PaletteButtonSpecStyle.PendantClose: case PaletteButtonSpecStyle.PendantMin: case PaletteButtonSpecStyle.PendantRestore: case PaletteButtonSpecStyle.WorkspaceMaximize: case PaletteButtonSpecStyle.WorkspaceRestore: case PaletteButtonSpecStyle.RibbonMinimize: case PaletteButtonSpecStyle.RibbonExpand: return PaletteButtonStyle.ButtonSpec; default: // Should never happen! Debug.Assert(false); return PaletteButtonStyle.ButtonSpec; } } /// <summary> /// Get the location for the button. /// </summary> /// <param name="style">Style of button spec.</param> /// <returns>HeaderLocation value.</returns> public override HeaderLocation GetButtonSpecLocation(PaletteButtonSpecStyle style) { switch (style) { case PaletteButtonSpecStyle.Generic: case PaletteButtonSpecStyle.Close: case PaletteButtonSpecStyle.Context: case PaletteButtonSpecStyle.Next: case PaletteButtonSpecStyle.Previous: case PaletteButtonSpecStyle.ArrowLeft: case PaletteButtonSpecStyle.ArrowRight: case PaletteButtonSpecStyle.ArrowUp: case PaletteButtonSpecStyle.ArrowDown: case PaletteButtonSpecStyle.DropDown: case PaletteButtonSpecStyle.PinVertical: case PaletteButtonSpecStyle.PinHorizontal: case PaletteButtonSpecStyle.FormClose: case PaletteButtonSpecStyle.FormMin: case PaletteButtonSpecStyle.FormMax: case PaletteButtonSpecStyle.FormRestore: case PaletteButtonSpecStyle.FormHelp: case PaletteButtonSpecStyle.PendantClose: case PaletteButtonSpecStyle.PendantMin: case PaletteButtonSpecStyle.PendantRestore: case PaletteButtonSpecStyle.WorkspaceMaximize: case PaletteButtonSpecStyle.WorkspaceRestore: case PaletteButtonSpecStyle.RibbonMinimize: case PaletteButtonSpecStyle.RibbonExpand: return HeaderLocation.PrimaryHeader; default: // Should never happen! Debug.Assert(false); return HeaderLocation.PrimaryHeader; } } /// <summary> /// Gets the edge to positon the button against. /// </summary> /// <param name="style">Style of button spec.</param> /// <returns>PaletteRelativeEdgeAlign value.</returns> public override PaletteRelativeEdgeAlign GetButtonSpecEdge(PaletteButtonSpecStyle style) { switch (style) { case PaletteButtonSpecStyle.Generic: case PaletteButtonSpecStyle.Close: case PaletteButtonSpecStyle.Context: case PaletteButtonSpecStyle.Next: case PaletteButtonSpecStyle.Previous: case PaletteButtonSpecStyle.ArrowLeft: case PaletteButtonSpecStyle.ArrowRight: case PaletteButtonSpecStyle.ArrowUp: case PaletteButtonSpecStyle.ArrowDown: case PaletteButtonSpecStyle.DropDown: case PaletteButtonSpecStyle.PinVertical: case PaletteButtonSpecStyle.PinHorizontal: case PaletteButtonSpecStyle.FormClose: case PaletteButtonSpecStyle.FormMin: case PaletteButtonSpecStyle.FormMax: case PaletteButtonSpecStyle.FormRestore: case PaletteButtonSpecStyle.FormHelp: case PaletteButtonSpecStyle.PendantClose: case PaletteButtonSpecStyle.PendantMin: case PaletteButtonSpecStyle.PendantRestore: case PaletteButtonSpecStyle.WorkspaceMaximize: case PaletteButtonSpecStyle.WorkspaceRestore: case PaletteButtonSpecStyle.RibbonMinimize: case PaletteButtonSpecStyle.RibbonExpand: return PaletteRelativeEdgeAlign.Far; default: // Should never happen! Debug.Assert(false); return PaletteRelativeEdgeAlign.Far; } } /// <summary> /// Gets the button orientation. /// </summary> /// <param name="style">Style of button spec.</param> /// <returns>PaletteButtonOrientation value.</returns> public override PaletteButtonOrientation GetButtonSpecOrientation(PaletteButtonSpecStyle style) { switch (style) { case PaletteButtonSpecStyle.Close: case PaletteButtonSpecStyle.Context: case PaletteButtonSpecStyle.ArrowLeft: case PaletteButtonSpecStyle.ArrowRight: case PaletteButtonSpecStyle.ArrowUp: case PaletteButtonSpecStyle.ArrowDown: case PaletteButtonSpecStyle.DropDown: case PaletteButtonSpecStyle.PinVertical: case PaletteButtonSpecStyle.PinHorizontal: case PaletteButtonSpecStyle.FormClose: case PaletteButtonSpecStyle.FormMin: case PaletteButtonSpecStyle.FormMax: case PaletteButtonSpecStyle.FormRestore: case PaletteButtonSpecStyle.FormHelp: case PaletteButtonSpecStyle.PendantClose: case PaletteButtonSpecStyle.PendantMin: case PaletteButtonSpecStyle.PendantRestore: case PaletteButtonSpecStyle.WorkspaceMaximize: case PaletteButtonSpecStyle.WorkspaceRestore: case PaletteButtonSpecStyle.RibbonMinimize: case PaletteButtonSpecStyle.RibbonExpand: return PaletteButtonOrientation.FixedTop; case PaletteButtonSpecStyle.Generic: case PaletteButtonSpecStyle.Next: case PaletteButtonSpecStyle.Previous: return PaletteButtonOrientation.Auto; default: // Should never happen! Debug.Assert(false); return PaletteButtonOrientation.Auto; } } #endregion #region RibbonGeneral /// <summary> /// Gets the ribbon shape that should be used. /// </summary> /// <returns>Ribbon shape value.</returns> public override PaletteRibbonShape GetRibbonShape() => PaletteRibbonShape.Office2010; /// <summary> /// Gets the text alignment for the ribbon context text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Font value.</returns> public override PaletteRelativeAlign GetRibbonContextTextAlign(PaletteState state) => PaletteRelativeAlign.Center; /// <summary> /// Gets the font for the ribbon context text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Font value.</returns> public override Font GetRibbonContextTextFont(PaletteState state) => _ribbonTabContextFont; /// <summary> /// Gets the color for the ribbon context text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Font value.</returns> public override Color GetRibbonContextTextColor(PaletteState state) => _contextTextColor; /// <summary> /// Gets the dark disabled color used for ribbon glyphs. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonDisabledDark(PaletteState state) => _disabledGlyphDark; /// <summary> /// Gets the light disabled color used for ribbon glyphs. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonDisabledLight(PaletteState state) => _disabledGlyphLight; /// <summary> /// Gets the color for the drop arrow light. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonDropArrowLight(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonDropArrowLight]; /// <summary> /// Gets the color for the drop arrow dark. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonDropArrowDark(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonDropArrowDark]; /// <summary> /// Gets the color for the dialog launcher dark. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonGroupDialogDark(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonGroupDialogDark]; /// <summary> /// Gets the color for the dialog launcher light. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonGroupDialogLight(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonGroupDialogLight]; /// <summary> /// Gets the color for the group separator dark. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonGroupSeparatorDark(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonGroupSeparatorDark]; /// <summary> /// Gets the color for the group separator light. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonGroupSeparatorLight(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonGroupSeparatorLight]; /// <summary> /// Gets the color for the minimize bar dark. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonMinimizeBarDark(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonMinimizeBarDark]; /// <summary> /// Gets the color for the minimize bar light. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonMinimizeBarLight(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonMinimizeBarLight]; /// <summary> /// Gets the color for the tab separator. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonTabSeparatorColor(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonTabSeparatorColor]; /// <summary> /// Gets the color for the tab context separators. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonTabSeparatorContextColor(PaletteState state) => _contextTabSeparator; /// <summary> /// Gets the font for the ribbon text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Font value.</returns> public override Font GetRibbonTextFont(PaletteState state) => _ribbonTabFont; /// <summary> /// Gets the rendering hint for the ribbon font. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteTextHint value.</returns> public override PaletteTextHint GetRibbonTextHint(PaletteState state) => PaletteTextHint.ClearTypeGridFit; /// <summary> /// Gets the color for the extra QAT button dark content color. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonQATButtonDark(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonQATButtonDark]; /// <summary> /// Gets the color for the extra QAT button light content color. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonQATButtonLight(PaletteState state) => _ribbonColors[(int)SchemeOfficeColors.RibbonQATButtonLight]; #endregion #region RibbonBack /// <summary> /// Gets the method used to draw the background of a ribbon item. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>PaletteRibbonBackStyle value.</returns> public override PaletteRibbonColorStyle GetRibbonBackColorStyle(PaletteRibbonBackStyle style, PaletteState state) { switch (style) { case PaletteRibbonBackStyle.RibbonAppMenuDocs: return PaletteRibbonColorStyle.Solid; case PaletteRibbonBackStyle.RibbonAppMenuInner: return PaletteRibbonColorStyle.RibbonAppMenuInner; case PaletteRibbonBackStyle.RibbonAppMenuOuter: return PaletteRibbonColorStyle.RibbonAppMenuOuter; case PaletteRibbonBackStyle.RibbonQATMinibar: return state == PaletteState.CheckedNormal ? PaletteRibbonColorStyle.RibbonQATMinibarDouble : PaletteRibbonColorStyle.RibbonQATMinibarSingle; case PaletteRibbonBackStyle.RibbonQATFullbar: return PaletteRibbonColorStyle.RibbonQATFullbarSquare; case PaletteRibbonBackStyle.RibbonQATOverflow: return PaletteRibbonColorStyle.RibbonQATOverflow; case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBorder: return PaletteRibbonColorStyle.LinearBorder; case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBack: return state == PaletteState.Pressed ? PaletteRibbonColorStyle.Empty : PaletteRibbonColorStyle.Linear; case PaletteRibbonBackStyle.RibbonGroupNormalBorder: case PaletteRibbonBackStyle.RibbonGroupCollapsedBorder: switch (state) { case PaletteState.Normal: case PaletteState.ContextNormal: return PaletteRibbonColorStyle.RibbonGroupNormalBorderSep; case PaletteState.Tracking: case PaletteState.ContextTracking: return PaletteRibbonColorStyle.RibbonGroupNormalBorderSepTrackingLight; case PaletteState.Pressed: case PaletteState.ContextPressed: return PaletteRibbonColorStyle.RibbonGroupNormalBorderSepPressedLight; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonGroupNormalTitle: case PaletteRibbonBackStyle.RibbonGroupCollapsedBack: return PaletteRibbonColorStyle.Empty; case PaletteRibbonBackStyle.RibbonGroupArea: switch (state) { case PaletteState.Normal: case PaletteState.CheckedNormal: return PaletteRibbonColorStyle.RibbonGroupAreaBorder3; case PaletteState.ContextCheckedNormal: return PaletteRibbonColorStyle.RibbonGroupAreaBorder4; case PaletteState.Tracking: return PaletteRibbonColorStyle.RibbonGroupNormalTrackingLight; case PaletteState.FocusOverride: return PaletteRibbonColorStyle.RibbonTabFocus2010; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonTab: switch (state) { case PaletteState.Disabled: case PaletteState.Normal: return PaletteRibbonColorStyle.Empty; case PaletteState.Tracking: case PaletteState.Pressed: case PaletteState.ContextTracking: return PaletteRibbonColorStyle.RibbonTabTracking2010; case PaletteState.FocusOverride: return PaletteRibbonColorStyle.RibbonTabFocus2010; case PaletteState.CheckedNormal: case PaletteState.CheckedTracking: case PaletteState.CheckedPressed: case PaletteState.ContextCheckedNormal: case PaletteState.ContextCheckedTracking: return PaletteRibbonColorStyle.RibbonTabSelected2010; default: // Should never happen! Debug.Assert(false); break; } break; default: // Should never happen! Debug.Assert(false); break; } return PaletteRibbonColorStyle.Empty; } /// <summary> /// Gets the first background color for the ribbon item. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonBackColor1(PaletteRibbonBackStyle style, PaletteState state) { switch (style) { case PaletteRibbonBackStyle.RibbonGalleryBack: return state switch { PaletteState.Disabled => _disabledBack, PaletteState.Tracking => _ribbonColors[(int)SchemeOfficeColors.RibbonGalleryBackTracking], _ => _ribbonColors[(int)SchemeOfficeColors.RibbonGalleryBackNormal] }; case PaletteRibbonBackStyle.RibbonGalleryBorder: return state switch { PaletteState.Disabled => _disabledBorder, _ => _ribbonColors[(int)SchemeOfficeColors.RibbonGalleryBorder] }; case PaletteRibbonBackStyle.RibbonAppMenuDocs: return _ribbonColors[(int)SchemeOfficeColors.AppButtonMenuDocsBack]; case PaletteRibbonBackStyle.RibbonAppMenuInner: return _ribbonColors[(int)SchemeOfficeColors.AppButtonInner1]; case PaletteRibbonBackStyle.RibbonAppMenuOuter: return _ribbonColors[(int)SchemeOfficeColors.AppButtonOuter1]; case PaletteRibbonBackStyle.RibbonQATMinibar: return state == PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.RibbonQATMini1] : _ribbonColors[(int)SchemeOfficeColors.RibbonQATMini1I]; case PaletteRibbonBackStyle.RibbonQATFullbar: return _ribbonColors[(int)SchemeOfficeColors.RibbonQATFullbar1]; case PaletteRibbonBackStyle.RibbonQATOverflow: return _ribbonColors[(int)SchemeOfficeColors.RibbonQATOverflow1]; case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBorder: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupFrameBorder1]; case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBack: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupFrameInside1]; case PaletteRibbonBackStyle.RibbonGroupNormalTitle: case PaletteRibbonBackStyle.RibbonGroupCollapsedBack: return Color.Empty; case PaletteRibbonBackStyle.RibbonGroupNormalBorder: case PaletteRibbonBackStyle.RibbonGroupCollapsedBorder: switch (state) { case PaletteState.Normal: case PaletteState.Tracking: case PaletteState.Pressed: case PaletteState.ContextNormal: case PaletteState.ContextTracking: case PaletteState.ContextPressed: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupBorder1]; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonAppButton: switch (state) { case PaletteState.Normal: return _appButtonNormal[0]; case PaletteState.Tracking: return _appButtonTrack[0]; case PaletteState.Pressed: return _appButtonPressed[0]; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonGroupArea: return state == PaletteState.ContextCheckedNormal ? Color.Empty : _ribbonColors[(int)SchemeOfficeColors.RibbonGroupsArea1]; case PaletteRibbonBackStyle.RibbonTab: switch (state) { case PaletteState.Tracking: case PaletteState.Pressed: case PaletteState.ContextTracking: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabTracking1]; case PaletteState.CheckedNormal: case PaletteState.CheckedTracking: case PaletteState.CheckedPressed: case PaletteState.ContextCheckedNormal: case PaletteState.ContextCheckedTracking: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabSelected1]; case PaletteState.FocusOverride: return _contextCheckedTabBorder1; case PaletteState.Normal: return Color.Empty; default: // Should never happen! Debug.Assert(false); break; } break; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } /// <summary> /// Gets the second background color for the ribbon item. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonBackColor2(PaletteRibbonBackStyle style, PaletteState state) { switch (style) { case PaletteRibbonBackStyle.RibbonAppMenuInner: return _ribbonColors[(int)SchemeOfficeColors.AppButtonInner2]; case PaletteRibbonBackStyle.RibbonAppMenuOuter: return _ribbonColors[(int)SchemeOfficeColors.AppButtonOuter2]; case PaletteRibbonBackStyle.RibbonQATMinibar: return state == PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.RibbonQATMini2] : _ribbonColors[(int)SchemeOfficeColors.RibbonQATMini2I]; case PaletteRibbonBackStyle.RibbonQATFullbar: return _ribbonColors[(int)SchemeOfficeColors.RibbonQATFullbar2]; case PaletteRibbonBackStyle.RibbonQATOverflow: return _ribbonColors[(int)SchemeOfficeColors.RibbonQATOverflow2]; case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBorder: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupFrameBorder2]; case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBack: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupFrameInside2]; case PaletteRibbonBackStyle.RibbonGroupNormalTitle: switch (state) { case PaletteState.Normal: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupTitle2]; case PaletteState.ContextNormal: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupTitleContext2]; case PaletteState.Tracking: case PaletteState.ContextTracking: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupTitleTracking2]; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonGroupNormalBorder: case PaletteRibbonBackStyle.RibbonGroupCollapsedBorder: switch (state) { case PaletteState.Normal: case PaletteState.Tracking: case PaletteState.Pressed: case PaletteState.ContextNormal: case PaletteState.ContextTracking: case PaletteState.ContextPressed: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupBorder2]; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonAppButton: switch (state) { case PaletteState.Normal: return _appButtonNormal[1]; case PaletteState.Tracking: return _appButtonTrack[1]; case PaletteState.Pressed: return _appButtonPressed[1]; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonGroupArea: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupsArea2]; case PaletteRibbonBackStyle.RibbonTab: switch (state) { case PaletteState.Tracking: case PaletteState.Pressed: case PaletteState.ContextTracking: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabTracking2]; case PaletteState.CheckedNormal: case PaletteState.CheckedTracking: case PaletteState.CheckedPressed: case PaletteState.ContextCheckedTracking: case PaletteState.ContextCheckedNormal: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabSelected2]; case PaletteState.FocusOverride: return _contextCheckedTabBorder2; case PaletteState.Normal: return Color.Empty; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonAppMenuDocs: case PaletteRibbonBackStyle.RibbonGalleryBack: case PaletteRibbonBackStyle.RibbonGalleryBorder: case PaletteRibbonBackStyle.RibbonGroupCollapsedBack: return Color.Empty; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } /// <summary> /// Gets the third background color for the ribbon item. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonBackColor3(PaletteRibbonBackStyle style, PaletteState state) { switch (style) { case PaletteRibbonBackStyle.RibbonAppMenuOuter: return _ribbonColors[(int)SchemeOfficeColors.AppButtonOuter3]; case PaletteRibbonBackStyle.RibbonQATMinibar: return state == PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.RibbonQATMini3] : _ribbonColors[(int)SchemeOfficeColors.RibbonQATMini3I]; case PaletteRibbonBackStyle.RibbonQATFullbar: return _ribbonColors[(int)SchemeOfficeColors.RibbonQATFullbar3]; case PaletteRibbonBackStyle.RibbonGroupNormalBorder: case PaletteRibbonBackStyle.RibbonGroupCollapsedBorder: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupBorder3]; case PaletteRibbonBackStyle.RibbonAppMenuDocs: case PaletteRibbonBackStyle.RibbonAppMenuInner: case PaletteRibbonBackStyle.RibbonQATOverflow: case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBorder: case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBack: case PaletteRibbonBackStyle.RibbonGroupCollapsedBack: case PaletteRibbonBackStyle.RibbonGroupNormalTitle: case PaletteRibbonBackStyle.RibbonGalleryBack: case PaletteRibbonBackStyle.RibbonGalleryBorder: return Color.Empty; case PaletteRibbonBackStyle.RibbonAppButton: switch (state) { case PaletteState.Normal: return _appButtonNormal[2]; case PaletteState.Tracking: return _appButtonTrack[2]; case PaletteState.Pressed: return _appButtonPressed[2]; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonGroupArea: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupsArea3]; case PaletteRibbonBackStyle.RibbonTab: switch (state) { case PaletteState.Tracking: case PaletteState.Pressed: case PaletteState.ContextTracking: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabTracking3]; case PaletteState.CheckedNormal: case PaletteState.CheckedTracking: case PaletteState.CheckedPressed: case PaletteState.ContextCheckedNormal: case PaletteState.ContextCheckedTracking: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabSelected3]; case PaletteState.FocusOverride: return _contextCheckedTabBorder3; case PaletteState.Normal: return Color.Empty; default: // Should never happen! Debug.Assert(false); break; } break; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } /// <summary> /// Gets the fourth background color for the ribbon item. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonBackColor4(PaletteRibbonBackStyle style, PaletteState state) { switch (style) { case PaletteRibbonBackStyle.RibbonQATMinibar: return state == PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.RibbonQATMini4] : _ribbonColors[(int)SchemeOfficeColors.RibbonQATMini4I]; case PaletteRibbonBackStyle.RibbonGroupNormalBorder: case PaletteRibbonBackStyle.RibbonGroupCollapsedBorder: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupBorder4]; case PaletteRibbonBackStyle.RibbonAppMenuDocs: case PaletteRibbonBackStyle.RibbonAppMenuInner: case PaletteRibbonBackStyle.RibbonAppMenuOuter: case PaletteRibbonBackStyle.RibbonQATFullbar: case PaletteRibbonBackStyle.RibbonQATOverflow: case PaletteRibbonBackStyle.RibbonGroupCollapsedBack: case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBorder: case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBack: case PaletteRibbonBackStyle.RibbonGroupNormalTitle: case PaletteRibbonBackStyle.RibbonGalleryBack: case PaletteRibbonBackStyle.RibbonGalleryBorder: return Color.Empty; case PaletteRibbonBackStyle.RibbonAppButton: switch (state) { case PaletteState.Normal: return _appButtonNormal[3]; case PaletteState.Tracking: return _appButtonTrack[3]; case PaletteState.Pressed: return _appButtonPressed[3]; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonGroupArea: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupsArea4]; case PaletteRibbonBackStyle.RibbonTab: switch (state) { case PaletteState.Tracking: case PaletteState.Pressed: case PaletteState.ContextTracking: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabTracking4]; case PaletteState.CheckedNormal: case PaletteState.CheckedTracking: case PaletteState.CheckedPressed: case PaletteState.ContextCheckedNormal: case PaletteState.ContextCheckedTracking: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabSelected4]; case PaletteState.FocusOverride: return _contextCheckedTabBorder4; case PaletteState.Normal: return Color.Empty; default: // Should never happen! Debug.Assert(false); break; } break; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } /// <summary> /// Gets the fifth background color for the ribbon item. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonBackColor5(PaletteRibbonBackStyle style, PaletteState state) { switch (style) { case PaletteRibbonBackStyle.RibbonAppMenuDocs: case PaletteRibbonBackStyle.RibbonAppMenuInner: case PaletteRibbonBackStyle.RibbonAppMenuOuter: case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBorder: case PaletteRibbonBackStyle.RibbonGroupCollapsedFrameBack: case PaletteRibbonBackStyle.RibbonGroupCollapsedBack: case PaletteRibbonBackStyle.RibbonGroupNormalTitle: case PaletteRibbonBackStyle.RibbonQATFullbar: case PaletteRibbonBackStyle.RibbonQATOverflow: case PaletteRibbonBackStyle.RibbonGalleryBack: case PaletteRibbonBackStyle.RibbonGalleryBorder: return Color.Empty; case PaletteRibbonBackStyle.RibbonGroupNormalBorder: case PaletteRibbonBackStyle.RibbonGroupCollapsedBorder: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupBorder5]; case PaletteRibbonBackStyle.RibbonQATMinibar: return state == PaletteState.Normal ? _ribbonColors[(int)SchemeOfficeColors.RibbonQATMini5] : _ribbonColors[(int)SchemeOfficeColors.RibbonQATMini5I]; case PaletteRibbonBackStyle.RibbonAppButton: switch (state) { case PaletteState.Normal: return _appButtonNormal[4]; case PaletteState.Tracking: return _appButtonTrack[4]; case PaletteState.Pressed: return _appButtonPressed[4]; default: // Should never happen! Debug.Assert(false); break; } break; case PaletteRibbonBackStyle.RibbonGroupArea: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupsArea5]; case PaletteRibbonBackStyle.RibbonTab: switch (state) { case PaletteState.Disabled: return _disabledText; case PaletteState.Pressed: return _ribbonColors[(int)SchemeOfficeColors.RibbonTabTracking2]; case PaletteState.Tracking: case PaletteState.CheckedNormal: case PaletteState.CheckedTracking: case PaletteState.CheckedPressed: case PaletteState.ContextTracking: case PaletteState.ContextCheckedNormal: case PaletteState.ContextCheckedTracking: case PaletteState.FocusOverride: case PaletteState.Normal: return Color.Empty; default: // Should never happen! Debug.Assert(false); break; } break; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } #endregion #region RibbonText /// <summary> /// Gets the =color for the item text. /// </summary> /// <param name="style">Text style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonTextColor(PaletteRibbonTextStyle style, PaletteState state) { switch (style) { case PaletteRibbonTextStyle.RibbonAppMenuDocsTitle: case PaletteRibbonTextStyle.RibbonAppMenuDocsEntry: return _ribbonColors[(int)SchemeOfficeColors.AppButtonMenuDocsText]; case PaletteRibbonTextStyle.RibbonGroupNormalTitle: return state switch { PaletteState.Disabled => _disabledText, _ => _ribbonColors[(int)SchemeOfficeColors.RibbonGroupTitleText] }; case PaletteRibbonTextStyle.RibbonTab: return state switch { PaletteState.Disabled => _disabledText, PaletteState.CheckedNormal or PaletteState.CheckedPressed or PaletteState.CheckedTracking or PaletteState.ContextCheckedNormal or PaletteState.ContextCheckedTracking or PaletteState.FocusOverride => _ribbonColors[(int)SchemeOfficeColors.RibbonTabTextChecked], _ => _ribbonColors[(int)SchemeOfficeColors.RibbonTabTextNormal] }; case PaletteRibbonTextStyle.RibbonGroupCollapsedText: return _ribbonColors[(int)SchemeOfficeColors.RibbonGroupCollapsedText]; case PaletteRibbonTextStyle.RibbonGroupButtonText: case PaletteRibbonTextStyle.RibbonGroupLabelText: case PaletteRibbonTextStyle.RibbonGroupCheckBoxText: case PaletteRibbonTextStyle.RibbonGroupRadioButtonText: return state == PaletteState.Disabled ? _disabledText : _ribbonColors[(int)SchemeOfficeColors.RibbonGroupCollapsedText]; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } #endregion #region ElementColor /// <summary> /// Gets the first element color. /// </summary> /// <param name="element">Element for which color is required.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetElementColor1(PaletteElement element, PaletteState state) { // We do not provide override values if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } switch (element) { case PaletteElement.TrackBarTick: return _trackBarColors[0]; case PaletteElement.TrackBarTrack: return _trackBarColors[1]; case PaletteElement.TrackBarPosition: return state switch { PaletteState.Disabled => Color.Empty, _ => _trackBarColors[4] }; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } /// <summary> /// Gets the second element color. /// </summary> /// <param name="element">Element for which color is required.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetElementColor2(PaletteElement element, PaletteState state) { if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } switch (element) { case PaletteElement.TrackBarTick: return _trackBarColors[0]; case PaletteElement.TrackBarTrack: return _trackBarColors[2]; case PaletteElement.TrackBarPosition: return state switch { PaletteState.Disabled => ControlPaint.Light(_ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder]), PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBorder], PaletteState.Tracking or PaletteState.FocusOverride => _buttonBorderColors[1], PaletteState.Pressed => _buttonBorderColors[3], _ => throw new ArgumentOutOfRangeException(nameof(state)) }; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } /// <summary> /// Gets the third element color. /// </summary> /// <param name="element">Element for which color is required.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetElementColor3(PaletteElement element, PaletteState state) { if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } switch (element) { case PaletteElement.TrackBarTick: return _trackBarColors[0]; case PaletteElement.TrackBarTrack: return _trackBarColors[3]; case PaletteElement.TrackBarPosition: return state switch { PaletteState.Disabled => ControlPaint.LightLight( _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1]), PaletteState.Normal => ControlPaint.Light( _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1]), PaletteState.Tracking => ControlPaint.Light(_buttonBackColors[2]), PaletteState.Pressed => ControlPaint.Light(_buttonBackColors[4]), _ => throw new ArgumentOutOfRangeException(nameof(state)) }; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } /// <summary> /// Gets the fourth element color. /// </summary> /// <param name="element">Element for which color is required.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetElementColor4(PaletteElement element, PaletteState state) { switch (element) { case PaletteElement.TrackBarTick: if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } return _trackBarColors[0]; case PaletteElement.TrackBarTrack: if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } return _trackBarColors[3]; case PaletteElement.TrackBarPosition: if (CommonHelper.IsOverrideStateExclude(state, PaletteState.FocusOverride)) { return Color.Empty; } return state switch { PaletteState.Disabled => ControlPaint.LightLight(_ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1]), PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1], PaletteState.Tracking or PaletteState.FocusOverride => _buttonBackColors[2], PaletteState.Pressed => _buttonBackColors[4], _ => throw new ArgumentOutOfRangeException(nameof(state)) }; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } /// <summary> /// Gets the fifth element color. /// </summary> /// <param name="element">Element for which color is required.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetElementColor5(PaletteElement element, PaletteState state) { switch (element) { case PaletteElement.TrackBarTick: if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } return _trackBarColors[0]; case PaletteElement.TrackBarTrack: if (CommonHelper.IsOverrideState(state)) { return Color.Empty; } return _trackBarColors[3]; case PaletteElement.TrackBarPosition: if (CommonHelper.IsOverrideStateExclude(state, PaletteState.FocusOverride)) { return Color.Empty; } return state switch { PaletteState.Disabled => ControlPaint.LightLight(_ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack1]), PaletteState.Normal => _ribbonColors[(int)SchemeOfficeColors.ButtonNormalBack2], PaletteState.Tracking or PaletteState.FocusOverride => _buttonBackColors[3], PaletteState.Pressed => _buttonBackColors[5], _ => throw new ArgumentOutOfRangeException(nameof(state)) }; default: // Should never happen! Debug.Assert(false); break; } return Color.Red; } #endregion #region Public /// <summary> /// Gets and sets the base font name used when defining fonts. /// </summary> public virtual string BaseFontName { get => string.IsNullOrEmpty(_baseFontName) ? "Segoe UI" : _baseFontName; set { // Is there a change in value? if ((string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(_baseFontName)) || (!string.IsNullOrEmpty(value) && string.IsNullOrEmpty(_baseFontName))) { // Cache new value _baseFontName = value; // Update fonts to reflect change DefineFonts(); // Use event to indicate palette has caused layout changes OnPalettePaint(this, new PaletteLayoutEventArgs(true, false)); } } } #endregion #region Protected /// <summary> /// Update the fonts to reflect system or user defined changes. /// </summary> protected override void DefineFonts() { // Release existing resources _header1ShortFont?.Dispose(); _header2ShortFont?.Dispose(); _headerFormFont?.Dispose(); _header1LongFont?.Dispose(); _header2LongFont?.Dispose(); _buttonFont?.Dispose(); _buttonFontNavigatorStack?.Dispose(); _buttonFontNavigatorMini?.Dispose(); _tabFontSelected?.Dispose(); _tabFontNormal?.Dispose(); _ribbonTabFont?.Dispose(); _ribbonTabContextFont?.Dispose(); _gridFont?.Dispose(); _calendarFont?.Dispose(); _calendarBoldFont?.Dispose(); _superToolFont?.Dispose(); _boldFont?.Dispose(); _italicFont?.Dispose(); var baseFontSize = BaseFontSize; var baseFontName = BaseFontName; _header1ShortFont = new Font(baseFontName, baseFontSize + 4.5f, FontStyle.Bold); _header2ShortFont = new Font(baseFontName, baseFontSize, FontStyle.Regular); _headerFormFont = new Font(baseFontName, SystemFonts.CaptionFont.SizeInPoints, FontStyle.Regular); _header1LongFont = new Font(baseFontName, baseFontSize + 1.5f, FontStyle.Regular); _header2LongFont = new Font(baseFontName, baseFontSize, FontStyle.Regular); _buttonFont = new Font(baseFontName, baseFontSize, FontStyle.Regular); _buttonFontNavigatorStack = new Font(_buttonFont, FontStyle.Bold); _buttonFontNavigatorMini = new Font(baseFontName, baseFontSize + 3.0f, FontStyle.Bold); _tabFontNormal = new Font(baseFontName, baseFontSize, FontStyle.Regular); _tabFontSelected = new Font(_tabFontNormal, FontStyle.Bold); _ribbonTabFont = new Font(baseFontName, baseFontSize, FontStyle.Regular); _ribbonTabContextFont = new Font(_ribbonTabFont, FontStyle.Bold); _gridFont = new Font(baseFontName, baseFontSize, FontStyle.Regular); _superToolFont = new Font(baseFontName, baseFontSize, FontStyle.Bold); _calendarFont = new Font(baseFontName, baseFontSize, FontStyle.Regular); _calendarBoldFont = new Font(baseFontName, baseFontSize, FontStyle.Bold); _boldFont = new Font(baseFontName, baseFontSize, FontStyle.Bold); _italicFont = new Font(baseFontName, baseFontSize, FontStyle.Italic); } #endregion #region ColorTable /// <summary> /// Gets access to the color table instance. /// </summary> public override KryptonColorTable ColorTable => _table ?? (_table = new KryptonColorTable2010(_ribbonColors, InheritBool.True, this)); #endregion #region OnUserPreferenceChanged /// <summary> /// Handle a change in the user preferences. /// </summary> /// <param name="sender">Source of event.</param> /// <param name="e">Event data.</param> protected override void OnUserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e) { // Remove the current table, so it gets regenerated when next requested _table = null; // Update fonts to reflect any change in system settings DefineFonts(); base.OnUserPreferenceChanged(sender, e); } #endregion } #endregion }
91.60941
3,503
0.707874
[ "BSD-3-Clause" ]
Krypton-Suite/Standard-Toolkit
Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Office 2010/PaletteOffice2010BlueLightMode.cs
451,729
C#
namespace Business.Resources.Information { public sealed class HostResource { #region Property public string OriginalImagePath { get; set; } public string ThumbnailImagePath { get; set; } #endregion } }
22.545455
54
0.645161
[ "MIT" ]
dong-nguyen-hd/HR-Management
BE/Business/Resources/Information/HostResource.cs
250
C#
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.Serialization; using System.Windows; using System.Windows.Media; using ICSharpCode.AvalonEdit.Rendering; namespace ICSharpCode.AvalonEdit.Highlighting { /// <summary> /// A brush used for syntax highlighting. Can retrieve a real brush on-demand. /// </summary> [Serializable] public abstract class HighlightingBrush { /// <summary> /// Gets the real brush. /// </summary> /// <param name="context">The construction context. context can be null!</param> public abstract Brush GetBrush(ITextRunConstructionContext context); /// <summary> /// Gets the color of the brush. /// </summary> /// <param name="context">The construction context. context can be null!</param> public virtual Color? GetColor(ITextRunConstructionContext context) { SolidColorBrush scb = GetBrush(context) as SolidColorBrush; if (scb != null) return scb.Color; else return null; } } /// <summary> /// Highlighting brush implementation that takes a frozen brush. /// </summary> [Serializable] sealed class SimpleHighlightingBrush : HighlightingBrush, ISerializable { readonly SolidColorBrush brush; public SimpleHighlightingBrush(SolidColorBrush brush) { brush.Freeze(); this.brush = brush; } public SimpleHighlightingBrush(Color color) : this(new SolidColorBrush(color)) {} public override Brush GetBrush(ITextRunConstructionContext context) { return brush; } public override string ToString() { return brush.ToString(); } SimpleHighlightingBrush(SerializationInfo info, StreamingContext context) { this.brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(info.GetString("color"))); brush.Freeze(); } void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("color", brush.Color.ToString(CultureInfo.InvariantCulture)); } } /// <summary> /// HighlightingBrush implementation that finds a brush using a resource. /// </summary> [Serializable] sealed class SystemColorHighlightingBrush : HighlightingBrush, ISerializable { readonly PropertyInfo property; public SystemColorHighlightingBrush(PropertyInfo property) { Debug.Assert(property.ReflectedType == typeof(SystemColors)); Debug.Assert(typeof(Brush).IsAssignableFrom(property.PropertyType)); this.property = property; } public override Brush GetBrush(ITextRunConstructionContext context) { return (Brush)property.GetValue(null, null); } public override string ToString() { return property.Name; } SystemColorHighlightingBrush(SerializationInfo info, StreamingContext context) { property = typeof(SystemColors).GetProperty(info.GetString("propertyName")); if (property == null) throw new ArgumentException("Error deserializing SystemColorHighlightingBrush"); } void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("propertyName", property.Name); } } }
28.991525
104
0.716165
[ "MIT" ]
Kiho/mongo-edi
ICSharpCode.AvalonEdit/Highlighting/HighlightingBrush.cs
3,423
C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace _03.Regexmon { class Program { static void Main(string[] args) { string text = Console.ReadLine(); Regex regex = new Regex(@"([^A-Za-z\-]+)|([A-Za-z]+\-[A-Za-z]+)"); MatchCollection matches = regex.Matches(text); foreach (Match match in matches) { Console.WriteLine($"{match.Value}"); } } } }
24.291667
78
0.564322
[ "MIT" ]
bobo4aces/02.SoftUni-TechModule
01. PF - 99. Exams/2017.07.09/03. Regexmon/03. Regexmon.cs
585
C#
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.Entity; using Core.MusicInfo; namespace Core.Data { public class SampleData : DropCreateDatabaseAlways<MusicStoreEntities> { protected override void Seed(MusicStoreEntities context) { var genres = new List<Genre> { new Genre { GenreName = "摇滚", Description="从20世纪50年代起,人们在广播和唱片中认识了一种新的流行音乐,这种音乐每一拍节奏都非常强烈,歌词写的也十分新鲜,一下子征服了许多美国人的心。1951年,美国克利夫兰电台首次播放这类音乐时,为了使听众感到新鲜,一位名叫艾伦·弗里德的播音员在播放前介绍时,给这种音乐命名为“摇滚乐”。1955年,一位名叫Bill Haley的歌星演唱并录制了一张名叫《整日摇滚》(Rock Around the Clock)的唱片,引起了极大的轰动,前后出售了1500多万张,成为世界上最畅销的唱片之一,摇滚音乐的名称便由此而来。"}, new Genre { GenreName = "爵士",Description="爵士乐(Jazz),于19世纪末20世纪初源于美国,诞生于南部港口城市新奥尔良,音乐根基来自布鲁斯(Blues)和拉格泰姆(Ragtime)。爵士乐讲究即兴,以具有摇摆特点的Shuffle节奏为基础,是非洲黑人文化和欧洲白人文化的结合。20世纪前十几年爵士乐主要集中在新奥尔良发展,1917年后转向芝加哥,30年代又转移至纽约,直至今天,爵士乐风靡全球。爵士乐的主要风格有:新奥尔良爵士、摇摆乐、比博普、冷爵士、自由爵士、拉丁爵士、融合爵士等。"}, new Genre { GenreName = "金属",Description="金属乐以重金属为主,[1] 包括黑金属,死亡金属,激流金属,新金属,厄运金属,华丽金属,重金属,工业金属等重型音乐。"}, new Genre { GenreName = "朋克",Description="朋克(Punk),又译为庞克,诞生于七十年代中期,一种源于六十年代车库摇滚和前朋克摇滚的简单摇滚乐。它是最原始的摇滚乐——由一个简单悦耳的主旋律和三个和弦组成,经过演变,朋克已经逐渐脱离摇滚,成为一种独立的音乐,朋克音乐不太讲究音乐技巧,更加倾向于思想解放和反主流的尖锐立场,这种初衷在二十世纪七十年代特定的历史背景下在英美两国都得到了积极效仿,最终形成了朋克运动。同时,朋克音乐在年轻人中十分流行,为世界多地青年所喜爱。"}, new Genre { GenreName = "迪斯科",Description="“Disco”这个词是“Discotheque”的简称,原意是指“供人跳舞的舞厅”,60年代初源于法国。60年代,随着音乐设备的更新,舞厅里只要拥有一套唱片播放机就可以完成原来乐队的工作,并且还可以随时得到各种不同的音乐,即经济又实惠。因此,各大舞厅不再雇佣乐队来伴奏,而是雇佣一名唱片播放员通过播放唱片来提供伴舞音乐。慢慢的,人们把这种由唱片播放出来的跳舞音乐也称作迪斯科。"}, new Genre { GenreName = "蓝调",Description="蓝调(英文:Blues,解作“蓝色”,又音译为布鲁斯)是一种基于五声音阶的声乐和乐器音乐,它的另一个特点是其特殊的和声。蓝调起源于过去美国黑人奴隶的灵魂乐、赞美歌、劳动歌曲、叫喊和圣歌。蓝调中使用的“蓝调之音”和启应的演唱方式都显示了它的西方来源。"}, new Genre { GenreName = "民谣",Description="民间流行的、赋予民族色彩的歌曲,称为民谣或民歌。民谣的历史悠远,故其作者多不知名。民谣的内容丰富,有宗教的、爱情的、战争的、工作的,也有饮酒、舞蹈作乐、祭典等等。民谣表现一个民族的感情与习尚,因此各有其独特的音阶与情调风格。如法国民谣的蓬勃、意大利民谣的热情、英国民谣的淳朴、日本民谣的悲愤、西班牙民谣的狂放不羁、中国民谣的缠绵悱恻,都表现了强烈的民族气质与色彩。"}, new Genre { GenreName = "乡村音乐",Description="乡村音乐(country music)是一种具有美国民族特色的流行音乐,于20世纪20年代兴起于美国南部,其根源来自英国民谣,是美国白人民族音乐代表。乡村音乐的特点是曲调简单,节奏平稳,带有叙事性,具有较浓的乡土气息,亲切热情而不失流行元素。多为歌谣体、二部曲式或三部曲式。" }, new Genre { GenreName = "流行",Description="流行音乐(POP Music),是全球最受欢迎的一种音乐风格。流行音乐是根据英语Popular Music翻译过来的。按照汉语词语表面去理解,所谓流行音乐,是指那些结构短小、内容通俗、形式活泼、情感真挚,并被广大群众所喜爱,广泛传唱或欣赏,流行一时的甚至流传后世的器乐曲和歌曲。这些乐曲和歌曲,植根于大众生活的丰厚土壤之中。因此,又有\"大众音乐\"之称。" } }; var artists = new List<Artist> { new Artist { ArtistName = "Adele", Description="阿黛尔·阿德金斯(Adele Adkins),1988年5月5日出生于伦敦托特纳姆,英国流行歌手。2008年,阿黛尔发行了首张专辑《19》,获得当年水星音乐奖提名,并在全球取得了超过900万的销售量。其中的单曲《Chasing Pavements》助其获得格莱美最佳新人和最佳流行女歌手两座大奖。2011年,阿黛尔推出第二张录音室专辑《21》,拥有三支冠军单曲。" }, new Artist { ArtistName = "Beyond", Description="Beyond,中国香港摇滚乐队,由黄家驹、黄贯中、黄家强、叶世荣组成[1-3] 。1983年Beyond成立,同年参加“山叶吉他比赛”获得冠军并正式出道。1986年自资发行乐队首张专辑《再见理想》。1988年凭借粤语专辑《秘密警察》获得关注。1989年凭借歌曲《真的爱你》获得第12届十大中文金曲奖、第7届十大劲歌金曲奖[4] 。1990年凭借歌曲《光辉岁月》获得第8届十大劲歌金曲奖[2] 。1991年9月,Beyond在香港红磡体育馆举办“生命接触”演唱会[5] 。1992年,Beyond赴日本发展演艺事业。1993年发行粤语专辑《乐与怒》,专辑中的歌曲《海阔天空》获得第16届十大中文金曲奖[6] ;6月30日,乐队主唱黄家驹去世,Beyond以三名成员的组成形式继续发展。" }, new Artist { ArtistName = "Taylor Swift" , Description="泰勒·斯威夫特(Taylor Swift),1989年12月13日出生于美国宾夕法尼亚州,美国流行音乐、乡村音乐创作型女歌手、音乐制作人、演员、慈善家。2006年与独立唱片公司大机器唱片签约,发行首张录音室专辑《泰勒·斯威夫特》,获美国唱片业协会认证5倍白金唱片[1]。2008年发行第二张录音室专辑《Fearless》,在美国公告牌专辑榜上获11周冠军,是2009年全美最畅销专辑,认证7倍白金唱片[2] ,专辑获第52届格莱美奖年度专辑,使泰勒成为获此奖项的最年轻歌手, [3] 也是获奖最多的乡村音乐专辑[4] 。" }, new Artist { ArtistName = "Michael Jackson" , Description="迈克尔·杰克逊(Michael Jackson,1958年8月29日-2009年6月25日),出生于美国印第安纳州加里市,美国歌手、词曲创作人、舞蹈家、表演家、慈善家、音乐家、人道主义者、和平主义者、慈善机构创办人。杰克逊是家族的第七个孩子,他在1964年作为杰克逊五人组的成员和他的兄弟一起在职业音乐舞台上初次登台,1968年乐队与当地的一家唱片公司合作出版了第一张唱片《Big Boy》。1971年12月,发行了个人首支单曲《Got to be there》,标志着其个人独唱生涯的开始。" }, new Artist { ArtistName = "阿杜" , Description="阿杜(Ado),原名杜成义,1973年3月11日出生于新加坡,新加坡歌手。在当歌手之前,阿杜是建筑工地的工头,直到有一天,阿杜陪同朋友去参加一个三千多人报名的试音比赛,意外受到评审的肯定与青睐,立刻与他签约为培训的歌手,加入海蝶唱片,从此步入歌坛。2002年发行第一张专辑《天黑》;同年,发行专辑《坚持到底》。2007年,发行专辑《差一点》[1] ,阿杜凭借歌曲《差一点》获得雪碧原创港台金曲奖[2] 。2008年,发行专辑《Do The Best》[3] 。2010年,发行专辑《没什么好怕》[4-5] ,并凭借该专辑获得CCTV《环球红歌盛典》媒体推荐最具特色艺人大奖。2011年11月8日,签约乐华娱乐[6] 。2012年,发行专辑《第9次初恋》[7] 。2013年,参与安徽卫视的综艺节目《我为歌狂》[8] 。" }, new Artist { ArtistName = "陈奕迅" , Description="陈奕迅(Eason Chan),1974年7月27日出生于香港,中国香港男歌手、演员,毕业于英国金斯顿大学。1995年因获得第14届新秀歌唱大赛冠军而正式出道。1996年发行个人首张专辑《陈奕迅》。1997年主演个人首部电影《旺角大家姐》。1998年凭借歌曲《天下无双》在乐坛获得关注。2000年发行的歌曲《K歌之王》奠定其在歌坛的地位[1] 。2001年发行流行摇滚风格的专辑《反正是我》。2003年发行个人首张概念专辑《黑·白·灰》;专辑中的歌曲《十年》获得第4届百事音乐风云榜十大金曲奖[2] 。" }, new Artist { ArtistName = "刀郎" , Description="刀郎,原名罗林。1971年6月22日出生于四川省内江市资中县,歌手、音乐人。2004年以单曲《2002年的第一场雪》正式出道,2005年凭借《冲动的惩罚》获全国“金唱片”奖,2006年推出专辑《谢谢你》和《披着羊皮的狼》。2011至2012年间举办“刀郎-谢谢你全国巡回演唱会”,2011年8月10日,推出专辑《刀郎2011-身披彩衣的姑娘》,2012年以《爱是你我》获第十二届“五个一工程”奖。" }, new Artist { ArtistName = "范玮琪" , Description="范玮琪(Fan Fan),1976年3月18日出生于美国俄亥俄州,华语流行乐女歌手、影视演员、主持人。1999年,签约福茂唱片,成为旗下签约艺人,并进行了为期一年的培训。2000年,推出首张个人音乐专辑《范范的世界》,从而正式进军歌坛[1] 。2001年,凭借专辑《范范的世界》入围“第12届台湾金曲奖”最佳新人奖[2] ;同年,推出第二张个人音乐专辑《太阳》[3] 。2002年,出演个人首部电视剧《爱情白皮书》[4] 。2003年,推出第三张个人音乐专辑《真善美》[5] 。2004年,在都市爱情喜剧《醋溜族》中饰演女主角小红[6] 。" }, new Artist { ArtistName = "古巨基" , Description="古巨基,1972年8月18日出生于香港,中国香港男歌手、演员、主持人,毕业于沙田官立中学。1991年,出演个人首部电视剧《横财三千万》,从而正式进入演艺圈。1992年,担任无线电视娱乐新闻节目《娱乐新闻眼》的主持人。1994年,推出首张个人音乐专辑《爱的解释》,从而正式进军乐坛[1] 。1997年,获”叱咤乐坛流行榜颁奖典礼“叱咤乐坛男歌手银奖。2000年,在民国情感剧《情深深雨濛濛》中饰演男主角何书桓[2] 。2003年,在古装言情剧《还珠格格第三部》中饰演五阿哥爱新觉罗·永琪[3] 。2004年,获得“叱咤乐坛流行榜颁奖典礼'叱咤乐坛男歌手金奖、叱咤乐坛我最喜爱的男歌手、叱咤乐坛我最喜爱的歌曲大奖[4] 。'" }, new Artist { ArtistName = "海明威" , Description="" }, new Artist { ArtistName = "黄大炜" , Description="" }, new Artist { ArtistName = "金玟岐" , Description="" }, new Artist { ArtistName = "李玉刚" , Description="" }, new Artist { ArtistName = "李宗盛" , Description="" }, new Artist { ArtistName = "梁静茹" , Description="" }, new Artist { ArtistName = "林俊杰" , Description="" }, new Artist { ArtistName = "刘德华" , Description="" }, new Artist { ArtistName = "毛宁" , Description="" }, new Artist { ArtistName = "张学友" , Description="" }, new Artist { ArtistName = "莫文蔚" , Description="" }, new Artist { ArtistName = "朴树" , Description="" }, new Artist { ArtistName = "齐秦" , Description="" }, new Artist { ArtistName = "王杰" , Description="" }, new Artist { ArtistName = "王菲" , Description="" }, new Artist { ArtistName = "王力宏" , Description="" }, new Artist { ArtistName = "伍佰" , Description="" }, new Artist { ArtistName = "薛之谦" , Description="" }, new Artist { ArtistName = "杨丞琳" , Description="" }, new Artist { ArtistName = "张赫宣" , Description="" }, new Artist { ArtistName = "张惠妹" , Description="" }, new Artist { ArtistName = "张信哲" , Description="" }, new Artist { ArtistName = "赵雷" , Description="" }, new Artist { ArtistName = "周传雄" , Description="" }, new Artist { ArtistName = "周杰伦" , Description="" }, new Artist { ArtistName = "任贤齐" , Description="" }, new Artist { ArtistName = "陈东升" , Description="" }, new Artist { ArtistName = "光良" , Description="" }, }; new List<Album> { new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "Adele的专辑" , Genre = genres.Single(g => g.GenreName == "摇滚" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "Adele" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "Beyond的专辑" , Genre = genres.Single(g => g.GenreName == "爵士" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "Beyond" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "Taylor Swift的专辑" , Genre = genres.Single(g => g.GenreName == "金属" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "Taylor Swift" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "Michael Jackson的专辑" , Genre = genres.Single(g => g.GenreName == "朋克" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "Michael Jackson" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "阿杜的专辑" , Genre = genres.Single(g => g.GenreName == "迪斯科" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "阿杜" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "陈奕迅的专辑" , Genre = genres.Single(g => g.GenreName == "蓝调" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "陈奕迅" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "刀郎的专辑" , Genre = genres.Single(g => g.GenreName == "民谣" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "刀郎" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "范玮琪的专辑" , Genre = genres.Single(g => g.GenreName == "乡村音乐" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "范玮琪" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "古巨基的专辑" , Genre = genres.Single(g => g.GenreName == "流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "古巨基" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "海明威的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "海明威" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "黄大炜的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "黄大炜" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "金玟岐的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "金玟岐" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "李玉刚的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "李玉刚" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "李宗盛的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "李宗盛" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "梁静茹的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "梁静茹" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "林俊杰的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "林俊杰" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "刘德华的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "刘德华" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "毛宁的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "毛宁" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "张学友的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "张学友" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "莫文蔚的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "莫文蔚" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "朴树的专辑" , Genre = genres.Single(g => g.GenreName =="流行"), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "朴树" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "齐秦的专辑" , Genre = genres.Single(g => g.GenreName =="流行"), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "齐秦" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "王杰的专辑" , Genre = genres.Single(g => g.GenreName =="流行"), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "王杰" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "王菲的专辑" , Genre = genres.Single(g => g.GenreName =="流行"), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "王菲" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "王力宏的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "王力宏" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "伍佰的专辑" , Genre = genres.Single(g => g.GenreName =="流行"), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "伍佰" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "薛之谦的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "薛之谦" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "杨丞琳的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "杨丞琳" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "张赫宣的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "张赫宣" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "张惠妹的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "张惠妹" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "张信哲的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "张信哲" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "赵雷的专辑" , Genre = genres.Single(g => g.GenreName =="流行"), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "赵雷" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "周传雄的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "周传雄" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "周杰伦的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "周杰伦" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "任贤齐的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "任贤齐" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "陈东升的专辑" , Genre = genres.Single(g => g.GenreName =="流行" ), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "陈东升" ), AlbumArtUrl = "/images/placeholder.jpg" }, new Album {GroundingTime=DateTime.Now, AlbumNum=10 ,AlbumStatus=true, AlbumName = "光良的专辑" , Genre = genres.Single(g => g.GenreName =="流行"), Price = 9.99M, Artist = artists.Single(a => a.ArtistName == "光良" ), AlbumArtUrl = "/images/placeholder.jpg" }, }.ForEach(a => context.Albums.Add(a)); } } }
177.109091
445
0.603942
[ "MIT" ]
Geolle/GGMusicStore
Core/Data/SampleData.cs
26,890
C#
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Converter.Core; using Converter.Core.Helpers; using Converter.Core.Models; using Newtonsoft.Json.Linq; namespace Converter.BitShares.Converters { public abstract class BaseConverter { public const string ProjName = "BitShares"; private const string Url = "https://raw.githubusercontent.com/gropox/steemjsgui/master/src/steemjs/api/types.json"; private static readonly Regex NamespacePref = new Regex(@"\b[a-z]+::", RegexOptions.IgnoreCase); private static readonly Regex ParamNormRegex = new Regex(@"(\bconst\b\s*)|(&*)", RegexOptions.IgnoreCase); private static readonly Regex ParamTypeRegex = new Regex(@"(?<=^|,\s*)[a-z0-9:_]+(<[a-z( ):_,0-9]*>)?", RegexOptions.IgnoreCase); private static readonly Regex ParamNameRegex = new Regex(@"(?<=[\w_>:]+\s+)[a-z0-9_]+(\s*=\s*[a-z0-9]+)?(?=,|$)", RegexOptions.IgnoreCase); protected static readonly Regex NotNameChar = new Regex("[^[a-z0-9_]]*", RegexOptions.IgnoreCase); protected readonly Dictionary<string, string> _knownTypes; public static readonly Dictionary<string, string> Founded = new Dictionary<string, string>(); public static readonly Dictionary<string, ParsedClass> FoundedClass = new Dictionary<string, ParsedClass>(); public static readonly List<SearchTask> UnknownTypes = new List<SearchTask>(); private Dictionary<string, string> _methodDescriptions = new Dictionary<string, string>(); private Dictionary<string, string> MethodDescriptions { get { if (_methodDescriptions == null) { _methodDescriptions = GetMethodDescriptions().Result; } return _methodDescriptions; } } protected readonly CashParser _cashParser; protected BaseConverter(Dictionary<string, string> knownTypes, CashParser cashParser) { _knownTypes = knownTypes; _cashParser = cashParser; } private async Task<Dictionary<string, string>> GetMethodDescriptions() { try { var result = new Dictionary<string, string>(); var client = new HttpClient(); var response = client.GetAsync(Url); var content = await response.Result.Content.ReadAsStringAsync(); var types = JObject.Parse(content); var sections = types.Properties().ToList(); foreach (var section in sections) { var sectJObject = JObject.Parse(section.Value.ToString()); var methods = sectJObject.Properties().ToList(); foreach (var method in methods) { var methodJObject = JObject.Parse(method.Value.ToString()); var desc = JObject.Parse(methodJObject["desc"].ToString()); var enDesc = desc["en"].ToString(); if (!result.ContainsKey(method.Name)) { result.Add(method.Name, enDesc); } } } return result; } catch { // } return new Dictionary<string, string>(); } public void PrintToFile(ParsedClass converted, string searchDir, string absPathToFile, string storeResultDir) { var outDir = $"{storeResultDir}\\{ProjName}\\"; switch (converted.ObjectType) { case ObjectType.Class: case ObjectType.Enum: { outDir += "Models\\"; break; } case ObjectType.Api: { outDir += "Apis\\"; break; } } if (!Directory.Exists(outDir)) Directory.CreateDirectory(outDir); File.WriteAllText($"{outDir}{converted.Name}.cs", PrintParsedClass(converted, absPathToFile, searchDir), Encoding.UTF8); foreach (var itm in UnknownTypes) { if (string.IsNullOrEmpty(itm.SearchDir)) itm.SearchDir = searchDir; } } //public ParsedClass Parse(string text, bool isApi) //{ // var lines = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None); // var preParseClass = _cashParser.TryParseClass(lines, ,isApi); // ExtendPreParsedClass(preParseClass); // return preParseClass; //} #region ParseText protected void ExtendPreParsedClass(ParsedClass parsedClass) { if (parsedClass == null) return; if (!string.IsNullOrEmpty(parsedClass.CppName)) parsedClass.Name = parsedClass.CppName.ToTitleCase(); if (!string.IsNullOrEmpty(parsedClass.CppInherit)) parsedClass.Inherit = new List<ParsedType> { GetKnownTypeOrDefault(parsedClass.CppInherit) }; if (parsedClass.CppConstructorParams != null && parsedClass.CppConstructorParams.Any()) { foreach (var itm in parsedClass.CppConstructorParams) parsedClass.ConstructorParams.Add(TryParseParam(itm)); } if (parsedClass.ObjectType != ObjectType.Enum) { string templateName = null; if (parsedClass.IsTemplate) templateName = _cashParser.Unpack(parsedClass.Template, 1); for (var i = 0; i < parsedClass.Fields.Count; i++) { var preParsedElement = parsedClass.Fields[i]; parsedClass.Fields[i] = TryParseElement(preParsedElement, templateName, parsedClass.ObjectType); } } parsedClass.Fields.RemoveAll(i => i == null); } protected abstract PreParsedElement TryParseElement(PreParsedElement preParsedElement, string templateName, ObjectType objectType); protected ParsedType GetKnownTypeOrDefault(string type, string templateName = null) { var isOptional = false; type = type.Trim(); if (NamespacePref.IsMatch(type)) type = NamespacePref.Replace(type, string.Empty); if (type.StartsWith("optional<")) { type = _cashParser.Unpack(type, 1); isOptional = true; } if (type.StartsWith("static ")) type = type.Remove(0, 7); if (type.StartsWith("const ")) type = type.Remove(0, 6); if (type.EndsWith("<>")) type = type.Remove(type.Length - 2); if (type.IndexOf('<') > -1) { var ct = GetKnownCompositType(type); ct.IsOptional = isOptional; return ct; } if (_knownTypes.ContainsKey(type)) { return new ParsedType { CppName = type, Name = _knownTypes[type], IsOptional = isOptional }; } if (!string.IsNullOrEmpty(templateName) && type.Equals(templateName, StringComparison.OrdinalIgnoreCase)) { return new ParsedType { CppName = type, Name = templateName, IsOptional = isOptional }; } if (Founded.ContainsKey(type)) { return new ParsedType { CppName = type, Name = Founded[type], IsOptional = isOptional }; } if (!NotNameChar.IsMatch(type)) { AddTypeToTask(type); return new ParsedType { CppName = type, Name = type.ToTitleCase(), IsOptional = isOptional }; } return new ParsedType { CppName = type, Name = "object", IsOptional = isOptional }; } private void AddTypeToTask(string type) { if (!Founded.ContainsKey(type)) { Founded.Add(type, type.ToTitleCase()); if (!UnknownTypes.Any(i => i.SearchLine.Equals(type) && string.IsNullOrEmpty(i.SearchDir))) { var task = new SearchTask { Converter = KnownConverter.StructConverter, SearchLine = type, }; UnknownTypes.Add(task); } } } private ParsedType GetKnownCompositType(string type) { if (type.StartsWith("map<")) //TODO: research is needed return new ParsedType { CppName = type, Name = "object" }; var unpacked = _cashParser.Unpack(type, 1); ParsedType parsedType; if (type.StartsWith("array<")) //TODO: research is needed { var countPart = unpacked.LastIndexOf(','); if (countPart > 0) { unpacked = unpacked.Remove(countPart); parsedType = GetKnownTypeOrDefault(unpacked); parsedType.IsArray = true; return parsedType; } } if (IsArray(type)) { parsedType = GetKnownTypeOrDefault(unpacked); parsedType.IsArray = true; return parsedType; } var chArray = _cashParser.SplitParams(unpacked); var tmpl = type.Remove(type.IndexOf('<')); parsedType = tmpl.Equals("pair") ? new ParsedType { Name = "KeyValuePair" } : GetKnownTypeOrDefault(tmpl); parsedType.IsTemplate = true; foreach (var item in chArray) { var ch = GetKnownTypeOrDefault(item); parsedType.Container.Add(ch); } return parsedType; } private bool IsArray(string line) { return line.StartsWith("set<") | line.StartsWith("vector<") | line.StartsWith("deque<"); } protected List<ParsedParams> TryParseParams(string parameters) { parameters = ParamNormRegex.Replace(parameters, string.Empty); parameters = parameters.Trim(); if (string.IsNullOrEmpty(parameters)) return new List<ParsedParams>(); var typeMatches = ParamTypeRegex.Matches(parameters); var nameMatches = ParamNameRegex.Matches(parameters); if (typeMatches.Count != nameMatches.Count) throw new InvalidCastException(); var rez = new List<ParsedParams>(); for (var i = 0; i < typeMatches.Count; i++) { var defaultValue = string.Empty; var name = nameMatches[i].Value; var eqv = name.IndexOf("=", StringComparison.Ordinal); if (eqv > -1) { defaultValue = name.Substring(eqv + 1).Trim(); name = name.Remove(eqv).Trim(); } var param = new ParsedParams() { CppName = name, Name = name.ToTitleCase(false), Default = defaultValue, CppType = typeMatches[i].Value, Type = GetKnownTypeOrDefault(typeMatches[i].Value) }; rez.Add(param); } return rez; } private ParsedParams TryParseParam(string parameters) { parameters = ParamNormRegex.Replace(parameters, string.Empty); parameters = parameters.Trim(); if (string.IsNullOrEmpty(parameters)) return new ParsedParams(); var typeMatche = ParamTypeRegex.Match(parameters); var nameMatche = ParamNameRegex.Match(parameters); if (!typeMatche.Success || !nameMatche.Success) throw new InvalidCastException(); var defaultValue = string.Empty; var name = nameMatche.Value; var eqv = name.IndexOf("=", StringComparison.Ordinal); if (eqv > -1) { defaultValue = name.Substring(eqv + 1).Trim(); name = name.Remove(eqv).Trim(); } var rez = new ParsedParams() { CppName = name, Name = name.ToTitleCase(false), Default = defaultValue, CppType = typeMatche.Value, Type = GetKnownTypeOrDefault(typeMatche.Value) }; return rez; } #endregion ParseText #region PrintClass private void PrinNamespace(StringBuilder sb, ParsedClass parsedClass) { switch (parsedClass.ObjectType) { case ObjectType.Class: { sb.AppendLine("using System;"); sb.AppendLine("using Newtonsoft.Json;"); sb.AppendLine(); sb.AppendLine($"namespace Ditch.{ProjName}.Models"); break; } case ObjectType.Enum: { sb.AppendLine("using Ditch.Core.Converters;"); sb.AppendLine("using Newtonsoft.Json;"); sb.AppendLine(); sb.AppendLine($"namespace Ditch.{ProjName}.Models"); break; } case ObjectType.Api: { sb.AppendLine("using Ditch.Core;"); sb.AppendLine("using System;"); sb.AppendLine("using System.Collections.Generic; "); sb.AppendLine("using Ditch.Core.JsonRpc;"); sb.AppendLine($"using Ditch.{ProjName}.Models;"); sb.AppendLine("using System.Threading;"); sb.AppendLine(); sb.AppendLine($"namespace Ditch.{ProjName}"); break; } } sb.AppendLine("{"); } public string PrintParsedClass(ParsedClass parsedClass, string absPathToFile, string searchDir) { var sb = new StringBuilder(); PrinNamespace(sb, parsedClass); AddClassName(sb, parsedClass, absPathToFile, 4); string templateName = null; if (parsedClass.IsTemplate) templateName = _cashParser.Unpack(parsedClass.Template, 1); var doc = string.Empty; if (parsedClass.ObjectType == ObjectType.Api && !string.IsNullOrEmpty(searchDir)) doc = File.ReadAllText(searchDir + absPathToFile); foreach (var t in parsedClass.Fields) { if (parsedClass.ObjectType == ObjectType.Api && !string.IsNullOrEmpty(doc) && !doc.Contains($"({t.CppName})")) continue; PrintParsedElements(sb, parsedClass, t, 8, templateName); } CloseTag(sb, 4); CloseTag(sb, 0); return sb.ToString(); } private void AddClassName(StringBuilder sb, ParsedClass parsedClass, string absPathToFile, int indentCount) { var indent = new string(' ', indentCount); if (!string.IsNullOrEmpty(parsedClass.MainComment)) sb.AppendLine($"{indent}{parsedClass.MainComment.Replace("\r\n", "\r\n" + indent)}{Environment.NewLine}"); sb.AppendLine($"{indent}/// <summary>"); sb.AppendLine($"{indent}/// {parsedClass.CppName}"); if (!string.IsNullOrEmpty(absPathToFile)) sb.AppendLine($@"{indent}/// {absPathToFile}"); sb.AppendLine($"{indent}/// </summary>"); switch (parsedClass.ObjectType) { case ObjectType.Class: { sb.AppendLine($"{indent}[JsonObject(MemberSerialization.OptIn)]"); sb.AppendLine($"{indent}public class {parsedClass.Name}{(parsedClass.IsTemplate ? parsedClass.Template : string.Empty)}{(parsedClass.Inherit.Any() ? $" : {string.Join(", ", parsedClass.Inherit)}" : string.Empty)}"); break; } case ObjectType.Enum: { sb.AppendLine($"{indent}[JsonConverter(typeof(EnumConverter))]"); sb.AppendLine($"{indent}public enum {parsedClass.Name}"); break; } case ObjectType.Api: { sb.AppendLine($"{indent}public partial class OperationManager"); break; } } sb.AppendLine($"{indent}{{"); } private string TypeCorrection(string line) { if (string.IsNullOrEmpty(line)) return line; return line.Replace("<", "&lt;"); } private void PrintParsedElements(StringBuilder sb, ParsedClass parsedClass, PreParsedElement parsedElement, int indentCount, string templateName) { var indent = new string(' ', indentCount); sb.AppendLine(); Comment briefComment = null; var parsedFunc = parsedElement as ParsedFunc; if (parsedFunc != null) { briefComment = Comment.TryParseMainComment(parsedFunc.MainComment); if (briefComment != null && !briefComment.IsEmpty()) parsedFunc.MainComment = Comment.RemoveBriefFromMainComment(parsedFunc.MainComment); } //if (!string.IsNullOrEmpty(parsedElement.MainComment)) //{ // sb.Append(indent); // sb.AppendLine(parsedElement.MainComment); // sb.AppendLine(); //} var isVoidType = false; if (parsedClass.ObjectType == ObjectType.Api && parsedFunc != null && parsedFunc.Params.Any()) { var paramName = parsedFunc.Params[0].Type.Name; isVoidType = (FoundedClass.ContainsKey(paramName) && FoundedClass[paramName].Inherit.Any(i => i.Name.Equals("VoidType"))); } var comment = parsedElement.Comment ?? string.Empty; //comment = comment.Replace("\\", $@"/// {Environment.NewLine}"); sb.AppendLine($"{indent}/// <summary>"); sb.AppendLine($"{indent}/// API name: {parsedElement.CppName}"); if (!string.IsNullOrWhiteSpace(briefComment?.Brief)) { sb.AppendLine($"{indent}/// {briefComment.Brief.Replace(Environment.NewLine, $"{Environment.NewLine}{indent}/// ")}"); sb.AppendLine($"{indent}///"); } if (parsedClass.ObjectType == ObjectType.Api && !string.IsNullOrWhiteSpace(parsedElement.CppName) && MethodDescriptions.ContainsKey(parsedElement.CppName)) { var text = MethodDescriptions[parsedElement.CppName]; if (!string.IsNullOrWhiteSpace(text) && (briefComment == null || !briefComment.IsBriefContainText(text))) { sb.AppendLine($"{indent}/// *{text.Trim()}"); } } sb.AppendLine($"{indent}/// {TypeCorrection(comment)}"); sb.AppendLine($"{indent}/// </summary>"); if (parsedFunc != null) { if (!isVoidType) foreach (var itm in parsedFunc.Params) { sb.Append($"{indent}/// <param name=\"{itm.Name}\">API type: {TypeCorrection(itm.CppType)}"); if (briefComment != null && briefComment.Params.ContainsKey(itm.CppName)) sb.Append(briefComment.Params[itm.CppName].Replace(Environment.NewLine, $"{Environment.NewLine}{indent}/// ")); sb.AppendLine("</param>"); } if (parsedClass.ObjectType == ObjectType.Api) sb.AppendLine($"{indent}/// <param name=\"token\">Throws a <see cref=\"T:System.OperationCanceledException\" /> if this token has had cancellation requested.</param>"); } if (!string.IsNullOrWhiteSpace(briefComment?.Return) || !string.IsNullOrEmpty(parsedElement.Type?.CppName)) { sb.Append($"{indent}/// <returns>"); if (!string.IsNullOrEmpty(parsedElement.Type?.CppName)) { sb.Append($"API type: {TypeCorrection(parsedElement.Type.CppName)}"); if (!string.IsNullOrWhiteSpace(briefComment?.Return)) sb.Append(" "); } if (!string.IsNullOrWhiteSpace(briefComment?.Return)) sb.Append($"{briefComment.Return.Replace(Environment.NewLine, $"{Environment.NewLine}{indent}/// ")}"); sb.AppendLine("</returns>"); } if (parsedClass.ObjectType == ObjectType.Api) sb.AppendLine($"{indent}/// <exception cref=\"T:System.OperationCanceledException\">The token has had cancellation requested.</exception>"); var type = GetTypeForPrint(parsedElement.Type, templateName); if (parsedFunc != null) { sb.Append(indent + "public JsonRpcResponse"); if (!type.Equals("void", StringComparison.OrdinalIgnoreCase)) sb.Append($"<{type}>"); if (parsedClass.ObjectType == ObjectType.Api) { sb.Append($" {parsedElement.Name}("); if (parsedFunc.Params.Any() && !isVoidType) sb.Append($"{string.Join(", ", parsedFunc.Params)}, "); sb.AppendLine("CancellationToken token)"); } else { sb.AppendLine($" {parsedElement.Name}({string.Join(", ", parsedFunc.Params)})"); } sb.AppendLine($"{indent}{{"); sb.Append($"{indent} return CustomGetRequest{(type.Equals("void", StringComparison.OrdinalIgnoreCase) ? string.Empty : $"<{type}>")}("); if (parsedClass.ObjectType == ObjectType.Api) sb.Append($"KnownApiNames.{parsedClass.Name}, "); sb.Append($"\"{parsedElement.CppName}\""); if (parsedClass.ObjectType == ObjectType.Api) { if (parsedFunc.Params.Any() && !isVoidType) { sb.Append(", new object[]{"); sb.Append(string.Join(", ", parsedFunc.Params.Select(i => i.Name))); sb.Append(", }"); } sb.Append(", token"); } else { sb.Append(", new object[] {"); if (parsedFunc.Params.Any()) sb.Append(string.Join(", ", parsedFunc.Params.Select(i => i.Name))); sb.Append("}"); } sb.AppendLine(");"); sb.AppendLine($"{indent}}}"); } else { if (parsedClass.ObjectType != ObjectType.Enum) sb.AppendLine($"{indent}[JsonProperty(\"{parsedElement.CppName}\"{(parsedElement.Type != null && parsedElement.Type.IsOptional ? ", NullValueHandling = NullValueHandling.Ignore" : string.Empty)})]"); sb.AppendLine(parsedElement.Type != null ? $"{indent}public {type} {parsedElement.Name} {{get; set;}}" : $"{indent}{parsedElement.Name},"); } } private class Comment { public string Brief { get; set; } public Dictionary<string, string> Params { get; set; } = new Dictionary<string, string>(); public string Return { get; set; } public bool IsEmpty() { return string.IsNullOrEmpty(Brief) && Params.Count == 0 && string.IsNullOrEmpty(Return); } public static string RemoveBriefFromMainComment(string mainComment) { if (!string.IsNullOrWhiteSpace(mainComment) && mainComment.Contains("//")) { var start = mainComment.IndexOf("/**", StringComparison.Ordinal); if (start > -1) { mainComment = mainComment.Remove(start).Trim(new[] { ' ', '\r', '\n' }); } return mainComment; } return string.Empty; } public static Comment TryParseMainComment(string mainComment) { if (!string.IsNullOrWhiteSpace(mainComment)) { var tag = "@brief "; var start = mainComment.IndexOf(tag, StringComparison.Ordinal); if (start == -1) { tag = "@param "; start = mainComment.IndexOf(tag, StringComparison.Ordinal); if (start == -1) { tag = "@return "; start = mainComment.IndexOf(tag, StringComparison.Ordinal); if (start == -1) return null; } } start += tag.Length; int end = mainComment.Length; var rez = new Comment(); while (start < end) { var newTag = GetBlockEnd(mainComment, start, out end); var line = mainComment.Substring(start, end - start); line = TrimLine(line); switch (tag) { case "@brief ": rez.Brief = line; break; case "@param ": var nameEnd = line.IndexOf(' '); rez.Params.Add(line.Remove(nameEnd), line.Substring(nameEnd)); break; case "@return ": rez.Return = line; break; } tag = newTag; start = end + tag.Length; end = mainComment.Length; } return rez; } return null; } private static string GetBlockEnd(string text, int start, out int end) { end = text.IndexOf("@param ", start, StringComparison.Ordinal); if (end > -1) return "@param "; end = text.IndexOf("@return ", start, StringComparison.Ordinal); if (end > -1) return "@return "; end = text.Length; return string.Empty; } private static string TrimLine(string line) { var nl = new[] { '\r', '\n' }; var rem = new[] { '\t', ' ', '*', '/' }; var lines = line.Split(nl, StringSplitOptions.RemoveEmptyEntries); return string.Join(Environment.NewLine, lines.Select(i => i.TrimStart(rem))).TrimEnd(nl); } public bool IsBriefContainText(string text) { if (string.IsNullOrEmpty(Brief)) return string.IsNullOrEmpty(text); var t1 = Brief.Replace('\r', ' ') .Replace('\n', ' ') .Replace('\t', ' ') .Replace(" ", " "); var t2 = text.Replace('\r', ' ') .Replace('\n', ' ') .Replace('\t', ' ') .Replace(" ", " "); return t1.Equals(t2, StringComparison.CurrentCulture); } } private string GetTypeForPrint(ParsedType parsedType, string templateName) { if (parsedType == null) return string.Empty; var type = parsedType.Name; //if (!(!string.IsNullOrEmpty(templateName) && type.Equals(templateName, StringComparison.OrdinalIgnoreCase) || _knownTypes.ContainsValue(parsedType.Name))) // type = $"I{type}"; if (parsedType.IsTemplate) type += $"<{string.Join(", ", parsedType.Container.Select(pt => GetTypeForPrint(pt, templateName)))}>"; if (parsedType.IsArray) type += "[]"; return type; } private void CloseTag(StringBuilder sb, int indentCount) { var indent = new string(' ', indentCount); sb.AppendLine($"{indent}}}"); } #endregion } }
40.261745
239
0.497416
[ "MIT" ]
Chainers/Ditch
Tools/CppToCsharpConverter/Converter.BitShares/Converters/BaseConverter.cs
29,997
C#
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using MudBlazor.Extensions; using MudBlazor.Utilities; namespace MudBlazor { public partial class MudField : MudComponentBase { protected string Classname => new CssBuilder("mud-input") .AddClass($"mud-input-{Variant.ToDescriptionString()}") .AddClass($"mud-input-margin-{Margin.ToDescriptionString()}", when: () => Margin != Margin.None) .AddClass("mud-input-underline", when: () => DisableUnderLine == false && Variant != Variant.Outlined) .AddClass("mud-shrink", when: () => !string.IsNullOrWhiteSpace(ChildContent?.ToString())) .AddClass("mud-disabled", Disabled) .AddClass("mud-input-error", Error || !string.IsNullOrEmpty(ErrorText)) .AddClass(Class) .Build(); protected string InnerClassname => new CssBuilder("mud-input-slot") .AddClass("mud-input-root") .AddClass("mud-input-slot-nopadding", when: () => InnerPadding == false) .AddClass($"mud-input-root-{Variant.ToDescriptionString()}") .AddClass($"mud-input-root-margin-{Margin.ToDescriptionString()}", when: () => Margin != Margin.None) .AddClass(Class) .Build(); protected string AdornmentClassname => new CssBuilder("mud-input-adornment") .AddClass($"mud-input-adornment-{Adornment.ToDescriptionString()}", Adornment != Adornment.None) .AddClass($"mud-text", !string.IsNullOrEmpty(AdornmentText)) .AddClass($"mud-input-root-filled-shrink", Variant == Variant.Filled) .AddClass(Class) .Build(); protected string InputControlClassname => new CssBuilder("mud-field") .AddClass(Class) .Build(); /// <summary> /// Child content of component. /// </summary> [Parameter] public RenderFragment ChildContent { get; set; } /// <summary> /// Will adjust vertical spacing. /// </summary> [Parameter] public Margin Margin { get; set; } = Margin.None; /// <summary> /// If true, the label will be displayed in an error state. /// </summary> [Parameter] public bool Error { get; set; } /// <summary> /// The ErrorText that will be displayed if Error true /// </summary> [Parameter] public string ErrorText { get; set; } /// <summary> /// The HelperText will be displayed below the text field. /// </summary> [Parameter] public string HelperText { get; set; } /// <summary> /// If true, the field will take up the full width of its container. /// </summary> [Parameter] public bool FullWidth { get; set; } /// <summary> /// If string has value the label text will be displayed in the input, and scaled down at the top if the field has value. /// </summary> [Parameter] public string Label { get; set; } /// <summary> /// Variant can be Text, Filled or Outlined. /// </summary> [Parameter] public Variant Variant { get; set; } = Variant.Text; /// <summary> /// If true, the input element will be disabled. /// </summary> [Parameter] public bool Disabled { get; set; } /// <summary> /// Icon that will be used if Adornment is set to Start or End. /// </summary> [Parameter] public string AdornmentIcon { get; set; } /// <summary> /// Text that will be used if Adornment is set to Start or End, the Text overrides Icon. /// </summary> [Parameter] public string AdornmentText { get; set; } /// <summary> /// Sets Start or End Adornment if not set to None. /// </summary> [Parameter] public Adornment Adornment { get; set; } = Adornment.None; /// <summary> /// Sets the Icon Size. /// </summary> [Parameter] public Size IconSize { get; set; } = Size.Small; /// <summary> /// Button click event if set and Adornment used. /// </summary> [Parameter] public EventCallback<MouseEventArgs> OnAdornmentClick { get; set; } /// <summary> /// If true, the inner contents padding is removed. /// </summary> [Parameter] public bool InnerPadding { get; set; } = true; /// <summary> /// If true, the field will not have an underline. /// </summary> [Parameter] public bool DisableUnderLine { get; set; } } }
38.878049
129
0.564826
[ "MIT" ]
whoAmI-cslim/MudBlazor
src/MudBlazor/Components/Field/MudField.razor.cs
4,784
C#
using DataAccess.Internal; using Shared.Models; namespace DataAccess.Implementations; public interface IEmployerRepository : IGenericRepository<EmployerModel, Guid> { Task<EmployerBalanace> GetEmployerBalanceBeforeAsync(Guid employerId, DateTime beforeDate); }
26.8
95
0.835821
[ "MIT" ]
musictopia2/Work-Tracker
WorkTracker/Backend/DataAccess/Implementations/IEmployerRepository.cs
270
C#
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.Options; using Microsoft.VisualStudio.LanguageServices.Remote; namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api { internal static class UnitTestingRemoteHostOptionsAccessor { private const string LocalRegistryPath = @"Roslyn\Internal\RemoteServices\"; public static Option<bool> OOP64Bit => new Option<bool>( nameof(RemoteHostOptions), nameof(OOP64Bit), defaultValue: false, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(OOP64Bit))); } }
40.842105
105
0.761598
[ "MIT" ]
Jay-Madden/roslyn
src/VisualStudio/Core/Def/ExternalAccess/UnitTesting/Api/UnitTestingRemoteHostOptionsAccessor.cs
778
C#
using SkuVaultApiWrapper.Models.SharedModels; using System.Collections.Generic; namespace SkuVaultApiWrapper.Models.GetWarehouses { public class GetWarehousesResponse : BaseResponseModel { public List<Warehouse> Warehouses { get; set; } } }
22.545455
55
0.806452
[ "MIT" ]
ntoates/SkuVaultApiWrapper
SkuVaultApiWrapper/Models/GetWarehouses/GetWarehousesResponse.cs
250
C#
using System; using Promitor.Core.Scraping.Configuration.Serialization; using Xunit; using YamlDotNet.RepresentationModel; namespace Promitor.Scraper.Tests.Unit.Serialization.v1 { public static class YamlAssert { /// <summary> /// Deserializes the yaml using the deserializer, and asserts that the /// specified property has been set. /// </summary> /// <typeparam name="TObject">The type of object being deserialized.</typeparam> /// <typeparam name="TResult">The property type.</typeparam> /// <param name="deserializer">The deserializer.</param> /// <param name="yamlText">The yaml to deserialize.</param> /// <param name="expected">The expected result.</param> /// <param name="propertyAccessor">The property to check.</param> public static void PropertySet<TObject, TResult>( IDeserializer<TObject> deserializer, string yamlText, TResult expected, Func<TObject, TResult> propertyAccessor) { // Arrange var node = YamlUtils.CreateYamlNode(yamlText); // Act var definition = deserializer.Deserialize(node); // Assert Assert.Equal(expected, propertyAccessor(definition)); } /// <summary> /// Deserializes the yaml and asserts that the specified property has been set. /// Use this overload where the deserializer actually returns a subclass of <typeparamref name="TBaseObject"/>. /// </summary> /// <typeparam name="TObject"></typeparam> /// <typeparam name="TBaseObject"></typeparam> /// <typeparam name="TResult"></typeparam> /// <param name="deserializer"></param> /// <param name="yamlText"></param> /// <param name="expected"></param> /// <param name="propertyAccessor"></param> public static void PropertySet<TObject, TBaseObject, TResult>( IDeserializer<TBaseObject> deserializer, string yamlText, TResult expected, Func<TObject, TResult> propertyAccessor) where TObject: TBaseObject { // Arrange var node = YamlUtils.CreateYamlNode(yamlText); // Act var definition = deserializer.Deserialize(node); // Assert Assert.Equal(expected, propertyAccessor((TObject)definition)); } /// <summary> /// Deserializes the yaml using the deserializer, and asserts that the /// specified property underneath the specified yaml element has been set. /// </summary> /// <typeparam name="TObject">The type of object being deserialized.</typeparam> /// <typeparam name="TResult">The property type.</typeparam> /// <param name="deserializer">The deserializer.</param> /// <param name="yamlText">The yaml to deserialize.</param> /// <param name="yamlElement">The element to find the properties under.</param> /// <param name="expected">The expected result.</param> /// <param name="propertyAccessor">The property to check.</param> public static void PropertySet<TObject, TResult>( IDeserializer<TObject> deserializer, string yamlText, string yamlElement, TResult expected, Func<TObject, TResult> propertyAccessor) { // Arrange var node = YamlUtils.CreateYamlNode(yamlText).Children[yamlElement]; // Act var definition = deserializer.Deserialize((YamlMappingNode)node); // Assert Assert.Equal(expected, propertyAccessor(definition)); } /// <summary> /// Deserializes the yaml and verifies that the specified property is null. /// </summary> /// <typeparam name="TObject">The type of object being deserialized.</typeparam> /// <param name="deserializer">The deserializer.</param> /// <param name="yamlText">The yaml to deserialize.</param> /// <param name="propertyAccessor">The property to check.</param> public static void PropertyNull<TObject>( IDeserializer<TObject> deserializer, string yamlText, Func<TObject, object> propertyAccessor) { // Arrange var node = YamlUtils.CreateYamlNode(yamlText); // Act var definition = deserializer.Deserialize(node); // Assert Assert.Null(propertyAccessor(definition)); } /// <summary> /// Deserializes the yaml and verifies that the specified property is null. /// </summary> /// <typeparam name="TObject">The type of object being deserialized.</typeparam> /// <typeparam name="TBaseObject">The type that the deserializer returns.</typeparam> /// <param name="deserializer">The deserializer.</param> /// <param name="yamlText">The yaml to deserialize.</param> /// <param name="propertyAccessor">The property to check.</param> public static void PropertyNull<TObject, TBaseObject>( IDeserializer<TBaseObject> deserializer, string yamlText, Func<TObject, object> propertyAccessor) where TObject: TBaseObject { // Arrange var node = YamlUtils.CreateYamlNode(yamlText); // Act var definition = deserializer.Deserialize(node); // Assert Assert.Null(propertyAccessor((TObject)definition)); } /// <summary> /// Deserializes the yaml and verifies that the specified property nested /// under the specified yaml element is null. /// </summary> /// <typeparam name="TObject">The type of object being deserialized.</typeparam> /// <param name="deserializer">The deserializer.</param> /// <param name="yamlText">The yaml to deserialize.</param> /// <param name="propertyAccessor">The property to check.</param> /// <param name="yamlElement">The element to look for the property under.</param> public static void PropertyNull<TObject>( IDeserializer<TObject> deserializer, string yamlText, string yamlElement, Func<TObject, object> propertyAccessor) { // Arrange var node = YamlUtils.CreateYamlNode(yamlText).Children[yamlElement]; // Act var definition = deserializer.Deserialize((YamlMappingNode)node); // Assert Assert.Null(propertyAccessor(definition)); } } }
44.482993
144
0.623949
[ "MIT" ]
burningalchemist/promitor
src/Promitor.Scraper.Tests.Unit/Serialization/v1/YamlAssert.cs
6,541
C#
using Extensions.Triggers; using Microsoft.Azure.WebJobs; using Microsoft.Azure.WebJobs.Description; using Microsoft.Azure.WebJobs.Host.Bindings; using Microsoft.Azure.WebJobs.Host.Config; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using Twitter.Services; namespace Extensions.Bindings { [Extension("Twitter")] public class TwitterBindingConfigProvider : IExtensionConfigProvider { private readonly INameResolver _nameResolver; private readonly ILoggerFactory _loggerFactory; private readonly ITwitterService _twitterService; public TwitterBindingConfigProvider(INameResolver nameResolver, ILoggerFactory loggerFactory, ITwitterService twitterService) { this._nameResolver = nameResolver; this._loggerFactory = loggerFactory; this._twitterService = twitterService; } public void Initialize(ExtensionConfigContext context) { var bindingRule = context.AddBindingRule<TwitterBindingAttribute>(); bindingRule.AddValidator(ValidateTwitterConfig); bindingRule.BindToCollector<OpenType>(typeof(TwitterBindingCollectorConverter), _nameResolver, _twitterService); bindingRule.BindToInput<TwitterBinder>(typeof(TwitterBindingConverter), _nameResolver, _twitterService); } private void ValidateTwitterConfig(TwitterBindingAttribute attribute, Type paramType) { if (string.IsNullOrEmpty(attribute.AccessToken)) throw new InvalidOperationException($"Twitter AccessToken must be set either via the attribute property or via configuration."); if (string.IsNullOrEmpty(attribute.AccessTokenSecret)) throw new InvalidOperationException($"Twitter AccessTokenSecret must be set either via the attribute property or via configuration."); if (string.IsNullOrEmpty(attribute.ConsumerKey)) throw new InvalidOperationException($"Twitter ConsumerKey must be set either via the attribute property or via configuration."); if (string.IsNullOrEmpty(attribute.ConsumerSecret)) throw new InvalidOperationException($"Twitter ConsumerSecret must be set either via the attribute property or via configuration."); } } }
43.578947
150
0.73752
[ "MIT" ]
PacktPublishing/Mastering-Azure-Serverless-Computing
Chapter02/Extensions/Bindings/TwitterBindingConfigProvider.cs
2,486
C#
////////////////////////////////////////////////////////////////////// // // // jcspDemos Demonstrations of the JCSP ("CSP for Java") Library // // Copyright (C) 1996-2018 Peter Welch, Paul Austin and Neil Brown // // 2001-2004 Quickstone Technologies Limited // // 2005-2018 Kevin Chalmers // // // // You may use this work under the terms of either // // 1. The Apache License, Version 2.0 // // 2. or (at your option), the GNU Lesser General Public License, // // version 2.1 or greater. // // // // Full licence texts are included in the LICENCE file with // // this library. // // // // Author contacts: P.H.Welch@kent.ac.uk K.Chalmers@napier.ac.uk // // // ////////////////////////////////////////////////////////////////////// using System; using CSPlang; using PlugAndPlay; namespace Alternative_Example { public class AltingBarrierGadget0Demo0 { public static void main(String[] argv) { int nUnits = 8; nUnits = (int)Console.Read(); //Ask.Int("\nnUnits = ", 3, 10); // make the buttons One2OneChannel[] _event = Channel.one2oneArray(nUnits); One2OneChannel[] configure = Channel.one2oneArray(nUnits); Boolean horizontal = true; FramedButtonArray buttons = new FramedButtonArray( "AltingBarrier: Gadget 0, Demo 0", nUnits, 120, nUnits * 100, horizontal, Channel.getInputArray(configure), Channel.getOutputArray(_event) ); // construct an array of front-ends to a single alting barrier AltingBarrier[] group = AltingBarrier.create(nUnits); // make the gadgets AltingBarrierGadget0[] gadgets = new AltingBarrierGadget0[nUnits]; for (int i = 0; i < gadgets.Length; i++) { gadgets[i] = new AltingBarrierGadget0(_event[i].In(), group[i], configure[i].Out()); } // run everything new CSPParallel( new IamCSProcess[] { buttons, new CSPParallel(gadgets) } ).run(); } } }
41.830769
100
0.429937
[ "MIT" ]
PasierbKarol/CSPdocs-Examples
Alternative Example/AltingBarrierGadget0Demo0.cs
2,719
C#
/* * Copyright 2015 Google Inc * * Licensed under the Apache License, Version 2.0(the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Text; using Google.Apis.Dfareporting.v3_4; using Google.Apis.Dfareporting.v3_4.Data; using Google.Apis.Download; namespace DfaReporting.Samples { /// <summary> /// This example illustrates how to download a file. /// </summary> class DownloadFile : SampleBase { /// <summary> /// Returns a description about the code example. /// </summary> public override string Description { get { return "This example illustrates how to download a file.\n"; } } /// <summary> /// Main method, to run this code example as a standalone application. /// </summary> /// <param name="args">The command line arguments.</param> public static void Main(string[] args) { SampleBase codeExample = new DownloadFile(); Console.WriteLine(codeExample.Description); codeExample.Run(DfaReportingFactory.getInstance()); } /// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long fileId = long.Parse(_T("INSERT_FILE_ID_HERE")); long reportId = long.Parse(_T("ENTER_REPORT_ID_HERE")); // Retrive the file metadata. File file = service.Files.Get(reportId, fileId).Execute(); if ("REPORT_AVAILABLE".Equals(file.Status)) { // Create a get request. FilesResource.GetRequest getRequest = service.Files.Get(reportId, fileId); // Optional: adjust the chunk size used when downloading the file. // getRequest.MediaDownloader.ChunkSize = MediaDownloader.MaximumChunkSize; // Execute the get request and download the file. using (System.IO.FileStream outFile = new System.IO.FileStream(GenerateFileName(file), System.IO.FileMode.Create, System.IO.FileAccess.Write)) { getRequest.Download(outFile); Console.WriteLine("File {0} downloaded to {1}", file.Id, outFile.Name); } } } private string GenerateFileName(File file) { // If no filename is specified, use the file ID instead. string fileName = file.FileName; if (String.IsNullOrEmpty(fileName)) { fileName = file.Id.ToString(); } String extension = "CSV".Equals(file.Format) ? ".csv" : ".xml"; return fileName + extension; } } }
34.170455
94
0.670768
[ "Apache-2.0" ]
googleads/googleads-dfa-reporting-samples
dotnet/v3.4/Reports/DownloadFile.cs
3,009
C#
using ShopApp.Models; using System.Collections.Generic; namespace ShopApp.Dal.Services.User.Contracts { public interface IUserService { ShopUser GetUserByName(string username); ShopUser GetUserById(string id); IEnumerable<ShopUser> GetAll(); } }
20.357143
48
0.705263
[ "MIT" ]
GMihalkow/Csharp-ASP-Web-Apps
ShopApp2.0/ShopApp.Dal/Services/User/Contracts/IUserService.cs
287
C#
namespace PathApi.Server.GrpcApi.V1 { using Google.Protobuf.WellKnownTypes; using Google.Type; using Grpc.Core; using PathApi.Server.PathServices; using PathApi.Server.PathServices.Models; using PathApi.V1; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using TrainStatus = PathApi.V1.GetUpcomingTrainsResponse.Types.UpcomingTrain.Types.Status; /// <summary> /// gRPC service implementation for the Routes service. /// </summary> internal sealed class RoutesApi : Routes.RoutesBase, IGrpcApi { private const int DEFAULT_PAGE_SIZE = 250; private readonly IPathDataRepository pathDataRepository; /// <summary> /// Constructs a new instance of the <see cref="RoutesApi"/>. /// </summary> /// <param name="pathDataRepository">The repository to use when looking up static path data.</param> public RoutesApi(IPathDataRepository pathDataRepository) { this.pathDataRepository = pathDataRepository; } /// <summary> /// Binds the Routes service to this implementation. /// </summary> /// <returns>The <see cref="ServerServiceDefinition"/> for this service that can be registered with a server.</returns> public ServerServiceDefinition BindService() { return Routes.BindService(this); } /// <summary> /// Handles the ListRoutes request. /// </summary> public override async Task<ListRoutesResponse> ListRoutes(ListRoutesRequest request, ServerCallContext context) { int offset = PaginationHelper.GetOffset(request.PageToken); int pageSize = request.PageSize == 0 ? DEFAULT_PAGE_SIZE : request.PageSize; ListRoutesResponse response = new ListRoutesResponse(); var routes = await this.GetAllRoutes(); response.Routes.Add(routes.Skip(offset).Take(pageSize)); if (routes.Count > offset + pageSize) { response.NextPageToken = PaginationHelper.GetPageToken(offset + pageSize); } return response; } /// <summary> /// Handles the GetRoute request. /// </summary> public override async Task<RouteData> GetRoute(GetRouteRequest request, ServerCallContext context) { if (request.Route == Route.Unspecified) { throw new RpcException(new Status(StatusCode.NotFound, "Invalid route supplied.")); } try { return (await GetAllRoutes()).Where(route => route.Route == request.Route).First(); } catch (InvalidOperationException) { throw new RpcException(new Status(StatusCode.NotFound, "Requested route not found.")); } } private async Task<List<RouteData>> GetAllRoutes() { List<RouteData> routes = new List<RouteData>(); var routeData = await this.pathDataRepository.GetRoutes(); routes = routeData.GroupBy(routeDataEntry => routeDataEntry.Route) .Select(route => this.ToRouteData(route)).ToList(); return routes; } private RouteData ToRouteData(IEnumerable<RouteLine> lines) { var firstLine = lines.First(); if (!lines.All(line => line.Route == firstLine.Route)) { throw new ArgumentException("All lines must be for the same route."); } RouteData routeData = new RouteData() { Route = firstLine.Route, Id = firstLine.Id, Name = firstLine.LongName, Color = firstLine.Color }; routeData.Lines.Add(lines.Select(line => new RouteData.Types.RouteLine() { DisplayName = line.DisplayName, Headsign = line.Headsign, Direction = RouteMappings.RouteDirectionToDirection[line.Direction] })); return routeData; } } }
37.265487
127
0.593683
[ "MIT" ]
kerrickstaley/path-data
server/GrpcApi/V1/RoutesApi.cs
4,211
C#
// Copyright (c) Huy Hoang. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using System; using System.IO.Abstractions.TestingHelpers; using Dash.Application; using Dash.Extensions; using FluentAssertions; using Xunit; namespace Dash.Tests.Extensions { public class FileSystemTests { [Fact] public void GetAbsoluteWorkingDirectory_NoProjectSpecified_ShouldReturnAbsolutePathOfProject() { // Arrange var sut = new MockFileSystem(null, "c:/temp/foo/bar"); var dashOptions = new DashOptions { Project = null }; // Act var result = sut.GetAbsoluteWorkingDirectory(dashOptions); // Assert result.Should().Be("c:/temp/foo/bar"); } [Fact] public void GetAbsoluteWorkingDirectory_AbsoluteProjectSpecified_ShouldReturnAbsolutePathOfProject() { // Arrange var sut = new MockFileSystem(); var dashOptions = new DashOptions { Project = "c:/temp/foobar/foo.csproj" }; // Act var result = sut.GetAbsoluteWorkingDirectory(dashOptions); // Assert result.Should().Be(@"c:\temp\foobar"); } [Fact] public void GetAbsoluteWorkingDirectory_RelativeProjectSpecified_ShouldReturnAbsolutePathOfProject() { // Arrange var sut = new MockFileSystem(null, "c:/temp/foo/bar"); var dashOptions = new DashOptions { Project = "foo.csproj" }; // Act var result = sut.GetAbsoluteWorkingDirectory(dashOptions); // Assert result.Should().Be(@"c:/temp/foo/bar"); } [Theory] [InlineData("./foo", null, @"c:\temp\foo")] [InlineData("./foo", "c:/temp/foo/bar.csproj", @"c:\temp\foo\foo")] [InlineData("../foo", null, @"c:\foo")] [InlineData("../foo", "c:/temp/foo/bar.csproj", @"c:\temp\foo")] public void AbsolutePath_RelativeUri_ShouldReturnAbsolutePath(string relativePath, string? project, string expectedAbsolutePath) { // Arrange var sut = new MockFileSystem(null, "c:/temp"); var uri = new Uri(relativePath, UriKind.Relative); // Act var result = sut.AbsolutePath(uri, new DashOptions { Project = project }); // Assert result.Should().Be(expectedAbsolutePath); } [Fact] public void AbsolutePath_AbsoluteUri_ShouldReturnAbsolutePath() { // Arrange var sut = new MockFileSystem(); var uri = new Uri("file:///c:/foo/bar"); // Act var result = sut.AbsolutePath(uri, new DashOptions { Project = null }); // Assert result.Should().Be(@"c:\foo\bar"); } } }
29.461538
136
0.561031
[ "Apache-2.0" ]
dotnet-dash/dash
src/Dash/test/Dash.Tests/Extensions/FileSystemTests.cs
3,066
C#
// *** WARNING: this file was generated by the Pulumi SDK Generator. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Threading.Tasks; using Pulumi.Serialization; namespace Pulumi.AzureNative.Synapse.V20201201.Inputs { /// <summary> /// Details of the encryption associated with the workspace /// </summary> public sealed class EncryptionDetailsArgs : Pulumi.ResourceArgs { /// <summary> /// Customer Managed Key Details /// </summary> [Input("cmk")] public Input<Inputs.CustomerManagedKeyDetailsArgs>? Cmk { get; set; } public EncryptionDetailsArgs() { } } }
27.103448
81
0.661578
[ "Apache-2.0" ]
polivbr/pulumi-azure-native
sdk/dotnet/Synapse/V20201201/Inputs/EncryptionDetailsArgs.cs
786
C#
using J2N.Threading; using Lucene.Net.Documents; using Lucene.Net.Index.Extensions; using NUnit.Framework; using System; using System.Threading; using Assert = Lucene.Net.TestFramework.Assert; using Console = Lucene.Net.Util.SystemConsole; namespace Lucene.Net.Index { /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using Analyzer = Lucene.Net.Analysis.Analyzer; using Directory = Lucene.Net.Store.Directory; using Document = Documents.Document; using English = Lucene.Net.Util.English; using FieldType = FieldType; using LuceneTestCase = Lucene.Net.Util.LuceneTestCase; using MockAnalyzer = Lucene.Net.Analysis.MockAnalyzer; using MockTokenizer = Lucene.Net.Analysis.MockTokenizer; using StringField = StringField; [TestFixture] public class TestThreadedForceMerge : LuceneTestCase { private static Analyzer ANALYZER; private const int NUM_THREADS = 3; //private final static int NUM_THREADS = 5; private const int NUM_ITER = 1; private const int NUM_ITER2 = 1; private volatile bool failed; [SetUp] public static void Setup() { ANALYZER = new MockAnalyzer(Random, MockTokenizer.SIMPLE, true); } private void SetFailed() { failed = true; } public virtual void RunTest(Random random, Directory directory) { IndexWriter writer = new IndexWriter(directory, ((IndexWriterConfig)NewIndexWriterConfig(TEST_VERSION_CURRENT, ANALYZER).SetOpenMode(OpenMode.CREATE).SetMaxBufferedDocs(2)).SetMergePolicy(NewLogMergePolicy())); for (int iter = 0; iter < NUM_ITER; iter++) { int iterFinal = iter; ((LogMergePolicy)writer.Config.MergePolicy).MergeFactor = 1000; FieldType customType = new FieldType(StringField.TYPE_STORED); customType.OmitNorms = true; for (int i = 0; i < 200; i++) { Document d = new Document(); d.Add(NewField("id", Convert.ToString(i), customType)); d.Add(NewField("contents", English.Int32ToEnglish(i), customType)); writer.AddDocument(d); } ((LogMergePolicy)writer.Config.MergePolicy).MergeFactor = 4; ThreadJob[] threads = new ThreadJob[NUM_THREADS]; for (int i = 0; i < NUM_THREADS; i++) { int iFinal = i; IndexWriter writerFinal = writer; threads[i] = new ThreadAnonymousClass(this, iterFinal, customType, iFinal, writerFinal); } for (int i = 0; i < NUM_THREADS; i++) { threads[i].Start(); } for (int i = 0; i < NUM_THREADS; i++) { threads[i].Join(); } Assert.IsTrue(!failed); int expectedDocCount = (int)((1 + iter) * (200 + 8 * NUM_ITER2 * (NUM_THREADS / 2.0) * (1 + NUM_THREADS))); Assert.AreEqual(expectedDocCount, writer.NumDocs, "index=" + writer.SegString() + " numDocs=" + writer.NumDocs + " maxDoc=" + writer.MaxDoc + " config=" + writer.Config); Assert.AreEqual(expectedDocCount, writer.MaxDoc, "index=" + writer.SegString() + " numDocs=" + writer.NumDocs + " maxDoc=" + writer.MaxDoc + " config=" + writer.Config); writer.Dispose(); writer = new IndexWriter(directory, (IndexWriterConfig)NewIndexWriterConfig(TEST_VERSION_CURRENT, ANALYZER).SetOpenMode(OpenMode.APPEND).SetMaxBufferedDocs(2)); DirectoryReader reader = DirectoryReader.Open(directory); Assert.AreEqual(1, reader.Leaves.Count, "reader=" + reader); Assert.AreEqual(expectedDocCount, reader.NumDocs); reader.Dispose(); } writer.Dispose(); } private class ThreadAnonymousClass : ThreadJob { private readonly TestThreadedForceMerge outerInstance; private readonly int iterFinal; private readonly FieldType customType; private readonly int iFinal; private readonly IndexWriter writerFinal; public ThreadAnonymousClass(TestThreadedForceMerge outerInstance, int iterFinal, FieldType customType, int iFinal, IndexWriter writerFinal) { this.outerInstance = outerInstance; this.iterFinal = iterFinal; this.customType = customType; this.iFinal = iFinal; this.writerFinal = writerFinal; } public override void Run() { try { for (int j = 0; j < NUM_ITER2; j++) { writerFinal.ForceMerge(1, false); for (int k = 0; k < 17 * (1 + iFinal); k++) { Document d = new Document(); d.Add(NewField("id", iterFinal + "_" + iFinal + "_" + j + "_" + k, customType)); d.Add(NewField("contents", English.Int32ToEnglish(iFinal + k), customType)); writerFinal.AddDocument(d); } for (int k = 0; k < 9 * (1 + iFinal); k++) { writerFinal.DeleteDocuments(new Term("id", iterFinal + "_" + iFinal + "_" + j + "_" + k)); } writerFinal.ForceMerge(1); } } catch (Exception t) when (t.IsThrowable()) { outerInstance.SetFailed(); Console.WriteLine(Thread.CurrentThread.Name + ": hit exception"); Console.WriteLine(t.StackTrace); } } } /* Run above stress test against RAMDirectory and then FSDirectory. */ [Test] public virtual void TestThreadedForceMerge_Mem() { Directory directory = NewDirectory(); RunTest(Random, directory); directory.Dispose(); } } }
39.102703
222
0.557368
[ "Apache-2.0" ]
10088/lucenenet
src/Lucene.Net.Tests/Index/TestThreadedForceMerge.cs
7,236
C#
using Foundation; using MvvmCross.Core.ViewModels; using MvvmCross.iOS.Platform; using MvvmCross.Platform; using UIKit; namespace BLE.Client.iOS { [Register("AppDelegate")] public partial class AppDelegate : MvxApplicationDelegate { UIWindow _window; public override bool FinishedLaunching(UIApplication app, NSDictionary options) { System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; _window = new UIWindow(UIScreen.MainScreen.Bounds); var setup = new Setup(this, _window); setup.Initialize(); var startup = Mvx.Resolve<IMvxAppStart>(); startup.Start(); _window.MakeKeyAndVisible(); return true; } } }
24.96875
107
0.649562
[ "MIT" ]
trevorcmit/RFID_BT_app
CS108 Demo/BLE.Client.iOS/AppDelegate.cs
801
C#
using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Reflection; using LExpression = System.Linq.Expressions.Expression; namespace Pidgin { public static partial class Parser<TToken> { /// <summary> /// Creates a parser that parses and returns a literal sequence of tokens /// </summary> /// <param name="tokens">A sequence of tokens</param> /// <returns>A parser that parses a literal sequence of tokens</returns> public static Parser<TToken, TToken[]> Sequence(params TToken[] tokens) { if (tokens == null) { throw new ArgumentNullException(nameof(tokens)); } return Sequence<TToken[]>(tokens); } /// <summary> /// Creates a parser that parses and returns a literal sequence of tokens. /// The input enumerable is enumerated and copied to a list. /// </summary> /// <typeparam name="TEnumerable">The type of tokens to parse</typeparam> /// <param name="tokens">A sequence of tokens</param> /// <returns>A parser that parses a literal sequence of tokens</returns> public static Parser<TToken, TEnumerable> Sequence<TEnumerable>(TEnumerable tokens) where TEnumerable : IEnumerable<TToken> { if (tokens == null) { throw new ArgumentNullException(nameof(tokens)); } return SequenceTokenParser<TToken, TEnumerable>.Create(tokens); } /// <summary> /// Creates a parser that applies a sequence of parsers and collects the results. /// This parser fails if any of its constituent parsers fail /// </summary> /// <typeparam name="T">The return type of the parsers</typeparam> /// <param name="parsers">A sequence of parsers</param> /// <returns>A parser that applies a sequence of parsers and collects the results</returns> public static Parser<TToken, IEnumerable<T>> Sequence<T>(params Parser<TToken, T>[] parsers) { return Sequence(parsers.AsEnumerable()); } /// <summary> /// Creates a parser that applies a sequence of parsers and collects the results. /// This parser fails if any of its constituent parsers fail /// </summary> /// <typeparam name="T">The return type of the parsers</typeparam> /// <param name="parsers">A sequence of parsers</param> /// <returns>A parser that applies a sequence of parsers and collects the results</returns> public static Parser<TToken, IEnumerable<T>> Sequence<T>(IEnumerable<Parser<TToken, T>> parsers) { if (parsers == null) { throw new ArgumentNullException(nameof(parsers)); } var parsersArray = parsers.ToArray(); if (parsersArray.Length == 1) { return parsersArray[0].Select(x => new[] { x }.AsEnumerable()); } return new SequenceParser<TToken, T>(parsersArray); } } internal sealed class SequenceParser<TToken, T> : Parser<TToken, IEnumerable<T>> { private readonly Parser<TToken, T>[] _parsers; public SequenceParser(Parser<TToken, T>[] parsers) { _parsers = parsers; } internal sealed override bool TryParse(ref ParseState<TToken> state, ref ExpectedCollector<TToken> expecteds, out IEnumerable<T> result) { var ts = new T[_parsers.Length]; for (var i = 0; i < _parsers.Length; i++) { var p = _parsers[i]; var success = p.TryParse(ref state, ref expecteds, out ts[i]); if (!success) { result = null; return false; } } result = ts; return true; } } internal static class SequenceTokenParser<TToken, TEnumerable> where TEnumerable : IEnumerable<TToken> { private static readonly Func<TEnumerable, Parser<TToken, TEnumerable>>? _createParser; public static Parser<TToken, TEnumerable> Create(TEnumerable tokens) { if (_createParser != null) { return _createParser(tokens); } return new SequenceTokenParserSlow<TToken, TEnumerable>(tokens); } static SequenceTokenParser() { var ttoken = typeof(TToken).GetTypeInfo(); var equatable = typeof(IEquatable<TToken>).GetTypeInfo(); if (ttoken.IsValueType && equatable.IsAssignableFrom(ttoken)) { var ctor = typeof(SequenceTokenParserFast<,>) .MakeGenericType(typeof(TToken), typeof(TEnumerable)) .GetTypeInfo() .DeclaredConstructors .Single(); var param = LExpression.Parameter(typeof(TEnumerable)); var create = LExpression.New(ctor, param); _createParser = LExpression.Lambda<Func<TEnumerable, Parser<TToken, TEnumerable>>>(create, param).Compile(); } } } internal sealed class SequenceTokenParserFast<TToken, TEnumerable> : Parser<TToken, TEnumerable> where TToken : struct, IEquatable<TToken> where TEnumerable : IEnumerable<TToken> { private readonly TEnumerable _value; private readonly ImmutableArray<TToken> _valueTokens; public SequenceTokenParserFast(TEnumerable value) { _value = value; _valueTokens = value.ToImmutableArray(); } internal sealed override bool TryParse(ref ParseState<TToken> state, ref ExpectedCollector<TToken> expecteds, out TEnumerable result) { var span = state.LookAhead(_valueTokens.Length); // span.Length <= _valueTokens.Length var errorPos = -1; for (var i = 0; i < span.Length; i++) { if (!span[i].Equals(_valueTokens[i])) { errorPos = i; break; } } if (errorPos != -1) { // strings didn't match state.Advance(errorPos); state.Error = new InternalError<TToken>( Maybe.Just(span[errorPos]), false, state.Location, null ); expecteds.Add(new Expected<TToken>(_valueTokens)); result = default; return false; } if (span.Length < _valueTokens.Length) { // strings matched but reached EOF state.Advance(span.Length); state.Error = new InternalError<TToken>( Maybe.Nothing<TToken>(), true, state.Location, null ); expecteds.Add(new Expected<TToken>(_valueTokens)); result = default; return false; } // OK state.Advance(_valueTokens.Length); result = _value; return true; } } internal sealed class SequenceTokenParserSlow<TToken, TEnumerable> : Parser<TToken, TEnumerable> where TEnumerable : IEnumerable<TToken> { private readonly TEnumerable _value; private readonly ImmutableArray<TToken> _valueTokens; public SequenceTokenParserSlow(TEnumerable value) { _value = value; _valueTokens = value.ToImmutableArray(); } internal sealed override bool TryParse(ref ParseState<TToken> state, ref ExpectedCollector<TToken> expecteds, out TEnumerable result) { var span = state.LookAhead(_valueTokens.Length); // span.Length <= _valueTokens.Length var errorPos = -1; for (var i = 0; i < span.Length; i++) { if (!EqualityComparer<TToken>.Default.Equals(span[i], _valueTokens[i])) { errorPos = i; break; } } if (errorPos != -1) { // strings didn't match state.Advance(errorPos); state.Error = new InternalError<TToken>( Maybe.Just(span[errorPos]), false, state.Location, null ); expecteds.Add(new Expected<TToken>(_valueTokens)); result = default; return false; } if (span.Length < _valueTokens.Length) { // strings matched but reached EOF state.Advance(span.Length); state.Error = new InternalError<TToken>( Maybe.Nothing<TToken>(), true, state.Location, null ); expecteds.Add(new Expected<TToken>(_valueTokens)); result = default; return false; } // OK state.Advance(_valueTokens.Length); result = _value; return true; } } }
36.301887
144
0.533472
[ "MIT" ]
LukeWoodward/Pidgin
Pidgin/Parser.Sequence.cs
9,620
C#
// Copyright (c) Petabridge <https://petabridge.com/>. All rights reserved. // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. using System.Linq; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes.Jobs; using NBench.Sdk; using NBench.Util; using static NBench.Sdk.Compiler.ReflectionDiscovery; namespace NBench.Microbenchmarks.SDK { [LegacyJitX64Job] [LegacyJitX86Job] [RyuJitX64Job] public class Sdk_ReflectionBenchmarkInvokerWithRealWork { public class AtomicCounterBenchmark { private readonly AtomicCounter _counter = new AtomicCounter(); [PerfSetup] public void Setup(BenchmarkContext context) { } [PerfBenchmark] [MemoryMeasurement(MemoryMetric.TotalBytesAllocated)] public void Run(BenchmarkContext context) { _counter.Increment(); } [PerfCleanup] public void Cleanup(BenchmarkContext context) { } } private readonly IBenchmarkInvoker _contextInvoker; public Sdk_ReflectionBenchmarkInvokerWithRealWork() { var benchmarkType = typeof(AtomicCounterBenchmark); var benchmarks = CreateBenchmarksForClass(benchmarkType); _contextInvoker = CreateInvokerForBenchmark(benchmarks.Single()); _contextInvoker.InvokePerfSetup(BenchmarkContext.Empty); } [Benchmark(Description = "How quickly can we invoke when injecting context into a ReflectionBenchmarkInvoker")] public void InvokeRunWithContext() { _contextInvoker.InvokeRun(BenchmarkContext.Empty); } } }
30.423729
119
0.65961
[ "Apache-2.0" ]
NicolaAtorino/NBench
benchmarks/NBench.Microbenchmarks/SDK/Sdk_ReflectionBenchmarkInvokerWithRealWork.cs
1,797
C#
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace Crikkit__Minecraft_Server_CP_ { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Launcher()); } } }
23.086957
65
0.627119
[ "Apache-2.0" ]
WiseHollow/Crikkit-Minecraft-Server-CP-
Crikkit (Minecraft Server CP)/Program.cs
533
C#
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System.Linq; using System.Management.Automation; namespace Microsoft.PowerShell.Commands { /// <summary> /// A cmdlet that gets the TraceSource instances that are instantiated in the process. /// </summary> [Cmdlet(VerbsCommon.Get, "TraceSource", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=2096707")] [OutputType(typeof(PSTraceSource))] public class GetTraceSourceCommand : TraceCommandBase { #region Parameters /// <summary> /// Gets or sets the category parameter which determines which trace switch to get. /// </summary> /// <value></value> [Parameter(Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] [ValidateNotNullOrEmpty()] public string[] Name { get { return _names; } set { if (value == null || value.Length == 0) { value = new string[] { "*" }; } _names = value; } } private string[] _names = new string[] { "*" }; #endregion Parameters #region Cmdlet code /// <summary> /// Gets the PSTraceSource for the specified category. /// </summary> protected override void ProcessRecord() { var sources = GetMatchingTraceSource(_names, true); var result = sources.OrderBy(static source => source.Name); WriteObject(result, true); } #endregion Cmdlet code } }
27.754098
105
0.554637
[ "MIT" ]
10088/PowerShell
src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/GetTracerCommand.cs
1,693
C#