mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-21 16:12:18 -05:00
49 lines
920 B
C#
49 lines
920 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ColorControl
|
|
{
|
|
internal abstract class PresetBase
|
|
{
|
|
public string shortcut { get; set; }
|
|
|
|
private int _id;
|
|
|
|
public int id
|
|
{
|
|
get
|
|
{
|
|
return _id;
|
|
}
|
|
set
|
|
{
|
|
if (value == 0 || ids.Contains(value))
|
|
{
|
|
value = GetNewId();
|
|
}
|
|
else
|
|
{
|
|
ids.Add(value);
|
|
}
|
|
_id = value;
|
|
}
|
|
}
|
|
|
|
public static List<int> ids = new List<int>();
|
|
|
|
public static int GetNewId()
|
|
{
|
|
int id;
|
|
do
|
|
{
|
|
id = new Random().Next();
|
|
}
|
|
while (ids.Contains(id));
|
|
|
|
ids.Add(id);
|
|
|
|
return id;
|
|
}
|
|
|
|
}
|
|
} |