コード例 #1
0
        public static void PasteDemo()
        {
            #region radspreadsheet-clipboard-support_1
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            worksheet.Cells[0, 0].SetValue("=CONCATENATE(\"Rad\", \"Spreadsheet\")");
            worksheet.Cells[0, 0].SetForeColor(new ThemableColor(Colors.Green));

            WorksheetFragment worksheetFragment = worksheet.Cells[0, 0].Copy();

            PasteOptions pasteOptions = new PasteOptions(PasteType.All);
            worksheet.Cells[1, 0].Paste(worksheetFragment, pasteOptions);
            #endregion

            #region radspreadsheet-clipboard-support_2
            PasteOptions pasteOptionsValues = new PasteOptions(PasteType.Values);
            worksheet.Cells[2, 0].Paste(worksheetFragment, pasteOptionsValues);
            #endregion

            #region radspreadsheet-clipboard-support_3
            PasteOptions valuesAndFormatting = new PasteOptions(PasteType.Formulas | PasteType.Formats);
            worksheet.Cells[3, 0].Paste(worksheetFragment, valuesAndFormatting);
            #endregion
        }
コード例 #2
0
 // Geometry pasted
 public override void OnPasteEnd(PasteOptions options)
 {
     if (tagExplorer != null)
     {
         tagExplorer.UpdateTreeSoon();
     }
 }
コード例 #3
0
ファイル: BuilderPlug.cs プロジェクト: 3dfxdev/3DGE_Builder
 // Geometry pasted
 public override void OnPasteEnd(PasteOptions options)
 {
     if (dockerpanel != null)
     {
         dockerpanel.UpdateListSoon();
     }
 }
コード例 #4
0
        // This pastes a prefab. Returns false when paste was cancelled.
        public void InsertPrefabStream(Stream stream, PasteOptions options)
        {
            // Cancel volatile mode
            General.Editing.DisengageVolatileMode();

            // Let the plugins know
            if (General.Plugins.OnPasteBegin(options))
            {
                // Ask the editing mode to prepare selection for pasting.
                if (General.Editing.Mode.OnPasteBegin(options))
                {
                    Cursor oldcursor = Cursor.Current;
                    Cursor.Current = Cursors.WaitCursor;

                    if (stream != null)
                    {
                        PastePrefab(stream, options);
                    }

                    General.MainWindow.UpdateInterface();

                    Cursor.Current = oldcursor;
                }
            }
        }
コード例 #5
0
 public void OnPasteEnd(PasteOptions options)
 {
     foreach (Plugin p in plugins)
     {
         p.Plug.OnPasteEnd(options.Copy());
     }
 }
コード例 #6
0
        // Constructor
        public PasteOptionsForm()
        {
            InitializeComponent();

            // Get defaults
            options = General.Settings.PasteOptions.Copy();
            pasteoptions.Setup(options);
        }
コード例 #7
0
 // This sets the options from the given PasteOptions
 public void Setup(PasteOptions options)
 {
     // Setup controls
     keeptags.Checked      = (options.ChangeTags == 0);
     renumbertags.Checked  = (options.ChangeTags == 1);
     removetags.Checked    = (options.ChangeTags == 2);
     removeactions.Checked = options.RemoveActions;
 }
コード例 #8
0
 // This sets the options from the given PasteOptions
 public void Setup(PasteOptions options)
 {
     // Setup controls
     keeptags.Checked      = (options.ChangeTags == 0);
     renumbertags.Checked  = (options.ChangeTags == 1);
     removetags.Checked    = (options.ChangeTags == 2);
     adjustheights.Checked = options.AdjustHeights;
 }
