public void ShowMessage(string s) { CustomMessageBox cmb = new CustomMessageBox(s); cmb.Owner = this; this.Effect = b; DoubleAnimation anim = new DoubleAnimation(); anim.From = 0; anim.To = 20; anim.Duration = (Duration)TimeSpan.FromSeconds(.3); b.BeginAnimation(BlurEffect.RadiusProperty, anim); if (cmb.ShowDialog() == true) { InitializeGame(); } else { anim.Duration = (Duration)TimeSpan.FromSeconds(0.15); GameGrid.Visibility = Visibility.Hidden; StartGame.Visibility = Visibility.Visible; } anim.From = 20; anim.To = 0; b.BeginAnimation(BlurEffect.RadiusProperty, anim); }
private void ShowTasks(bool animate) { ShowSavegames(false); if (animate && TaskListPanel.Visibility == Visibility.Hidden) { TaskListPanel.BeginAnimation(DockPanel.OpacityProperty, null); var anim = new DoubleAnimation(0, 2, new Duration(TimeSpan.FromSeconds(0.1))) { DecelerationRatio = 1 }; TaskListPanel.BeginAnimation(DockPanel.OpacityProperty, anim); var blur = new BlurEffect { RenderingBias = RenderingBias.Quality, Radius = 30 }; TaskListPanel.Effect = blur; var anim0 = new DoubleAnimation(10, 0, new Duration(TimeSpan.FromSeconds(0.5))) { DecelerationRatio = 1 }; anim0.Completed += (object sender, EventArgs e) => { SaveListPanel.Effect = null; }; blur.BeginAnimation(BlurEffect.RadiusProperty, anim0); } TaskListPanel.Visibility = Visibility.Visible; }
public Pokemon2D() { IsHitTestVisible = false; UseLayoutRounding = true; Image = new Image() { Stretch = Stretch.UniformToFill }; Image.SnapsToDevicePixels = true; Image.Effect = ImageEffect = new BlurEffect() { Radius = 0, KernelType = KernelType.Box }; Children.Add(Image); FaintAnimation = new DoubleAnimation(0, 0, Duration.Automatic); FaintAnimation.Completed += (sender, e) => { Image.Source = null; Pokemon.RemoveListener(this); Pokemon = null; Image.BeginAnimation(Image.HeightProperty, null); }; BeginChangeImageAnimation = new DoubleAnimation(0, 15, new Duration(TimeSpan.FromSeconds(0.5))); EndChangeImageAnimation = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(0.5))); BeginChangeImageAnimation.Completed += (sender, e) => { RefreshImage(); ImageEffect.BeginAnimation(BlurEffect.RadiusProperty, EndChangeImageAnimation); }; }
public NumberInput(string title, string description) { InitializeComponent(); Opacity = 0; var anim = new DoubleAnimation(1, new Duration(TimeSpan.FromSeconds(0.1))) { DecelerationRatio = 1 }; BeginAnimation(Window.OpacityProperty, anim); var blur = new BlurEffect { Radius = 10, RenderingBias = RenderingBias.Quality }; Effect = blur; var anim0 = new DoubleAnimation(1, new Duration(TimeSpan.FromSeconds(0.4))) { DecelerationRatio = 1 }; blur.BeginAnimation(BlurEffect.RadiusProperty, anim0); Title = title; Description.Text = description; }
private async Task ShowPinInputAnimate() { await EnsurePinInputAnimationSecurity(); _inputShowLock = true; var time = 1200; var timeSpan = TimeSpan.FromMilliseconds(time); var effect = new BlurEffect() { Radius = 0 }; grid.Effect = effect; var animation = new DoubleAnimation(30, new Duration(timeSpan)); var opacityAnimation = new DoubleAnimation(1, new Duration(timeSpan)); effect.BeginAnimation(BlurEffect.RadiusProperty, animation); grid.IsHitTestVisible = false; pinInputGrid.Visibility = Visibility.Visible; pinInputGrid.BeginAnimation(OpacityProperty, opacityAnimation); pinInputGrid.Focus(); await Task.Delay(timeSpan); grid.IsHitTestVisible = false; pinInputGrid.Visibility = Visibility.Visible; pinInput.Focus(); _inputShowLock = false; }
public ListInput(string title, string description, string[] items) { InitializeComponent(); Opacity = 0; var anim = new DoubleAnimation(1, new Duration(TimeSpan.FromSeconds(0.1))); anim.DecelerationRatio = 1; BeginAnimation(Window.OpacityProperty, anim); var blur = new BlurEffect(); blur.Radius = 10; blur.RenderingBias = RenderingBias.Quality; Effect = blur; var anim0 = new DoubleAnimation(1, new Duration(TimeSpan.FromSeconds(0.4))); anim0.DecelerationRatio = 1; blur.BeginAnimation(BlurEffect.RadiusProperty, anim0); Title = title; Description.Text = description; foreach (var item in items) { ItemList.Items.Add(item); } }
/// <summary> /// Turning blur off /// </summary> /// <param name="element">bluring element</param> /// <param name="duration">blur animation duration</param> public static void BlurDisable(this UIElement element, TimeSpan duration) { BlurEffect blur = element.Effect as BlurEffect; if (blur == null || blur.Radius == 0) { return; } DoubleAnimation blurDisable = new DoubleAnimation(blur.Radius, 0, duration); blur.BeginAnimation(BlurEffect.RadiusProperty, blurDisable); }
/// <summary> /// Включение анимации для эффекта размытия элемента /// </summary> /// <param name="element">UI-элемент назначения</param> /// <param name="blurRadius">Радиус размытия</param> /// <param name="duration">Время эффекта</param> /// <param name="beginTime">Время задержки</param> public static void BlurApply(this UIElement element, double blurRadius, TimeSpan duration, TimeSpan beginTime) { var blur = new BlurEffect { Radius = 0 }; var blurEnable = new DoubleAnimation(0, blurRadius, duration) { BeginTime = beginTime }; element.Effect = blur; blur.BeginAnimation(BlurEffect.RadiusProperty, blurEnable); }
/// <summary> /// Apply blur effect to the specified <see cref="UIElement"/> /// </summary> /// <param name="element">Element to blur</param> /// <param name="blurRadius">Blur radius</param> /// <param name="duration">Blur transition duration</param> /// <param name="beginTime">Blur transition start time</param> public static void ApplyBlur(this UIElement element, double blurRadius, TimeSpan duration, TimeSpan beginTime) { BlurEffect blurEffect = new BlurEffect { Radius = 0.0 }; DoubleAnimation doubleAnimation1 = new DoubleAnimation(0.0, blurRadius, duration) { BeginTime = beginTime }; DoubleAnimation doubleAnimation2 = doubleAnimation1; element.Effect = blurEffect; blurEffect.BeginAnimation(BlurEffect.RadiusProperty, doubleAnimation2); }
public void AnimateBlur(int from, int to) { BlurEffect b = new BlurEffect(); owner.Effect = b; DoubleAnimation anim = new DoubleAnimation(); anim.From = from; anim.To = to; anim.Duration = (Duration)TimeSpan.FromSeconds(AnimationTime); b.BeginAnimation(BlurEffect.RadiusProperty, anim); }
private void InitiateLogin(User user) { var effect = new BlurEffect(); effect.RenderingBias = RenderingBias.Performance; effect.KernelType = KernelType.Box; effect.Radius = 0; var duration = new Duration(TimeSpan.FromMilliseconds(333)); var anim = new DoubleAnimation(0.0, 20.0, duration); anim.Completed += (sender, args) => { MainViewModel.Instance.CurrentUser = user; anim = new DoubleAnimation(0.0, duration); anim.Completed += (o, eventArgs) => { Effect = null; }; effect.BeginAnimation(BlurEffect.RadiusProperty, anim); }; Effect = effect; effect.BeginAnimation(BlurEffect.RadiusProperty, anim); }
private void BlurTabs() { if (Tabs.Effect != null) { return; } var effect = new BlurEffect { Radius = 0 }; Tabs.Effect = effect; effect.BeginAnimation(BlurEffect.RadiusProperty, new DoubleAnimation(5, fastTime)); GotoBackground.BeginAnimation(OpacityProperty, new DoubleAnimation(0, .7, fastTime)); }
void AssociatedObject_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) { if ((bool)e.NewValue == false) { //Blur BlurEffect effect = AssociatedObject.Effect as BlurEffect; effect.BeginAnimation(BlurEffect.RadiusProperty, new DoubleAnimation(10, TimeSpan.FromSeconds(0.5))); } else { //UnBlur BlurEffect effect = AssociatedObject.Effect as BlurEffect; effect.BeginAnimation(BlurEffect.RadiusProperty, new DoubleAnimation(0, TimeSpan.FromSeconds(0.25))); } }
public void CloseEditor() { DoubleAnimation animation = new DoubleAnimation(); animation.From = 10d; animation.To = 0d; animation.Duration = TimeSpan.FromSeconds(0.5d); BlurEffect effect = (BlurEffect)LeftPanel.Effect; animation.Completed += HideEditorFrame; effect.BeginAnimation(BlurEffect.RadiusProperty, animation); LeftPanel.Effect = effect; RightPanel.Effect = effect; }
static void BlurApply(UIElement element, double blurRadius, TimeSpan duration, TimeSpan beginTime, EventHandler onBlured) { BlurEffect blur = new BlurEffect() { Radius = 0 }; DoubleAnimation blurEnable = new DoubleAnimation(0, blurRadius, duration) { BeginTime = beginTime }; element.Effect = blur; blurEnable.Completed += onBlured; blur.BeginAnimation(BlurEffect.RadiusProperty, blurEnable); }
static void BlurDisable(UIElement element, TimeSpan duration, TimeSpan beginTime, EventHandler onBlured) { BlurEffect blur = element.Effect as BlurEffect; if (blur == null || blur.Radius == 0) { return; } DoubleAnimation blurDisable = new DoubleAnimation(blur.Radius, 0, duration) { BeginTime = beginTime }; blurDisable.Completed += onBlured; blur.BeginAnimation(BlurEffect.RadiusProperty, blurDisable); //while (blur.Radius > 0) { } }
public void CloseEditor() { DoubleAnimation animation = new DoubleAnimation(); animation.From = 10d; animation.To = 0d; animation.Duration = TimeSpan.FromSeconds(0.5d); BlurEffect effect = (BlurEffect)LeftPanel.Effect; animation.Completed += HideEditorFrame; effect.BeginAnimation(BlurEffect.RadiusProperty, animation); LeftPanel.Effect = effect; RightPanel.Effect = effect; Tools.Animations.FadeOut(ConversationsPage.Instance.Editor, .25d, null); EditorHub.HubInstance.ShowNavigatorPanel(); }
/// <summary> /// 变更精灵的模糊度动画 /// <para>这是一个特效互斥动画,多个特效互斥动画之间不叠加</para> /// </summary> /// <param name="sprite">精灵对象</param> /// <param name="duration">动画时长</param> /// <param name="fromRadius">起始模糊半径</param> /// <param name="toRadius">目标模糊半径</param> public static void BlurMutexAnimation(YuriSprite sprite, Duration duration, double fromRadius, double toRadius) { if (duration.TimeSpan.TotalMilliseconds == 0 || GlobalConfigContext.GAME_PERFORMANCE_TYPE == GlobalConfigContext.PerformanceType.NoEffect) { BlurEffect m_BlurEffect = new BlurEffect(); sprite.AnimationElement.Effect = m_BlurEffect; m_BlurEffect.RenderingBias = GlobalConfigContext.GAME_PERFORMANCE_TYPE == GlobalConfigContext.PerformanceType.HighQuality ? RenderingBias.Quality : RenderingBias.Performance; m_BlurEffect.Radius = toRadius; sprite.Descriptor.BlurRadius = toRadius; } else { BlurEffect m_BlurEffect = new BlurEffect(); sprite.AnimationElement.Effect = m_BlurEffect; m_BlurEffect.RenderingBias = GlobalConfigContext.GAME_PERFORMANCE_TYPE == GlobalConfigContext.PerformanceType.HighQuality ? RenderingBias.Quality : RenderingBias.Performance; DoubleAnimation m_DA = new DoubleAnimation { From = fromRadius, To = toRadius, Duration = duration, EasingFunction = new CubicEase(), }; sprite.AnimateCount++; var flagSb = new Storyboard { Name = "FlagSb_" + DateTime.Now.Ticks }; SpriteAnimation.aniDict[flagSb] = sprite; m_DA.Completed += (sender, args) => { sprite.Descriptor.BlurRadius = sprite.Descriptor.ToBlurRadius; m_BlurEffect.Radius = toRadius; sprite.AnimateCount--; aniDict.Remove(flagSb); }; m_BlurEffect.BeginAnimation(BlurEffect.RadiusProperty, m_DA); } }
public void AnimateBlurEffect(int zIndex, int from, int to, int opacityFrom, int opacityTo) { Panel.SetZIndex(PopupGrid, zIndex); BlurEffect b = new BlurEffect(); MainView.Effect = b; DoubleAnimation anim = new DoubleAnimation(); anim.From = from; anim.To = to; anim.Duration = (Duration)TimeSpan.FromSeconds(.1); DoubleAnimation opacityAnimation = new DoubleAnimation(); opacityAnimation.From = opacityFrom; opacityAnimation.To = opacityTo; opacityAnimation.Duration = (Duration)TimeSpan.FromSeconds(.1); PopupGrid.BeginAnimation(OpacityProperty, opacityAnimation); b.BeginAnimation(BlurEffect.RadiusProperty, anim); }
// -------- Alerting System (AS) -------- // -------- Message Communication System (SWA compatibility) -------- public void LoadToFloatingFrame(Page page) { FloatingFrame.Visibility = Visibility.Visible; FloatingFrame.Opacity = 0d; FloatingFrame.Navigate(page); Tools.Animations.FadeIn(FloatingFrame, .25d, null); BlurEffect effect = new BlurEffect(); effect.Radius = 0d; DoubleAnimation animation = new DoubleAnimation(); animation.From = 0d; animation.To = 10d; animation.Duration = TimeSpan.FromSeconds(0.5d); effect.BeginAnimation(BlurEffect.RadiusProperty, animation); DisplayFrame.Effect = effect; ActionBar.Effect = effect; }
private void UpdateUiForConnectButtonClick() { //if prev was on if (_prevConnectionState) { //turn off //update button text ConnectButton.Content = "Connect"; //disable message entry MessageTextBox.IsEnabled = false; SendMessageButton.IsEnabled = false; StopButton.IsEnabled = false; //disable server and port text boxes ServerTextBox.IsEnabled = true; PortTextBox.IsEnabled = true; //create animations var ledBlurRadiusAnimation = new DoubleAnimation(LedBlurRadius, 0, TimeSpan.FromSeconds(LightToggleAnimLength)); var logoImageBlurRadiusAnimation = new DoubleAnimation(LogoBlurRadius, 0, TimeSpan.FromSeconds(LightToggleAnimLength)); var ledOpacityAnimation = new DoubleAnimation(LedOnOpacity, LedOffOpacity, TimeSpan.FromSeconds(LightToggleAnimLength)); var logoOpacityAnimation = new DoubleAnimation(LogoOnOpacity, LogoOffOpacity, TimeSpan.FromSeconds(LightToggleAnimLength)); //start animations _ledBlurEffect.BeginAnimation(BlurEffect.RadiusProperty, ledBlurRadiusAnimation); _logoBlurEffect.BeginAnimation(BlurEffect.RadiusProperty, logoImageBlurRadiusAnimation); ConnectionStatusLedImage.BeginAnimation(OpacityProperty, ledOpacityAnimation); LogoImageBlurLayer.BeginAnimation(OpacityProperty, logoOpacityAnimation); LogoImage.BeginAnimation(OpacityProperty, logoOpacityAnimation); } else { //else turn on // update button text ConnectButton.Content = "Disconnect"; //enable message entry MessageTextBox.IsEnabled = true; SendMessageButton.IsEnabled = true; StopButton.IsEnabled = true; //enable server and port text boxes ServerTextBox.IsEnabled = false; PortTextBox.IsEnabled = false; //create animations var ledBlurRadiusAnimation = new DoubleAnimation(0, LedBlurRadius, TimeSpan.FromSeconds(LightToggleAnimLength)); var logoImageBlurRadiusAnimation = new DoubleAnimation(0, LogoBlurRadius, TimeSpan.FromSeconds(LightToggleAnimLength)); var ledOpacityAnimation = new DoubleAnimation(LedOffOpacity, LedOnOpacity, TimeSpan.FromSeconds(LightToggleAnimLength)); var logoOpacityAnimation = new DoubleAnimation(LogoOffOpacity, LogoOnOpacity, TimeSpan.FromSeconds(LightToggleAnimLength)); //start animations _ledBlurEffect.BeginAnimation(BlurEffect.RadiusProperty, ledBlurRadiusAnimation); _logoBlurEffect.BeginAnimation(BlurEffect.RadiusProperty, logoImageBlurRadiusAnimation); ConnectionStatusLedImage.BeginAnimation(OpacityProperty, ledOpacityAnimation); LogoImageBlurLayer.BeginAnimation(OpacityProperty, logoOpacityAnimation); LogoImage.BeginAnimation(OpacityProperty, logoOpacityAnimation); } }
public void ToClear() { var animation = resource.Animation.Instance.SearchAnimationResouce <DoubleAnimation>("CountTo0"); effect?.BeginAnimation(BlurEffect.RadiusProperty, animation); }
void timer_Tick(object sender, EventArgs e) { this.ParentJanitor.ScreenSaverRuns = true; this.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, (DummyDelegate) delegate { ScatterViewItem svi = new ScatterViewItem(); //Viewbox svi = new Viewbox(); Viewbox vb = new Viewbox(); Label label = new Label(); label.Content = d[rand.Next(0, d.Count)]; label.Foreground = new SolidColorBrush(Colors.White); label.Width = 200; label.Height = 50; label.FontSize = 20; label.FontWeight = FontWeights.ExtraLight; label.HorizontalContentAlignment = HorizontalAlignment.Center; vb.Child = label; svi.Content = vb; vb.IsEnabled = false; svi.Orientation = 0; svi.Opacity = 0; svi.Width = 4000; svi.Height = 1000; BlurEffect blur = new BlurEffect(); blur.Radius = 50; blur.RenderingBias = RenderingBias.Performance; blur.KernelType = KernelType.Gaussian; svi.Effect = blur; svi.ApplyTemplate(); svi.Background = new SolidColorBrush(Colors.Transparent); svi.ShowsActivationEffects = false; Microsoft.Surface.Presentation.Generic.SurfaceShadowChrome ssc; ssc = svi.Template.FindName("shadow", svi) as Microsoft.Surface.Presentation.Generic.SurfaceShadowChrome; ssc.Visibility = Visibility.Hidden; svi.BorderBrush = Brushes.Transparent; svi.IsHitTestVisible = false; svi.ClipToBounds = false; DoubleAnimation blurAnim = new DoubleAnimation(20, 10, new Duration(TimeSpan.FromSeconds(4)), FillBehavior.Stop); blurAnim.AutoReverse = true; blur.BeginAnimation(BlurEffect.RadiusProperty, blurAnim, HandoffBehavior.Compose); DoubleAnimation WidthAnim = new DoubleAnimation(200, 4000, new Duration(TimeSpan.FromSeconds(8)), FillBehavior.Stop); WidthAnim.Completed += new EventHandler(WidthAnim_Completed); svi.BeginAnimation(ScatterViewItem.WidthProperty, WidthAnim, HandoffBehavior.Compose); DoubleAnimation HeightAnim = new DoubleAnimation(50, 1000, new Duration(TimeSpan.FromSeconds(8)), FillBehavior.Stop); svi.BeginAnimation(ScatterViewItem.HeightProperty, HeightAnim, HandoffBehavior.Compose); DoubleAnimation OpacityAnim = new DoubleAnimation(0, .5, new Duration(TimeSpan.FromSeconds(4)), FillBehavior.Stop); OpacityAnim.AutoReverse = true; svi.BeginAnimation(ScatterViewItem.OpacityProperty, OpacityAnim, HandoffBehavior.Compose); //sb.Children.Add(blurAnim); //sb.Children.Add(WidthAnim); //sb.Children.Add(HeightAnim); //sb.Children.Add(OpacityAnim); //Storyboard.SetTarget(blurAnim, blur); //Storyboard.SetTarget(WidthAnim, svi); //Storyboard.SetTarget(HeightAnim, svi); //Storyboard.SetTarget(OpacityAnim, svi); //Storyboard.SetTargetProperty(blurAnim, new PropertyPath(BlurEffect.RadiusProperty)); //Storyboard.SetTargetProperty(WidthAnim, new PropertyPath(ScatterViewItem.WidthProperty)); //Storyboard.SetTargetProperty(HeightAnim, new PropertyPath(ScatterViewItem.HeightProperty)); //Storyboard.SetTargetProperty(OpacityAnim, new PropertyPath(ScatterViewItem.OpacityProperty)); //sb.Begin(); MainSV.Items.Add(svi); }); }
void IPokemonOutwardEvents.ImageChanged() { ImageEffect.BeginAnimation(BlurEffect.RadiusProperty, BeginChangeImageAnimation); }
/* * Show screen containing all saved games found, allow user to load a game */ private void ShowLoadGameScreen() { AllowResize(false); TextBlock questionTextBlock = new TextBlock { Name = "questionTextBlock", Text = Settings.deleteGamesOnLoadScreen ? _environment.currentLanguage.UI_loadMenu_deleteInstructions : _environment.currentLanguage.UI_loadMenu_loadInstructions, TextAlignment = TextAlignment.Center, FontSize = 21, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White), Margin = new Thickness(10, 10, 10, 20) }; // Create grid for save slots Grid slotGrid = new Grid { Name = "slotGrid", Margin = new Thickness(10, 10, 10, 10), }; slotGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); slotGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); slotGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); slotGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); slotGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); slotGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); // Create save slots for (var i = 0; i < 3; i++) { for (var j = 1; j <= 3; j++) { // Gets the save file for this slot Savegame save = Savegame.DeserializeSaveGame(3 * i + j); // Creates UI content Button slot = new Button() { Name = "save_0" + (3 * i + j), Margin = new Thickness(10, 10, 10, 10), Width = 300, Height = 100 }; slotGrid.Children.Add(slot); Grid.SetColumn(slot, j - 1); Grid.SetRow(slot, i); if (save == null) { TextBlock emptySlotText = new TextBlock { Name = "emptySlotText", Text = _environment.currentLanguage.UI_emptySlot, FontSize = 21, FontWeight = FontWeights.Bold }; slot.Content = emptySlotText; } else if (Settings.deletedSaveSlot == (3 * i + j)) { TextBlock emptySlotText = new TextBlock { Name = "emptySlotText", Text = _environment.currentLanguage.UI_emptySlot, FontSize = 21, FontWeight = FontWeights.Bold }; slot.Content = emptySlotText; Settings.deletedSaveSlot = -1; } else { slot.Click += LoadSlotOnClick; Background selBackground = _assets.backgrounds.Find(bg => bg.name == save.currentEnvironment.currentBackgroundName); Image slotImage = new Image { Source = new BitmapImage(selBackground.imageUri) }; TextBlock slotText = new TextBlock { Name = "slotText", Text = save.currentEnvironment.fullText, TextWrapping = TextWrapping.Wrap, TextTrimming = TextTrimming.CharacterEllipsis, MaxHeight = 70, FontSize = 14, FontWeight = FontWeights.DemiBold }; TextBlock slotDate = new TextBlock { Name = "slotDate", Text = save.currentTime.ToString(CultureInfo.CurrentCulture), TextTrimming = TextTrimming.CharacterEllipsis, FontSize = 12, Margin = new Thickness(0, 10, 0, 0) }; Grid innerRightSlotGrid = new Grid { Name = "innerRightSlotGrid", Margin = new Thickness(5, 0, 0, 0) }; innerRightSlotGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(5, GridUnitType.Star) }); innerRightSlotGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(2, GridUnitType.Star) }); innerRightSlotGrid.Children.Add(slotText); innerRightSlotGrid.Children.Add(slotDate); Grid.SetRow(slotText, 0); Grid.SetRow(slotDate, 1); Grid innerSlotGrid = new Grid { Name = "innerSlotGrid", }; innerSlotGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); innerSlotGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); innerSlotGrid.Children.Add(innerRightSlotGrid); innerSlotGrid.Children.Add(slotImage); Grid.SetColumn(slotImage, 0); Grid.SetColumn(innerRightSlotGrid, 1); slot.Content = innerSlotGrid; } } } TextBlock changeModeTextBlock = new TextBlock { Name = "changeModeTextBlock", FontSize = 21, FontWeight = FontWeights.Bold, Text = Settings.deleteGamesOnLoadScreen ? _environment.currentLanguage.UI_loadMenu_load : _environment.currentLanguage.UI_loadMenu_delete }; Button changeModeButton = new Button { Name = "cancelButton", IsCancel = true, Content = changeModeTextBlock, Margin = new Thickness(5, 5, 5, 5), Padding = new Thickness(5, 5, 5, 5), Width = 240 }; changeModeButton.Click += (sender, args) => { Settings.deleteGamesOnLoadScreen = !Settings.deleteGamesOnLoadScreen; ClearViewport(true); ShowLoadGameScreen(); }; TextBlock cancelTextBlock = new TextBlock { Name = "cancelTextBlock", Text = _environment.currentLanguage.UI_cancel, FontSize = 21, FontWeight = FontWeights.Bold }; Button cancelButton = new Button { Name = "cancelButton", IsCancel = true, Content = cancelTextBlock, Margin = new Thickness(5, 5, 5, 5), Padding = new Thickness(5, 5, 5, 5), Width = 240 }; cancelButton.Click += (sender, args) => { MainMenu(false, false); }; Grid buttonGrid = new Grid { Name = "buttonGrid", Margin = new Thickness(10, 10, 10, 10), }; buttonGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); buttonGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); buttonGrid.Children.Add(changeModeButton); buttonGrid.Children.Add(cancelButton); Grid.SetColumn(changeModeButton, 0); Grid.SetColumn(cancelButton, 1); StackPanel verticalStackPanel = new StackPanel { Name = "verticalStackPanel", Orientation = Orientation.Vertical, }; verticalStackPanel.Children.Add(questionTextBlock); verticalStackPanel.Children.Add(slotGrid); verticalStackPanel.Children.Add(buttonGrid); Border saveMenuBorder = new Border { Name = "saveMenuBorder", BorderThickness = new Thickness(5, 5, 5, 5), BorderBrush = new SolidColorBrush(Colors.White), Background = new SolidColorBrush(Color.FromArgb(148, 0, 0, 0)), Child = verticalStackPanel, MinWidth = 960, MinHeight = 540 }; ViewportContainer.Children.Add(saveMenuBorder); Canvas.SetLeft(saveMenuBorder, 160); Canvas.SetTop(saveMenuBorder, 90); Panel.SetZIndex(saveMenuBorder, 7); // Background blur BlurEffect blur = new BlurEffect { Radius = 0 }; DoubleAnimation blurAnimation = new DoubleAnimation(0.0, 5.0, new Duration(TimeSpan.FromMilliseconds(300))); _backgroundImage.Effect = blur; blur.BeginAnimation(BlurEffect.RadiusProperty, blurAnimation); }
/* * Show screen containing various options like text speed, music/sound volume... */ private void ShowOptionsScreen() { AllowResize(false); TextBlock optionsTextBlock = new TextBlock { Name = "gameNameTextBlock", Text = _environment.currentLanguage.UI_mainMenu_options, FontSize = 48, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.AliceBlue) }; ViewportContainer.Children.Add(optionsTextBlock); Canvas.SetLeft(optionsTextBlock, 100); Canvas.SetTop(optionsTextBlock, 50); Panel.SetZIndex(optionsTextBlock, 2); // Text speed setting TextBlock textSpeedTextBlock = new TextBlock { Name = "textSpeedTextBlock", Text = _environment.currentLanguage.UI_options_textSpeed, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; ViewportContainer.Children.Add(textSpeedTextBlock); Canvas.SetLeft(textSpeedTextBlock, 100); Canvas.SetTop(textSpeedTextBlock, 200); Panel.SetZIndex(textSpeedTextBlock, 2); Slider textSpeedSlider = new Slider { Width = 320, TickPlacement = TickPlacement.BottomRight, Minimum = 0.01, Maximum = 0.2, Value = 2.0 / Settings.textDisplaySpeedInMiliseconds, TickFrequency = 0.01, IsSnapToTickEnabled = true }; textSpeedSlider.ValueChanged += (sender, args) => { Settings.textDisplaySpeedInMiliseconds = (int)Math.Round(2.0 / textSpeedSlider.Value); }; ViewportContainer.Children.Add(textSpeedSlider); Canvas.SetLeft(textSpeedSlider, 400); Canvas.SetTop(textSpeedSlider, 200); Panel.SetZIndex(textSpeedSlider, 2); // Music volume setting TextBlock musicVolumeTextBlock = new TextBlock { Name = "musicVolumeTextBlock", Text = _environment.currentLanguage.UI_options_musicVolume, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; ViewportContainer.Children.Add(musicVolumeTextBlock); Canvas.SetLeft(musicVolumeTextBlock, 100); Canvas.SetTop(musicVolumeTextBlock, 250); Panel.SetZIndex(musicVolumeTextBlock, 2); Slider musicVolumeSlider = new Slider { Width = 320, TickPlacement = TickPlacement.BottomRight, Minimum = 0, Maximum = 1, Value = Settings.musicVolumeMultiplier, TickFrequency = 0.05, IsSnapToTickEnabled = true }; musicVolumeSlider.ValueChanged += (sender, args) => { Settings.musicVolumeMultiplier = musicVolumeSlider.Value; _backgroundMusicPlayer.Volume = musicVolumeSlider.Value; }; ViewportContainer.Children.Add(musicVolumeSlider); Canvas.SetLeft(musicVolumeSlider, 400); Canvas.SetTop(musicVolumeSlider, 250); Panel.SetZIndex(musicVolumeSlider, 2); // Sound volume setting TextBlock soundVolumeTextBlock = new TextBlock { Name = "soundVolumeTextBlock", Text = _environment.currentLanguage.UI_options_soundVolume, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; ViewportContainer.Children.Add(soundVolumeTextBlock); Canvas.SetLeft(soundVolumeTextBlock, 100); Canvas.SetTop(soundVolumeTextBlock, 300); Panel.SetZIndex(soundVolumeTextBlock, 2); Slider soundVolumeSlider = new Slider { Width = 320, TickPlacement = TickPlacement.BottomRight, Minimum = 0, Maximum = 1, Value = Settings.soundVolumeMultiplier, TickFrequency = 0.05, IsSnapToTickEnabled = true }; soundVolumeSlider.ValueChanged += (sender, args) => { Settings.soundVolumeMultiplier = soundVolumeSlider.Value; _soundEffectPlayer.Volume = soundVolumeSlider.Value; }; ViewportContainer.Children.Add(soundVolumeSlider); Canvas.SetLeft(soundVolumeSlider, 400); Canvas.SetTop(soundVolumeSlider, 300); Panel.SetZIndex(soundVolumeSlider, 2); Button backButton = new Button { Name = "backButton", Width = 320, Height = 48, Background = new SolidColorBrush(Color.FromArgb(192, 16, 16, 16)) }; TextBlock backTextBlock = new TextBlock { Name = "backTextBlock", Text = _environment.currentLanguage.UI_back, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; backButton.Content = backTextBlock; backButton.Click += (sender, args) => { SaveSettings(); MainMenu(false, false); }; ViewportContainer.Children.Add(backButton); Canvas.SetLeft(backButton, 100); Canvas.SetTop(backButton, 600); Panel.SetZIndex(backButton, 2); // Color character names setting TextBlock colorNamesTextBlock = new TextBlock { Name = "colorNamesTextBlock", Text = _environment.currentLanguage.UI_options_colorNames, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; ViewportContainer.Children.Add(colorNamesTextBlock); Canvas.SetLeft(colorNamesTextBlock, 100); Canvas.SetTop(colorNamesTextBlock, 350); Panel.SetZIndex(colorNamesTextBlock, 2); CheckBox colorNamesCheckBox = new CheckBox { Name = "colorNamesCheckBox", IsChecked = Settings.colorCharacterNames }; colorNamesCheckBox.Checked += (sender, args) => { Settings.colorCharacterNames = true; }; colorNamesCheckBox.Unchecked += (sender, args) => { Settings.colorCharacterNames = false; }; ViewportContainer.Children.Add(colorNamesCheckBox); Canvas.SetLeft(colorNamesCheckBox, 400); Canvas.SetTop(colorNamesCheckBox, 350); Panel.SetZIndex(colorNamesCheckBox, 2); // Color text box border setting TextBlock colorBordersTextBlock = new TextBlock { Name = "colorBordersTextBlock", Text = _environment.currentLanguage.UI_options_colorBorders, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; ViewportContainer.Children.Add(colorBordersTextBlock); Canvas.SetLeft(colorBordersTextBlock, 100); Canvas.SetTop(colorBordersTextBlock, 400); Panel.SetZIndex(colorBordersTextBlock, 2); CheckBox colorBordersCheckBox = new CheckBox { Name = "colorBordersCheckBox", IsChecked = Settings.colorTextBorders }; colorBordersCheckBox.Checked += (sender, args) => { Settings.colorTextBorders = true; }; colorBordersCheckBox.Unchecked += (sender, args) => { Settings.colorTextBorders = false; }; ViewportContainer.Children.Add(colorBordersCheckBox); Canvas.SetLeft(colorBordersCheckBox, 400); Canvas.SetTop(colorBordersCheckBox, 400); Panel.SetZIndex(colorBordersCheckBox, 2); // Background blur BlurEffect blur = new BlurEffect { Radius = 0 }; DoubleAnimation blurAnimation = new DoubleAnimation(0.0, 5.0, new Duration(TimeSpan.FromMilliseconds(300))); _backgroundImage.Effect = blur; blur.BeginAnimation(BlurEffect.RadiusProperty, blurAnimation); }