private int HandleEvent(string fileName, DocumentSaveType_e type)
        {
            var args = new DocumentSaveArgs()
            {
                FileName = fileName,
                Cancel   = false
            };

            Delegate?.Invoke(m_Doc, type, args);

            if (args.FileName != fileName)
            {
                if (type == DocumentSaveType_e.SaveAs)
                {
                    m_Doc.Model.SetSaveAsFileName(args.FileName);
                    return(HResult.S_FALSE);
                }
                else if (type == DocumentSaveType_e.SaveCurrent)
                {
                    throw new NotSupportedException("File name can be changed for SaveAs file only");
                }
            }

            return(args.Cancel ? HResult.S_FALSE : HResult.S_OK);
        }
Beispiel #2
0
 private void OnSaving(IXDocument doc, DocumentSaveType_e type,
                       DocumentSaveArgs args)
 {
     if (doc == m_App.Documents.Active)
     {
         InvokeTrigger(Triggers_e.DocumentSave, doc);
     }
 }
Beispiel #3
0
        private void OnModelSaving(IXDocument doc, DocumentSaveType_e type, DocumentSaveArgs args)
        {
            if (type == DocumentSaveType_e.SaveAs)
            {
                var tempDir = Path.GetTempPath();
                var ext     = Path.GetExtension(args.FileName);

                IXProperty titlePrp = null;

                if (doc is ISwDocument3D)
                {
                    titlePrp = (doc as ISwDocument3D).Configurations.Active.Properties.GetOrPreCreate(FILE_NAME_PRP);
                }

                if (titlePrp == null || !titlePrp.Exists())
                {
                    titlePrp = doc.Properties.GetOrPreCreate(FILE_NAME_PRP);
                }

                var prpVal = "";

                if (titlePrp.Exists())
                {
                    prpVal = titlePrp.Value?.ToString();
                }

                if (string.IsNullOrEmpty(prpVal))
                {
                    prpVal = Guid.NewGuid().ToString();
                }

                var destFile = Path.Combine(tempDir, prpVal + ext);

                args.FileName = destFile;
            }
        }