コード例 #9
0
        public void InsertPreviousPrefab()
        {
            PasteOptions options = General.Settings.PasteOptions.Copy();

            // Is there a previously inserted prefab?
            if (IsPreviousPrefabAvailable)
            {
                // Does the file still exist?
                if (File.Exists(lastprefabfile))
                {
                    // Cancel volatile mode
                    General.Editing.DisengageVolatileMode();

                    // Let the plugins know
                    if (General.Plugins.OnPasteBegin(options))
                    {
                        // Ask the editing mode to prepare selection for pasting.
                        if (General.Editing.Mode.OnPasteBegin(options))
                        {
                            Cursor     oldcursor = Cursor.Current;
                            FileStream stream    = null;

                            try
                            {
                                Cursor.Current = Cursors.WaitCursor;
                                stream         = File.OpenRead(lastprefabfile);
                            }
                            catch (Exception e)
                            {
                                Cursor.Current = oldcursor;
                                General.ErrorLogger.Add(ErrorType.Error, e.GetType().Name + " while reading prefab from file: " + e.Message);
                                General.WriteLog(e.StackTrace);
                                General.ShowErrorMessage("Error while reading prefab from file! See log file for error details.", MessageBoxButtons.OK);
                            }

                            if (stream != null)
                            {
                                PastePrefab(stream, options);
                            }
                            stream.Dispose();
                            General.MainWindow.UpdateInterface();
                            Cursor.Current = oldcursor;
                        }
                    }
                }
                else
                {
                    General.MessageBeep(MessageBeepType.Warning);
                    lastprefabfile = null;
                    General.MainWindow.UpdateInterface();
                }
            }
            else
            {
                General.MessageBeep(MessageBeepType.Warning);
            }
        }
コード例 #10
0
        // This pastes a prefab. Returns false when paste was cancelled.
        internal void PastePrefab(Stream filedata, PasteOptions options)
        {
            // Create undo
            General.MainWindow.DisplayStatus(StatusType.Action, "Inserted prefab.");
            General.Map.UndoRedo.CreateUndo("Insert prefab");

            // Decompress stream
            MemoryStream decompressed = new MemoryStream((int)filedata.Length * 3);

            filedata.Seek(0, SeekOrigin.Begin);
            BZip2.Decompress(filedata, decompressed);
            MemoryStream memstream = new MemoryStream(decompressed.ToArray());

            decompressed.Dispose();

            // Mark all current geometry
            General.Map.Map.ClearAllMarks(true);

            // Read data stream
            UniversalStreamReader reader = new UniversalStreamReader();

            reader.StrictChecking = false;
            General.Map.Map.BeginAddRemove();
            reader.Read(General.Map.Map, memstream);
            General.Map.Map.EndAddRemove();

            // The new geometry is not marked, so invert the marks to get it marked
            General.Map.Map.InvertAllMarks();

            // Convert UDMF fields back to flags and activations, if needed
            if (!(General.Map.FormatInterface is UniversalMapSetIO))
            {
                General.Map.Map.TranslateFromUDMF();
            }

            // Modify tags and actions if preferred
            if (options.ChangeTags == PasteOptions.TAGS_REMOVE)
            {
                Tools.RemoveMarkedTags();
            }
            if (options.ChangeTags == PasteOptions.TAGS_RENUMBER)
            {
                Tools.RenumberMarkedTags();
            }
            if (options.RemoveActions)
            {
                Tools.RemoveMarkedActions();
            }

            // Done
            memstream.Dispose();
            General.Map.Map.UpdateConfiguration();
            General.Map.ThingsFilter.Update();
            General.Editing.Mode.OnPasteEnd(options);
            General.Plugins.OnPasteEnd(options);
        }
コード例 #11
0
        public bool OnPasteBegin(PasteOptions options)
        {
            bool result = true;

            foreach (Plugin p in plugins)
            {
                result &= p.Plug.OnPasteBegin(options.Copy(), result);
            }
            return(result);
        }
コード例 #12
0
ファイル: BaseClassicMode.cs プロジェクト: volte/doombuilderx
        // This is called when something was pasted.
        public override void OnPasteEnd(PasteOptions options)
        {
            General.Map.Map.ClearAllSelected();
            General.Map.Map.SelectMarkedGeometry(true, true);

            // Switch to EditSelectionMode
            //EditSelectionMode editmode = new EditSelectionMode();
            //editmode.Pasting = true;
            //editmode.PasteOptions = options;
            General.Editing.ChangeMode("EditSelectionMode");
        }
