コード例 #1
0
        private void buttonConvertPartToCode_Click(object sender, EventArgs e)
        {
            var sendingData = (string)null;

            if (_selectedPartIndex != -1)
            {
                var part = LocalDataHolder.Part_Get(_selectedPartIndex);
                sendingData = part.Id.ToString();
                sendingData = JsonConvert.SerializeObject(part);
            }



            ObjectWrapper returnable = new ObjectWrapper();
            ObjectWrapper sendable   = new ObjectWrapper(sendingData);

            var hexagonShowForm = new HexagonShowForm(returnable, sendable);
            var thr             = new Thread(() => { Application.Run(hexagonShowForm); });

            thr.SetApartmentState(ApartmentState.STA);
            thr.Start();
            this.Visible = false;
            while (!hexagonShowForm.IsDisposed)
            {
                Thread.Sleep(10);
            }

            this.Visible = true;
        }
コード例 #2
0
        private void buttonPutOne_Click(object sender, EventArgs e)
        {
            var part = LocalDataHolder.Part_Get(_selectedPartIndex);

            part.PushOne();
            FillPart(part);
        }
コード例 #3
0
        private void buttonTakePart_Click(object sender, EventArgs e)
        {
            var part = LocalDataHolder.Part_Get(_selectedPartIndex);

            try
            {
                part.TakeOne();
                MessageBox.Show("Successfully Taken One");
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to Take One");
            }

            FillPart(part);
        }
コード例 #4
0
        private void buttonUpdatePart_Click(object sender, EventArgs e)
        {
            if (!_editingPart)
            {
                if (_selectedPartIndex == -1)
                {
                    MessageBox.Show("Select Part");
                    return;
                }

                try
                {
                    var part = LocalDataHolder.Part_Get(_selectedPartIndex);
                    FillPart(part);
                }
                catch (IndexOutOfRangeException)
                {
                    MessageBox.Show("No Local Part With Index " + _selectedPartIndex + " Known");
                }

                buttonUpdatePart.Text           = "Save";
                buttonInsertPart.Enabled        = false;
                buttonCancelEditingPart.Enabled = true;
                _editingPart           = true;
                buttonPutPart.Enabled  = true;
                buttonTakePart.Enabled = true;
            }
            else
            {
                var id = int.Parse(textBoxPartId.Text);

                var countryId = LocalDataHolder.Country_Get(comboBoxPartCountry.SelectedIndex).Id;

                var manufacturerId = LocalDataHolder.Manufacturer_Get(comboBoxPartManufacturer.SelectedIndex).Id;

                var name = textBoxPartName.Text;

                string technicalData = "";

                try
                {
                    var technicalDataJson = JToken.Parse(richTextBoxPartTechnicalData.Text);
                    technicalData = technicalDataJson.ToString(Formatting.None);
                }
                catch (Exception)
                {
                    MessageBox.Show("Error Parsing Technical Data JSON");
                    return;
                }

                var lifetime = int.Parse(textBoxPartLifetime.Text);

                var count = int.Parse(textBoxPartCount.Text);

                var part = new Part(id, countryId, manufacturerId, name, technicalData, lifetime, count);

                LocalDataHolder.Part_Update(part);

                ClearPartFields();

                FillData();

                buttonUpdatePart.Text           = "Update";
                buttonInsertPart.Enabled        = true;
                buttonCancelEditingPart.Enabled = false;
                _editingPart = false;

                buttonPutPart.Enabled  = false;
                buttonTakePart.Enabled = false;
            }
        }