static void Main(string[] args) { string str = ""; bool stop = false; var debounceDispatcher = new DebounceDispatcher(1000); do { var key = Console.ReadKey(true); //trigger when to stop and exit if (key.Key == ConsoleKey.Escape) { stop = true; } str += key.KeyChar; //every keypress iteration call dispatcher but the Action will be invoked only after stop pressing and waiting 1000 milliseconds debounceDispatcher.Debounce(() => { Console.WriteLine($"{str} - {DateTime.UtcNow.ToString("hh:mm:ss.fff")}"); str = ""; }); }while (!stop); //wait trigger to stop and exit }
void Start() { debounceDispatcher = new DebounceDispatcher(1000); TypeEventSystem.Register <FileDragIn>((fileDragIn) => { var path = fileDragIn.Path; System.IO.FileInfo file = new System.IO.FileInfo(path); if (file.Extension == ".csb") { Paths = GetPaths(); } else if (file.Extension == ".png") { RefreshItems(); } }); TypeEventSystem.Register <DeleteItem>((t) => { if (t.Extension == ".csb") { Paths = GetPaths(); RefreshItems(); } }); }
public CanvasOverlaySvc(CanvasView canvasView) { _canvasView = canvasView; _redrawDispatcher = new DebounceDispatcher(); _shapes = new ConcurrentDictionary <string, BaseShape>(); _canvasViewModel = _canvasView.DataContext as CanvasViewModel; _canvasView.SizeChanged += CanvasViewSizeChanged; _redrawCts = new CancellationTokenSource(); _redrawTask = Task.Run(RedrawTask); }
public AsyncDataListBox(Func <string, Task <IEnumerable <Option> > > queryOptions, Func <object, Task <Option> > findOption = null, int debounceInterval = 250, string placeholder = "Search") { _debounceDispatcher = new DebounceDispatcher(debounceInterval); this.SetClass("async-data-list-box"); _queryOptions = queryOptions; _findOption = findOption; _loadingDiv.SetClass("async-data-list-box--loading"); _textBox.HtmlElement["list"] = _dataList.HtmlElement.ID; _textBox.HtmlElement["autocomplete"] = "off"; _textBox.HtmlElement["spellcheck"] = "false"; _textBox.HtmlElement["placeholder"] = placeholder; _textBox.TextInput += (sender, args) => OnTextInput(); VisualTree.Add(_loadingDiv); VisualTree.Add(_textBox); VisualTree.Add(_dataList); _loadingDiv.SetVisibility(false); }
public MainViewModel() { RefreshCommand = new RelayCommand(() => RaisePropertyChanged(nameof(CommonItems))); ClearBmCommand = new RelayCommand(ClearBm); ClearItemBmCommand = new RelayCommand <CommonItem>(ClearItemBm); ClearItemCommand = new RelayCommand <CommonItem>(ClearItem); OpenItemCommand = new RelayCommand <CommonItem>(OpenItem); Tirs = Enumerable.Repeat(new Tuple <string, int?>("-", null), 1) .Concat(Enumerable.Range(1, 8).Select(x => Tuple.Create(x.ToString(), (int?)x))); Enchants = Enumerable.Repeat(new Tuple <string, int?>("-", null), 1) .Concat(Enumerable.Range(0, 4).Select(x => Tuple.Create(x.ToString(), (int?)x))); Qualities = Enumerable.Repeat(new Tuple <string, int?>("-", null), 1) .Concat(Enumerable.Range(1, 5).Select(x => Tuple.Create(x.ToString(), (int?)x))); ShopCategories = Enumerable.Repeat(new Tuple <string, ShopCategory?>("-", null), 1).Concat(Enum .GetValues(typeof(ShopCategory)).Cast <ShopCategory?>() .Select(x => Tuple.Create(x.Value.ToString(), x))); ShopSubCategories = Enumerable.Repeat(new Tuple <string, ShopSubCategory?>("-", null), 1) .Concat(Enum.GetValues(typeof(ShopSubCategory)).Cast <ShopSubCategory?>() .Select(x => Tuple.Create(x.Value.ToString(), x))); BuyTownManager = new TownManager(); SellTownManager = new TownManager(); CraftTownManager = new TownManager(); AuctionTownManager = new TownManager(); _mdm = new MarketDataManager(); _bdm = new BuildingDataManager(CraftTownManager); var loader = new XmlLoader(_bdm, CraftTownManager, BuyTownManager, SellTownManager); loader.LoadModel(); Items = loader.Items.Values.Where(x => x.ShopSubCategory != Model.Items.Categories.ShopSubCategory.Event) .ToDictionary(k => k.Id + (k.QualityLevel > 1 ? $"_{k.QualityLevel}" : "")); LoadData(); Artefacts = loader.Artefacts; _debounceDispatcher = new DebounceDispatcher(); // foreach (var item in Items.Values) // { // item.PropertyChanged += (sender, args) => // { // //if (args.PropertyName == "Pos") // RefreshTree(); // }; // } BuildingsViewModel = new BuildingsViewModel(loader.CraftBuildings, CraftTownManager); _albionParser = new AlbionParser(); BuyTownManager.Town = Location.None; SellTownManager.Town = Location.None; CraftTownManager.Town = Location.None; AuctionTownManager.Town = Location.None; AuctionTownManager.TownChanged += p => { if (BuyTownManager.Town == Location.None) { BuyTownManager.Town = p.Town; } if (SellTownManager.Town == Location.None) { SellTownManager.Town = p.Town; } if (CraftTownManager.Town == Location.None) { CraftTownManager.Town = p.Town; } }; InitAlbionParser(); CostCalcOptions.Instance.ProfitsChanged += RefreshTree; CostCalcOptions.Instance.Changed += RefreshTree; }
protected override void OnInitialized() { debounceTimer = new(); }