コード例 #1
0
        /// <summary>
        /// Handle the application shutting down.
        /// </summary>
        /// <param name="sender">
        /// The event sender.
        /// </param>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        private void OnExit(object sender, ExitEventArgs e)
        {
            // Free up all our view models
            foreach (Window window in Windows)
            {
                IDisposable disposable = window.DataContext as IDisposable;
                if (disposable == null)
                {
                    continue;
                }
                try
                {
                    disposable.Dispose();
                }
                catch (Exception ex)
                {
                    Logger.ApplicationInstance.Error("Failed to free up view model " + disposable.GetType().Name + " for window " + window.GetType().Name, ex);
                }
            }

            // Free up our ethereum manager
            try
            {
                _ethereumManager?.Dispose();
            }
            catch (Exception ex)
            {
                Logger.ApplicationInstance.Error("Failed to free up ethereum manager", ex);
            }
            _ethereumManager = null;
        }
コード例 #2
0
 /// <summary>
 /// Create a new instance of this class.
 /// </summary>
 /// <param name="ethereumManager">
 /// The ethereum manager that this view model uses to obtain information.
 /// </param>
 protected BaseViewModel(EthereumManager ethereumManager)
 {
     ExitCommand      = new DelegateCommand(Exit);
     LogViewCommand   = new DelegateCommand(LogView);
     IsUiEnabled      = true;
     _ethereumManager = ethereumManager;
 }
コード例 #3
0
        /// <summary>
        /// Handle the application terminating.
        /// </summary>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        protected override void OnExit(ExitEventArgs e)
        {
            // Free any resources we are using
            _ethereumManager?.Dispose();
            _ethereumManager = null;

            // Call to base
            base.OnExit(e);
        }
コード例 #4
0
        /// <summary>
        /// Create a new instance of this class.
        /// </summary>
        /// <param name="ethereumManager">
        /// The ethereum manager that this view model uses to obtain information.
        /// </param>
        public SplashScreenViewModel(EthereumManager ethereumManager)
            : base(ethereumManager)
        {
            // Setup defaults
            StatusText = MessageConnecting;

            // Start our thread that waits for ethereum network contact to have been established
            _thread = new Thread(ThreadEntry)
            {
                IsBackground = true, Name = "Startup Ethereum Monitoring"
            };
            _isAlive = true;
            _thread.Start();
        }
コード例 #5
0
        /// <summary>
        /// Create a new instance of htis class.
        /// </summary>
        public SiftApp()
        {
            // Create our ethereum manager thread that the UI will need
            string url = null;

            try
            {
                string value = ConfigurationManager.AppSettings["Lts.Sift.WinClient.EthereumRpcUrl"];
            }
            catch (Exception ex)
            {
                Logger.ApplicationInstance.Error("Error parsing value for ethereum URL, will use default", ex);
            }
            _ethereumManager = new EthereumManager(string.IsNullOrEmpty(url) ? "http://localhost:8545/" : url);

            // Hookup to events
            Exit += OnExit;
        }
コード例 #6
0
        /// <summary>
        /// Create a new instance of this class.
        /// </summary>
        /// <param name="ethereumManager">
        /// The ethereum manager that this view model uses to obtain information.
        /// </param>
        public IcoViewModel(EthereumManager ethereumManager)
            : base(ethereumManager)
        {
            if (Accounts.Count > 0)
            {
                SelectedAccount = Accounts[0];
            }
            _ethereumManager.Accounts.CollectionChanged += OnAccountsChanged;
            _ethereumManager.PropertyChanged            += OnEthereumManagerPropertyChanged;
            IsAccountSelectionVisible   = Accounts.Count != 1;
            SiftInvestCommand           = new AwaitableDelegateCommand(Invest);
            SiftIncreaseQuantityCommand = new DelegateCommand(() => { SiftAmountToPurchase++; });
            SiftDecreaseQuantityCommand = new DelegateCommand(() => { SiftAmountToPurchase--; });

            // Create a timer to wait for ICO to open
            _icoOpenTimer = new Timer(1000)
            {
                AutoReset = true,
                Enabled   = true
            };
            _icoOpenTimer.Elapsed += OnIcoIsOpenTimer;
        }