Пример #1
0
        public static void Initialize(MainForm mainForm)
        {
            MainForm = mainForm;

            SettingsManager.Initialize();
            CultureManager.Initialize();

            var defaultFont = new Font(SystemFont.Default);

            DefaultFontSize   = defaultFont.Size;
            DefaultFontFamily = defaultFont.Family;

            FontSize1 = (byte)Math.Round(DefaultFontSize * 1.11);
            FontSize2 = (byte)Math.Round(DefaultFontSize * 1.33);
            FontSize3 = (byte)Math.Round(DefaultFontSize * 2.22);

            using (var button = new Button()) {
                var handler = button.Handler;

                var fieldInfo = handler.GetType().GetField("MinimumSize");
                if (fieldInfo != null)
                {
                    var size = (Size)(fieldInfo.GetValue(null));
                    size.Width = 0;
                    fieldInfo.SetValue(null, size);
                }
                else
                {
                    fieldInfo = handler.GetType().GetField("MinimumWidth");
                    if (fieldInfo != null)
                    {
                        fieldInfo.SetValue(null, 0);
                    }
                }
            }

            var storedPathSettings    = SettingsManager.Paths;
            var daemonProcessSettings = new DaemonProcessSettings {
                SoftwareDaemon      = GetAbsolutePath(storedPathSettings.SoftwareDaemon),
                DirectoryDaemonData = GetAbsolutePath(storedPathSettings.DirectoryDaemonData),
            };
            var accountManagerProcessSettings = new AccountManagerProcessSettings {
                SoftwareAccountManager  = GetAbsolutePath(storedPathSettings.SoftwareAccountManager),
                DirectoryAccountBackups = GetAbsolutePath(storedPathSettings.DirectoryAccountBackups),
                FileAccountData         = GetAbsolutePath(storedPathSettings.FileAccountData),
            };

            var storedNetworkSettings = SettingsManager.Network;
            var rpcSettings           = new RpcSettings(
                storedNetworkSettings.RpcUrlHostDaemon,
                storedNetworkSettings.RpcUrlPortDaemon,
                storedNetworkSettings.RpcUrlHostAccountManager,
                storedNetworkSettings.RpcUrlPortAccountManager
                );

            if (storedNetworkSettings.IsProxyEnabled)
            {
                if (!string.IsNullOrEmpty(storedNetworkSettings.ProxyHost))
                {
                    rpcSettings.Proxy = new WebProxy(storedNetworkSettings.ProxyHost, storedNetworkSettings.ProxyPort);
                }
            }

            MoneroProcessManager = new MoneroProcessManager(rpcSettings, accountManagerProcessSettings, daemonProcessSettings);
            MoneroRpcManager     = new MoneroRpcManager(rpcSettings);

            DataSourceAddressBook = new ObservableCollection <SettingsManager.ConfigElementContact>(SettingsManager.AddressBook.Elements);
            DataSourceAddressBook.CollectionChanged += OnDataSourceAddressBookCollectionChanged;
        }
Пример #2
0
        static void StartDemo()
        {
            // Assign a new instance of the process manager to a variable
            MoneroProcessManager = new MoneroProcessManager(
                Config.ClientRpcSettings,
                Config.ClientAccountManagerProcessSettings,
                Config.ClientDaemonProcessSettings
                );

            // Assign a new instance of the RPC manager to a variable
            MoneroRpcManager = new MoneroRpcManager(
                Config.ClientRpcSettings,
                Config.ClientTimerSettings
                );

            // First, declare event handlers for the daemon
            var daemonRpc = MoneroRpcManager.Daemon;

            daemonRpc.NetworkInformationChanged += OnDaemonNetworkInformationChanged;
            daemonRpc.BlockchainSynced          += OnDaemonBlockchainSynced;

            // Optionally, declare event handlers for the account manager
            var accountManagerRpc = MoneroRpcManager.AccountManager;

            accountManagerRpc.Initialized         += OnAccountManagerRpcInitialized;
            accountManagerRpc.AddressReceived     += OnAccountManagerAddressReceived;
            accountManagerRpc.TransactionReceived += OnAccountManagerTransactionReceived;
            accountManagerRpc.BalanceChanged      += OnAccountManagerBalanceChanged;

            if (Config.IsDaemonProcessRemote)
            {
                // Daemon RPC functions will not be available if the line below is commented out
                daemonRpc.Initialize();
            }
            else
            {
                // Initialize the daemon RPC manager as soon as the corresponding process is available
                var daemonProcess = MoneroProcessManager.Daemon;
                daemonProcess.Initialized += delegate {
                    // Daemon RPC functions will not be available if the line below is commented out
                    daemonRpc.Initialize();
                };
                daemonProcess.Start();
            }

            if (Config.IsAccountManagerProcessRemote)
            {
                // The account manager's RPC functions will not be available if the line below is commented out
                accountManagerRpc.Initialize();
            }
            else
            {
                // Initialize the account manager's RPC wrapper as soon as the corresponding process is available
                var accountManagerProcess = MoneroProcessManager.AccountManager;
                accountManagerProcess.Initialized += delegate {
                    // The account manager's RPC functions will not be available if the line below is commented out
                    accountManagerRpc.Initialize();
                };
                accountManagerProcess.PassphraseRequested += delegate {
                    accountManagerProcess.Passphrase = "x";
                };
                accountManagerProcess.Start();
            }
        }