Ejemplo n.º 1
0
        /// <summary>
        /// This button opens the other form(EditCreateBlock.cs) in order to Create a new block to the library.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void butCreateBlock_Click(object sender, EventArgs e)
        {
            EditCreateBlock frm = new EditCreateBlock();

            frm.InitializeDialog(null, vectorDrawBaseControl1.ActiveDocument);
            frm.ShowDialog(this);

            vdBlock exported = frm.ExportedBlock;

            if (exported != null)
            {
                this.butSave.Enabled = true;
                vdBlock blk = new vdBlock();
                blk.SetUnRegisterDocument(vectorDrawBaseControl1.ActiveDocument);
                blk.setDocumentDefaults();
                blk.MatchProperties(exported, vectorDrawBaseControl1.ActiveDocument);
                vectorDrawBaseControl1.ActiveDocument.Blocks.AddItem(blk);
                LoadLibraryBlocks(exported.Name);
                DrawPreview(exported.Name);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This button opens the other form(EditCreateBlock.cs) in order to edit the selected block from the library.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void butEdit_Click(object sender, EventArgs e)
        {
            string selectedname = (string)listBlocks.SelectedItem;

            if (selectedname != null && selectedname != "")
            {
                vdBlock blk = vectorDrawBaseControl1.ActiveDocument.Blocks.FindName(selectedname);
                if (blk != null)
                {
                    EditCreateBlock frm = new EditCreateBlock();
                    frm.InitializeDialog(blk, vectorDrawBaseControl1.ActiveDocument);
                    frm.ShowDialog(this);

                    vdBlock exported = frm.ExportedBlock;
                    if (exported != null)
                    {
                        this.butSave.Enabled = true;
                        blk.MatchProperties(exported, vectorDrawBaseControl1.ActiveDocument);
                        LoadLibraryBlocks(exported.Name);
                        DrawPreview(exported.Name);
                    }
                }
            }
        }