protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Config config = new Config(); try { config.LoadWithoutEvent(); } catch { } if (config.FirstTimeStarted) { SplashView splash = new SplashView(); splash.IsVisibleChanged += splash_IsVisibleChanged; splash.Show(); } else { StartMain(config.IsTradingPostDataProvider); } }
//private void CheckItemSell(HotItem item) //{ // if (item.Notify && DateTime.Now > item.AcceptTime + item.TimeOut) // { // item.UpdatePrices(); // if (item.BuyPrice > item.UnitPrice) // { // MainWindow.Dispatcher.BeginInvoke((Action)delegate // { // var model = // new NotificationModel(item, // new NotifierRule(item, RuleType.Higher, item.UnitPrice, ContextType.Other, null), "Higher", DateTime.Now, NotificationType.Buy); // NotifiactionViewModel.AddBuyNotification(model); // NotifiactionViewModel.ShowOnNotifiaction(); // }); // } // } //} //private void CheckItemBuy(HotItem item) //{ // if (item.Notify && DateTime.Now > item.AcceptTime + item.TimeOut) // { // item.UpdatePrices(); // if (item.SellPrice < item.UnitPrice) // { // MainWindow.Dispatcher.BeginInvoke((Action)delegate // { // var model = // new NotificationModel(item, // new NotifierRule(item, RuleType.Less, item.UnitPrice, ContextType.Other, null), "Less", DateTime.Now, NotificationType.Sell); // NotifiactionViewModel.AddBuyNotification(model); // NotifiactionViewModel.ShowOnNotifiaction(); // }); // } // } //} //private void Worker(object state) //{ // try // { // while (IsRunning) // { // RefreshTransactions(); // for (int i = 0; i < BuyingViewModel.Items.Count; i++) // { // HotItem item = BuyingViewModel.Items[i]; // CheckItemSell(item); // foreach (var it in item.Items) // { // CheckItemSell(it); // } // } // for (int i = 0; i < SellingViewModel.Items.Count; i++) // { // HotItem item = SellingViewModel.Items[i]; // CheckItemBuy(item); // foreach (var it in item.Items) // { // CheckItemBuy(it); // } // } // Thread.Sleep(random.Next(HotItemController.CurrentApi.WorkerTransactionTimeOut - 500, HotItemController.CurrentApi.WorkerTransactionTimeOut + 500)); // } // } // catch (ThreadInterruptedException) // { // IsRunning = false; // } //} private void LoadConfig() { Config = new Config(); try { Config.Load(); } catch { Config.Save(); } foreach (HotItem item in Config.Items) { AddItemInternal(item); item.BuyContext.Item = item; // XML Loading item.SellContext.Item = item;// XML Loading item.MarginContext.Item = item; foreach (NotifierRule r in item.BuyContext.Rules) { r.Item = item; item.BuyContext.ActivateEventHandler(r); } foreach (NotifierRule r in item.SellContext.Rules) { r.Item = item; item.SellContext.ActivateEventHandler(r); } foreach (NotifierRule r in item.MarginContext.Rules) { r.Item = item; item.MarginContext.ActivateEventHandler(r); } } HotItemController.Gem.LoadConfig(Config); SettingsViewModel.ChangeLanguage(Config.LanguageKey); }
void Config_Loading(object sender, EventArgs e) { this.Config = (Config)sender; LoadColumns(); }
public void LoadConfig(Config config) { BuyGemsRules.Rules = config.RulesBuyGems; BuyGoldRules.Rules = config.RulesBuyGold; BuyGemsRules.ActivateEventHandler(); BuyGoldRules.ActivateEventHandler(); }