Esempio n. 1
0
        private void loadPreset_Click(object sender, EventArgs e)
        {
            ToolStripDropDownItem tsi = sender as ToolStripDropDownItem;

            if (tsi != null)
            {
                string name = tsi.Text;

                MODEL m = ModelBase.CloneModel(Settings.Default.PresetModels.GetPresetModel <MODEL>(name));

                SetModel(m);
            }
        }
Esempio n. 2
0
        private void savePreset_Click(object sender, EventArgs e)
        {
            InputBox f = new InputBox("Save preset", "What's the name for the new preset", "");

            if (f.ShowDialog(this.FindForm()) == DialogResult.OK)
            {
                string name = f.Input.Trim();
                if (name == "")
                {
                    return;
                }

                //search the current focused control
                Queue <Control> queue = new Queue <Control>();
                queue.Enqueue(this);
                while (queue.Count > 0)
                {
                    Control c = queue.Dequeue();
                    if (c.Focused)
                    {
                        ForceValidation(c);
                        break;
                    }

                    foreach (Control c2 in c.Controls)
                    {
                        queue.Enqueue(c2);
                    }
                }

                MODEL m = ModelBase.CloneModel(GetModel());
                Settings.Default.PresetModels.AddPresetModel(name, m);
                if (!presetList.Contains(name))
                {
                    presetList.Add(name);
                    presetList.Sort();
                }
                BuildMenu();
            }
        }
Esempio n. 3
0
        private void addMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem tsi = sender as ToolStripItem;

            if (tsi != null)
            {
                AvailableModule module = (AvailableModule)tsi.Tag;

                // create a model for this module
                // i use the view to create the model, if it has a default model we get this one
                PresetableViewBase view = module.CreateNewView();
                view.PreInit();
                ModelBase m = ModelBase.CloneModel(view.GetModelBase());

//                // see https://trac.irgendwie.net/PhotoTagStudio/ticket/72
//                // special for rename and copyMove - only on of them in every macro
//                if (m is RenameModel || m is CopyMoveModel)
//                {
//                    // check if there is already on of these
//                    foreach (ListViewItem l in this.listItems.Items)
//                        if (l.Tag is RenameModel || l.Tag is CopyMoveModel)
//                        {
//                            MessageBox.Show("You cannot add more than one of Renamer and Copy/Move to each macro. It makes simply no sense...",
//                                "Execute PhotoTagStudio Macro", MessageBoxButtons.OK, MessageBoxIcon.Information);
//                            return; //do not add
//                        }
//                }

                ListViewItem lvi = new ListViewItem(module.Name);
                lvi.Tag = m;
                this.listItems.Items.Add(lvi);

                this.listItems.SelectedItems.Clear();
                lvi.Selected = true;
            }
        }