public void OnOk(Window win) { if (this.CurrentViewModel is GoogleHistoryViewModel) { GoogleHistoryViewModel gh = this.CurrentViewModel as GoogleHistoryViewModel; this.m_history = gh.Adapt <GoogleHistory>(); this.m_history.OnRetrievedDataHandler = History_OnRetrievedData; this.m_history.ExecuteAsync(); this.CurrentViewModel = new LoadingViewModel(); this.IsOkButtonVisible = false; this.RaisePropertyChanged(null); } else if (this.CurrentViewModel is LoadingViewModel) { } else if (this.CurrentViewModel is DataResultViewModel) { this.OnCancel(win); DataResultViewModel dvm = this.CurrentViewModel as DataResultViewModel; if (ExcelHandler.WriteToRangeHandler != null) { ExcelHandler.WriteToRangeHandler(dvm.Result, dvm.GH); } } }
private void History_OnRetrievedData(GoogleHistory gh, object[,] result) { DataResultViewModel dvm = new DataResultViewModel(); dvm.GH = gh; dvm.Result = result; this.CurrentViewModel = dvm; this.IsOkButtonVisible = true; this.IsCancelButonVisible = false; this.RaisePropertyChanged(null); }
private void btnOK_Click(object sender, RoutedEventArgs e) { history = new GoogleHistory(); history.SecurityId = this.tbSecurityId.Text; history.StartDate = DateTime.Parse(this.tbStartDate.Text); history.EndDate = DateTime.Parse(this.tbEndDate.Text); this.Visibility = Visibility.Hidden; history.OnRetrievedDataHandler = History_OnRetrievedData; history.ExecuteAsync(); WindowHelper.ShowWindow(createLoadingInstance, null); }
internal static GoogleHistory GetHistoryByRange(Range targetRange) { ExcelUIThreadProtecter.CheckIsExcelUIMainThread(); GoogleHistory result = null; string rangeName = MainThreadLogic.RangeManager.GetRangeName(targetRange); if (string.IsNullOrEmpty(rangeName) == false) { result = ExcelWvvm.Entities.GoogleHistories.GetByRangeName(rangeName); } return(result); }
internal static void ShowRefreshingComment(GoogleHistory history, string commnet = "Refreshing...") { ExcelUIThreadProtecter.CheckIsExcelUIMainThread(); Worksheet ws = ExcelApp.Application.ActiveSheet; Range targetRange = MainThreadLogic.RangeManager.GetRange(ws, history.RangeName); if (targetRange != null) { targetRange = targetRange.Cells[1, 1]; Comment refreshingComment = targetRange.Comment; if (refreshingComment == null) { refreshingComment = targetRange.AddComment(); } refreshingComment.Shape.TextFrame.AutoSize = true; refreshingComment.Shape.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; //refreshingComment.Shape.Fill.ForeColor.RGB =RGB(220, 220, 220); refreshingComment.Shape.Fill.OneColorGradient(Microsoft.Office.Core.MsoGradientStyle.msoGradientDiagonalUp, 1, (float)0.4); refreshingComment.Visible = true; refreshingComment.Text(commnet); } }
private void History_OnRetrievedData(GoogleHistory gh, object[,] result) { WindowHelper.CloseWindow(this.loadingWindow); WindowHelper.ShowWindow <WinDataResult>(showDataResult, new object[] { result, gh }); }
public static object[,] GoogleHistory(GoogleHistory history) { System.Threading.Thread.Sleep(5000); //to simulate slow call. return(GoogleHistory(history.SecurityId, history.StartDate.ToOADate(), history.EndDate.ToOADate(), "d", "dohlcv", false, false)); }
public static void WriteToRange(object[,] result, GoogleHistory history) { Tuple <GoogleHistory, object[, ]> parameters = new Tuple <GoogleHistory, object[, ]>(history, result); ExcelDna.Integration.ExcelAsyncUtil.QueueAsMacro(writeRangeToExcel, parameters); }