Exemplo n.º 1
0
        private void InitializeSmartEvent()
        {
            // focus dummy
            _focusIn  = new SmartEvent(this, "focused");
            _focusOut = new SmartEvent(this, "unfocused");

            _focusIn.On  += (s, e) => { ((WebView)s).SetFocus(true); };
            _focusOut.On += (s, e) => { ((WebView)s).SetFocus(false); };

            _loadStarted             = new SmartEvent(this, _realHandle, "load,started");
            _loadFinished            = new SmartEvent(this, _realHandle, "load,finished");
            _loadError               = new SmartEvent <SmartCallbackLoadErrorArgs>(this, _realHandle, "load,error", SmartCallbackLoadErrorArgs.CreateFromSmartEvent);
            _titleChanged            = new SmartEvent <SmartCallbackArgs>(this, _realHandle, "title,changed", SmartCallbackArgs.CreateFromSmartEvent);
            _urlChanged              = new SmartEvent <SmartCallbackArgs>(this, _realHandle, "url,changed", SmartCallbackArgs.CreateFromSmartEvent);
            _contextMenuCustomize    = new SmartEvent <ContextMenuCustomizeEventArgs>(this, _realHandle, "contextmenu,customize", ContextMenuCustomizeEventArgs.CreateFromSmartEvent);
            _contextMenuItemSelected = new SmartEvent <ContextMenuItemEventArgs>(this, _realHandle, "contextmenu,selected", ContextMenuItemEventArgs.CreateFromSmartEvent);
            _policyNavigationDecide  = new SmartEvent <NavigationPolicyEventArgs>(this, _realHandle, "policy,navigation,decide", NavigationPolicyEventArgs.CreateFromSmartEvent);
            _policyNewWindowDecide   = new SmartEvent <NewWindowPolicyEventArgs>(this, _realHandle, "policy,newwindow,decide", NewWindowPolicyEventArgs.CreateFromSmartEvent);
            _policyResponseDecide    = new SmartEvent <ResponsePolicyEventArgs>(this, _realHandle, "policy,response,decide", ResponsePolicyEventArgs.CreateFromSmartEvent);

            _loadStarted.On             += (s, e) => { LoadStarted?.Invoke(this, EventArgs.Empty); };
            _loadFinished.On            += (s, e) => { LoadFinished?.Invoke(this, EventArgs.Empty); };
            _loadError.On               += (s, e) => { LoadError?.Invoke(this, e); };
            _titleChanged.On            += (s, e) => { TitleChanged?.Invoke(this, e); };
            _urlChanged.On              += (s, e) => { UrlChanged?.Invoke(this, e); };
            _policyNavigationDecide.On  += (s, e) => { NavigationPolicyDecideRequested?.Invoke(this, e); };
            _policyNewWindowDecide.On   += (s, e) => { NewWindowPolicyDecideRequested?.Invoke(this, e); };
            _policyResponseDecide.On    += (s, e) => { ResponsePolicyDecideRequested?.Invoke(this, e); };
            _contextMenuItemSelected.On += (s, e) => { ContextMenuItemSelected?.Invoke(this, e); };
            _contextMenuCustomize.On    += (s, e) => { _contextMenuCustomizeDelegate?.Invoke(e.Menu); };
        }
Exemplo n.º 2
0
 public IABLoader(LoadProgess prog, LoadFinished loadFinish)
 {
     commonBundlePath = "";
     bundleName       = "";
     loadProgess      = prog;
     loadFinished     = loadFinish;
     iABResLoad       = null;
 }
