Exemple #1
0
        public override void Add()
        {
            AddressForm.Address = new Domain.Entities.Address()
            {
                Id           = 0,
                CreateDate   = DateTime.Now,
                CreatedBy    = Dashboard.Username,
                LastUpdateBy = Dashboard.Username
            };

            AddressForm.Text = Resources.AddressFormStrings.TitleAdd;
            var result = AddressForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                var repository = UnitOfWork.Data.Addresses;

                var address = AddressForm.Address;

                address.CreateDate = address.CreateDate;

                repository.Insert(address);

                UnitOfWork.Data.Save();
            }

            RefreshAll();
        }
Exemple #2
0
        // Funkcja do tworzenia adresu odpala formularz do wypełnienia danych adresowych
        public AddressObject CreateAddress()
        {
            AddressObject addressObject = null;

            using (AddressForm addressForm = new AddressForm())
            {
                if (addressForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    addressObject = addressForm.AddressObj;
                }
            }

            return(addressObject);
        }
    /// <summary>
    /// We either want to start or stop searching
    /// </summary>
    private void btnSearch_Click(object sender, System.EventArgs e)
    {
        if (!isSearching)
        {
            if( hostAddress != null )
                hostAddress.Dispose();

            hostAddress = new Address();
            hostAddress.ServiceProvider = deviceAddress.ServiceProvider;

            // See if we should prompt the user for the remote address
            if (ConnectWizard.ProviderRequiresPort(hostAddress.ServiceProvider))
            {
                AddressForm addressDialog = new AddressForm(connectionWizard.DefaultPort);
                addressDialog.ShowDialog(this);

                // If the user cancelled the address form, abort the search
                if (addressDialog.DialogResult != DialogResult.OK)
                    return;

                // If a port was specified, add the component
                if (addressDialog.Hostname != "")
                    hostAddress.AddComponent(Address.KeyHostname, addressDialog.Hostname);

                // If a hostname was specified, add the component
                if (addressDialog.Port > 0)
                    hostAddress.AddComponent(Address.KeyPort, addressDialog.Port);
            }

            //Time to enum our hosts
            ApplicationDescription desc = new ApplicationDescription();
            desc.GuidApplication = connectionWizard.ApplicationGuid;

            // If the user was not already asked for address information, DirectPlay
            // should prompt with native UI
            FindHostsFlags flags = 0;
            if (!ConnectWizard.ProviderRequiresPort(deviceAddress.ServiceProvider))
                flags = FindHostsFlags.OkToQueryForAddressing;

            peer.FindHosts(desc,hostAddress,deviceAddress,null,Timeout.Infinite,0,Timeout.Infinite, flags, out findHostHandle);
            isSearching = true;
            btnCreate.Enabled = false;
            btnSearch.Text = "Stop Search";
        }
        else
        {
            btnSearch.Text = "Stopping...";
            btnSearch.Enabled = false;
            if (findHostHandle != 0)
                peer.CancelAsyncOperation(findHostHandle);
        }
    }
    /// <summary>
    /// We either want to start or stop searching
    /// </summary>
    private void btnSearch_Click(object sender, System.EventArgs e)
    {
        if (!isSearching)
        {
            if (hostAddress != null)
            {
                hostAddress.Dispose();
            }

            hostAddress = new Address();
            hostAddress.ServiceProvider = deviceAddress.ServiceProvider;

            // See if we should prompt the user for the remote address
            if (ConnectWizard.ProviderRequiresPort(hostAddress.ServiceProvider))
            {
                AddressForm addressDialog = new AddressForm(connectionWizard.DefaultPort);
                addressDialog.ShowDialog(this);

                // If the user cancelled the address form, abort the search
                if (addressDialog.DialogResult != DialogResult.OK)
                {
                    return;
                }

                // If a port was specified, add the component
                if (addressDialog.Hostname != "")
                {
                    hostAddress.AddComponent(Address.KeyHostname, addressDialog.Hostname);
                }

                // If a hostname was specified, add the component
                if (addressDialog.Port > 0)
                {
                    hostAddress.AddComponent(Address.KeyPort, addressDialog.Port);
                }
            }

            //Time to enum our hosts
            ApplicationDescription desc = new ApplicationDescription();
            desc.GuidApplication = connectionWizard.ApplicationGuid;

            // If the user was not already asked for address information, DirectPlay
            // should prompt with native UI
            FindHostsFlags flags = 0;
            if (!ConnectWizard.ProviderRequiresPort(deviceAddress.ServiceProvider))
            {
                flags = FindHostsFlags.OkToQueryForAddressing;
            }

            peer.FindHosts(desc, hostAddress, deviceAddress, null, Timeout.Infinite, 0, Timeout.Infinite, flags, out findHostHandle);
            isSearching       = true;
            btnCreate.Enabled = false;
            btnSearch.Text    = "Stop Search";
        }
        else
        {
            btnSearch.Text    = "Stopping...";
            btnSearch.Enabled = false;
            if (findHostHandle != 0)
            {
                peer.CancelAsyncOperation(findHostHandle);
            }
        }
    }