Exemplo n.º 1
0
        private bool SaveProject()
        {
            if (string.IsNullOrEmpty(_currentProject.FileName))
            {
                if (saveProjectDialog.ShowDialog(this) == DialogResult.OK)
                {
                    var result = SaveProject(saveProjectDialog.FileName);

                    if (result)
                    {
                        _mruManager.AddRecentFile(saveProjectDialog.FileName);
                    }

                    return(result);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(SaveProject(_currentProject.FileName));
            }
        }
Exemplo n.º 2
0
        //private void newMultipleFile()
        //{
        //    string newFilePath = getFilePath();

        //    if (newFilePath == null) return;

        //    CreateMultipleChampionshipFile(newFilePath);

        //    openFile ( newFilePath);
        //}

        /// <summary>
        /// Opens the championship file. There is a background worker for the really hard stuff.
        /// I.e. loading the events data.
        /// </summary>
        /// <param name="FilePath"></param>
        internal void openFile(string FilePath)
        {
            BackgroundWorker worker = new BackgroundWorker();

            Stopwatch watch = new Stopwatch();

            if (!System.IO.File.Exists(FilePath))
            {
                return;
            }

            if (FilePath.ToLower( ).Contains("appdata"))
            {
                MessageBoxResult msg = MessageBox.Show("The file you are trying to open is stored in a temporary location. " +
                                                       "\nWe strongly recommend that you move this file to your Desktop or your Documents directory before opening it." +
                                                       "\nDo you wish to continue to open this file? ",
                                                       "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                if (msg == MessageBoxResult.No)
                {
                    return; // abort the load process
                }
            }

            if (FilePath.ToLower( ).Contains(".zip") || FilePath.ToLower( ).Contains(".rar"))
            {
                MessageBoxResult msg = MessageBox.Show("The file you are trying to open is inside a compressed archive." +
                                                       "\nWe strongly recommend that you extract the file to your Desktop or your Documents directory before opening it." +
                                                       "\nDo you wish to continue? ",
                                                       "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                if (msg == MessageBoxResult.No)
                {
                    return; // abort the load process
                }
            }


            watch.Start( );

            ChampionshipSolutions.MainWindow.BusyIndicator.IsBusy = true;

            if (FConnFile.OpenFile(FilePath))
            {
                if (mruManager != null)
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        mruManager.AddRecentFile(FilePath);
                        mruManager.IsEnabled = false;
                    }), null);
                }

                controls.Clear( );

                ((App)App.Current).CurrentChampionship = new ChampionshipVM( );
                //CurrentChampionship.Championship.database = GetFileDetails ( ).IO;
                this.EventPage = new EventsPage( );


                worker.DoWork += (o, a) =>
                {
                    Console.WriteLine("Loading Events");

                    this.EventPage.ReloadPage( );
                    Dispatcher.Invoke(new Action(() =>
                    {
                    }), null);
                };


                worker.RunWorkerCompleted += (o, a) =>
                {
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Championship", isEnabled = true, DisplayPage = new ChampionshipPage( )
                    });
                    Console.WriteLine("Loading Teams");
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Teams", isEnabled = true, DisplayPage = new TeamsPage( )
                    });
                    Console.WriteLine("Loading Schools");
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Schools & Clubs", isEnabled = true, DisplayPage = new SchoolsPage( )
                    });
                    Console.WriteLine("Loading Athletes");
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Athletes", isEnabled = true, DisplayPage = new AthltesPage( )
                    });
                    Console.WriteLine("Loading Groups");
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Groups", isEnabled = true, DisplayPage = new GroupsPage( )
                    });
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Events", isEnabled = true, DisplayPage = EventPage
                    });
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Import Results", isEnabled = !IsEntryForm( ), DisplayPage = new ImportResultsPage( )
                    });
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Scan Results", isEnabled = !IsEntryForm( ), DisplayPage = new ScannerPage( )
                    });
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Reports", isEnabled = true, DisplayPage = new ReportsPage( )
                    });
                    //controls.Add ( new MainPageControl ( ) { Content = "Exports" , isEnabled = false , DisplayPage = new ExportsPage ( ) } );
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Web Server", isEnabled = !IsEntryForm( ), DisplayPage = new WebServerPage( )
                    });
                    //controls.Add ( new MainPageControl ( ) { Content = "Scripts" , isEnabled = false , DisplayPage = new ScriptsPage ( ) } );
                    Console.WriteLine("Loading Templates");
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Templates", isEnabled = !IsEntryForm( ), DisplayPage = new TemplatesPage( )
                    });


                    ReportLibrary = CSReportLibrary.getLibrary( );


                    ChampionshipSolutions.MainWindow.Frame.Navigate(new OpenedPage( ));
                    watch.Stop( );

                    ChampionshipSolutions.MainWindow.BusyIndicator.IsBusy = false;

                    Console.WriteLine("**************************");
                    Console.WriteLine("*****Loading complete*****");
                    Console.WriteLine("*File open took " + watch.Elapsed.TotalSeconds + " seconds.**");
                    Console.WriteLine("********DB Reads = " + GetFileDetails().IO.DBReadCounter + "*****");
                    Console.WriteLine("*****Cache Reads = " + GetFileDetails().IO.CacheReadCounter + "***");
                    Console.WriteLine("**************************");

                    ChampionshipSolutions.Diag.Diagnostics.LogLine("Opened File at " + FilePath + " in " + watch.Elapsed.TotalSeconds + " seconds.", ChampionshipSolutions.Diag.MessagePriority.Infomation);
                };

                worker.RunWorkerAsync( );
            }
            else
            {
                ChampionshipSolutions.MainWindow.BusyIndicator.IsBusy = false;
            }
        }
