Exemplo n.º 1
0
        private void OnSave()
        {
            saveButton.Enabled = false;
            ProtocolElementModel newModel = new ProtocolElementModel
            {
                ID    = idTextBox.Text,
                Name  = nameTextBox.Text,
                Value = valueTextBox.Text
            };

            protocolElements[protocolList.SelectedIndex] = newModel;
        }
Exemplo n.º 2
0
        private void OnAddElement(ProtocolElementModel protocol)
        {
            protocolList.Items.Add(protocol.ID);
            protocolList.SelectedIndex = protocolList.Items.Count - 1;

            idTextBox.Text    = protocol.ID;
            nameTextBox.Text  = protocol.Name;
            valueTextBox.Text = protocol.Value;

            createButton.Enabled         = protocolList.Items.Count != 0;
            saveToFileButton.Enabled     = protocolList.Items.Count != 0;
            saveToFileButton.ToolTipText = !saveToFileButton.Enabled ? "Нельзя сохранять пустой файл." : string.Empty;
            mergeAllBtn.Enabled          = protocolList.Items.Count > 1;
        }
Exemplo n.º 3
0
        private void ElemenetsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
            {
                ProtocolElementModel protocol = e.NewItems[0] as ProtocolElementModel;
                if (InvokeRequired)
                {
                    Invoke(new Action(() => OnAddElement(protocol)));
                    return;
                }
                else
                {
                    OnAddElement(protocol);
                    return;
                }
            }

            case NotifyCollectionChangedAction.Remove:
            {
                protocolList.Items.RemoveAt(protocolList.SelectedIndex);
            }
            break;

            case NotifyCollectionChangedAction.Replace:
            {
                ProtocolElementModel protocol = e.NewItems[0] as ProtocolElementModel;
                protocolList.Items[protocolList.SelectedIndex] = protocol.ID;

                idTextBox.Text    = protocol.ID;
                nameTextBox.Text  = protocol.Name;
                valueTextBox.Text = protocol.Value;
            }
            break;

            case NotifyCollectionChangedAction.Reset:
            {
                protocolList.Items.Clear();

                idTextBox.Clear();
                nameTextBox.Clear();
                valueTextBox.Clear();
            }
            break;
            }
            createButton.Enabled         = protocolList.Items.Count != 0;
            saveToFileButton.Enabled     = protocolList.Items.Count != 0;
            saveToFileButton.ToolTipText = !saveToFileButton.Enabled ? "Нельзя сохранять пустой файл." : string.Empty;
        }
Exemplo n.º 4
0
        private void MergeAllBtn_Click(object sender, EventArgs e)
        {
            ProtocolElementModel model = new ProtocolElementModel {
                ID = "Diagnosis"
            };
            string value = string.Empty;

            foreach (var item in protocolElements)
            {
                value += item.Name + item.Value + "\\r\\n";
            }
            model.Value = value.Remove(value.LastIndexOf("\\r\\n"));
            protocolElements.Clear();
            protocolElements.Add(model);
        }
Exemplo n.º 5
0
        private void OnAdd()
        {
            ProtocolElementModel model = new ProtocolElementModel();

            protocolElements.Add(model);
        }