Example #1
0
    //Function to load file text from streaming assets
    public IEnumerator LoadFromFile(string fileName, bool isLocalPath, LoadFileDelegate fileDelegate)
    {
//		Debug.Log ("LoadFromFile");
        string filePath = "";

        if (isLocalPath)
        {
            filePath = Helpers.formatLocalUrlToRead(fileName);
        }
        else
        {
            filePath = Helpers.formatLocalPersistentUrlToRead(fileName);
        }

        WWW www = new WWW(filePath);

        yield return(www);

        if (www.error == null)
        {
            Debug.Log("JSON -->>" + www.text);
            fileDelegate(false, www.text);
        }
        else
        {
            Debug.Log("filePathError: " + www.error);
            fileDelegate(true, www.error);
        }

        yield return(null);
    }
 internal static void LoadFromFileAsynch(string fileName, FileImportMethod style)
 {
     if (!File.Exists(fileName))
     {
         return;
     }
     try {
         LoadFileDelegate d = new LoadFileDelegate(ReadMessagesFromFile);
         // TODO : FireAndForget support required so we dont leak like a bottomer.
         d.BeginInvoke(fileName, style, null, null);
         // We just let this happen in the background and dissapear when its done.
     } catch (IOException ex) {
         // OK what do we do about errors ?
         //Bilge.Dump(ex, "Error occured during LoadFromFileAsynch method");
         MexCore.TheCore.ViewManager.AddUserNotificationMessageByIndex(ViewSupportManager.UserMessages.ErrorDuringfileImport, ViewSupportManager.UserMessageType.ErrorMessage, null);
     }
 }
 public void BeginLoadFile(AsyncCallback callback)
 {
     LoadFileDelegate loadFileDelegate = new LoadFileDelegate(LoadFile);
     IAsyncResult result = loadFileDelegate.BeginInvoke(callback, null);
 }
Example #4
0
        public LogWindow AddFileTab(string givenFileName, bool isTempFile, string title,
                                    bool forcePersistenceLoading,
                                    ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel)
        {
            string    logFileName = FindFilenameForSettings(givenFileName);
            LogWindow win         = FindWindowForFile(logFileName);

            if (win != null)
            {
                if (!isTempFile)
                {
                    AddToFileHistory(givenFileName);
                }
                SelectTab(win);
                return(win);
            }

            EncodingOptions encodingOptions = new EncodingOptions();

            FillDefaultEncodingFromSettings(encodingOptions);
            LogWindow logWindow =
                new LogWindow(this, logFileName, isTempFile, forcePersistenceLoading);

            logWindow.GivenFileName = givenFileName;

            if (preProcessColumnizer != null)
            {
                logWindow.ForceColumnizerForLoading(preProcessColumnizer);
            }

            if (isTempFile)
            {
                logWindow.TempTitleName  = title;
                encodingOptions.Encoding = new UnicodeEncoding(false, false);
            }
            AddLogWindow(logWindow, title, doNotAddToDockPanel);
            if (!isTempFile)
            {
                AddToFileHistory(givenFileName);
            }

            LogWindowData data = logWindow.Tag as LogWindowData;

            data.color = this.defaultTabColor;
            setTabColor(logWindow, this.defaultTabColor);
            //data.tabPage.BorderColor = this.defaultTabBorderColor;
            if (!isTempFile)
            {
                foreach (ColorEntry colorEntry in ConfigManager.Settings.fileColors)
                {
                    if (colorEntry.fileName.ToLower().Equals(logFileName.ToLower()))
                    {
                        data.color = colorEntry.color;
                        setTabColor(logWindow, colorEntry.color);
                        break;
                    }
                }
            }
            if (!isTempFile)
            {
                SetTooltipText(logWindow, logFileName);
            }

            if (givenFileName.EndsWith(".lxp"))
            {
                logWindow.ForcedPersistenceFileName = givenFileName;
            }

            // this.BeginInvoke(new LoadFileDelegate(logWindow.LoadFile), new object[] { logFileName, encoding });
            LoadFileDelegate loadFileFx = new LoadFileDelegate(logWindow.LoadFile);

            loadFileFx.BeginInvoke(logFileName, encodingOptions, null, null);
            return(logWindow);
        }