Exemplo n.º 3
0
        private void filesLoaded(object sender, EventArgs e)
        {
            try {
                FileUtils f = sender as FileUtils;
                foreach (string file in f.Filenames)
                {
                    MethodInfo info = Classes[file].GetMethod("Load");
                    if (info != null)
                    {
                        info.Invoke(null, new object[] { new StreamReader(FileUtils.GetFileStream(file, false), Encoding.UTF8) });
                    }
                }
                if (LoadFinished != null)
                {
                    LoadFinished.Invoke(this, EventArgs.Empty);
                }
            } catch (Exception ex) {
                if (RetryCount > 3)
                {
                    new Base.ErrorBox()
                    {
                        Title        = "Error loading a cache",
                        Function     = "filesLoaded()",
                        SuggestedFix = "The Caches have failed to load three times in a row. This most likely means you either need to forcibly update to a new version of Rawr in the Browser or you need to clear your Silverlight cache (in Silverlight Settings)",
                        TheException = ex,
                    }.Show();
                    return;
                }
                exes.Add(ex);
                new Base.ErrorBox()
                {
                    Title        = "Error loading a cache",
                    Function     = "filesLoaded()",
                    TheException = ex,
                }.Show();
                RetryCount++;
                string dir = "";
#if !SILVERLIGHT
                dir = "ClientBin\\";
#endif
                new FileUtils(new string[] {
                    //dir+"BuffCache.xml",
                    dir + "BuffSets.xml",
                    //dir+"EnchantCache.xml",
                    dir + "ItemCache.xml",
                    dir + "ItemFilter.xml",
                    dir + "PetTalents.xml",
                    dir + "Settings.xml",
                    dir + "Talents.xml",
                    dir + "TinkeringCache.xml",
                }).Delete();
                // We delete the bad ones and try to load files again, which should put us in the proper loop
                LoadFiles();
            }
        }
Exemplo n.º 4
0
        private void filesLoaded(object sender, EventArgs e)
        {
            FileUtils f = sender as FileUtils;

            foreach (string file in f.Filenames)
            {
                MethodInfo info = Classes[file].GetMethod("Load");
                if (info != null)
                {
                    info.Invoke(null, new object[] { new StreamReader(FileUtils.GetFileStream(file, false), Encoding.UTF8) });
                }
            }
            if (LoadFinished != null)
            {
                LoadFinished.Invoke(this, EventArgs.Empty);
            }
        }
        public IAsyncOperation <LoadMoreItemsResult> LoadMoreItemsAsync(uint count)
        {
            var dispatcher = Window.Current.Dispatcher;

            return(Task.Run <LoadMoreItemsResult>(
                       async() =>
            {
                uint resultCount = 0;
                IEnumerable <I> result = null;

                for (int i = 0; i < partsCount; i++)
                {
                    //dispatcher.RunAsync doesn't wait for task to be done, so we use this method instead.
                    await DispatcherEx.RunTaskAsync(dispatcher, async() =>
                    {
                        result = await source.GetPagedItems(currentPage++, itemsPerPart);

                        if (result == null || result.Count() == 0)
                        {
                            hasMoreItems = false;
                            LoadFinished?.Invoke(new EventArgs());
                        }
                        else
                        {
                            resultCount = (uint)result.Count();

                            foreach (I item in result)
                            {
                                if (VisibilityDecider(item))
                                {
                                    this.Add(item);
                                }
                            }
                        }
                    }, CoreDispatcherPriority.High);
                }
                return new LoadMoreItemsResult()
                {
                    Count = resultCount
                };
            }).AsAsyncOperation <LoadMoreItemsResult>());
        }
Exemplo n.º 6
0
        public void Execute(object parameter)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "ファイル(*.xml)|*.xml|すべてのファイル(*.*)|*.*";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Database.Instance.Load(ofd.FileName);
                    LoadFinished?.Invoke(this, new EventArgs());
                    MessageBox.Show("OK");
                }
                catch
                {
                    LoadFinished?.Invoke(this, new EventArgs());
                    MessageBox.Show("NG");
                }
            }
        }
