using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Perforce.P4;
namespace DemoInstaller
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
grpUserDetails.Enabled = false;
}
private bool checkUser()
{
var svr = new P4Server(tbPort.Text, tbUser.Text, tbPassword.Text);
var caption = "Unity Demo Installer";
var result = false;
if (!svr.Connect())
{
MessageBox.Show("Can't connect to server - please check Port and User ID fields",
caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
return result;
}
if (!svr.checkUser())
{
MessageBox.Show("Error making user a superuser",
caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
return result;
}
if (!svr.updateTypemap())
{
MessageBox.Show("Error creating a typemap",
caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
return result;
}
MessageBox.Show("User is a superuser, typemap is configured.",
caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
result = true;
return result;
}
private void btnCheckUser_Click(object sender, EventArgs e)
{
if (checkUser())
{
grpUserDetails.Enabled = true;
}
}
}
}