public void Dispose() { if (_controlType == AccountType.Customer) { ProgressBar1.Dispose(); ProgressBar2.Dispose(); ProgressBar5.Dispose(); ProgressBar10.Dispose(); CoinsViewModel model = DataContext as CoinsViewModel; //if (model != null) //{ model.DisposeRequest -= Dispose; //} } }
// Update is called once per frame void Update() { //Progress Seasons if (GameManager.instance.dialogStage >= (int)DialogueStages.ActivatedSpring) { PanelSpring.SetActive(true); } if (GameManager.instance.dialogStage >= (int)DialogueStages.ActivatedSummer) { PanelSummer.SetActive(true); } if (GameManager.instance.dialogStage >= (int)DialogueStages.ActivatedAutumn) { PanelAutumn.SetActive(true); } if (GameManager.instance.dialogStage >= (int)DialogueStages.ActivatedWinter) { PanelWinter.SetActive(true); } //ProgressBar if (bioMatterHub.bioMatter >= 100) { ProgressBar1.SetActive(true); } else { ProgressBar1.SetActive(false); } if (bioMatterHub.bioMatter >= 200) { ProgressBar2.SetActive(true); } else { ProgressBar2.SetActive(false); } if (bioMatterHub.bioMatter >= 300) { ProgressBar3.SetActive(true); } else { ProgressBar3.SetActive(false); } if (bioMatterHub.bioMatter >= 400) { ProgressBar4.SetActive(true); } else { ProgressBar4.SetActive(false); } if (bioMatterHub.bioMatter >= 500) { ProgressBar5.SetActive(true); if (GameManager.instance.dialogStage >= (int)DialogueStages.ActivatedWinter && !GameManager.instance.gameIsOver) { GameManager.instance.dialogue.endGame(); GameManager.instance.gameIsOver = true; } } else { ProgressBar5.SetActive(false); } }
public void startrun5() { OnRun++; sd5.Visibility = System.Windows.Visibility.Visible; sp5.Visibility = System.Windows.Visibility.Visible; this.Height += 74; ProcessStartInfo startUWG = new ProcessStartInfo(); //startUWG.FileName = "C:\\Users\\anakano\\Documents\\Research\\UWG2.1\\For_Installer\\UWGv2.0.exe"; startUWG.FileName = "UWGEngine.exe"; //make sure there is space in between each of the four inputs and that folder extension ends with \\ startUWG.Arguments = ep + "\\ " + ef5 + " " + xp5 + "\\ " + xf5 + " " + rp + "\\ " + rf5 + " " + mon + " " + day + " " + dur; //startUWG.Arguments = this.epwPath + this.epwFileName + this.xmlPath + this.xmlFilename; startUWG.UseShellExecute = false; startUWG.CreateNoWindow = true; startUWG.RedirectStandardOutput = true; double maxx = System.Convert.ToDouble(dur); ProgressBar5.Maximum = System.Convert.ToDouble(dur); UWGs5 = Process.Start(startUWG); UWGst5 = 1; UWGs5.EnableRaisingEvents = true; UWGs5.Exited += new EventHandler(onClose); StreamReader UWGreader = UWGs5.StandardOutput; new Thread(() => { String UWGreaderst; int value = 0; while (!UWGreader.EndOfStream) { UWGreaderst = UWGreader.ReadLine(); this.Dispatcher.Invoke(new Action(() => { if (UWGreaderst == "le") { ProgressBar5.IsIndeterminate = false; RunningInfo5.Text = "Loading EPW file..."; DoubleAnimation ani = new DoubleAnimation(maxx, TimeSpan.FromSeconds(15)); ProgressBar5.BeginAnimation(ProgressBar.ValueProperty, ani); } if (UWGreaderst == "lx") { RunningInfo5.Text = "Loading XML file..."; DoubleAnimation ani1 = new DoubleAnimation(0, TimeSpan.FromSeconds(0)); ProgressBar5.BeginAnimation(ProgressBar.ValueProperty, ani1); DoubleAnimation ani2 = new DoubleAnimation(maxx, TimeSpan.FromSeconds(15)); ProgressBar5.BeginAnimation(ProgressBar.ValueProperty, ani2); } if (UWGreaderst == "start") { DoubleAnimation ani1 = new DoubleAnimation(0, TimeSpan.FromSeconds(0)); ProgressBar5.BeginAnimation(ProgressBar.ValueProperty, ani1); ProgressBar5.Value = 0; RunningInfo5.Text = "Generating Day " + System.Convert.ToString(1) + "..."; } if (UWGreaderst == "+") { value++; ProgressBar5.Visibility = System.Windows.Visibility.Visible; // ProgressBar.Value = value; DoubleAnimation ani = new DoubleAnimation(value, TimeSpan.FromSeconds(.5)); ProgressBar5.BeginAnimation(ProgressBar.ValueProperty, ani); if (value == System.Convert.ToDouble(dur)) { value = value - 1; } RunningInfo5.Text = "Generating Day " + System.Convert.ToString(value + 1) + "..."; } if (UWGreaderst == "end") { RunningInfo5.Text = "Writing new EPW file"; } if (UWGreaderst == "over") { UWGst5 = 0; RunningInfo5.Text = "Generating finished!"; System.IO.File.Delete(System.IO.Path.Combine(ep, ef5)); } })); } }).Start(); }
public void SetControlType(AccountType type) { CoinsViewModel model = new CoinsViewModel(_controlType = type).BindToMainModel(); model.InitTemplate(() => { if (model.PayBalance > 0) { int h = 40 * _drawnCoins.Count; StringBuilder template = new StringBuilder(); template.AppendFormat("<ToolTip xmlns ='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'><ToolTip.Style><Style TargetType=\"ToolTip\"><Setter Property=\"OverridesDefaultStyle\" Value=\"True\" /><Setter Property=\"Template\"><Setter.Value><ControlTemplate TargetType=\"ToolTip\"><Border BorderBrush=\"Black\" BorderThickness=\"1\"><Grid Height=\"{0}\" Width=\"140\" Background=\"AntiqueWhite\"><Canvas Margin=\"5,5,5,5\">", h); foreach (KeyValuePair <CoinType, int> coin in _drawnCoins) { template.AppendFormat("<Image x:Name=\"ibar{0}\" Stretch=\"None\" Width=\"100\" Height=\"30\" VerticalAlignment=\"Top\" HorizontalAlignment=\"Left\">", (int)coin.Key); template.Append("<Image.Style><Style TargetType=\"{x:Type Image}\"></Style></Image.Style></Image>"); template.AppendFormat("<Label x:Name=\"lbl{0}\" VerticalAlignment=\"Top\" HorizontalAlignment=\"Right\" FontWeight=\"Normal\" FontStyle=\"Italic\">x{1}</Label>", (int)coin.Key, coin.Value); } template.Append("</Canvas></Grid></Border></ControlTemplate></Setter.Value></Setter></Style></ToolTip.Style></ToolTip>"); ToolTip tooltip = (ToolTip)XamlReader.Parse(template.ToString()); tooltip.AddHandler(LoadedEvent, new RoutedEventHandler((object o, RoutedEventArgs e) => { int i = _drawnCoins.Count - 1; ToolTip tt = o as ToolTip; foreach (KeyValuePair <CoinType, int> coin in _drawnCoins) { Image img = tt.Template.FindName(string.Format("ibar{0}", (int)coin.Key), tt) as Image; Style simg = new Style(typeof(Image)); simg.Setters.Add(new Setter(Image.SourceProperty, ResourceLoadHelper.GetCoinsProgressBarLineImage(AccountType.Customer, (int)coin.Key, new Size(100, 30), coin.Value, 10, (Color)ColorConverter.ConvertFromString("Gold"), (Color)ColorConverter.ConvertFromString("Chocolate")).Source)); img.Style = simg; Label lbl = tt.Template.FindName(string.Format("lbl{0}", (int)coin.Key), tt) as Label; Canvas.SetTop(lbl, 10 + i * 40); Canvas.SetRight(lbl, 0); Canvas.SetTop(img, i-- *40); } _drawnCoins.Clear(); })); return(tooltip); } return(null); }); DataContext = model; switch (_controlType) { case AccountType.Customer: ChangeButton.Visibility = Visibility.Collapsed; Canvas.SetTop(ProgressBar1, 0); Canvas.SetTop(ProgressBar2, 40); Canvas.SetTop(ProgressBar5, 80); Canvas.SetTop(ProgressBar10, 120); break; case AccountType.VendingMachine: DropCoins.Visibility = Visibility.Collapsed; Canvas.SetLeft(ProgressBar1, 0); Canvas.SetLeft(ProgressBar2, 40); Canvas.SetLeft(ProgressBar5, 80); Canvas.SetLeft(ProgressBar10, 120); break; default: break; } ProgressBar1.SetControlType(type, CoinType.coin1); ProgressBar2.SetControlType(type, CoinType.coin2); ProgressBar5.SetControlType(type, CoinType.coin5); ProgressBar10.SetControlType(type, CoinType.coin10); Binding toolTip = new Binding("PutCoinBox.ToolTip"); toolTip.Source = model; toolTip.Mode = BindingMode.OneWay; ChangeButton.SetBinding(Button.ToolTipProperty, toolTip); if (_controlType == AccountType.Customer) { model.DisposeRequest += Dispose; } }