Exemplo n.º 7
0
        private void InitializeSmartEvent()
        {
            // focus dummy
            _focusIn  = new SmartEvent(this, "focused");
            _focusOut = new SmartEvent(this, "unfocused");

            _focusIn.On  += (s, e) => { ((WebView)s).SetFocus(true); };
            _focusOut.On += (s, e) => { ((WebView)s).SetFocus(false); };

            _loadStarted  = new SmartEvent(this, _realHandle, "load,started");
            _loadFinished = new SmartEvent(this, _realHandle, "load,finished");
            _loadError    = new SmartEvent <SmartCallbackLoadErrorArgs>(this, _realHandle, "load,error", SmartCallbackLoadErrorArgs.CreateFromSmartEvent);
            _titleChanged = new SmartEvent <SmartCallbackArgs>(this, _realHandle, "title,changed", SmartCallbackArgs.CreateFromSmartEvent);
            _urlChanged   = new SmartEvent <SmartCallbackArgs>(this, _realHandle, "url,changed", SmartCallbackArgs.CreateFromSmartEvent);

            _loadStarted.On  += (s, e) => { LoadStarted?.Invoke(this, EventArgs.Empty); };
            _loadFinished.On += (s, e) => { LoadFinished?.Invoke(this, EventArgs.Empty); };
            _loadError.On    += (s, e) => { LoadError?.Invoke(this, e); };
            _titleChanged.On += (s, e) => { TitleChanged?.Invoke(this, e); };
            _urlChanged.On   += (s, e) => { UrlChanged?.Invoke(this, e); };
        }
Exemplo n.º 8
0
        public virtual void ReleaseListeners(object target)
        {
            if (ListChanged != null)
            {
                foreach (Delegate d in ListChanged.GetInvocationList())
                {
                    if (target == null || d.Target == target)
                    {
                        ListChanged -= (ListChangedEventHandler)d;
                    }
                }
            }
            if (LoadFinished != null)
            {
                foreach (Delegate d in LoadFinished.GetInvocationList())
                {
                    if (target == null || d.Target == target)
                    {
                        LoadFinished -= (LoadFinishedEventHandler)d;
                    }
                }
            }
            if (ListItemChanged != null)
            {
                foreach (Delegate d in ListItemChanged.GetInvocationList())
                {
                    if (target == null || d.Target == target)
                    {
                        ListItemChanged -= (ListItemChangedEventHandler)d;
                    }
                }
            }

            foreach (T ho in this)
            {
                ho.ReleaseListeners(target);
            }
        }
Exemplo n.º 9
0
        private void BuildWebView()
        {
            _platform = PlatformHelper.GetGTKPlatform();

            if (_platform == GTKPlatform.Windows)
            {
                _webViewWindows = new WebViewWindows();

                _webViewWindows.WebBrowser.Navigating += (sender, args) =>
                {
                    LoadStarted?.Invoke(this, args);
                };

                _webViewWindows.WebBrowser.Navigated += (sender, args) =>
                {
                    LoadFinished?.Invoke(this, args);
                };

                Add(_webViewWindows);
            }
            else
            {
                _webViewLinux = new WebViewLinux();

                _webViewLinux.WebView.LoadStarted += (sender, args) =>
                {
                    LoadStarted?.Invoke(this, args);
                };

                _webViewLinux.WebView.LoadFinished += (sender, args) =>
                {
                    LoadFinished?.Invoke(this, args);
                };

                Add(_webViewLinux);
            }
        }
