Пример #1
0
 private void SaveSettings()
 {
     SavePosAndSize();
     //SaveColumnWidth();
     SaveGameBounds();
     SaveTeamBounds();
     xs.WriteSetting(Setting.LastFile, curFile);
     xs.WriteSetting(Setting.LastTab, tabControl1.SelectedIndex);
     xs.WriteSetting(Setting.TableIndex, cbTable.SelectedIndex);
     xs.Save();
 }
Пример #2
0
        /// <summary>
        /// I wrote this when the program crashed after an hour.
        /// Intermediate results can now be saved to avoid losing data.
        /// </summary>
        private static void SaveIntermediateResult(Core core, Guid guid, int value, int repetition, ResultClusterer result, ProgressReporter proggy)
        {
            string fileName = UiControls.GetTemporaryFile("." + value + "." + repetition + ".intermediate.dat", guid);

            LookupByGuidSerialiser guidS = core.GetLookups();

            proggy.Enter("Saving intermediate results");
            XmlSettings.Save <ResultClusterer>(new FileDescriptor(fileName, SerialisationFormat.MSerialiserFastBinary), result, guidS, proggy);

            if (core.SetLookups(guidS))
            {
                // UIDs have changed
                SaveSession(core, proggy);
            }

            proggy.Leave();
        }
Пример #3
0
        /// <summary>
        /// Saves results to file
        ///
        /// Returns pointer (unless originalPointer is NULL, in which case the action is assumed to be an export and is ignored).
        /// </summary>
        private static ClusterEvaluationPointer SaveResults(Core core, string fileName, ClusterEvaluationPointer originalPointer, ClusterEvaluationResults results, ProgressReporter proggy)
        {
            LookupByGuidSerialiser guidS = core.GetLookups();

            proggy.Enter("Saving results");
            XmlSettings.Save <ClusterEvaluationResults>(fileName, results, guidS, proggy);

            if (core.SetLookups(guidS))
            {
                // UIDs have changed
                SaveSession(core, proggy);
            }

            proggy.Leave();

            if (originalPointer == null)
            {
                return(null);
            }

            return(new ClusterEvaluationPointer(fileName, originalPointer.Configuration));
        }
Пример #4
0
        internal static Window CreateDisplayWindow(string xamlFileName, XmlSettings settingsInstance, string windowTitle)
        {
            var configWindow = new Window();

            try
            {
                var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

                var pluginPath = Path.Combine(assemblyPath, "plugins");

                if (assemblyPath == null)
                {
                    return(null);
                }

                var xamlInterfaceFile = FileManager.GetFile(pluginPath, xamlFileName);

                if (!File.Exists(xamlInterfaceFile))
                {
                    return(null);
                }

                var xamlContent = File.ReadAllText(xamlInterfaceFile);

                configWindow.DataContext = settingsInstance;

                var mainControl = (UserControl)XamlReader.Load(new MemoryStream(Encoding.UTF8.GetBytes(xamlContent)));

                Action <object, CancelEventArgs> closingHandler = delegate(object sender, CancelEventArgs e)
                {
                    if (!CloseAllowed)
                    {
                        settingsInstance.Save();
                        configWindow.Visibility = Visibility.Hidden;
                        e.Cancel = true;
                        Logger.Debug("Hiding {0} Window", windowTitle);
                    }
                    else
                    {
                        Logger.Debug("Closing {0} Window", windowTitle);
                    }
                };

                var windowBorderSize = 16;
                var windowHeaderSize = 37;

                configWindow.Content  = mainControl;
                configWindow.Width    = mainControl.Width + windowBorderSize;
                configWindow.Height   = mainControl.Height + windowHeaderSize;
                configWindow.Title    = windowTitle;
                configWindow.Closing += (s, e) => closingHandler(s, e);

                configWindow.Owner = Application.Current.MainWindow;
                configWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                Application.Current.MainWindow.Closing += Application_Closing;

                Windows.Add(xamlFileName, configWindow);

                return(configWindow);
            }
            catch (Exception ex)
            {
                Logger.Debug("Failed to load Config UI {0}", ex);
            }
            return(null);
        }
Пример #5
0
        internal static Window CreateDisplayWindow (string xamlFileName, XmlSettings settingsInstance, string windowTitle)
        {
            var configWindow = new Window();

            try
            {
                var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

                var pluginPath = Path.Combine(assemblyPath, "plugins");
                
                if (assemblyPath == null)
                    return null;

                var xamlInterfaceFile = FileManager.GetFile(pluginPath, xamlFileName);

                if (!File.Exists(xamlInterfaceFile))
                    return null;

                var xamlContent = File.ReadAllText(xamlInterfaceFile);

                configWindow.DataContext = settingsInstance;

                var mainControl = (UserControl) XamlReader.Load(new MemoryStream(Encoding.UTF8.GetBytes(xamlContent)));

                Action<object, CancelEventArgs> closingHandler = delegate(object sender, CancelEventArgs e)
                {
                    if (!CloseAllowed)
                    {
                        settingsInstance.Save();
                        configWindow.Visibility = Visibility.Hidden;
                        e.Cancel = true;
                        Logger.Debug("Hiding {0} Window", windowTitle);
                    }
                    else
                    {
                        Logger.Debug("Closing {0} Window", windowTitle);
                    }
                            
                };

                var windowBorderSize = 16;
                var windowHeaderSize = 37;

                configWindow.Content = mainControl;
                configWindow.Width = mainControl.Width + windowBorderSize;
                configWindow.Height = mainControl.Height + windowHeaderSize;
                configWindow.Title = windowTitle;
                configWindow.Closing += (s,e) => closingHandler(s,e);

                configWindow.Owner = Application.Current.MainWindow;
                configWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                Application.Current.MainWindow.Closing += Application_Closing;

                Windows.Add(xamlFileName, configWindow);

                return configWindow;
                
            }
            catch (Exception ex)
            {
                Logger.Debug("Failed to load Config UI {0}", ex);
            }
            return null;
        }
Пример #6
0
 /// <summary>
 /// Saves all data
 /// </summary>
 public void Save(string fileName, ProgressReporter prog)
 {
     XmlSettings.Save <Core>(fileName, this, null, prog);
 }