コード例 #13
0
        public void InsertPrefabFile()
        {
            PasteOptions options = General.Settings.PasteOptions.Copy();

            // Cancel volatile mode
            General.Editing.DisengageVolatileMode();

            // Let the plugins know
            if (General.Plugins.OnPasteBegin(options))
            {
                // Ask the editing mode to prepare selection for pasting.
                if (General.Editing.Mode.OnPasteBegin(options))
                {
                    Cursor oldcursor = Cursor.Current;

                    OpenFileDialog openfile = new OpenFileDialog();
                    openfile.Filter          = "Doom Builder Prefabs (*.dbprefab)|*.dbprefab";
                    openfile.Title           = "Open Prefab";
                    openfile.AddExtension    = false;
                    openfile.CheckFileExists = true;
                    openfile.Multiselect     = false;
                    openfile.ValidateNames   = true;
                    if (openfile.ShowDialog(General.MainWindow) == DialogResult.OK)
                    {
                        FileStream stream = null;

                        try
                        {
                            Cursor.Current = Cursors.WaitCursor;
                            stream         = File.OpenRead(openfile.FileName);
                        }
                        catch (Exception e)
                        {
                            Cursor.Current = oldcursor;
                            General.ErrorLogger.Add(ErrorType.Error, e.GetType().Name + " while reading prefab from file: " + e.Message);
                            General.WriteLog(e.StackTrace);
                            General.ShowErrorMessage("Error while reading prefab from file! See log file for error details.", MessageBoxButtons.OK);
                        }

                        if (stream != null)
                        {
                            PastePrefab(stream, options);
                            lastprefabfile = openfile.FileName;
                        }
                        General.MainWindow.UpdateInterface();
                        stream.Dispose();
                    }

                    Cursor.Current = oldcursor;
                }
            }
        }
コード例 #14
0
ファイル: DteHandler.cs プロジェクト: jcteague/dtt
 public void PasteCode(EditPoint objEditPt, string code, PasteOptions pasteOption)
 {
     switch (pasteOption)
     {
         case PasteOptions.Overwrite:
             objEditPt.Delete(code.Length);
             break;
         case PasteOptions.Append:
             objEditPt.EndOfDocument();
             break;
     }
     objEditPt.Insert(code);
 }
コード例 #15
0
        // This is called when something was pasted.
        public override void OnPasteEnd(PasteOptions options)
        {
            General.Map.Map.ClearAllSelected();
            General.Map.Map.SelectMarkedGeometry(true, true);
            General.Map.Renderer2D.UpdateExtraFloorFlag();             //mxd

            // Switch to EditSelectionMode
            EditSelectionMode editmode = new EditSelectionMode();

            editmode.Pasting      = true;
            editmode.PasteOptions = options;
            General.Editing.ChangeMode(editmode);
        }
コード例 #16
0
ファイル: DocumentWrapper.cs プロジェクト: jcteague/dtt
 public void Paste(int line, string text, PasteOptions option)
 {
     var objEditPt = TextDocument.CreateEditPoint();
     objEditPt.MoveToLineAndOffset(line, 1);
     objEditPt.Insert(text);
     switch (option)
     {
         case PasteOptions.Overwrite:
             var textLines = text.Split('\n').Count(textline => textline != "");
             var textSelection = TextDocument.Selection;
             textSelection.MoveTo(line + textLines, 1);
             textSelection.LineDown(true, textLines);
             textSelection.Delete();
             break;
     }
 }
コード例 #17
0
        // This returns the options as set by the user
        public PasteOptions GetOptions()
        {
            PasteOptions options = new PasteOptions();

            // Collect settings
            if (keeptags.Checked)
            {
                options.ChangeTags = 0;
            }
            else if (renumbertags.Checked)
            {
                options.ChangeTags = 1;
            }
            else if (removetags.Checked)
            {
                options.ChangeTags = 2;
            }
            options.RemoveActions = removeactions.Checked;

            return(options);
        }
