/// <summary>
 /// Gets whether the command can be executed.  Ensures that there is a bookmark to delete.
 /// </summary>
 /// <param name="parameter">The bookmark to delete</param>
 /// <returns>Returns true if there is a bookmark to delete and it belongs to the <see cref="Bookmarks"/> collection</returns>
 public bool CanExecute(object parameter)
 {
     // Make sure the bookmarks collection is initialized and that the
     // passed-in bookmark is in the collection
     Bookmark.MapBookmark bookmark = parameter as Bookmark.MapBookmark;
     return(Bookmarks != null && bookmark != null && Bookmarks.Contains(bookmark));
 }
예제 #2
0
 /// <summary>
 /// 导出文件
 /// </summary>
 public async void Export()
 {
     LoadingVisibility = Visibility.Visible;
     System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
     if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         var folderPath = folderBrowserDialog.SelectedPath;
         await System.Threading.Tasks.Task.Run(() =>
         {
             Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application()
             {
                 Visible = false, DisplayAlerts = WdAlertLevel.wdAlertsNone
             };
             try
             {
                 for (int i = 0; i < DT.Rows.Count; i++)
                 {
                     var row       = DT.Rows[i];
                     var doc       = app.Documents.OpenNoRepairDialog(TemplateFilePath, false, true);
                     var bookmarks = doc.Bookmarks;
                     foreach (Bookmark bookmark in bookmarks)
                     {
                         if (DT.Columns.Contains(bookmark.Name))
                         {
                             var text            = row[bookmark.Name].ToString();
                             bookmark.Range.Text = text;
                         }
                     }
                     string filepath = string.Concat(folderPath, @"\", (!string.IsNullOrEmpty(SelectedBookmark) && Bookmarks.Contains(SelectedBookmark)) ? row[SelectedBookmark].ToString() : i.ToString(), ".docx");
                     doc.SaveAs2(filepath);
                     doc.Close(false);
                 }
             }
             catch (Exception e)
             {
             }
             finally
             {
                 app.Quit(false);
             }
         });
     }
     LoadingVisibility = Visibility.Collapsed;
 }
예제 #3
0
        private void ClickPlanet(PlanetaryObject planet)
        {
            MainWindow wnd = game.GetWnd();

            wnd.PlanetName.Text = planet.Name;
            SelectedPlanet      = planet;

            //Zoom to sun if clicked
            if (planet.Type == PlanetaryType.Sun && Camera.Zoom < .2f)
            {
                newZoom       = .25f;
                CameraPointTo = SelectedPlanet.Position - new Vector2(((Game.MainWindow.ClientWidth) / 2) - SelectedPlanet.Radius * Camera.Zoom, ((Game.MainWindow.ClientHeight) / 2) - SelectedPlanet.Radius * Camera.Zoom);
            }
            if (planet.Type == PlanetaryType.Planet && Camera.Zoom < .28f)
            {
                newZoom       = .6f;
                CameraPointTo = SelectedPlanet.Position - new Vector2(((Game.MainWindow.ClientWidth) / 2) - SelectedPlanet.Radius * Camera.Zoom, ((Game.MainWindow.ClientHeight) / 2) - SelectedPlanet.Radius * Camera.Zoom);
            }

            MainWindow.btnUniverse[5].Enabled     = Bookmarks.Contains(SelectedPlanet);
            MainWindow.btnUniverse[5].Glyph.Color = MainWindow.btnUniverse[5].Enabled ? Color.White : Color.Gray;
            MainWindow.btnUniverse[2].Enabled     = !Bookmarks.Contains(SelectedPlanet);
            MainWindow.btnUniverse[2].Glyph.Color = MainWindow.btnUniverse[2].Enabled ? Color.White : Color.Gray;

            for (int i = 0; i < MainWindow.universeStatLabels.Count(); i++)
            {
                MainWindow.universeStatLabels[i].Text      = string.Empty;
                MainWindow.universeStatLabels[i].TextColor = Color.White;
            }

            if (planet.Type == PlanetaryType.Sun)
            {
                MainWindow.btnLand.Enabled = MainWindow.btnUniverse[4].Enabled = false;
                wnd.PlanetName.Text        = planet.Name;
                wnd.PlanetDesc.Text        = planet.Description;

                MainWindow.universeStatLabels[0].Text = "Coordinates: " + Math.Round(planet.Position.X) + " " + Math.Round(planet.Position.Y);
                MainWindow.universeStatLabels[1].Text = "Objects:";
                for (int i = 1; i < MathHelper.Clamp(planet.Parent.Children.Count(), 0, MainWindow.universeStatLabels.Count() - 1); i++)
                {
                    MainWindow.universeStatLabels[i + 1].Text      = "  -" + planet.Parent.Children[i].Name;
                    MainWindow.universeStatLabels[i + 1].TextColor = planet.Parent.Children[i].Color;
                    PlanetaryObject p = planet.Parent.Children[i];
                }
            }
            else if (planet.Type == PlanetaryType.Planet)
            {
                MainWindow.btnLand.Enabled = MainWindow.btnUniverse[4].Enabled = true;
                wnd.PlanetName.Text        = planet.Name;
                wnd.PlanetDesc.Text        = planet.Description;

                MainWindow.universeStatLabels[0].Text = "Size: " + Game.GetPlanetWidth(planet) + " feet wide by " + Game.GetPlanetHeight(planet) + " feet thick";
                MainWindow.universeStatLabels[1].Text = "Coordinates: " + Math.Round(planet.Position.X) + " " + Math.Round(planet.Position.Y);
                MainWindow.universeStatLabels[2].Text = "Seed: " + planet.Seed;
                MainWindow.universeStatLabels[3].Text = "Gravity: " + Math.Round(planet.Gravity, 1);
            }
            if (planet == HomePlanet)
            {
                wnd.PlanetDesc.Text += " - Home";
            }
        }