public void ShowExpress() { TargetCanvas.UpdateLayout(); TargetCanvas.Children.Clear(); if (SceneList.Count == 0 && EpisodeList.Count == 0) { return; } if (TargetCanvas.ActualHeight == 0 || TargetCanvas.ActualWidth == 0) { return; } DrawTimeLine(); DrawTimeMark(); if (IsShowEpisode) { foreach (var e in EpisodeList) { DrawEpisode(e); } } foreach (var s in SceneList) { DrawScene(s); } RefreshSceneSummary(); }
private void DrawSection(float x, float y, float w, float h, float u0, float v0, float u1, float v1) { float crx = x, cry = y, crw = w, crh = h; if (ClampRect.Size > 0) { crx = ClampRect.x; cry = ClampRect.y; crw = ClampRect.w; crh = ClampRect.h; } if (MathHelpers.Approximately(ClampRect.Size, 0) || (crx <= x && cry <= y && crx + crw >= x + w && cry + crh >= y + h)) { if (RoundLocation) { x = (int)x; y = (int)y; } TargetCanvas.PushTexturePart(this, x, y, w, h, u0, v0, u1, v1, Angle, Color); } else { if (crx >= x + w || crx + crw <= x || cry >= y + h || cry + crh <= y || crw <= 0 || crh <= 0) { return; } float cx = x, cy = y, cw = w, ch = h, cu0 = u0, cv0 = v0, cu1 = u1, cv1 = v1; if (crx > x) { cu0 = u0 + (u1 - u0) * (crx - x) / w; cx = crx; cw = cw - (crx - x); } if (crx + crw < x + w) { cu1 = u1 - (u1 - u0) * (x + w - crx - crw) / w; cw = crx + crw - cx; } if (cry > y) { cv0 = v0 + (v1 - v0) * (cry - y) / h; cy = cry; ch = ch - (cry - y); } if (cry + crh < y + h) { cv1 = v1 - (v1 - v0) * (y + h - cry - crh) / h; ch = cry + crh - cy; } if (RoundLocation) { cx = (int)cx; cy = (int)cy; } TargetCanvas.PushTexturePart(this, cx, cy, cw, ch, cu0, cv0, cu1, cv1, Angle, Color); } }
public FreeCellFlash() { // spawn the wpf control var c = new TargetCanvas(); Func<string, Class> f = e => KnownEmbeddedResources.Default[ScriptCoreLib.Shared.Avalon.Cards.KnownAssets.Path.Sounds + "/" + e + ".mp3"]; var deal = f("deal"); var click = f("click"); var drag = f("drag"); var win = f("win"); c.Sounds.deal = () => deal.ToSoundAsset().play(); c.Sounds.click = () => click.ToSoundAsset().play(); c.Sounds.drag = () => drag.ToSoundAsset().play(); c.Sounds.win = () => win.ToSoundAsset().play(); AvalonExtensions.AttachToContainer(c, this); }
/** * The initializationMonitoringFunction is run once per frame by the Cycle method of the POST page. * When it returns TRUE, the application switches to the first page that comes after the POST page. * If There is no other page than the POST page, then nothing will happen. */ public MyOnScreenApplication WithDefaultPostPage(Func <MyOnScreenApplication, bool> initializationMonitoringFunction) { // Make sure the POST page is the first one added if (Pages.Count() > 0) { throw new InvalidOperationException("The POST page must be the first page ever added to the application"); } // Enforce the order of builder operations to avoid null pointer exceptions if (Canvas == null) { throw new InvalidOperationException("Please call WithCanvas() before calling WithDefaultPostPage()"); } // Make sure the initialization function is set if (initializationMonitoringFunction == null) { throw new ArgumentException("The initialization monitoring function must be a lambda taking in a MyOnScreenObject and returning a bool"); } // Create the POST page and give it the functionality of switching to the next page once // the initialization monitoring function returns true MyPage POSTPage = (MyPage) new MyPage() .WithInvertedColors() .WithClientPreDrawMethod((MyCanvas TargetCanvas, int iterationIndex) => { TargetCanvas.Clear(); }) .WithClientCycleMethod((MyOnScreenObject obj, int iterationIndex) => { if (initializationMonitoringFunction(this)) { SwitchToPage(1); // will do nothing if the page does not exist } }); // Add the POST page to the application this.AddPage(POSTPage); // Add another filled panel to the POST page, to serve as background for the INITIALIZING text MyPanel TextBackgroundPanel = new MyPanel(0, 0, 2, 2).WithOptionalParameters(true, true, false); POSTPage.AddChild(TextBackgroundPanel); // Add the INIIALIZING text label to the POST page MyTextLabel TextLabel = new MyTextLabel("INITIALIZING", 1, 1).WithOptionalParameters(true, true, true); POSTPage.AddChild(TextLabel); // Compute the location and dimensions of the text and that of its back panel based on // the resolution of the Canvas int textLabelWidth = TextLabel.GetWidth(); int textLabelHeight = TextLabel.GetHeight(); // Update the label coordinates TextLabel.x = (Canvas.GetResX() - textLabelWidth) / 2; TextLabel.y = (Canvas.GetResY() - textLabelHeight) / 2 - 3; // Update the panel coordinates (the drawing framework handles overflows) TextBackgroundPanel.x = TextLabel.x - 3; TextBackgroundPanel.y = TextLabel.y - 2; TextBackgroundPanel.SetWidth(textLabelWidth + 6); TextBackgroundPanel.SetHeight(textLabelHeight + 3); // Add the moving square (a panel with some simple animation logic) POSTPage.AddChild( new MyPanel(TextBackgroundPanel.x, TextBackgroundPanel.y + TextBackgroundPanel.GetHeight() + 2, 7, 4) .WithOptionalParameters(true, true, false) .WithClientCycleMethod((MyOnScreenObject obj, int iterationIndex) => { obj.x++; if (obj.x > TextBackgroundPanel.x + TextBackgroundPanel.GetWidth() - 7) { obj.x = TextBackgroundPanel.x; } }) ); return(this); }