Exemplo n.º 10
0
        public void AddHandlersWithLoad(ListChangedEventHandler listChangedEventHandler,
                                        LoadFinishedEventHandler loadFinishedEventHandler,
                                        ListItemChangedEventHandler itemChangedEventHandler)
        {
            #if (CHATTY_DEBUG)
            string msg = "*** HRA LIST AddHandlersWithLoad on : " + this.ToString() + System.Environment.NewLine;
            if (listChangedEventHandler != null)
            {
                msg += "By: " + listChangedEventHandler.Target.ToString();
            }
            else if (loadFinishedEventHandler != null)
            {
                msg += "By: " + loadFinishedEventHandler.Target.ToString();
            }
            else if (itemChangedEventHandler != null)
            {
                msg += "By: " + itemChangedEventHandler.Target.ToString();
            }

            Logger.Instance.DebugToLog(msg);
            #endif

            if (listChangedEventHandler != null)
            {
                if (ListChanged == null)
                {
                    ListChanged += listChangedEventHandler;
                }
                else
                {
                    bool ok = true;
                    foreach (Delegate d in ListChanged.GetInvocationList())
                    {
                        if (d.Target == listChangedEventHandler.Target)
                        {
                            ok = false;
                        }
                    }
                    if (ok)
                    {
                        ListChanged += listChangedEventHandler;
                    }
                }
            }

            if (loadFinishedEventHandler != null)
            {
                if (LoadFinished == null)
                {
                    LoadFinished += loadFinishedEventHandler;
                }
                else
                {
                    bool ok = true;
                    foreach (Delegate d in LoadFinished.GetInvocationList())
                    {
                        if (d.Target == loadFinishedEventHandler.Target)
                        {
                            ok = false;
                        }
                    }
                    if (ok)
                    {
                        LoadFinished += loadFinishedEventHandler;
                    }
                }
            }

            if (itemChangedEventHandler != null)
            {
                if (ListItemChanged == null)
                {
                    ListItemChanged += itemChangedEventHandler;
                }
                else
                {
                    bool ok = true;
                    foreach (Delegate d in ListItemChanged.GetInvocationList())
                    {
                        if (d.Target == loadFinishedEventHandler.Target)
                        {
                            ok = false;
                        }
                    }
                    if (ok)
                    {
                        ListItemChanged += itemChangedEventHandler;
                    }
                }
            }

            if (loaded)
            {
                if (loadFinishedEventHandler != null)
                {
                    HraListLoadedEventArgs args = new HraListLoadedEventArgs();
                    args.sender     = this;
                    args.workerArgs = new RunWorkerCompletedEventArgs(this, null, false);
                    loadFinishedEventHandler.Invoke(args);
                }
            }
            else
            {
                LoadList();
            }
        }
Exemplo n.º 11
0
 public override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
 {
     LoadFinished?.Invoke();
 }
Exemplo n.º 12
0
 private void OnLoadFinished()
 {
     Debug.LogWarning($"Successfully displaying game buttons.");
     LoadFinished?.Invoke();
 }
Exemplo n.º 13
0
        public async Task LoadPlugins(string basePath, List <string> include, List <string> exclude, string[] args)
        {
            LoadStarting?.Invoke(this, null);
            var uniqueFiles = await GetAllPluginFiles(basePath);

            foreach (var file in uniqueFiles)
            {
                var dlls = await Task.Run(() => Directory.GetFiles(Path.GetDirectoryName(file), "*.dll", SearchOption.AllDirectories));

                _dlls.AddRange(dlls);
            }

            var argsDict = new Dictionary <string, string>();

            foreach (var arg in args)
            {
                var parts = arg.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length >= 2)
                {
                    argsDict[parts[0]] = string.Join("=", parts.Skip(1));
                }
            }

            var currentLoaded = new List <IPlugin>();

            foreach (var file in uniqueFiles)
            {
                var name = Path.GetFileName(file).Split('.')[2];
                if (include.Any(i => name.ToLower().StartsWith(i.ToLower()) || i == "*") && (exclude == null || !exclude.Any(e => name.ToLower().StartsWith(e.ToLower()) || e == "*")))
                {
                    try
                    {
                        _logger.Info(this, $"Loading plugin: {Path.GetFileName(file)} - {file}");
                        var ass        = LoadAssembly(file);
                        var pluginType = GetTypesSafely(ass).FirstOrDefault(t => typeof(IPlugin).IsAssignableFrom(t));
                        if (pluginType == null)
                        {
                            continue;
                        }

                        var inst = _kernel.Get(pluginType) as IPlugin;

                        foreach (var prop in GetTypeInjectableProperties(pluginType))
                        {
                            var attr = prop.GetCustomAttribute <PanaceaInjectAttribute>();
                            if (argsDict.ContainsKey(attr.Alias))
                            {
                                prop.SetValue(inst, Convert.ChangeType(argsDict[attr.Alias], prop.PropertyType));
                            }
                        }

                        currentLoaded.Add(inst);
                        _loadedPlugins.Add(name, inst);
                        PluginLoaded?.Invoke(this, inst);
                    }
                    catch
                    {
                        if (Debugger.IsAttached)
                        {
                            Debugger.Break();
                        }
                    }
                }
            }
            foreach (var inst in currentLoaded)
            {
                try
                {
                    await inst.BeginInit();
                }
                catch (Exception ex)
                {
                    _logger.Error(this, ex.Message);
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                }
            }
            foreach (var inst in currentLoaded)
            {
                try
                {
                    await inst.EndInit();
                }
                catch
                {
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                }
            }
            LoadFinished?.Invoke(this, null);
        }
