private async void cloneButton_Click(object sender, EventArgs e)
        {
            var dialog = new TextFieldDialog("Cloned item profile", "Profile", data.ProfileName);
            var res    = dialog.ShowDialog();

            if (res != DialogResult.OK)
            {
                return;
            }
            var clonedItem = JsonConvert.DeserializeObject <LogLabel>(JsonConvert.SerializeObject(data));

            clonedItem._id         = Guid.NewGuid().ToString();
            clonedItem.ProfileName = dialog.Result;
            if (clonedItem.ProfileName == data.ProfileName)
            {
                clonedItem.Name += "_cloned";
            }
            await _controller.AddLabel(clonedItem);

            RaiseOnDataDirty();
        }
Exemple #2
0
        private void cbProfile_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbProfile.SelectedItem.ToString() == _selectedProfile)
            {
                return;//nothing changed
            }
            if (cbProfile.SelectedItem.ToString() == CREATE_NEW_PROFILE)
            {
                var form = new TextFieldDialog("Create new profile", "Profile name");
                var res  = form.ShowDialog();
                if (res == DialogResult.OK)
                {
                    string newProfile = form.Result;
                    if (string.IsNullOrEmpty(newProfile))
                    {
                        MessageBox.Show("Given name is null or empty");
                        SelectProfile(_selectedProfile);
                        return;
                    }
                    if (_profiles.Contains(newProfile))
                    {
                        MessageBox.Show("Such profile already exists");
                        SelectProfile(_selectedProfile);
                        return;
                    }
                    _selectedProfile    = newProfile;
                    _justCreatedProfile = newProfile;
                    RefreshDataInAdapter();
                }
                else
                {
                    SelectProfile(_selectedProfile);
                }
                return;
            }

            _selectedProfile = cbProfile.SelectedItem.ToString();
            RefreshDataInAdapter();
        }