Exemple #1
0
        private void btnCopyToRight_Click(object sender, EventArgs e)
        {
            if (rightTreeView.SelectedNode == null)
            {
                MessageBox.Show("Select destination node in right window", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                return;
            }

            if (leftTreeView.SelectedNode == null)
            {
                MessageBox.Show("Select source node in left window", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                return;
            }

            /*
            IItem destItem = rightTreeView.SelectedNode.Tag as IItem;
            IItem srcItem = leftTreeView.SelectedNode.Tag as IItem;
            destItem.CopyTo(srcItem, true);
            */

            _srcItem = leftTreeView.SelectedNode.Tag as IItem;
            _destItem = rightTreeView.SelectedNode.Tag as IItem;
            _destinationNode = rightTreeView.SelectedNode;

            CopyOptions CopyOptionsForm = new CopyOptions();
            string[] sLanguages = _srcItem.GetLanguages();
            foreach (string sLang in sLanguages)
            {
                CopyOptionsForm.comboFromLanguage.Items.Add(sLang);
            }

            sLanguages = _destItem.GetLanguages();
            foreach (string sLang in sLanguages)
            {
                CopyOptionsForm.comboToLanguage.Items.Add(sLang);
            }
            CopyOptionsForm.comboToLanguage.SelectedIndex = 0;
            CopyOptionsForm.lblToPath.Text = "(" + new Uri(_destItem.GetHostUrl()).Host + ")" + _destItem.Path;

            // Setting this AFTER the destination, enables autoselect of correct destination language
            CopyOptionsForm.comboFromLanguage.SelectedIndex = 0;
            CopyOptionsForm.lblFromPath.Text = "(" + new Uri(_srcItem.GetHostUrl()).Host + ")" + _srcItem.Path;

            // Plugins
            CopyOptionsForm._itemCopyPlugins = _itemCopyPlugins;

            // Show Copyoptions
            if (CopyOptionsForm.ShowDialog(this) == DialogResult.Cancel)
                return;

            // Get copyOptions result
            _srcItem.Options.Language = CopyOptionsForm.comboFromLanguage.Text;
            _destItem.Options.Language = CopyOptionsForm.comboToLanguage.Text;
            _destItem.Options.CopyItem = CopyItem;
            if (CopyOptionsForm.rbOverwrite.Checked)
                _destItem.Options.CopyOperation = CopyOperations.Overwrite;
            else if (CopyOptionsForm.rbSkipExisting.Checked)
                _destItem.Options.CopyOperation = CopyOperations.SkipExisting;
            else if (CopyOptionsForm.rbCreateNewItemIDs.Checked)
                _destItem.Options.CopyOperation = CopyOperations.GenerateNewItemIDs;
            else if (CopyOptionsForm.rbUseNames.Checked)
                _destItem.Options.CopyOperation = CopyOperations.UseNames;
            _destItem.Options.RecursiveOperation = CopyOptionsForm.cbRecursive.Checked;

            //            _srcItem.Options.Database = CopyOptionsForm.tbFromDatabase.Text;
            //            _destItem.Options.Database = CopyOptionsForm.tbToDatabase.Text;

            // Security settings
            _srcItem.Options.CopySecuritySettings = CopyOptionsForm.cbCopySecurity.Checked;
            _destItem.Options.CopySecuritySettings = CopyOptionsForm.cbCopySecurity.Checked;
            _destItem.Options.DefaultSecurityDomain = CopyOptionsForm.tbSecurityDomain.Text;
            _destItem.Options.RootRole = CopyOptionsForm.tbRootRole.Text;
            _destItem.Options.SetItemRightsExplicitly = CopyOptionsForm.cbSetItemRightsExplicitly.Checked;

            Util.backgroundWorker.RunWorkerAsync(new BackgroundWorkerArgument("copy", null, null, this));

            _progressForm = new ProgressForm();
            _progressForm.ShowDialog(this);
        }