コード例 #1
0
        public void AddToLibrary(ICustomLibrary customLibrary)
        {
            try
            {
                string           objectName = CommonDefine.Untitled;
                ISerializeWriter writer     = GetSerializeWriter(ref objectName);
                if (writer == null)
                {
                    return;
                }

                IDocumentService DocService = ServiceLocator.Current.GetInstance <IDocumentService>();
                ILibrary         library    = DocService.LibraryManager.GetLibrary(customLibrary.LibraryGID, customLibrary.FileName);
                if (library != null)
                {
                    ICustomObject newObject = library.AddCustomObject(writer, objectName, CreateIconImage(false), null);
                    if (newObject != null)
                    {
                        customLibrary.AddCustomObject(newObject.Guid);
                    }
                }
                else
                {
                    // If we cannot get the specific library, there is something wrong about this custom library.
                    // Refresh this custom library
                    customLibrary.Refresh();
                }
            }
            catch (Exception ex)
            {
                NLogger.Warn("Add to library failed. ex:{0}", ex.ToString());

                MessageBox.Show(GlobalData.FindResource("Error_Create_Library") + ex.Message);
            }
        }
コード例 #2
0
 private void AddToLibraryCommandHandler(ICustomLibrary library)
 {
     AddToLibrary(library);
 }