Here are the examples of the csharp api System.Enum.GetNames(System.Type) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1027 Examples
19
View Source File : XnaToFnaHelper.cs
License : zlib License
Project Creator : 0x0ade
License : zlib License
Project Creator : 0x0ade
public static void Initialize(XnaToFnaGame game) {
Game = game;
TextInputEXT.TextInput += KeyboardEvents.CharEntered;
game.Window.ClientSizeChanged += SDLWindowSizeChanged;
string maximumGamepadCountStr = Environment.GetEnvironmentVariable(
"FNA_GAMEPAD_NUM_GAMEPADS"
);
if (string.IsNullOrEmpty(maximumGamepadCountStr) ||
!int.TryParse(maximumGamepadCountStr, out MaximumGamepadCount) ||
MaximumGamepadCount < 0) {
MaximumGamepadCount = Enum.GetNames(typeof(PlayerIndex)).Length;
}
DeviceEvents.IsGamepadConnected = new bool[MaximumGamepadCount];
PlatformHook("ApplyWindowChanges");
}
19
View Source File : DotNetToJScript.cs
License : MIT License
Project Creator : 1y0n
License : MIT License
Project Creator : 1y0n
static string GetEnumString(Type enum_type)
{
return String.Join(", ", Enum.GetNames(enum_type));
}
19
View Source File : GraphyManager.cs
License : MIT License
Project Creator : 1ZouLTReX1
License : MIT License
Project Creator : 1ZouLTReX1
public void ToggleModes()
{
int len = Enum.GetNames(typeof(ModulePreset)).Length;
m_modulePresetState = (ModulePreset) (((int)m_modulePresetState + 1) % len);
SetPreset(m_modulePresetState);
}
19
View Source File : DOTweenAnimationInspector.cs
License : MIT License
Project Creator : 39M
License : MIT License
Project Creator : 39M
DOTweenAnimationType AnimationToDOTweenAnimationType(string animation)
{
if (_datString == null) _datString = Enum.GetNames(typeof(DOTweenAnimationType));
animation = animation.Replace("/", "");
return (DOTweenAnimationType)(Array.IndexOf(_datString, animation));
}
19
View Source File : JsonExtension.cs
License : MIT License
Project Creator : 4egod
License : MIT License
Project Creator : 4egod
public static T ToEnum<T>(this string str)
{
var enumType = typeof(T);
foreach (var name in Enum.GetNames(enumType))
{
var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single();
if (enumMemberAttribute.Value == str) return (T)Enum.Parse(enumType, name);
}
//throw exception or whatever handling you want or
return default(T);
}
19
View Source File : Add.cshtml.cs
License : GNU Lesser General Public License v3.0
Project Creator : 8720826
License : GNU Lesser General Public License v3.0
Project Creator : 8720826
public void OnGet()
{
Conditions = Enum.GetNames(typeof(QuestTriggerConditionEnum));
}
19
View Source File : Add.cshtml.cs
License : GNU Lesser General Public License v3.0
Project Creator : 8720826
License : GNU Lesser General Public License v3.0
Project Creator : 8720826
public async Task<IActionResult> OnPostAsync()
{
ErrorMessage = "";
if (!ModelState.IsValid)
{
Conditions = Enum.GetNames(typeof(QuestTriggerConditionEnum));
return Page();
}
var result = await _questAppService.Add( Quest);
if (!result.IsSuccess)
{
ErrorMessage = result.Message;
return Page();
}
else
{
return RedirectToPage("/Quest/Index");
}
/*
try
{
var task = _mapper.Map<QuestEnreplacedy>(Quest);
await _db.Quests.AddAsync(task);
await _db.SaveChangesAsync();
await AddSuccess(new OperatorLog
{
Type = OperatorLogType.添加任务,
Content = JsonConvert.SerializeObject(Quest)
});
}
catch (Exception ex)
{
ErrorMessage = ex.Message;
await AddError(new OperatorLog
{
Type = OperatorLogType.添加任务,
Content = $"Data={JsonConvert.SerializeObject(Quest)},ErrorMessage={ErrorMessage}"
});
return Page();
}
return Redirect(UrlReferer);
*/
}
19
View Source File : MicroVM.Assembler.cs
License : MIT License
Project Creator : a-downing
License : MIT License
Project Creator : a-downing
static bool TryStringToOpcode(string str, out CPU.Opcode opcode) {
var names = Enum.GetNames(typeof(CPU.Opcode));
var values = Enum.GetValues(typeof(CPU.Opcode));
str = str.ToUpperInvariant();
for(int i = 0; i < names.Length; i++) {
if(names[i] == str) {
opcode = (CPU.Opcode)values.GetValue(i);
return true;
}
}
opcode = 0;
return false;
}
19
View Source File : MicroVM.Assembler.cs
License : MIT License
Project Creator : a-downing
License : MIT License
Project Creator : a-downing
static bool TryStringToCond(string str, out CPU.Cond cond) {
var names = Enum.GetNames(typeof(CPU.Cond));
var values = Enum.GetValues(typeof(CPU.Cond));
str = str.ToUpperInvariant();
for(int i = 0; i < names.Length; i++) {
if(names[i] == str) {
cond = (CPU.Cond)values.GetValue(i);
return true;
}
}
cond = 0;
return false;
}
19
View Source File : MicroVM.Assembler.cs
License : MIT License
Project Creator : a-downing
License : MIT License
Project Creator : a-downing
void AllocateRegisters() {
var names = Enum.GetNames(typeof(CPU.Register));
for(int i = 0; i < names.Length; i++) {
var name = names[i].ToLowerInvariant();
symbols.Add(name, new Symbol {
name = name,
var = new Variable{ val32 = new CPU.Value32{ Int = i } },
type = Symbol.Type.REGISTER
});
}
}
19
View Source File : Stereo3DGUI.cs
License : Apache License 2.0
Project Creator : A7ocin
License : Apache License 2.0
Project Creator : A7ocin
void Start () {
b = new bool[System.Enum.GetNames(typeof(StereoState)).Length];
}
19
View Source File : Stereo3DGUI.cs
License : Apache License 2.0
Project Creator : A7ocin
License : Apache License 2.0
Project Creator : A7ocin
void DrawGUI () {
// Rig
int hOffset = 50;
// Convergence
GUI.Label(new Rect(Screen.width / 2, Screen.height - hOffset - 40, 90, 20),"Convergence");
_s3d.Convergence =
GUI.HorizontalSlider(
new Rect(Screen.width / 2 + 90,Screen.height - hOffset - 35,80,20),
_s3d.Convergence,
_s3d.MinConvergence,
_s3d.MaxConvergence);
// Interaxial
GUI.Label(new Rect(Screen.width / 2, Screen.height - hOffset - 20, 90, 20),"Interaxial");
_s3d.Interaxial =
GUI.HorizontalSlider(
new Rect(Screen.width / 2 + 90,Screen.height - hOffset - 15,80,20),
_s3d.Interaxial,
_s3d.MinInteraxial,
_s3d.MaxInteraxial);
// 3D Mode
for(int i = 0; i < b.Length; i++) {
bool tmp = b[i];
if (b[i]) {
GUI.Toggle(
new Rect(Screen.width / 2 + 220, Screen.height - hOffset - 60 + (20*i),100,20),
b[i],
System.Enum.GetNames(typeof(StereoState))[i]);
} else {
b[i] =
GUI.Toggle(
new Rect(Screen.width / 2 + 220, Screen.height - hOffset - 60 + (20*i),100,20),
b[i],
System.Enum.GetNames(typeof(StereoState))[i]);
}
if (b[i] && !tmp) {
b = new bool[System.Enum.GetNames(typeof(StereoState)).Length];
b[i] = true;
_s3d.SetMode((StereoState)i);
}
}
}
19
View Source File : MixedRealityGesturesProfileInspector.cs
License : Apache License 2.0
Project Creator : abist-co-ltd
License : Apache License 2.0
Project Creator : abist-co-ltd
private void UpdateGestureLabels()
{
var allGestureTypeNames = Enum.GetNames(typeof(GestureInputType));
var tempIds = new List<int>();
var tempContent = new List<GUIContent>();
for (int i = 0; i < allGestureTypeNames.Length; i++)
{
if (allGestureTypeNames[i].Equals("None") ||
thisProfile.Gestures.All(mapping => !allGestureTypeNames[i].Equals(mapping.GestureType.ToString())))
{
tempContent.Add(new GUIContent(allGestureTypeNames[i]));
tempIds.Add(i);
}
}
allGestureIds = tempIds.ToArray();
allGestureLabels = tempContent.ToArray();
}
19
View Source File : InputSimulationWindow.cs
License : Apache License 2.0
Project Creator : abist-co-ltd
License : Apache License 2.0
Project Creator : abist-co-ltd
private void OnGUI()
{
LoadIcons();
if (!Application.isPlaying)
{
EditorGUILayout.HelpBox("Input simulation is only available in play mode", MessageType.Info);
return;
}
DrawSimulationGUI();
EditorGUILayout.Separator();
string[] modeStrings = Enum.GetNames(typeof(ToolMode));
Mode = (ToolMode)GUILayout.SelectionGrid((int)Mode, modeStrings, modeStrings.Length);
switch (mode)
{
case ToolMode.Record:
DrawRecordingGUI();
break;
case ToolMode.Playback:
DrawPlaybackGUI();
break;
}
EditorGUILayout.Space();
// XXX Reloading the scene is currently not supported,
// due to the life cycle of the MRTK "instance" object (see #4530).
// Enable the button below once scene reloading is supported!
#if false
using (new GUIEnabledWrapper(Application.isPlaying))
{
bool reloadScene = GUILayout.Button("Reload Scene");
if (reloadScene)
{
Scene activeScene = SceneManager.GetActiveScene();
if (activeScene.IsValid())
{
SceneManager.LoadScene(activeScene.name);
return;
}
}
}
#endif
}
19
View Source File : DragAxisToScale.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void DragAxisToScale_Loaded(object sender, RoutedEventArgs e)
{
// Performing multiple updates in a SuspendUpdates block is efficient as only one redraw is performed
using (sciChart.SuspendUpdates())
{
// Create a dataset of type X=double, Y=double
var dataSeries0 = new XyDataSeries<double, double>();
var dataSeries1 = new XyDataSeries<double, double>();
var data2 = DataManager.Instance.GetFourierSeriesForMountainExample(1.0, 0.1);
var data1 = DataManager.Instance.GetDampedSinewave(1500, 3.0, 0.0, 0.005, data2.Count);
// Append data to series.
dataSeries0.Append(data1.XData, data1.YData);
dataSeries1.Append(data2.XData, data2.YData);
// replacedign data series to RenderableSeries
// Note: you can also data-bind them in MVVM
mountainSeries.DataSeries = dataSeries1;
lineSeries.DataSeries = dataSeries0;
// Set initial zoom
sciChart.XAxis.VisibleRange = new DoubleRange(3, 6);
sciChart.ZoomExtentsY();
dragModes.ItemsSource = Enum.GetNames(typeof(AxisDragModes));
dragXYDirection.ItemsSource = Enum.GetNames(typeof(XyDirection));
}
}
19
View Source File : MouseDragToPanXOrY.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void MouseDragToPanXOrY_Loaded(object sender, RoutedEventArgs e)
{
// Performing multiple updates in a SuspendUpdates block is efficient as only one redraw is performed
using (sciChart.SuspendUpdates())
{
// Add some data series
var dataSeries0 = new XyDataSeries<double, double>();
var dataSeries1 = new XyDataSeries<double, double>();
var data2 = DataManager.Instance.GetFourierSeries(1.0, 0.1);
var data1 = DataManager.Instance.GetDampedSinewave(1500, 3.0, 0.0, 0.005, data2.Count);
// Append data to series.
dataSeries0.Append(data1.XData, data1.YData);
dataSeries1.Append(data2.XData, data2.YData);
// replacedign data-series to renderable series
sciChart.RenderableSeries[0].DataSeries = dataSeries0;
sciChart.RenderableSeries[1].DataSeries = dataSeries1;
// Set initial zoom
sciChart.XAxis.VisibleRange = new DoubleRange(3, 6);
sciChart.ZoomExtentsY();
}
panXYDirection.ItemsSource = Enum.GetNames(typeof(XyDirection));
}
19
View Source File : EnumValuesExtension.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public override object ProvideValue(IServiceProvider serviceProvider)
{
return Enum.GetNames(_enumType);
}
19
View Source File : Enlightenment.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public static void RemoveAttributes(Player player)
{
var propertyCount = Enum.GetNames(typeof(PropertyAttribute)).Length;
for (var i = 1; i < propertyCount; i++)
{
var attribute = (PropertyAttribute)i;
player.Attributes[attribute].Ranks = 0;
player.Attributes[attribute].ExperienceSpent = 0;
player.Session.Network.EnqueueSend(new GameMessagePrivateUpdateAttribute(player, player.Attributes[attribute]));
}
propertyCount = Enum.GetNames(typeof(PropertyAttribute2nd)).Length;
for (var i = 1; i < propertyCount; i += 2)
{
var attribute = (PropertyAttribute2nd)i;
player.Vitals[attribute].Ranks = 0;
player.Vitals[attribute].ExperienceSpent = 0;
player.Session.Network.EnqueueSend(new GameMessagePrivateUpdateVital(player, player.Vitals[attribute]));
}
player.SendMessage("Your attribute training fades.", ChatMessageType.Broadcast);
}
19
View Source File : Enlightenment.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public static void RemoveSkills(Player player)
{
var propertyCount = Enum.GetNames(typeof(Skill)).Length;
for (var i = 1; i < propertyCount; i++)
{
var skill = (Skill)i;
player.ResetSkill(skill, false);
}
player.AvailableExperience = 0;
player.Session.Network.EnqueueSend(new GameMessagePrivateUpdatePropertyInt64(player, PropertyInt64.AvailableExperience, 0));
var heritageGroup = DatManager.PortalDat.CharGen.HeritageGroups[(uint)player.Heritage];
var availableSkillCredits = 0;
availableSkillCredits += (int)heritageGroup.SkillCredits; // base skill credits allowed
availableSkillCredits += player.QuestManager.GetCurrentSolves("ArantahKill1"); // additional quest skill credit
availableSkillCredits += player.QuestManager.GetCurrentSolves("OswaldManualCompleted"); // additional quest skill credit
availableSkillCredits += player.QuestManager.GetCurrentSolves("LumAugSkillQuest"); // additional quest skill credits
player.AvailableSkillCredits = availableSkillCredits;
player.Session.Network.EnqueueSend(new GameMessagePrivateUpdatePropertyInt(player, PropertyInt.AvailableSkillCredits, player.AvailableSkillCredits ?? 0));
}
19
View Source File : UnknownEnum.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public static object Parse(Type enumType, string stringValue)
{
var underlyingType = Nullable.GetUnderlyingType(enumType);
enumType = underlyingType != null ? underlyingType : enumType;
var names = Enum.GetNames(enumType);
if (!string.IsNullOrEmpty(stringValue))
{
var match = names.FirstOrDefault(name => string.Equals(name, stringValue, StringComparison.OrdinalIgnoreCase));
if (match != null)
{
return Enum.Parse(enumType, match);
}
// maybe we have an enum member with an EnumMember attribute specifying a custom name
foreach (var field in enumType.GetFields())
{
var enumMemberAttribute = field.GetCustomAttributes(typeof(EnumMemberAttribute), false).FirstOrDefault() as EnumMemberAttribute;
if (enumMemberAttribute != null && string.Equals(enumMemberAttribute.Value, stringValue, StringComparison.OrdinalIgnoreCase))
{
// we already have the field, no need to do enum.parse on it
return field.GetValue(null);
}
}
}
return Enum.Parse(enumType, UnknownName);
}
19
View Source File : UnknownEnumJsonConverter.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public override bool CanConvert(Type objectType)
{
// we require one member to be named "Unknown"
return objectType.IsEnum && Enum.GetNames(objectType).Any(name => string.Equals(name, UnknownName, StringComparison.OrdinalIgnoreCase));
}
19
View Source File : FlagsEnum.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public static object ParseKnownFlags(Type enumType, string stringValue)
{
ArgumentUtility.CheckForNull(enumType, nameof(enumType));
if (!enumType.IsEnum)
{
throw new ArgumentException(PipelinesWebApiResources.FlagEnumTypeRequired());
}
// Check for the flags attribute in debug. Skip this reflection in release.
Debug.replacedert(enumType.GetCustomAttributes(typeof(FlagsAttribute), inherit: false).Any(), "FlagsEnum only intended for enums with the Flags attribute.");
// The exception types below are based on Enum.TryParseEnum (http://index/?query=TryParseEnum&rightProject=mscorlib&file=system%5Cenum.cs&rightSymbol=bhaeh2vnegwo)
if (stringValue == null)
{
throw new ArgumentNullException(stringValue);
}
if (String.IsNullOrWhiteSpace(stringValue))
{
throw new ArgumentException(PipelinesWebApiResources.NonEmptyEnumElementsRequired(stringValue));
}
if (UInt64.TryParse(stringValue, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out ulong ulongValue))
{
return Enum.Parse(enumType, stringValue);
}
var enumNames = Enum.GetNames(enumType).ToHashSet(name => name, StringComparer.OrdinalIgnoreCase);
var enumMemberMappings = new Lazy<IDictionary<string, string>>(() =>
{
IDictionary<string, string> mappings = null;
foreach (var field in enumType.GetFields())
{
if (field.GetCustomAttributes(typeof(EnumMemberAttribute), false).FirstOrDefault() is EnumMemberAttribute enumMemberAttribute)
{
if (mappings == null)
{
mappings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
mappings.Add(enumMemberAttribute.Value, field.GetValue(null).ToString());
}
}
return mappings;
});
var values = stringValue.Split(s_enumSeparatorCharArray);
var matches = new List<string>();
for (int i = 0; i < values.Length; i++)
{
string value = values[i].Trim();
if (String.IsNullOrEmpty(value))
{
throw new ArgumentException(PipelinesWebApiResources.NonEmptyEnumElementsRequired(stringValue));
}
if (enumNames.Contains(value))
{
matches.Add(value);
}
else if (enumMemberMappings.Value != null && enumMemberMappings.Value.TryGetValue(value, out string matchingValue))
{
matches.Add(matchingValue);
}
}
if (!matches.Any())
{
return Enum.Parse(enumType, "0");
}
string matchesString = String.Join(", ", matches);
return Enum.Parse(enumType, matchesString, ignoreCase: true);
}
19
View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
private void BindResources(Type srType, Type enumType) {
if (resourcesListView == null)
return;
// Build list
List<ResourceData> resources = new List<ResourceData>();
string[] names = Enum.GetNames(enumType);
foreach (string name in names)
resources.Add(new ResourceData(srType, enumType, name));
// Bind
resourcesListView.ItemsSource = resources;
// Update selection
if (resourcesListView.Items.Count > 0)
resourcesListView.SelectedIndex = 0;
}
19
View Source File : FlowSwitch.cs
License : GNU General Public License v3.0
Project Creator : Adam-Wilkinson
License : GNU General Public License v3.0
Project Creator : Adam-Wilkinson
private INodeComponent GenerateSwitchesFor(ITypeDefinition typeDef)
{
if (typeDef.ValueType.IsEnum)
{
return Constructor.NodeComponentList(Enum.GetNames(typeDef.ValueType).Select(x => ValueDisplay(typeDef, Enum.Parse(typeDef.ValueType, x))));
}
return Constructor.NodeComponentList(
Constructor.NodeComponentAutoCloner(Constructor.NodeField("Case").WithInput(typeDef).WithFlowOutput(), 0, (x) => $"Case {x + 1}"),
defaultOutput
);
}
19
View Source File : BarcodesViewModel.cs
License : MIT License
Project Creator : ahmed-abdelrazek
License : MIT License
Project Creator : ahmed-abdelrazek
public async Task OnLoadedAsync()
{
await Task.Run(() =>
{
foreach (var item in Enum.GetNames(typeof(RotateFlipType)))
{
if (item.ToString().Trim().ToLower() == "rotatenoneflipnone")
{
continue;
}
RotateTypes.Add(item.ToString());
}
SelectedRotate = "Rotate180FlipXY";
Encoders = new List<Enumeration<byte>>();
foreach (var type in Enum.GetValues(typeof(BarCodeEncoders)))
{
Encoders.Add(new Enumeration<byte>
{
Id = (byte)type,
Name = Enumerations.GetEnumDescription((BarCodeEncoders)type).ToString()
});
}
SelectedEncoder = "Code 128";
});
}
19
View Source File : EnumSample.cs
License : The Unlicense
Project Creator : ahotko
License : The Unlicense
Project Creator : ahotko
public override void Execute()
{
replacedle("EnumSampleExecute");
Section("Simple Enum");
//'This must be Thursday,' said Arthur to himself, sinking low over his beer. 'I never could get the hang of Thursdays.'
WeekDay weekDay = WeekDay.Thursday;
Console.WriteLine($"weekDay Enum value: default={weekDay.ToString()}, string={weekDay.ToString("g")}, decimal={weekDay.ToString("d")}, hex=0x{weekDay.ToString("x")}");
var enumValues = Enum.GetNames(typeof(WeekDay));
Console.WriteLine("WeekDays Enum values:");
foreach (string value in enumValues)
{
Console.WriteLine(value);
}
LineBreak();
Section("Typed Enum (short)");
Priority priority = Priority.Low;
Console.WriteLine($"Priority Enum values: default={priority.ToString()}, string={priority.ToString("g")}, decimal={priority.ToString("d")}, hex=0x{priority.ToString("x")}");
priority = Priority.Normal;
Console.WriteLine($"Priority Enum values: default={priority.ToString()}, string={priority.ToString("g")}, decimal={priority.ToString("d")}, hex=0x{priority.ToString("x")}");
priority = Priority.Highest;
Console.WriteLine($"Priority Enum values: default={priority.ToString()}, string={priority.ToString("g")}, decimal={priority.ToString("d")}, hex=0x{priority.ToString("x")}");
Section("Enum Flags");
SidesAndCorners sidesAndCorners = SidesAndCorners.Bottom;
OutputSidesAndCorners(sidesAndCorners);
sidesAndCorners = SidesAndCorners.Full;
OutputSidesAndCorners(sidesAndCorners);
sidesAndCorners = SidesAndCorners.Top | SidesAndCorners.Bottom;
OutputSidesAndCorners(sidesAndCorners);
sidesAndCorners = SidesAndCorners.TopLeft;
OutputSidesAndCorners(sidesAndCorners);
//checking flags
Console.WriteLine($"sidesAndCorners.Top is set={sidesAndCorners.HasFlag(SidesAndCorners.Top)}");
Console.WriteLine($"sidesAndCorners.TopLeft is set={sidesAndCorners.HasFlag(SidesAndCorners.TopLeft)}");
Console.WriteLine($"sidesAndCorners.Full is set={sidesAndCorners.HasFlag(SidesAndCorners.Full)}");
Console.WriteLine($"sidesAndCorners.Bottom is set={sidesAndCorners.HasFlag(SidesAndCorners.Bottom)}");
Section("Enum with Description");
Status status= Status.NotCompleted;
Console.WriteLine($"status value: default={status.ToString()}, string={status.ToString("g")}, decimal={status.ToString("d")}, hex=0x{status.ToString("x")}");
var statusValues = Enum.GetValues(typeof(Status));
Console.WriteLine("Status Enum values:");
foreach (Status value in statusValues)
{
Console.WriteLine($"ordinal={(int)value}, value={value.ToString()}, description={value.GetDescription<Status>()}");
}
LineBreak();
Finish();
}
19
View Source File : DSPSampleProviders.cs
License : MIT License
Project Creator : aksyr
License : MIT License
Project Creator : aksyr
public void Execute(ref ExecuteContext<NoParameters, Providers> context)
{
var providers = context.Providers;
replacedert.That(providers.Count, Is.EqualTo(Enum.GetNames(typeof(Providers)).Length));
// First is single value, so check its 0th element can be accessed.
SampleProvider singleProv = providers.GetSampleProvider(Providers.Single);
replacedert.That(singleProv.Valid, Is.False);
replacedert.That(providers.GetCount(Providers.Single), Is.EqualTo(1));
replacedert.Throws<ArgumentOutOfRangeException>(() => providers.GetSampleProvider(Providers.Single, 1));
// Second item is a var array. These are born empty.
replacedert.Throws<ArgumentOutOfRangeException>(() => providers.GetSampleProvider(Providers.VariableSizeArray));
replacedert.That(providers.GetCount(Providers.VariableSizeArray), Is.EqualTo(0));
// Third item is a fixed array. These are born with their final size.
replacedert.That(providers.GetCount(Providers.FixedArray), Is.EqualTo(3));
for (int i = 0; i < 3; ++i)
{
SampleProvider p = providers.GetSampleProvider(Providers.FixedArray, 0);
replacedert.That(p.Valid, Is.False);
}
replacedert.Throws<ArgumentOutOfRangeException>(() => providers.GetSampleProvider(Providers.FixedArray, 3));
replacedert.Throws<ArgumentOutOfRangeException>(() => providers.GetSampleProvider(3));
}
19
View Source File : ProgramArguments.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
private bool ParseValue(Type type, string stringData, out object value)
{
// null is only valid for bool variables
// empty string is never valid
if ((stringData != null || type == typeof(bool)) && (stringData == null || stringData.Length > 0))
{
try
{
if (type == typeof(string))
{
value = stringData;
return true;
}
else if (type == typeof(bool))
{
if (stringData == null || stringData == "+")
{
value = true;
return true;
}
else if (stringData == "-")
{
value = false;
return true;
}
}
else if (type == typeof(int))
{
value = int.Parse(stringData);
return true;
}
else if (type == typeof(uint))
{
value = int.Parse(stringData);
return true;
}
else
{
Debug.replacedert(type.IsEnum);
bool valid = false;
foreach (string name in Enum.GetNames(type))
{
if (name == stringData)
{
valid = true;
break;
}
}
if (valid)
{
value = Enum.Parse(type, stringData, true);
return true;
}
}
}
catch
{
// catch parse errors
}
}
ReportBadArgumentValue(stringData);
value = null;
return false;
}
19
View Source File : NodeTerrainDetailEditor.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
public override void OnNodeGUI()
{
EditorGUIUtility.labelWidth = 100;
node.outputDetail.biomeDetailMask = EditorGUILayout.MaskField("details", node.outputDetail.biomeDetailMask, Enum.GetNames(typeof(TerrainDetailType)));
}
19
View Source File : FeaturesSubLayerPropertiesDrawer.cs
License : MIT License
Project Creator : alen-smajic
License : MIT License
Project Creator : alen-smajic
public void DrawUI(SerializedProperty property)
{
objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
var serializedMapObject = property.serializedObject;
AbstractMap mapObject = (AbstractMap)serializedMapObject.targetObject;
tileJSONData = mapObject.VectorData.GetTileJsonData();
var sourceTypeProperty = property.FindPropertyRelative("_sourceType");
var sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
var displayNames = sourceTypeProperty.enumDisplayNames;
var names = sourceTypeProperty.enumNames;
int count = sourceTypeProperty.enumDisplayNames.Length;
if (!_isGUIContentSet)
{
_sourceTypeContent = new GUIContent[count];
var index = 0;
foreach (var name in names)
{
_sourceTypeContent[index] = new GUIContent
{
text = displayNames[index],
tooltip = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), name)).Description(),
};
index++;
}
// for (int index0 = 0; index0 < count; index0++)
// {
// _sourceTypeContent[index0] = new GUIContent
// {
// text = displayNames[index0],
// tooltip = ((VectorSourceType)index0).Description(),
// };
// }
_isGUIContentSet = true;
}
//sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
sourceTypeValue = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), names[sourceTypeProperty.enumValueIndex]));
var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions");
var layerSourceProperty = sourceOptionsProperty.FindPropertyRelative("layerSource");
var layerSourceId = layerSourceProperty.FindPropertyRelative("Id");
var isActiveProperty = sourceOptionsProperty.FindPropertyRelative("isActive");
switch (sourceTypeValue)
{
case VectorSourceType.MapboxStreets:
case VectorSourceType.MapboxStreetsV8:
case VectorSourceType.MapboxStreetsWithBuildingIds:
case VectorSourceType.MapboxStreetsV8WithBuildingIds:
var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue);
layerSourceId.stringValue = sourcePropertyValue.Id;
GUI.enabled = false;
if (_isInitialized)
{
LoadEditorTileJSON(property, sourceTypeValue, layerSourceId.stringValue);
}
else
{
_isInitialized = true;
}
if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded)
{
EditorGUILayout.HelpBox("Invalid Tileset Id / There might be a problem with the internet connection.", MessageType.Error);
}
GUI.enabled = true;
isActiveProperty.boolValue = true;
break;
case VectorSourceType.Custom:
if (_isInitialized)
{
string test = layerSourceId.stringValue;
LoadEditorTileJSON(property, sourceTypeValue, layerSourceId.stringValue);
}
else
{
_isInitialized = true;
}
if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded)
{
EditorGUILayout.HelpBox("Invalid Tileset Id / There might be a problem with the internet connection.", MessageType.Error);
}
isActiveProperty.boolValue = true;
break;
case VectorSourceType.None:
isActiveProperty.boolValue = false;
break;
default:
isActiveProperty.boolValue = false;
break;
}
if (sourceTypeValue != VectorSourceType.None)
{
EditorGUILayout.LabelField(new GUIContent
{
text = "Map Features",
tooltip = "Visualizers for vector features contained in a layer. "
});
var subLayerArray = property.FindPropertyRelative("vectorSubLayers");
var layersRect = EditorGUILayout.GetControlRect(GUILayout.MinHeight(Mathf.Max(subLayerArray.arraySize + 1, 1) * _lineHeight + MultiColumnHeader.DefaultGUI.defaultHeight),
GUILayout.MaxHeight((subLayerArray.arraySize + 1) * _lineHeight + MultiColumnHeader.DefaultGUI.defaultHeight));
if (!m_Initialized)
{
bool firstInit = m_MultiColumnHeaderState == null;
var headerState = FeatureSubLayerTreeView.CreateDefaultMultiColumnHeaderState();
if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
{
MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
}
m_MultiColumnHeaderState = headerState;
var multiColumnHeader = new FeatureSectionMultiColumnHeader(headerState);
if (firstInit)
{
multiColumnHeader.ResizeToFit();
}
treeModel = new TreeModel<FeatureTreeElement>(GetData(subLayerArray));
if (m_TreeViewState == null)
{
m_TreeViewState = new TreeViewState();
}
if (layerTreeView == null)
{
layerTreeView = new FeatureSubLayerTreeView(m_TreeViewState, multiColumnHeader, treeModel);
}
layerTreeView.multiColumnHeader = multiColumnHeader;
m_Initialized = true;
}
layerTreeView.Layers = subLayerArray;
layerTreeView.Reload();
layerTreeView.OnGUI(layersRect);
if (layerTreeView.hasChanged)
{
EditorHelper.CheckForModifiedProperty(property);
layerTreeView.hasChanged = false;
}
selectedLayers = layerTreeView.GetSelection();
//if there are selected elements, set the selection index at the first element.
//if not, use the Selection index to persist the selection at the right index.
if (selectedLayers.Count > 0)
{
//ensure that selectedLayers[0] isn't out of bounds
if (selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature > subLayerArray.arraySize - 1)
{
selectedLayers[0] = subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature;
}
SelectionIndex = selectedLayers[0];
}
else
{
if (SelectionIndex > 0 && (SelectionIndex - FeatureSubLayerTreeView.uniqueIdFeature <= subLayerArray.arraySize - 1))
{
selectedLayers = new int[1] { SelectionIndex };
layerTreeView.SetSelection(selectedLayers);
}
}
GUILayout.Space(EditorGUIUtility.singleLineHeight);
EditorGUILayout.BeginHorizontal();
GenericMenu menu = new GenericMenu();
foreach (var name in Enum.GetNames(typeof(PresetFeatureType)))
{
menu.AddItem(new GUIContent() { text = name }, false, FetchPresetProperties, name);
}
GUILayout.Space(0); // do not remove this line; it is needed for the next line to work
Rect rect = GUILayoutUtility.GetLastRect();
rect.y += 2 * _lineHeight / 3;
if (EditorGUILayout.DropdownButton(new GUIContent { text = "Add Feature" }, FocusType.Preplacedive, (GUIStyle)"minibuttonleft"))
{
menu.DropDown(rect);
}
//replacedign subLayerProperties after fetching it from the presets clreplaced. This happens everytime an element is added
if (subLayerProperties != null)
{
subLayerArray.arraySize++;
var subLayer = subLayerArray.GetArrayElementAtIndex(subLayerArray.arraySize - 1);
SetSubLayerProps(subLayer);
//Refreshing the tree
layerTreeView.Layers = subLayerArray;
layerTreeView.AddElementToTree(subLayer);
layerTreeView.Reload();
selectedLayers = new int[1] { subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature };
layerTreeView.SetSelection(selectedLayers);
subLayerProperties = null; // setting this to null so that the if block is not called again
if (EditorHelper.DidModifyProperty(property))
{
isLayerAdded = true;
}
}
if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright"))
{
foreach (var index in selectedLayers.OrderByDescending(i => i))
{
if (layerTreeView != null)
{
var subLayer = subLayerArray.GetArrayElementAtIndex(index - FeatureSubLayerTreeView.uniqueIdFeature);
VectorLayerProperties vectorLayerProperties = (VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property);
VectorSubLayerProperties vectorSubLayerProperties = (VectorSubLayerProperties)EditorHelper.GetTargetObjectOfProperty(subLayer);
vectorLayerProperties.OnSubLayerPropertyRemoved(new VectorLayerUpdateArgs { property = vectorSubLayerProperties });
layerTreeView.RemoveItemFromTree(index);
subLayerArray.DeleteArrayElementAtIndex(index - FeatureSubLayerTreeView.uniqueIdFeature);
layerTreeView.treeModel.SetData(GetData(subLayerArray));
}
}
selectedLayers = new int[0];
layerTreeView.SetSelection(selectedLayers);
}
EditorGUILayout.EndHorizontal();
GUILayout.Space(EditorGUIUtility.singleLineHeight);
if (selectedLayers.Count == 1 && subLayerArray.arraySize != 0 && selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature >= 0)
{
//ensure that selectedLayers[0] isn't out of bounds
if (selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature > subLayerArray.arraySize - 1)
{
selectedLayers[0] = subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature;
}
SelectionIndex = selectedLayers[0];
var layerProperty = subLayerArray.GetArrayElementAtIndex(SelectionIndex - FeatureSubLayerTreeView.uniqueIdFeature);
layerProperty.isExpanded = true;
var subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");
bool isLayerActive = subLayerCoreOptions.FindPropertyRelative("isActive").boolValue;
if (!isLayerActive)
{
GUI.enabled = false;
}
DrawLayerVisualizerProperties(sourceTypeValue, layerProperty, property);
if (!isLayerActive)
{
GUI.enabled = true;
}
}
else
{
GUILayout.Label("Select a visualizer to see properties");
}
}
}
19
View Source File : HelpGenerator.cs
License : MIT License
Project Creator : AlexGhiondea
License : MIT License
Project Creator : AlexGhiondea
private static string GetEnumValuesreplacedtring(Type enumType)
{
return string.Join(",", Enum.GetNames(enumType));
}
19
View Source File : EditableIf.cs
License : MIT License
Project Creator : alexismorin
License : MIT License
Project Creator : alexismorin
private void Init( object fieldname, object comparison, object expectedvalue )
{
FieldName = fieldname.ToString();
var names = Enum.GetNames( typeof( ComparisonOperators ) );
var name = comparison.ToString().ToLower().Replace( " ", "" );
for( int i = 0; i < names.Length; i++ )
{
if( names[ i ].ToLower() == name )
{
op = (ComparisonOperators)i;
break;
}
}
ExpectedValue = expectedvalue;
}
19
View Source File : EnumPropertyTest.cs
License : MIT License
Project Creator : alexleen
License : MIT License
Project Creator : alexleen
[Test]
public void Ctor_ShouldUseStringValues()
{
Collectionreplacedert.AreEquivalent(Enum.GetNames(typeof(MailPriority)), mSut.Values);
}
19
View Source File : IconManager.cs
License : Apache License 2.0
Project Creator : Algoryx
License : Apache License 2.0
Project Creator : Algoryx
private static Texture2D[] LoadIconContent<T>( string[] iconFilenames )
where T : struct
{
var enumValues = System.Enum.GetValues( typeof( T ) );
var enumNames = System.Enum.GetNames( typeof( T ) );
var icons = new Texture2D[ enumValues.Length ];
foreach ( int index in enumValues ) {
if ( string.IsNullOrEmpty( iconFilenames[ index ] ) ) {
if ( enumNames[ index ] != "None" )
Debug.LogWarning( "Filename for tool icon "
+ (ToolIcon)index +
" not given - ignoring icon." );
else
icons[ index ] = null;
continue;
}
icons[ index ] = GetIcon( iconFilenames[ index ] );
if ( icons[ index ] == null )
Debug.LogWarning( "Unable to load tool icon " +
(ToolIcon)index +
" at: " +
Directory + '/' + iconFilenames[ index ] );
}
return icons;
}
19
View Source File : TypeExtensions.cs
License : MIT License
Project Creator : aliencube
License : MIT License
Project Creator : aliencube
public static List<IOpenApiAny> ToOpenApiStringCollection(this Type type, NamingStrategy namingStrategy)
{
if (!type.IsUnflaggedEnumType())
{
return null;
}
var names = Enum.GetNames(type);
return names.Select(p => (IOpenApiAny)new OpenApiString(namingStrategy.GetPropertyName(p, false)))
.ToList();
}
19
View Source File : IntegrationTests.cs
License : Apache License 2.0
Project Creator : allure-framework
License : Apache License 2.0
Project Creator : allure-framework
private void ParseFeatures(string featuresDir)
{
var parser = new Parser();
var scenarios = new List<Scenario>();
var features = new DirectoryInfo(featuresDir).GetFiles("*.feature");
scenarios.AddRange(features.SelectMany(f =>
{
var children = parser.Parse(f.FullName).Feature.Children.ToList();
var scenarioOutlines = children.Where(x => (x as dynamic).Examples.Length > 0).ToList();
foreach (var s in scenarioOutlines)
{
var examplesCount = ((s as dynamic).Examples as dynamic)[0].TableBody.Length;
for (int i = 1; i < examplesCount; i++)
{
children.Add(s);
}
}
return children;
})
.Select(x => x as Scenario));
scenariosByStatus =
scenarios.GroupBy(x => x.Tags.FirstOrDefault(x =>
Enum.GetNames(typeof(Status)).Contains(x.Name.Replace("@", "")))?.Name
.Replace("@", "") ??
"_notag_", x => x.Name);
}
19
View Source File : InstancesController.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
[Authorize(Policy = AuthzConstants.POLICY_INSTANCE_READ)]
[HttpPut("{instanceOwnerPartyId:int}/{instanceGuid:guid}/readstatus")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[Produces("application/json")]
public async Task<ActionResult<Instance>> UpdateReadStatus(
[FromRoute] int instanceOwnerPartyId,
[FromRoute] Guid instanceGuid,
[FromQuery] string status)
{
if (!Enum.TryParse(status, true, out ReadStatus newStatus))
{
return BadRequest($"Invalid read status: {status}. Accepted types include: {string.Join(", ", Enum.GetNames(typeof(ReadStatus)))}");
}
string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}";
Instance instance = await _instanceRepository.GetOne(instanceId, instanceOwnerPartyId);
Instance updatedInstance;
try
{
if (instance.Status == null)
{
instance.Status = new InstanceStatus();
}
instance.Status.ReadStatus = newStatus;
updatedInstance = await _instanceRepository.Update(instance);
updatedInstance.SetPlatformSelfLinks(_storageBaseAndHost);
}
catch (Exception e)
{
_logger.LogError(e, $"Unable to update read status for instance {instanceId}");
return StatusCode(StatusCodes.Status500InternalServerError);
}
return Ok(updatedInstance);
}
19
View Source File : ProcessController.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn
[HttpGet("history")]
[Authorize(Policy = "InstanceRead")]
[ProducesResponseType(StatusCodes.Status200OK)]
[Produces("application/json")]
public async Task<ActionResult<ProcessHistoryList>> GetProcessHistory(
[FromRoute] int instanceOwnerPartyId,
[FromRoute] Guid instanceGuid)
{
string[] eventTypes = Enum.GetNames(typeof(InstanceEventType)).Where(x => x.StartsWith("process")).ToArray();
string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}";
ProcessHistoryList processHistoryList = new ProcessHistoryList();
try
{
List<InstanceEvent> processEvents = await _instanceEventRepository.ListInstanceEvents(instanceId, eventTypes, null, null);
processHistoryList.ProcessHistory = ProcessHelper.MapInstanceEventsToProcessHistory(processEvents);
return Ok(processHistoryList);
}
catch (Exception e)
{
_logger.LogError($"Unable to retriece process history for instance object {instanceId}. Due to {e}");
return StatusCode(500, $"Unable to retriece process history for instance object {instanceId}: {e.Message}");
}
}
19
View Source File : Color2.cs
License : MIT License
Project Creator : amwx
License : MIT License
Project Creator : amwx
private static void InitColorTable()
{
if (ColorTable == null)
{
var kcs = Enum.GetValues<KnownColor>();
var names = Enum.GetNames<KnownColor>();
ColorTable = new Dictionary<Color2, string>(kcs.Length);
for (int i = 0; i < kcs.Length; i++)
{
var c2 = Color2.FromUInt((uint)kcs[i]);
if (!ColorTable.ContainsKey(c2))
ColorTable.Add(c2, names[i]);
}
}
}
19
View Source File : JsonTreeView.cs
License : MIT License
Project Creator : Analogy-LogViewer
License : MIT License
Project Creator : Analogy-LogViewer
private void LoadImgaeList()
{
ImageList treeImages = new ImageList();
treeImages.ImageSize = new Size(16, 16);
ComponentResourceManager images = new ComponentResourceManager(typeof(JsonNodeImages));
foreach (var type in Enum.GetNames(typeof(JTokenType)))
{
try
{
treeImages.Images.Add(type, (Bitmap)images.GetObject(type));
}
catch (Exception)
{
treeImages.Images.Add(type, (Bitmap)images.GetObject("Undefined"));
}
}
ImageList = treeImages;
}
19
View Source File : OpNameTests.cs
License : MIT License
Project Creator : AndyPook
License : MIT License
Project Creator : AndyPook
[Fact]
public void NatsOperationId_verify_enum()
{
var names = Enum.GetNames(typeof(NatsOperationId));
foreach(var name in names)
{
var opId = name switch
{
"OK" => NatsOperation.GetOpId("+OK"),
"ERR" => NatsOperation.GetOpId("-ERR"),
_ => NatsOperation.GetOpId(name)
};
var n = Enum.GetName(typeof(NatsOperationId), opId);
replacedert.Equal(name, n);
}
19
View Source File : EnumUtil.cs
License : MIT License
Project Creator : anet-team
License : MIT License
Project Creator : anet-team
public static IEnumerable<EnumDisplay> GetDisplayList(Type enumType)
{
foreach (var name in Enum.GetNames(enumType))
{
var member = enumType.GetMember(name);
// 忽略过时枚举值
var obsoleteAttribute = member[0].GetCustomAttribute<ObsoleteAttribute>();
if (obsoleteAttribute != null)
continue;
// 忽略没有 DisplayAttribute 的枚举值
var displayAttribute = member[0].GetCustomAttribute<DisplayAttribute>();
if (displayAttribute == null)
continue;
yield return new EnumDisplay
{
Value = Convert.ToInt32(Enum.Parse(enumType, name)),
Field = name,
Name = displayAttribute.GetName(),
Order = displayAttribute.GetOrder() ?? 0,
Group = displayAttribute.GetGroupName()
};
}
}
19
View Source File : AnnotationStyles.cs
License : MIT License
Project Creator : AngeloCresta
License : MIT License
Project Creator : AngeloCresta
private void SetCalloutControls()
{
foreach(string style in Enum.GetNames(typeof(System.Windows.Forms.DataVisualization.Charting.CalloutStyle)))
{
AnnotationStyle.Items.Add(style);
}
AnnotationStyle.SelectedIndex = 2;
AnnotationStyle.Enabled = true;
AnnotationStyle1.Items.Clear();
AnnotationStyle1.Items.Add("Yellow");
AnnotationStyle1.Items.Add("White");
AnnotationStyle1.Items.Add("Gold");
AnnotationStyle1.Items.Add("Brown");
StyleLabel1.Text = "Back Color:";
AnnotationStyle1.SelectedIndex = 2;
AnnotationStyle1.Enabled = true;
StyleLabel2.Text = "";
AnnotationStyle2.Visible = false;
}
19
View Source File : AnnotationStyles.cs
License : MIT License
Project Creator : AngeloCresta
License : MIT License
Project Creator : AngeloCresta
private void SetBorder3DControls()
{
foreach(string skinStyle in Enum.GetNames(typeof(System.Windows.Forms.DataVisualization.Charting.BorderSkinStyle)))
{
AnnotationStyle.Items.Add(skinStyle);
}
AnnotationStyle.SelectedIndex = 1;
AnnotationStyle.Enabled = true;
AnnotationStyle1.Items.Clear();
AnnotationStyle1.Items.Add("Yellow");
AnnotationStyle1.Items.Add("White");
AnnotationStyle1.Items.Add("Gold");
AnnotationStyle1.Items.Add("Brown");
StyleLabel1.Text = "Border Color:";
AnnotationStyle1.SelectedIndex = 2;
AnnotationStyle1.Enabled = true;
StyleLabel2.Text = "";
AnnotationStyle2.Visible = false;
}
19
View Source File : AnnotationStyles.cs
License : MIT License
Project Creator : AngeloCresta
License : MIT License
Project Creator : AngeloCresta
private void SetArrowControls()
{
foreach(string arrow in Enum.GetNames(typeof(System.Windows.Forms.DataVisualization.Charting.ArrowStyle)))
{
AnnotationStyle.Items.Add(arrow);
}
AnnotationStyle.SelectedIndex = 0;
AnnotationStyle.Enabled = true;
for(int i = 1; i <= 10; i++)
AnnotationStyle1.Items.Add(i.ToString());
StyleLabel1.Text = "Arrow Si&ze:";
AnnotationStyle1.SelectedIndex = 3;
AnnotationStyle1.Enabled = true;
StyleLabel2.Text = "";
AnnotationStyle2.Visible = false;
}
19
View Source File : AnnotationStyles.cs
License : MIT License
Project Creator : AngeloCresta
License : MIT License
Project Creator : AngeloCresta
private void SetColorLineControls()
{
AnnotationStyle1.Items.Clear();
AnnotationStyle1.Items.Add("Yellow");
AnnotationStyle1.Items.Add("White");
AnnotationStyle1.Items.Add("Gold");
AnnotationStyle1.Items.Add("Brown");
StyleLabel1.Text = "Back C&olor:";
AnnotationStyle1.SelectedIndex = 2;
AnnotationStyle1.Enabled = true;
foreach(string lineName in Enum.GetNames(typeof(System.Windows.Forms.DataVisualization.Charting.ChartDashStyle)))
{
AnnotationStyle2.Items.Add(lineName);
}
StyleLabel2.Text = "Line St&yle:";
AnnotationStyle2.SelectedIndex = 5;
AnnotationStyle2.Visible = true;
}
19
View Source File : AnnotationStyles.cs
License : MIT License
Project Creator : AngeloCresta
License : MIT License
Project Creator : AngeloCresta
private void SetLineControls(bool showAnchors)
{
foreach(string lineName in Enum.GetNames(typeof(System.Windows.Forms.DataVisualization.Charting.ChartDashStyle)))
{
AnnotationStyle.Items.Add(lineName);
}
AnnotationStyle.SelectedIndex = 5;
AnnotationStyle.Enabled = true;
if(showAnchors)
{
foreach(string arrowStyle in Enum.GetNames(typeof(System.Windows.Forms.DataVisualization.Charting.LineAnchorCapStyle)))
{
AnnotationStyle1.Items.Add(arrowStyle);
AnnotationStyle2.Items.Add(arrowStyle);
}
AnnotationStyle1.SelectedIndex = 1;
AnnotationStyle1.Enabled = true;
AnnotationStyle2.SelectedIndex = 1;
AnnotationStyle2.Visible = true;
StyleLabel1.Text = "Start Cap:";
StyleLabel2.Text = "End Cap:";
}
}
19
View Source File : LegendTitle.cs
License : MIT License
Project Creator : AngeloCresta
License : MIT License
Project Creator : AngeloCresta
private void Legendreplacedle_Load(object sender, System.EventArgs e)
{
this.tb_Text.Text = @"Chart Control";
this.cb_Color.SelectedIndex = 0;
foreach(string sepTypes in Enum.GetNames(typeof(LegendSeparatorStyle)))
{
this.cb_Separator.Items.Add(sepTypes);
}
foreach(string alignmentTypes in Enum.GetNames(typeof(StringAlignment)))
{
this.cb_Alignment.Items.Add(alignmentTypes);
}
this.cb_Separator.SelectedIndex = 3;
this.cb_SeparatorColor.SelectedIndex = 0;
this.cb_Alignment.SelectedIndex = 1;
this.cb_Docking.SelectedIndex = 2;
}
19
View Source File : MultilpleTitles.cs
License : MIT License
Project Creator : AngeloCresta
License : MIT License
Project Creator : AngeloCresta
private void Multiplereplacedles_Load(object sender, System.EventArgs e)
{
this.Alignment.Items.Add( "Near" );
this.Alignment.Items.Add( "Center" );
this.Alignment.Items.Add( "Far" );
this.Alignment.SelectedIndex = 1;
foreach( string docking in Enum.GetNames(typeof(System.Windows.Forms.DataVisualization.Charting.Docking)))
{
this.Docking.Items.Add( docking );
}
this.Docking.SelectedIndex = 3;
initialized = true;
}
19
View Source File : CursorAppearance.cs
License : MIT License
Project Creator : AngeloCresta
License : MIT License
Project Creator : AngeloCresta
private void CursorAppearance_Load(object sender, System.EventArgs e)
{
foreach(string lineName in Enum.GetNames(typeof(System.Windows.Forms.DataVisualization.Charting.ChartDashStyle)))
{
this.XLineDashStyle.Items.Add(lineName);
this.YLineDashStyle.Items.Add(lineName);
}
this.XLineDashStyle.SelectedIndex = 5;
this.YLineDashStyle.SelectedIndex = 5;
foreach(String colorName in KnownColor.GetNames(typeof(KnownColor)))
{
this.XLineColor.Items.Add(colorName);
this.YLineColor.Items.Add(colorName);
this.SelectionColor.Items.Add(colorName);
}
this.XLineSize.SelectedIndex = 0;
this.XLineColor.SelectedIndex = this.XLineColor.Items.IndexOf("Black");
this.YLineSize.SelectedIndex = 0;
this.YLineColor.SelectedIndex = this.XLineColor.Items.IndexOf("Black");
this.SelectionColor.SelectedIndex = this.XLineColor.Items.IndexOf("Highlight");
Axis axisX = Chart1.ChartAreas["Default"].AxisX;
CustomLabel label = null;
label = axisX.CustomLabels.Add(Math.PI - Math.PI / 5, Math.PI + Math.PI / 5, "pi");
label.GridTicks = GridTickTypes.All;
label = axisX.CustomLabels.Add(2 * Math.PI - Math.PI / 5, 2 * Math.PI + Math.PI / 5, "2pi");
label.GridTicks = GridTickTypes.All;
label = axisX.CustomLabels.Add(3 * Math.PI - Math.PI / 5, 3 * Math.PI + Math.PI / 5, "3pi");
label.GridTicks = GridTickTypes.All;
double t;
for(t = 0; t <= (7 * Math.PI / 2); t += Math.PI/6)
{
double ch1 = Math.Sin(t);
Chart1.Series["Default"].Points.AddXY(t, ch1);
}
Chart1.ChartAreas["Default"].CursorX.Position = Math.PI / 2;
Chart1.ChartAreas["Default"].CursorY.Position = -1.0;
}
See More Examples