Example #1
0
        public static int CreateNewTabReturn(int IDList, string FileName, Encoding encoding, bool encodingbom, StorageListTypes type, string content)
        {
            var newtab = new InfosTab
            {
                TabName                     = FileName,
                TabStorageMode              = type,
                TabEncoding                 = encoding.CodePage,
                TabEncodingWithBOM          = encodingbom,
                TabEncodingReplacingRequest = EncodingReplacingRequest.NotRequested,
                TabContentType              = ContentType.File,
                CanBeDeleted                = true,
                CanBeModified               = true,
                TabType                     = LanguagesHelper.GetLanguageType(FileName),
                TabInvisibleByDefault       = false
            };

            int id_tab = Task.Run(async() => { return(await TabsWriteManager.CreateTabAsync(newtab, IDList, false)); }).Result;

            if (Task.Run(async() => { return(await TabsWriteManager.PushTabContentViaIDAsync(new TabID {
                    ID_Tab = id_tab, ID_TabsList = IDList
                }, content, false)); }).Result)
            {
                Messenger.Default.Send(new STSNotification {
                    Type = TypeUpdateTab.NewTab, ID = new TabID {
                        ID_Tab = id_tab, ID_TabsList = IDList
                    }
                });
                return(id_tab);
            }
            else
            {
                return(0);
            }
        }
Example #2
0
        public static void CreateNewTabInFolder(int IDList, TabID FolderIDs, string FileName, Encoding encoding, StorageListTypes type, string content)
        {
            var newtab = new InfosTab
            {
                TabName               = FileName,
                TabStorageMode        = type,
                TabEncoding           = encoding.CodePage,
                TabContentType        = ContentType.File,
                CanBeDeleted          = true,
                CanBeModified         = true,
                TabType               = LanguagesHelper.GetLanguageType(FileName),
                TabInvisibleByDefault = true
            };

            Task.Run(() =>
            {
                int id_tab = Task.Run(async() => { return(await TabsWriteManager.CreateTabAsync(newtab, IDList, false)); }).Result;
                if (Task.Run(async() => { return(await TabsWriteManager.PushTabContentViaIDAsync(new TabID {
                        ID_Tab = id_tab, ID_TabsList = IDList
                    }, content, false)); }).Result)
                {
                    Messenger.Default.Send(new STSNotification {
                        Type = TypeUpdateTab.NewTab, ID = new TabID {
                            ID_Tab = id_tab, ID_TabsList = IDList
                        }
                    });

                    InfosTab Folder = TabsAccessManager.GetTabViaID(FolderIDs);
                    Folder.FolderContent.Add(id_tab);
                    Task.Run(async() => { await TabsWriteManager.PushUpdateTabAsync(Folder, FolderIDs.ID_TabsList, false); });
                }
            });
        }
        public static async Task <int> CreateNewTab(int IDList, string FileName, Encoding encoding, StorageListTypes type, string content)
        {
            string extension = "";

            foreach (string type_file in FileTypes.List_Type_extensions)
            {
                if (FileName.Contains(type_file))
                {
                    extension = FileTypes.GetExtensionType(Path.GetExtension(FileName));
                    break;
                }
                else
                {
                    continue;
                }
            }
            var newtab = new InfosTab
            {
                TabName               = FileName,
                TabStorageMode        = type,
                TabEncoding           = encoding.CodePage,
                TabContentType        = ContentType.File,
                CanBeDeleted          = true,
                CanBeModified         = true,
                TabType               = extension,
                TabInvisibleByDefault = false
            };
            int id_tab = await TabsWriteManager.CreateTabAsync(newtab, IDList, false);

            if (await TabsWriteManager.PushTabContentViaIDAsync(new TabID {
                ID_Tab = id_tab, ID_TabsList = IDList
            }, content, false))
            {
                Messenger.Default.Send(new STSNotification {
                    Type = TypeUpdateTab.NewTab, ID = new TabID {
                        ID_Tab = id_tab, ID_TabsList = IDList
                    }
                });
                return(id_tab);
            }
            else
            {
                return(0);
            }
        }