コード例 #18
0
        // This returns the options as set by the user
        public PasteOptions GetOptions()
        {
            PasteOptions options = new PasteOptions();

            // Collect settings
            if (keeptags.Checked)
            {
                options.ChangeTags = 0;
            }
            else if (renumbertags.Checked)
            {
                options.ChangeTags = 1;
            }
            else if (removetags.Checked)
            {
                options.ChangeTags = 2;
            }
            options.AdjustHeights = adjustheights.Checked;

            return(options);
        }
        public static void Main()
        {
            // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
            // The path to the documents directory.

            //Source directory
            string sourceDir = RunExamples.Get_SourceDirectory();

            //Output directory
            string outputDir = RunExamples.Get_OutputDirectory();

            // Load sample excel file
            Workbook wb = new Workbook(sourceDir + "SamplePasteOptions.xlsx");

            // Access the first sheet which contains chart
            Worksheet source = wb.Worksheets[0];

            // Add another sheet named DestSheet
            Worksheet destination = wb.Worksheets.Add("DestSheet");

            // Set CopyOptions.ReferToDestinationSheet to true
            CopyOptions options = new CopyOptions();

            options.ReferToDestinationSheet = true;

            // Set PasteOptions
            PasteOptions pasteOptions = new PasteOptions();

            pasteOptions.PasteType        = PasteType.Values;
            pasteOptions.OnlyVisibleCells = true;

            // Copy all the rows of source worksheet to destination worksheet which includes chart as well
            // The chart data source will now refer to DestSheet
            destination.Cells.CopyRows(source.Cells, 0, 0, source.Cells.MaxDisplayRange.RowCount, options, pasteOptions);

            // Save workbook in xlsx format
            wb.Save(outputDir + "outputSamplePasteOptions.xlsx", SaveFormat.Xlsx);

            Console.WriteLine("PastingRowsColumnsWithPasteOptions executed successfully.\r\n");
        }
コード例 #20
0
        public static void Run()
        {
            // ExStart:GetRowHeightsOfSourceRangeToDestinationRange
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create workbook object
            Workbook workbook = new Workbook();

            // Source worksheet
            Worksheet srcSheet = workbook.Worksheets[0];

            // Add destination worksheet
            Worksheet dstSheet = workbook.Worksheets.Add("Destination Sheet");

            // Set the row height of the 4th row. This row height will be copied to destination range
            srcSheet.Cells.SetRowHeight(3, 50);

            // Create source range to be copied
            Range srcRange = srcSheet.Cells.CreateRange("A1:D10");

            // Create destination range in destination worksheet
            Range dstRange = dstSheet.Cells.CreateRange("A1:D10");

            // PasteOptions, we want to copy row heights of source range to destination range
            PasteOptions opts = new PasteOptions();

            opts.PasteType = PasteType.RowHeights;

            // Copy source range to destination range with paste options
            dstRange.Copy(srcRange, opts);

            // Write informative message in cell D4 of destination worksheet
            dstSheet.Cells["D4"].PutValue("Row heights of source range copied to destination range");

            // Save the workbook in xlsx format
            workbook.Save(dataDir + "output_out.xlsx", SaveFormat.Xlsx);
            // ExEnd:GetRowHeightsOfSourceRangeToDestinationRange
        }
コード例 #21
0
        public static void Run()
        {
            // ExStart:GetRowHeightsOfSourceRangeToDestinationRange
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create workbook object
            Workbook workbook = new Workbook();

            // Source worksheet
            Worksheet srcSheet = workbook.Worksheets[0];

            // Add destination worksheet
            Worksheet dstSheet = workbook.Worksheets.Add("Destination Sheet");

            // Set the row height of the 4th row. This row height will be copied to destination range
            srcSheet.Cells.SetRowHeight(3, 50);

            // Create source range to be copied
            Range srcRange = srcSheet.Cells.CreateRange("A1:D10");

            // Create destination range in destination worksheet
            Range dstRange = dstSheet.Cells.CreateRange("A1:D10");

            // PasteOptions, we want to copy row heights of source range to destination range
            PasteOptions opts = new PasteOptions();
            opts.PasteType = PasteType.RowHeights;

            // Copy source range to destination range with paste options
            dstRange.Copy(srcRange, opts);

            // Write informative message in cell D4 of destination worksheet
            dstSheet.Cells["D4"].PutValue("Row heights of source range copied to destination range");

            // Save the workbook in xlsx format
            workbook.Save(dataDir + "output_out.xlsx", SaveFormat.Xlsx);
            // ExEnd:GetRowHeightsOfSourceRangeToDestinationRange
        }
コード例 #22
0
		// Geometry pasted
		public override void OnPasteEnd(PasteOptions options)
		{
			if (portalexplorer != null) portalexplorer.UpdateTreeSoon();
		}
