Esempio n. 1
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listItems.SelectedItems.Count == 0)
            {
                this.Cursor = Cursors.WaitCursor;
                this.viewPanel.Controls.Clear();
                this.Cursor = Cursors.Default;
                return;
            }

            this.Cursor = Cursors.WaitCursor;

            ListViewItem lvi = listItems.SelectedItems[0];

            ModelBase          model       = (ModelBase)lvi.Tag;
            Type               typeOfModel = model.GetType();
            PresetableViewBase view        = null;

            foreach (KeyValuePair <string, AvailableModule> availableModule in AvailableModules)
            {
                if (availableModule.Value.Model == typeOfModel)
                {
                    view = availableModule.Value.CreateNewView();
                    break;
                }
            }

            viewPanel.Controls.Clear();
            if (view != null)
            {
                viewPanel.Controls.Add(view);
                view.Dock = DockStyle.Fill;
                view.PreInitMacroMode();

                view.SetModelBase(model);
            }

            this.Cursor = Cursors.Default;
        }
Esempio n. 2
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;
            }
        }