Exemplo n.º 14
0
 private void ClientLoadFinished(object sender, UI.LoadFinishedEventArgs e)
 {
     UpdateDefaultControls();
     LoadFinished?.Invoke(Pair ?? this, e);
 }
Exemplo n.º 15
0
        public async Task <bool> LoadAsync()
        {
            if (IsLoaded || IsLoading)
            {
                return(false);
            }

            IsLoading = true;

            int currentLine = -1;

            List <GrepLine> linesWithContext = await Task.Run(() =>
            {
                List <GrepLine> list = new List <GrepLine>();
                if (GrepSettings.Instance.Get <bool>(GrepSettings.Key.ShowLinesInContext))
                {
                    list = result.GetLinesWithContext(GrepSettings.Instance.Get <int>(GrepSettings.Key.ContextLinesBefore),
                                                      GrepSettings.Instance.Get <int>(GrepSettings.Key.ContextLinesAfter));
                }
                else
                {
                    list = result.GetLinesWithContext(0, 0);
                }

                return(list);
            });

            if (this.Count == 1 && this[0].GrepLine.LineNumber == -1)
            {
                if (Application.Current != null)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                                                                     this.Clear()
                                                                     ));
                }
            }

            List <FormattedGrepLine> tempList = new List <FormattedGrepLine>();

            for (int i = 0; i < linesWithContext.Count; i++)
            {
                GrepLine line           = linesWithContext[i];
                bool     isSectionBreak = false;

                // Adding separator
                if (tempList.Count > 0 && GrepSettings.Instance.Get <bool>(GrepSettings.Key.ShowLinesInContext) &&
                    (currentLine != line.LineNumber && currentLine + 1 != line.LineNumber))
                {
                    isSectionBreak = true;
                }

                currentLine = line.LineNumber;
                if (currentLine <= 999 && LineNumberColumnWidth < 30)
                {
                    LineNumberColumnWidth = 30;
                }
                else if (currentLine > 999 && LineNumberColumnWidth < 35)
                {
                    LineNumberColumnWidth = 35;
                }
                else if (currentLine > 9999 && LineNumberColumnWidth < 47)
                {
                    LineNumberColumnWidth = 47;
                }
                else if (currentLine > 99999 && LineNumberColumnWidth < 50)
                {
                    LineNumberColumnWidth = 50;
                }
                tempList.Add(new FormattedGrepLine(line, formattedResult, LineNumberColumnWidth, isSectionBreak));
            }

            if (Application.Current != null)
            {
                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    foreach (var l in tempList)
                    {
                        this.Add(l);
                    }
                }
                                                                 ));
            }
            IsLoaded  = true;
            IsLoading = false;
            LoadFinished?.Invoke(this, EventArgs.Empty);
            return(true);
        }