コード例 #23
0
 // This is called when pasting begins
 public override bool OnPasteBegin(PasteOptions options)
 {
     // These modes support pasting
     return(true);
 }
コード例 #24
0
        // This performs the paste. Returns false when paste was cancelled.
        private bool DoPasteSelection(PasteOptions options)
        {
            // Check if possible to copy/paste
            if (General.Editing.Mode.Attributes.AllowCopyPaste)
            {
                // Anything to paste?
                if (Clipboard.ContainsData(CLIPBOARD_DATA_FORMAT))
                {
                    // Cancel volatile mode
                    General.Editing.DisengageVolatileMode();

                    // Let the plugins know
                    if (General.Plugins.OnPasteBegin(options))
                    {
                        // Ask the editing mode to prepare selection for pasting.
                        if (General.Editing.Mode.OnPasteBegin(options.Copy()))
                        {
                            // Create undo
                            General.MainWindow.DisplayStatus(StatusType.Action, "Pasted selected elements.");
                            General.Map.UndoRedo.CreateUndo("Paste");

                            // Read from clipboard
                            Stream memstream = (Stream)Clipboard.GetData(CLIPBOARD_DATA_FORMAT);
                            memstream.Seek(0, SeekOrigin.Begin);

                            // Mark all current geometry
                            General.Map.Map.ClearAllMarks(true);

                            // Read data stream
                            UniversalStreamReader reader = new UniversalStreamReader();
                            reader.StrictChecking = false;
                            General.Map.Map.BeginAddRemove();
                            reader.Read(General.Map.Map, memstream);
                            General.Map.Map.EndAddRemove();

                            // The new geometry is not marked, so invert the marks to get it marked
                            General.Map.Map.InvertAllMarks();

                            // Convert UDMF fields back to flags and activations, if needed
                            if (!(General.Map.FormatInterface is UniversalMapSetIO))
                            {
                                General.Map.Map.TranslateFromUDMF();
                            }

                            // Modify tags and actions if preferred
                            if (options.ChangeTags == PasteOptions.TAGS_REMOVE)
                            {
                                Tools.RemoveMarkedTags();
                            }
                            if (options.ChangeTags == PasteOptions.TAGS_RENUMBER)
                            {
                                Tools.RenumberMarkedTags();
                            }
                            if (options.RemoveActions)
                            {
                                Tools.RemoveMarkedActions();
                            }

                            // Clean up
                            memstream.Dispose();

                            // Check if anything was pasted
                            int totalpasted = General.Map.Map.GetMarkedThings(true).Count;
                            totalpasted += General.Map.Map.GetMarkedVertices(true).Count;
                            totalpasted += General.Map.Map.GetMarkedLinedefs(true).Count;
                            totalpasted += General.Map.Map.GetMarkedSidedefs(true).Count;
                            totalpasted += General.Map.Map.GetMarkedSectors(true).Count;
                            if (totalpasted > 0)
                            {
                                General.Map.Map.UpdateConfiguration();
                                General.Map.ThingsFilter.Update();
                                General.Editing.Mode.OnPasteEnd(options.Copy());
                                General.Plugins.OnPasteEnd(options);
                            }
                            return(true);
                        }
                    }

                    // Aborted
                    return(false);
                }
                else
                {
                    // Nothing usefull on the clipboard
                    General.MessageBeep(MessageBeepType.Warning);
                    return(false);
                }
            }
            else
            {
                // Paste not allowed
                General.MessageBeep(MessageBeepType.Warning);
                return(false);
            }
        }
コード例 #25
0
ファイル: DocumentWrapper.cs プロジェクト: jcteague/dtt
 public void Paste(int line, PasteOptions option)
 {
     Paste(line, Selection.Text, option);
 }
コード例 #26
0
        async Task ExecutePasteAsync(PasteOptions opts)
        {
            var data = await GetDataAsync(opts.Format);

            Console.Write(data);
        }
コード例 #27
0
 // Called after new geometry has been pasted in. The new geometry is marked.
 public virtual void OnPasteEnd(PasteOptions options)
 {
 }
コード例 #28
0
 // Called before pasting. Override this and return true to indicate that paste is allowed to contiue.
 public virtual bool OnPasteBegin(PasteOptions options)
 {
     return(false);
 }
