public void OpenFile(string filePath) { _file = new StreamReader(filePath, Encoding.UTF8); Position = new PointerPosition(); }
private void AdjustPointer1(PointerPosition position) { CreatePointer1Points(position.Length); Polygon poly = GetTemplateChild("polygonPointer1") as Polygon; if ((poly != null) && (poly.Effect != null) && (poly.Effect.GetType() == typeof(DropShadowEffect))) { DropShadowEffect shadow = new DropShadowEffect(); shadow.Color = ((DropShadowEffect)poly.Effect).Color; shadow.Opacity = ((DropShadowEffect)poly.Effect).Opacity; shadow.BlurRadius = ((DropShadowEffect)poly.Effect).BlurRadius; shadow.ShadowDepth = ((DropShadowEffect)poly.Effect).ShadowDepth; shadow.Direction = position.Angle + DropShadowAngle + Rotation; poly.Effect = shadow; } }
void ISynthesizer.ChangeTone(PointerPosition position) { _waveSource.ChangeWave(position.X, position.Y); }
/// <summary> /// Updates curl position. /// </summary> /// <param name="pointerPos"></param> private void UpdateCurlPosition(PointerPosition pointerPos) { // Default curl radius. double radius = mRenderer.GetPageRect(CURL_RIGHT).Width() / 3; // TODO: This is not an optimal solution. Based on feedback received so // far; pressure is not very accurate, it may be better not to map // coefficient to range [0f, 1f] but something like [.2f, 1f] instead. // Leaving it as is until get my hands on a real device. On emulator // this doesn't work anyway. radius *= Math.Max(1f - pointerPos.mPressure, 0f); // NOTE: Here we set pointerPos to mCurlPos. It might be a bit confusing // later to see e.g "mCurlPos.X - mDragStartPos.X" used. But it's // actually pointerPos we are doing calculations against. Why? Simply to // optimize code a bit with the cost of making it unreadable. Otherwise // we had to this in both of the next if-else branches. mCurlPos.Set(pointerPos.mPos); // If curl happens on right page, or on left page on two page mode, // we'll calculate curl position from pointerPos. if (mCurlState == CURL_RIGHT || (mCurlState == CURL_LEFT && mViewMode == SHOW_TWO_PAGES)) { mCurlDir.X = mCurlPos.X - mDragStartPos.X; mCurlDir.Y = mCurlPos.Y - mDragStartPos.Y; float dist = (float)Math.Sqrt(mCurlDir.X * mCurlDir.X + mCurlDir.Y * mCurlDir.Y); // Adjust curl radius so that if page is dragged far enough on // opposite side, radius gets closer to zero. float pageWidth = mRenderer.GetPageRect(CurlRenderer.PAGE_RIGHT) .Width(); double curlLen = radius * Math.PI; if (dist > (pageWidth * 2) - curlLen) { curlLen = Math.Max((pageWidth * 2) - dist, 0f); radius = curlLen / Math.PI; } // Actual curl position calculation. if (dist >= curlLen) { double translate = (dist - curlLen) / 2; if (mViewMode == SHOW_TWO_PAGES) { mCurlPos.X -= mCurlDir.X * (float)translate / dist; } else { float pageLeftX = mRenderer .GetPageRect(CurlRenderer.PAGE_RIGHT).Left; radius = Math.Max(Math.Min(mCurlPos.X - pageLeftX, radius), 0f); } mCurlPos.Y -= mCurlDir.Y * (float)translate / dist; } else { double angle = Math.PI * Math.Sqrt(dist / curlLen); double translate = radius * Math.Sin(angle); mCurlPos.X += mCurlDir.X * (float)translate / dist; mCurlPos.Y += mCurlDir.Y * (float)translate / dist; } } // Otherwise we'll let curl follow pointer position. else if (mCurlState == CURL_LEFT) { // Adjust radius regarding how close to page edge we are. float pageLeftX = mRenderer.GetPageRect(CurlRenderer.PAGE_RIGHT).Left; radius = Math.Max(Math.Min(mCurlPos.X - pageLeftX, radius), 0f); float pageRightX = mRenderer.GetPageRect(CurlRenderer.PAGE_RIGHT).Right; mCurlPos.X -= Math.Min(pageRightX - mCurlPos.X, (float)radius); mCurlDir.X = mCurlPos.X + mDragStartPos.X; mCurlDir.Y = mCurlPos.Y - mDragStartPos.Y; } SetCurlPosition(mCurlPos, mCurlDir, radius); }
void ISynthesizer.BeginTone(PointerPosition position) { _waveSource.BeginWave(position.X, position.Y); }