예제 #1
0
        private void OpenInInternalBrowser(
            WebEntryInfo webEntryInfo,
            IContentContainer contentContainer,
            object selectedObject,
            string webEntityInfoPropertyName = null)
        {
            string             url = webEntryInfo != null ? webEntryInfo.Url : null;
            BrowserPrivateType browserPrivateType = webEntryInfo.BrowserPrivateType;
            ViewType           viewType           = webEntryInfo.RecоmmendedViewType;

            bool isFile = false;
            bool isUrl  = false;

            FileUtils.IsFilePath(url, out isFile, out isUrl);
            if (isFile)
            {
                if (viewType == ViewType.NONE)
                {
                    viewType = GetViewTypeByFilePath(url);
                }
            }
            else
            {
                viewType = ViewType.CefBrowser;
            }

            BaseViewWindow itemViewWindow = AppManager.Instance.CreateContent(contentContainer, AppManager.Instance.DefaultViewWindowType,
                                                                              new Dictionary <string, object>()
            {
                { "Item", selectedObject },
                { "WebEntityInfoPropertyName", webEntityInfoPropertyName },
                { "BrowserPrivateType", browserPrivateType }
            }) as BaseViewWindow;

            itemViewWindow.ViewType     = viewType;
            itemViewWindow.FileFullPath = url;
            itemViewWindow.ProcessView();
        }
예제 #2
0
        private void CreateOpenInInternalBrowserContextMenu(List <ToolStripItem> subs2,
                                                            ViewType viewType,
                                                            ViewType recоmmendedViewType,
                                                            BrowserPrivateType browserPrivateType,
                                                            string url,
                                                            WebEntryInfo webEntryInfo,
                                                            IContentContainer contentContainer,
                                                            object selectedObject,
                                                            string webEntityInfoPropertyName = null)
        {
            ToolStripMenuItem menuItem = new ToolStripMenuItem();

            StringBuilder text = new StringBuilder();

            text.Append(WebAccountLibRes.Open_in_ + " ");
            if (viewType == ViewType.Awesomium)
            {
                text.Append(WebAccountLibRes.Awesomium);
            }
            else if (viewType == ViewType.CefBrowser)
            {
                text.Append(WebAccountLibRes.Chromium_Embedded);
            }
            else if (viewType == ViewType.IE)
            {
                text.Append(WebAccountLibRes.IE);
            }
            else if (viewType == ViewType.Simple)
            {
                text.Append(WebAccountLibRes.Simple_editor);
            }
            else if (viewType == ViewType.WORD)
            {
                text.Append(WebAccountLibRes.MS_Word);
            }
            if (viewType == ViewType.CefBrowser)
            {
                if (browserPrivateType == BrowserPrivateType.COMMON_CACHE)
                {
                    text.Append("");
                }
                else if (browserPrivateType == BrowserPrivateType.PERSONAL_IN_MEMORY_CACHE)
                {
                    text.Append(WebAccountLibRes.__private_in_memory_cache_);
                }
                else if (browserPrivateType == BrowserPrivateType.PERSONAL_OLD_DISK_CACHE)
                {
                    text.Append(WebAccountLibRes.__private_persistent_cache_);
                }
                else if (browserPrivateType == BrowserPrivateType.PERSONAL_NEW_DISK_CACHE)
                {
                    text.Append(WebAccountLibRes.__private_persistent_cache__cleared__);
                }
            }
            menuItem.Text   = text.ToString();
            menuItem.Click += (s, em) =>
            {
                try
                {
                    if (CheckLevel(webEntryInfo) == false)
                    {
                        return;
                    }

                    BaseViewWindow itemViewWindow = AppManager.Instance.CreateContent(contentContainer, AppManager.Instance.DefaultViewWindowType,
                                                                                      new Dictionary <string, object>()
                    {
                        { "Item", selectedObject },
                        { "WebEntityInfoPropertyName", webEntityInfoPropertyName },
                        { "BrowserPrivateType", browserPrivateType }
                    }) as BaseViewWindow;
                    itemViewWindow.ViewType     = viewType;
                    itemViewWindow.FileFullPath = url;
                    itemViewWindow.ProcessView();
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            subs2.Add(menuItem);
        }
예제 #3
0
        static public void CreateCefBrowser(BrowserPrivateType BrowserPrivateType, object LinkedObject, string WebEntityInfoPropertyName, string FileFullPath, ref UserControl viewControl)
        {
            WebEntryInfo webEntryInfo = null;

            if (LinkedObject != null)
            {
                IList <WebEntryInfoWrap> webEntryInfos = WebEntryInfo.GetWebEntryInfosFromObject(LinkedObject);
                if (webEntryInfos.Count > 1)
                {
                    if (WebEntityInfoPropertyName == null)
                    {
                        throw new Exception("WebEntityInfoPropertyName not set, but found more than one WebEntityInfo");
                    }
                    else
                    {
                        WebEntryInfoWrap webEntryInfoWrap = webEntryInfos.Where <WebEntryInfoWrap>(s => s.Property.Name == WebEntityInfoPropertyName).FirstOrDefault();
                        if (webEntryInfoWrap == null)
                        {
                            throw new Exception("Not found WebEntityInfo with specified name: " + WebEntityInfoPropertyName);
                        }
                        else
                        {
                            webEntryInfo = webEntryInfoWrap.WebEntryInfo;
                        }
                    }
                }
                else if (webEntryInfos.Count == 1)
                {
                    webEntryInfo = webEntryInfos[0].WebEntryInfo;
                }
            }
            else
            {
                webEntryInfo = new WebEntryInfo();
            }
            //if (viewControl == null || !(viewControl is EmbeddedBrowserControl))
            //{
            webEntryInfo.BrowserPrivateType = BrowserPrivateType;
            if (BrowserPrivateType == BrowserPrivateType.PERSONAL_OLD_DISK_CACHE
                //|| BrowserPrivateType == BrowserPrivateType.PERSONAL_NEW_DISK_CACHE
                )
            {
                string path = null;

                JActor actor = null;

                if (LinkedObject != null)
                {
                    var  pl = LinkedObject.GetType().GetProperties();
                    Type at = typeof(JActor);
                    foreach (var p in pl)
                    {
                        if (p.PropertyType == at)
                        {
                            actor = AttrHelper.GetPropertyValue(LinkedObject, p) as JActor;
                            break;
                        }
                    }
                }
                //PropertyInfo actorProperty = AttrHelper.GetProperty(typeof(JActor), LinkedObject.GetType());
                //if (actorProperty != null) actor = AttrHelper.GetPropertyValue(LinkedObject, actorProperty) as JActor;
                if (actor != null)
                {
                    path = Dm.Instance.GetCacheFullPathForObjectUniqueForCompAndUser(actor);
                }
                else
                {
                    path = Dm.Instance.GetCacheFullPathForObjectUniqueForCompAndUser(LinkedObject);
                }
                webEntryInfo.CachePath = path;
            }
            else if (BrowserPrivateType == BrowserPrivateType.COMMON_CACHE)
            {
                string path = Dm.Instance.GetBrowserCommonCachePathUniqueForCompAndUser();
                webEntryInfo.CachePath = path;
            }
            viewControl = new EmbeddedBrowserControl(FileFullPath, webEntryInfo, EmbeddedBrowserHelper.MultiThreadedMessageLoop);
        }