public override async void Load(object userState) { _currentUserState = userState; if (IsBusy) { return; } if (AsyncRemoteCollectionView.PageIndex < 0) { return; } IsBusy = true; LoadStarted?.Invoke(this, EventArgs.Empty); try { var result = await _load(); CurrentResult = result; _onLoadCompleted?.Invoke(result); OnLoadCompleted(new AsyncCompletedEventArgs(result.Error, result.IsCanceled, _currentUserState)); } catch (Exception ex) { OnLoadCompleted(new AsyncCompletedEventArgs(ex, false, null)); } finally { IsBusy = false; } }
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); }; }
public override void Load(object userState) { _currentUserState = userState; if (IsBusy) { return; } if (RemoteCollectionView.PageIndex < 0) { return; } IsBusy = true; LoadStarted?.Invoke(this, EventArgs.Empty); try { CurrentOperation = _load(); } catch (Exception) { IsBusy = false; throw; } }
private void ProgressChanged(object sender, ProgressTaskChangeArgs args) { if (!IsLoading && args.NewValue > 0.0f && args.NewValue < 1.0f) { IsLoading = true; LoadStarted?.Invoke(this); } }
public void Search(string exportLocalName, DateTime exportDateFrom, DateTime exportDateTo) { LoadStarted?.Invoke(); ExportsSearchCryteria searchCryteria = BuildCryteria(exportLocalName, exportDateFrom, exportDateTo); List <Export> result = Map(searchService.GetExports(searchCryteria)); LoadCompleted?.Invoke(); RefreshList?.Invoke(result); }
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); }; }
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); } }
internal protected virtual void OnLoadStart(LoadStartEventArgs e) { LoadStarted?.Invoke(this, e); }
public override void DidStartProvisionalNavigation(WKWebView webView, WKNavigation navigation) { LoadStarted?.Invoke(); }
//@cond IGNORE public void OnRendererLoadStarted(string messageId) { LoadStarted?.Invoke(this, new MessageLoadStartedEventArgs(messageId)); }
/// <summary> /// Loads database data into in-memory objects /// </summary> public void Load() { // NeoFly database file path string dbPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\NeoFly\common.db"; if (!File.Exists(dbPath)) { throw new FileNotFoundException(dbPath); } DataSetNeoFlyData = new DataSet(); // In-memory log table structure TableLog = DataSetNeoFlyData.Tables.Add("log"); TableLog.Columns.Add("Export", typeof(bool)); TableLog.Columns.Add("Id", typeof(int)); TableLog.Columns.Add("Date", typeof(DateTime)); TableLog.Columns.Add("From", typeof(string)); TableLog.Columns.Add("To", typeof(string)); // In-memory trajectory log table structure TableTrajectoryLog = DataSetNeoFlyData.Tables.Add("trajectoryLog"); TableTrajectoryLog.Columns.Add("Id", typeof(int)); TableTrajectoryLog.Columns.Add("FlightId", typeof(int)); TableTrajectoryLog.Columns.Add("Lon", typeof(double)); TableTrajectoryLog.Columns.Add("Lat", typeof(double)); TableTrajectoryLog.Columns.Add("Altitude", typeof(int)); // Relation between flight and flight trajectory RelationLoTrajectoryLog = DataSetNeoFlyData.Relations.Add(TableLog.Columns["Id"], TableTrajectoryLog.Columns["FlightId"]); // Db connection using (var connection = new SqliteConnection("Data Source=" + dbPath)) { connection.Open(); // Airport command var commandAirport = connection.CreateCommand(); commandAirport.CommandText = "SELECT lonx, laty, altitude FROM airport WHERE ident = $ident"; commandAirport.Parameters.Add("$ident", SqliteType.Text); commandAirport.Prepare(); // Trajectory log command var commandTrajectoryLog = connection.CreateCommand(); commandTrajectoryLog.CommandText = "SELECT id, location, altitude FROM trajectoryLog WHERE flightId = $flightId ORDER BY id"; commandTrajectoryLog.Parameters.Add("$flightId", SqliteType.Integer); commandTrajectoryLog.Prepare(); // Log command var commandLog = connection.CreateCommand(); commandLog.CommandText = "SELECT COUNT(*) FROM log"; int logCount = Convert.ToInt32(commandLog.ExecuteScalar()); int currentLog = 0; LoadStarted?.Invoke(this, new NeoFlyDataLoadEventArgs() { RowCount = logCount }); commandLog = connection.CreateCommand(); commandLog.CommandText = "SELECT id, date, fp FROM log ORDER BY date"; using (var readerLog = commandLog.ExecuteReader()) { while (readerLog.Read()) { try { // Flight var row = TableLog.NewRow(); row["Id"] = readerLog.GetInt32(0); row["Date"] = readerLog.GetDateTime(1); string[] fp = readerLog.GetString(2).Split('>'); row["From"] = fp[0]; row["To"] = fp[1]; row["Export"] = true; TableLog.Rows.Add(row); // Trajectory bool trajectoryData = false; commandTrajectoryLog.Parameters["$flightId"].Value = row["Id"]; using (var readerTrajectoryLog = commandTrajectoryLog.ExecuteReader()) { while (readerTrajectoryLog.Read()) { var trajRow = TableTrajectoryLog.NewRow(); trajRow["Id"] = readerTrajectoryLog.GetInt32(0); trajRow["FlightId"] = row["Id"]; // The location field may be corrupt, in that case the row is skipped string[] location = readerTrajectoryLog.GetString(1).Split(','); if (location.Length != 2) { continue; } // The latitude value is checked double coordValue; if (!double.TryParse(location[0], NumberStyles.Float, CultureInfo.InvariantCulture, out coordValue)) { continue; } trajRow["Lat"] = coordValue; // The longitude value is checked if (!double.TryParse(location[1], NumberStyles.Float, CultureInfo.InvariantCulture, out coordValue)) { continue; } trajRow["Lon"] = coordValue; // Altitude trajRow["Altitude"] = readerTrajectoryLog.GetInt32(2); // We skip the row is the coordinates are "0,0" if ((double)trajRow["Lat"] == 0 && (double)trajRow["Lon"] == 0) { continue; } TableTrajectoryLog.Rows.Add(trajRow); trajectoryData = true; } } // If no trajectory data is available (old NeoFly version), we add two waypoints: departure and arrival if (!trajectoryData) { foreach (string airportId in fp) { commandAirport.Parameters["$ident"].Value = airportId; using (var readerFrom = commandAirport.ExecuteReader()) { if (readerFrom.Read()) { var trajRow = TableTrajectoryLog.NewRow(); trajRow["FlightId"] = row["Id"]; trajRow["Lon"] = readerFrom.GetDouble(0); trajRow["Lat"] = readerFrom.GetDouble(1); trajRow["Altitude"] = readerFrom.GetInt32(2); TableTrajectoryLog.Rows.Add(trajRow); } } } } } finally { LoadProgress?.Invoke(this, new NeoFlyDataLoadEventArgs() { CurrentRow = ++currentLog }); } } } LoadEnded?.Invoke(this, null); } }