Пример #1
0
        //private void DeleteConnection()
        //{
        //    var result = MessageBoxEx.Show(this, "Are you sure you want to delete this connection", "Block Studio", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

        //    if (result == DialogResult.Yes)
        //    {
        //        var selectedNode = (ConnectionNode)tvConnections.SelectedNode;
        //        var savedConnection = selectedNode.Connection;
        //        BlockStudioProjectService.RemoveSavedConnection(savedConnection);
        //        tvConnections.SelectedNode = null;
        //        tvConnections.Nodes.Remove(selectedNode);
        //    }
        //}


        private void LaunchInstanceMenuItem_Click(object sender, EventArgs e)
        {
            var getInstanceState = GethService.GetPortAndInstanceUse(BlockStudioProjectService.BlockStudioProject.Connection.RpcPort);

            if (getInstanceState == GethInstanceState.InstanceRunning)
            {
                MessageBoxEx.Show(this, string.Format("RpcPort {0} currently in use", BlockStudioProjectService.BlockStudioProject.Connection.RpcPort), "Block Studio", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            else
            {
                GethService.RunGethInstance(BlockStudioProjectService.BlockStudioProject.Connection);
            }
        }
Пример #2
0
        private void LoadProject()
        {
            if (BlockStudioProjectService.BlockStudioProject != null)
            {
                TreeNodeManager.RefreshProject();

                var runningPort = BlockStudioProjectService.BlockStudioProject.Connection.RpcPort;

                var gethInstanceState = GethService.GetPortAndInstanceUse(runningPort);
                if (gethInstanceState == GethInstanceState.NoInstanceRunning)
                {
                    // run geth
                    //GethService.RunGethInstance(BlockStudioProjectService.BlockStudioProject.Connection);
                    //Thread.Sleep(1000);
                    //AttemptConnection(TreeNodeManager.GetConnectionNode());
                    //connectionPanel1.BindControls();
                }

                tabControl1.Visible = true;
            }
        }
        private void TestConnection()
        {
            var savedConnection = (Connection)pgOptions.SelectedObject;

            if (savedConnection.ConnectionType == ConnectionType.Instance)
            {
                var getInstanceState = GethService.GetPortAndInstanceUse(savedConnection.RpcPort);
                if (getInstanceState == GethInstanceState.InstanceRunning)
                {
                    MessageBoxEx.Show(this, string.Format("RpcPort {0} currently in use", savedConnection.RpcPort), "Block Studio", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                }
                else
                {
                    GethService.RunGethInstance(savedConnection, true);
                }
            }
            else
            {
                var url             = savedConnection.Url;
                var port            = savedConnection.RpcPort;
                var ethereumService = new EthereumService(url, port);

                try
                {
                    var version = ethereumService.GetWeb3ClientVersion();
                    var result  = MessageBoxEx.Show(this, "_connection Successful", "Block Studio", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                }
                catch (Exception)
                {
                    var result = MessageBoxEx.Show(this, string.Format("Could not connect, is Ethereum running on port {0}?", savedConnection.RpcPort), "Block Studio", MessageBoxButtons.RetryCancel,
                                                   MessageBoxIcon.Error);

                    if (result == DialogResult.Retry)
                    {
                        TestConnection();
                    }
                }
            }
        }
        private void SetCommandLinePreview()
        {
            var command = GethService.GetCommandLineArgs(BlockStudioProjectService.BlockStudioProject.Connection);

            txtCommandLineArgs.Text = "geth " + command;
        }