}//安全的代码 public void Hide(double?time = null, bool isAsyn = false) { if (time == null) { time = SharedSetting.SwitchSpeed; } EasyAmal amsc = new EasyAmal(shower, "(Opacity)", 1.0, 0.0, (double)time); amsc.Start(isAsyn); }//安全的代码
public void Hide(double?time = null, bool isAsyn = false) { if (locked) { return; } if (time == null) { time = SharedSetting.SwitchSpeed / 2.0; } EasyAmal amsc = new EasyAmal(UsageArea, "(Opacity)", 1.0, 0.0, (double)time); amsc.Start(isAsyn); }
public void SayAt(string line, RectangleF location, double?time = null, bool isAsyn = false) { if (time == null) { time = SharedSetting.TextSpeed; } EasyAmal m_txt = null; Vist.Dispatcher.Invoke(new Action(() => { TextBlock n_mfLine = new TextBlock { Text = line, FontSize = Lines_Usage.FontSize, FontFamily = Lines_Usage.FontFamily, FontStyle = Lines_Usage.FontStyle, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightGray), Width = location.Width, Height = location.Height, Margin = new Thickness(location.Left, location.Top, 0, 0) }; freedomLines.Add(n_mfLine); if (time == 0) { Vist.Children.Add(n_mfLine); return; } n_mfLine.Opacity = 0; Vist.Children.Add(n_mfLine); m_txt = new EasyAmal(n_mfLine, "(Opacity)", 0.0, 1.0, (double)time); })); m_txt.Start(isAsyn); }
public void CleanAllFreedom(double?time = null) { if (time == null) { time = SharedSetting.TextSpeed; } for (int i = 0; i < freedomLines.Count; i++) { EasyAmal mns = new EasyAmal(freedomLines[i], "(Opacity)", 1.0, 0.0, (double)time); if (i != freedomLines.Count - 1) { mns.Start(true); } else { mns.Start(false); } } for (int i = 0; i < freedomLines.Count; i++) { Vist.Children.Remove(freedomLines[i]); } freedomLines.Clear(); }
public Character(Theatre father, string name, string template, bool canshow = true, double?time = null, bool isAscy = true, double vel_x = 0, double vel_y = 0) { var layer = father.CharacterLayer; m_father = father; ManualResetEvent msbn = new ManualResetEvent(false); _name = name; if (time == null) { time = SharedSetting.SwitchSpeed; } layer.Dispatcher.Invoke(new Action(() => { whereIsShowed = layer; Init_action = Stage.LoadBitmap(template); shower = new Image { Width = Init_action.Size.Width * (layer.Height / Init_action.Size.Height), Height = layer.Height, VerticalAlignment = VerticalAlignment.Bottom, Stretch = Stretch.Fill, Margin = new Thickness(vel_x, 0, 0, vel_y) }; if (time != 0 || !canshow) { shower.Opacity = 0; } whereIsShowed.Children.Add(shower); Direct2DImage direct2DImage = new Direct2DImage(new Size2((int)shower.Width, (int)shower.Height), 30); direct2DImage.DrawProc += (View, Souce, Width, Height) => { D2DBitmap m_bp = D2DBitmap.FromWicBitmap(View.View, Init_action, new BitmapProperties1(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied))); View.View.BeginDraw(); View.View.Clear(null); View.View.DrawBitmap(m_bp, new RawRectangleF(0, 0, Width, Height), 1, SharpDX.Direct2D1.BitmapInterpolationMode.Linear, new RawRectangleF(0, 0, Init_action.Size.Width, Init_action.Size.Height)); View.View.EndDraw(); m_bp.Dispose(); return(DrawProcResult.Death); }; direct2DImage.Disposing += (e, s) => { Last_Draw = s.LastDraw; msbn.Set(); }; direct2DImage.DrawStartup(shower); })); msbn.WaitOne(); msbn.Dispose(); if (!canshow) { return; } EasyAmal aml = new EasyAmal(shower, "(Opacity)", 0.0, 1.0, (double)time); aml.Start(isAscy); }//已经确认过安全的代码,再次修改需要小心
public void Say(string line, string character = "", double?time = null) { if (time == null) { time = SharedSetting.TextSpeed; } #region log call string load_printed = ""; string ral_printf_str = ""; if (character != "") { ral_printf_str += "[" + character + "] "; } ral_printf_str += line; foreach (var c in ral_printf_str) { Vist.Dispatcher.Invoke(new Action(() => { load_printed += c; var ap_l = GamingBook.MeasureTextWidth(_Contents, _Contents.FontSize, load_printed); if (ap_l.Width > _Contents.Width) { _Contents.Dispatcher.Invoke(new Action(() => { GamingTheatre.Preparation += '\n'; })); load_printed = ""; } GamingTheatre.Preparation += c; })); } GamingTheatre.Preparation += "\n"; #endregion EasyAmal esyn = new EasyAmal(Lines_Usage, "(Opacity)", 1.0, 0.0, (double)time); esyn.Start(false); Lines_Usage.Dispatcher.Invoke(new Action(() => { Lines_Usage.Text = line; if (character == "" && chat_usage.Opacity == 1) { EasyAmal _st = new EasyAmal(chat_usage, "(Opacity)", 1.0, 0.0, (double)time); _st.Start(true); Character_Usage.Text = character; } else if (character != "" && chat_usage.Opacity == 0) { Character_Usage.Text = character; EasyAmal _st = new EasyAmal(chat_usage, "(Opacity)", 0.0, 1.0, (double)time); _st.Start(true); } else { Character_Usage.Text = character; } })); esyn = new EasyAmal(Lines_Usage, "(Opacity)", 0.0, 1.0, (double)time); esyn.Start(false); }