Exemplo n.º 3
0
        private void OpenKIFFile(string kifFilePath)
        {
            KIFFilePath = kifFilePath;
            mruManager.AddRecentFile(KIFFilePath);
            GeneralGameManager = new GeneralGameManager(KIFFilePath, 10, 10, Properties.Settings.Default.WcfSvcHostExecutable, Properties.Settings.Default.TempFilePath)
            {
                StartNextMoveEvent = startNextTurnEvent, PrevMoveEvent = prevTurnEvent
            };
            GeneralGame.UseOldWayOfGeneratingAndApplyingMoves =
                useOriginalMoveGenerationAndApplicationToolStripMenuItem.Checked;

            playerToolStripMenuItem.DropDownItems.Clear();
            int playerOutputWindowX    = 0;
            int playerOutputWindowY    = htmlOutputForm.Location.Y + htmlOutputForm.Height;
            int playerOutputFormWidth  = (this.ClientRectangle.Width - 5) / (GeneralGameManager.TheGeneralGame.FindRoles().Count() == 0 ? 1 : GeneralGameManager.TheGeneralGame.FindRoles().Count());
            int playerOutputFormHeight = this.ClientRectangle.Height - 25 - this.statusStrip1.Height - managerOutputForm.Height - htmlOutputForm.Height - (2 * SystemInformation.HorizontalScrollBarHeight);
            int playerFormCount        = 0;

            foreach (string role in GeneralGameManager.TheGeneralGame.FindRoles())
            {
                var playerOutputForm = new Form()
                {
                    MdiParent     = this,
                    Text          = role,
                    StartPosition = FormStartPosition.Manual,
                    Location      = new Point(playerOutputWindowX, playerOutputWindowY),
                    Width         = playerOutputFormWidth,
                    Height        = playerOutputFormHeight,
                    Tag           = PlayerWindowConfigStringPrefix + playerFormCount
                };
                var playerOutputTextBox = new TextBox()
                {
                    Dock = DockStyle.Fill, Multiline = true, ScrollBars = ScrollBars.Both
                };
                playerOutputForm.Controls.Add(playerOutputTextBox);
                DebugAndTraceHelper.AddListener(new TextboxTraceListener(playerOutputTextBox), role);
                playerOutputWindowX += playerOutputForm.Bounds.Width;
                WindowGeometryPersistence.SetFormsGeometry(Properties.Settings.Default.WindowGeometry, playerOutputForm);
                playerOutputForm.Show();
                outputForms.Add(playerOutputForm);

                var mi = new ToolStripMenuItem(role);
                playerToolStripMenuItem.DropDownItems.Add(mi);

                var submi = new ToolStripMenuItem("Query Player Prolog Engine");
                mi.DropDownItems.Add(submi);
                submi.Click += (o, k) =>
                {
                    var dialog = new PrologQuery(GeneralGameManager.Players.Where(n => n.Role == role).First().GetPrologEngine());
                    dialog.Show(this);
                };

                playerFormCount++;
            }

            startGameToolStripMenuItem.Enabled = true;

            saveCollapsedParseTreesToolStripMenuItem.Enabled = true;
            saveParseTreesToolStripMenuItem.Enabled          = true;
            saveHornClausesToolStripMenuItem.Enabled         = true;

            queryGamePrologEngineToolStripMenuItem.Enabled       = true;
            dumpPrologEngineUserClausesToolStripMenuItem.Enabled = true;
        }