コード例 #29
0
 // Paste clicked
 private void paste_Click(object sender, EventArgs e)
 {
     options           = pasteoptions.GetOptions();
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
コード例 #30
0
        public override bool OnPasteBegin(PasteOptions options)
        {
            if (copyslopevertexgroups == null || copyslopevertexgroups.Count == 0)
            {
                return(false);
            }

            // Unselect all slope vertices, so the pasted vertices can be selected
            foreach (SlopeVertexGroup svg in BuilderPlug.Me.SlopeVertexGroups)
            {
                svg.SelectVertices(false);
            }

            float l = copyslopevertexgroups[0].Vertices[0].Pos.x;
            float r = copyslopevertexgroups[0].Vertices[0].Pos.x;
            float t = copyslopevertexgroups[0].Vertices[0].Pos.y;
            float b = copyslopevertexgroups[0].Vertices[0].Pos.y;

            // Find the outer dimensions of all SVGs to paste
            foreach (SlopeVertexGroup svg in copyslopevertexgroups)
            {
                foreach (SlopeVertex sv in svg.Vertices)
                {
                    if (sv.Pos.x < l)
                    {
                        l = sv.Pos.x;
                    }
                    if (sv.Pos.x > r)
                    {
                        r = sv.Pos.x;
                    }
                    if (sv.Pos.y > t)
                    {
                        t = sv.Pos.y;
                    }
                    if (sv.Pos.y < b)
                    {
                        b = sv.Pos.y;
                    }
                }
            }

            Vector2D center = new Vector2D(l + ((r - l) / 2), b + ((t - b) / 2));
            Vector2D diff   = center - General.Map.Grid.SnappedToGrid(mousemappos);

            foreach (SlopeVertexGroup svg in copyslopevertexgroups)
            {
                int id;
                List <SlopeVertex> newsv = new List <SlopeVertex>();

                foreach (SlopeVertex sv in svg.Vertices)
                {
                    newsv.Add(new SlopeVertex(new Vector2D(sv.Pos.x - diff.x, sv.Pos.y - diff.y), sv.Z));
                }

                SlopeVertexGroup newsvg = BuilderPlug.Me.AddSlopeVertexGroup(newsv, out id);
                newsvg.SelectVertices(true);
            }

            // Redraw the display, so that pasted SVGs are shown immediately
            General.Interface.RedrawDisplay();

            // Don't go into the standard process for pasting, so tell the core that
            // pasting should not proceed
            return(false);
        }
コード例 #31
0
        public void InsertPrefabFile()
        {
            // Check if possible to copy/paste
            if (General.Editing.Mode.Attributes.AllowCopyPaste)
            {
                PasteOptions options = General.Settings.PasteOptions.Copy();

                // Cancel volatile mode
                General.Editing.DisengageVolatileMode();

                // Let the plugins know
                if (General.Plugins.OnPasteBegin(options))
                {
                    // Ask the editing mode to prepare selection for pasting.
                    if (General.Editing.Mode.OnPasteBegin(options))
                    {
                        Cursor oldcursor = Cursor.Current;

                        OpenFileDialog openfile = new OpenFileDialog();

                        // ano - we remember locations for different things separately
                        // so we have to keep track of it ourselves
                        string initial_directory = General.Settings.ReadSetting("prefabinitialdirectory", "");
                        if (Directory.Exists(initial_directory))
                        {
                            openfile.InitialDirectory = initial_directory;
                        }

                        openfile.Filter          = "Doom Builder Prefabs (*.dbprefab)|*.dbprefab";
                        openfile.Title           = "Open Prefab";
                        openfile.AddExtension    = false;
                        openfile.CheckFileExists = true;
                        openfile.Multiselect     = false;
                        openfile.ValidateNames   = true;
                        if (openfile.ShowDialog(General.MainWindow) == DialogResult.OK)
                        {
                            FileStream stream = null;

                            try
                            {
                                Cursor.Current = Cursors.WaitCursor;
                                stream         = File.OpenRead(openfile.FileName);
                                // ano - save initial directory ourselves
                                General.Settings.WriteSetting("prefabinitialdirectory", Path.GetDirectoryName(openfile.FileName));
                            }
                            catch (Exception e)
                            {
                                Cursor.Current = oldcursor;
                                General.ErrorLogger.Add(ErrorType.Error, e.GetType().Name + " while reading prefab from file: " + e.Message);
                                Logger.WriteLogLine(e.StackTrace);
                                General.ShowErrorMessage("Error while reading prefab from file! See log file for error details.", MessageBoxButtons.OK);
                            }

                            if (stream != null)
                            {
                                PastePrefab(stream, options);
                                lastprefabfile = openfile.FileName;
                            }
                            General.MainWindow.UpdateInterface();
                            stream.Dispose();
                        }

                        Cursor.Current = oldcursor;
                    }
                }
            }
            else
            {
                // Insert not allowed
                General.MessageBeep(MessageBeepType.Warning);
            }
        }
コード例 #32
0
        // This pastes a prefab. Returns false when paste was cancelled.
        internal void PastePrefab(Stream filedata, PasteOptions options)
        {
            // Create undo
            General.MainWindow.DisplayStatus(StatusType.Action, "Inserted prefab.");
            General.Map.UndoRedo.CreateUndo("Insert prefab");

            // Decompress stream
            MemoryStream memstream; //mxd

            try
            {
                memstream = Data.SharpCompressHelper.DecompressStream(filedata); //mxd
                memstream.Seek(0, SeekOrigin.Begin);
            }
            catch (Exception e)
            {
                General.ErrorLogger.Add(ErrorType.Error, e.GetType().Name + " while reading prefab from file: " + e.Message);
                Logger.WriteLogLine(e.StackTrace);
                General.ShowErrorMessage("Unable to load prefab. See log file for error details.", MessageBoxButtons.OK);
                return;
            }

            // Mark all current geometry
            General.Map.Map.ClearAllMarks(true);

            // Read data stream
            UniversalStreamReader reader = new UniversalStreamReader();

            reader.StrictChecking = false;
            General.Map.Map.BeginAddRemove();
            reader.Read(General.Map.Map, memstream);
            General.Map.Map.EndAddRemove();

            // The new geometry is not marked, so invert the marks to get it marked
            General.Map.Map.InvertAllMarks();

            // Convert UDMF fields back to flags and activations, if needed
            if (!(General.Map.FormatInterface is UniversalMapSetIO))
            {
                General.Map.Map.TranslateFromUDMF();
            }

            // Modify tags and actions if preferred
            if (options.ChangeTags == PasteOptions.TAGS_REMOVE)
            {
                Tools.RemoveMarkedTags();
            }
            if (options.ChangeTags == PasteOptions.TAGS_RENUMBER)
            {
                Tools.RenumberMarkedTags();
            }
            if (options.RemoveActions)
            {
                Tools.RemoveMarkedActions();
            }

            // Done
            memstream.Dispose();
            General.Map.Map.UpdateConfiguration();
            General.Map.ThingsFilter.Update();
            General.Editing.Mode.OnPasteEnd(options);
            General.Plugins.OnPasteEnd(options);
        }
コード例 #33
0
        // This performs the paste. Returns false when paste was cancelled.
        private static void DoPasteSelection(PasteOptions options)
        {
            // Check if possible to copy/paste
            if (General.Editing.Mode.Attributes.AllowCopyPaste)
            {
                bool havepastedata    = Clipboard.ContainsData(CLIPBOARD_DATA_FORMAT);              //mxd
                bool havedb2pastedata = Clipboard.ContainsData(CLIPBOARD_DATA_FORMAT_DB2);          //mxd

                // Anything to paste?
                if (havepastedata || havedb2pastedata)
                {
                    // Cancel volatile mode
                    General.Editing.DisengageVolatileMode();

                    // Let the plugins know
                    if (General.Plugins.OnPasteBegin(options))
                    {
                        // Ask the editing mode to prepare selection for pasting.
                        if (General.Editing.Mode.OnPasteBegin(options.Copy()))
                        {
                            // Create undo
                            General.MainWindow.DisplayStatus(StatusType.Action, "Pasted selected elements.");
                            General.Map.UndoRedo.CreateUndo("Paste");

                            // Mark all current geometry
                            General.Map.Map.ClearAllMarks(true);

                            // Read from clipboard
                            if (havepastedata)
                            {
                                using (Stream memstream = (Stream)Clipboard.GetData(CLIPBOARD_DATA_FORMAT))
                                {
                                    // Rewind before use
                                    memstream.Seek(0, SeekOrigin.Begin);

                                    // Read data stream
                                    ClipboardStreamReader reader = new ClipboardStreamReader();                                     //mxd
                                    General.Map.Map.BeginAddRemove();
                                    bool success = reader.Read(General.Map.Map, memstream);
                                    General.Map.Map.EndAddRemove();
                                    if (!success)                                    //mxd
                                    {
                                        General.Map.UndoRedo.WithdrawUndo();         // This will also mess with the marks...
                                        General.Map.Map.ClearAllMarks(true);         // So re-mark all current geometry...
                                    }
                                }
                            }
                            // mxd. DB2/DB64 interop
                            else if (havedb2pastedata)
                            {
                                using (Stream memstream = (Stream)Clipboard.GetData(CLIPBOARD_DATA_FORMAT_DB2))
                                {
                                    // Read data stream
                                    UniversalStreamReader reader = new UniversalStreamReader(new Dictionary <MapElementType, Dictionary <string, UniversalType> >());
                                    reader.StrictChecking = false;
                                    General.Map.Map.BeginAddRemove();
                                    reader.Read(General.Map.Map, memstream);
                                    General.Map.Map.EndAddRemove();
                                }
                            }
                            else
                            {
                                throw new NotImplementedException("Unknown clipboard data format!");
                            }

                            // The new geometry is not marked, so invert the marks to get it marked
                            General.Map.Map.InvertAllMarks();

                            // Check if anything was pasted
                            List <Thing> things      = General.Map.Map.GetMarkedThings(true);                       //mxd
                            int          totalpasted = things.Count;
                            totalpasted += General.Map.Map.GetMarkedVertices(true).Count;
                            totalpasted += General.Map.Map.GetMarkedLinedefs(true).Count;
                            totalpasted += General.Map.Map.GetMarkedSidedefs(true).Count;
                            totalpasted += General.Map.Map.GetMarkedSectors(true).Count;

                            if (totalpasted > 0)
                            {
                                // Convert UDMF fields back to flags and activations, if needed
                                if (!(General.Map.FormatInterface is UniversalMapSetIO))
                                {
                                    General.Map.Map.TranslateFromUDMF();
                                }

                                // Modify tags and actions if preferred
                                if (options.ChangeTags == PasteOptions.TAGS_REMOVE)
                                {
                                    Tools.RemoveMarkedTags();
                                }
                                if (options.ChangeTags == PasteOptions.TAGS_RENUMBER)
                                {
                                    Tools.RenumberMarkedTags();
                                }
                                if (options.RemoveActions)
                                {
                                    Tools.RemoveMarkedActions();
                                }

                                foreach (Thing t in things)
                                {
                                    t.UpdateConfiguration();                                                        //mxd
                                }
                                General.Map.ThingsFilter.Update();
                                General.Editing.Mode.OnPasteEnd(options.Copy());
                                General.Plugins.OnPasteEnd(options);
                            }
                        }
                    }
                }
                else
                {
                    // Nothing useful on the clipboard
                    // [ZZ] don't beep if 3D mode is currently engaged. the 3D mode allows you to copy/paste non-geometry stuff.
                    //      note that this is a hack and probably needs to be fixed properly by making it beep elsewhere so that the current active mode can decide this.
                    if (!(General.Editing.Mode is VisualMode))
                    {
                        General.MessageBeep(MessageBeepType.Warning);
                    }
                }
            }
            else
            {
                // Paste not allowed
                General.MessageBeep(MessageBeepType.Warning);
            }
        }
コード例 #34
0
ファイル: Plug.cs プロジェクト: 3dfxdev/3DGE_Builder
 /// <summary>
 /// Called by the Doom Builder core when the user wants to paste geometry into the map.
 /// Return false to abort the paste operation.
 /// The result parameter is false when the operation was already aborted by another plugin.
 /// </summary>
 public virtual bool OnPasteBegin(PasteOptions options, bool result)
 {
     return(true);
 }