Exemplo n.º 1
0
        public static void Loader()
        {
            var chain = new ProgressChain();

            chain.OnChange += delegate { SplashScreen.Progress = chain.Progress * 0.7f; };

            chain.AddTask(delegate(ProgressHandler handler)
            {
                if (Configuration.Load(handler) == Configuration.ResultCode.ERROR)
                {
                }
            }, 30f);

            chain.AddTask(delegate(ProgressHandler handler)
            {
                if (DynamicTypes.Load(handler) == DynamicTypes.ResultCode.ERROR)
                {
                }
            }, 10f);

            chain.AddTask(delegate(ProgressHandler handler)
            {
                if (GuiConfiguration.Load(handler) == GuiConfiguration.ResultCode.ERROR)
                {
                    handler.Progress = 100f;
                }
            }, 30f);

            chain.Start();

            /*if (DynamicTypes.Load() == DynamicTypes.ResultCode.OK)
             * {
             *  SplashScreen.Progress = 100;
             * }*/
        }
        public MainWindow()
        {
            InitializeComponent();
            _model = new MainViewModel();
            DataContext = _model;

            _guiConfigurationProvider = new GuiConfigurationProvider(new FileStorageProvider());
            _guiConfiguration = _guiConfigurationProvider.LoadConfiguration();
            _guiConfiguration.PropertyChanged += ConfigurationPropertyChanged;
        }
Exemplo n.º 3
0
        void LookupFormClosed(object sender, EventArgs e)
        {
            GuiConfiguration.Save();

            RemoveEventHandlers();

            // This is done as a hint to the GC, because forms which are open for a long time
            // might not trigger a gen2 collection when closing.
            // We want to reclaim the memory in case there are other windows open.
            // GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized);
            GC.Collect(GC.MaxGeneration);
        }
Exemplo n.º 4
0
        // Update UI state.
        void SettingChanging(object sender, SettingChangedEventArgs e)
        {
            if (e.SettingName == "IgnoreAccents" || e.SettingName == "IgnoreCase")
            {
                // This shouldn't fire the CheckedChanged/SettingChanged events in an infinite loop.
                if (e.SettingName == "IgnoreAccents")
                {
                    ignoreAccentsMenuItem.Checked = ignoreAccentsCheck.Checked = GuiConfiguration.IgnoreAccents;
                }
                else if (e.SettingName == "IgnoreCase")
                {
                    ignoreCaseMenuItem.Checked = ignoreCaseCheck.Checked = GuiConfiguration.IgnoreCase;
                }

                // We might want to skip this if nothing was actually changed.
                UpdateResults();
            }
            else if (e.SettingName == "ListFontName" || e.SettingName == "ListFontSize")
            {
                // Note: this is slightly inefficient -- if both are set at once it redisplays twice.
                Font disposeOf = null;
                if (listFontComponent != null)
                {
                    components.Remove(listFontComponent);
                    disposeOf = grid.Font;
                }
                var font = GuiConfiguration.GetListFont();
                if (font != null)
                {
                    if (defaultGridFont == null)
                    {
                        defaultGridFont = grid.Font;
                    }
                    listFontComponent = new DisposableComponent(font);
                    grid.Font         = font;
                }
                else
                {
                    grid.Font = defaultGridFont;
                }
                if (disposeOf != null)
                {
                    disposeOf.Dispose();
                }
                AdjustGridRowHeight();
            }
        }
Exemplo n.º 5
0
        void MainClientWindow_Loaded(object sender, RoutedEventArgs e)
        {
            this.Loaded -= new RoutedEventHandler(MainClientWindow_Loaded);
            GuiConfiguration configuration = ConfigurationAccess.Current.GuiConfiguration;

            AlwaysHighlight = configuration.StickyHighlighting;
            GameSpeed       = configuration.GameSpeed;
            LogExpanded     = configuration.ExpandLog;
            if (string.IsNullOrEmpty(configuration.SignInName))
            {
                ChangeName(null, null);
            }
            else
            {
                gameBoard.ThePlayer = new GuiMainPlayer(new Player(configuration.SignInName));
            }
            Microsoft.Win32.SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged);
        }
Exemplo n.º 6
0
        public LookupForm(IBilingualDictionary dictionary)
            : this()
        {
            components.Add(new DisposableComponent(new LookupFormFileIsInUse(this, dictionary.Path)));
            components.Add(new DisposableComponent(dictionary));

            Dictionary = dictionary;

            var mru = GuiConfiguration.RecentDictionaries ?? new MruList <DictionaryInfo>(10);

            mru.Update(dictionary.Info);
            GuiConfiguration.RecentDictionaries = mru;

            Font listFont = GuiConfiguration.GetListFont();

            if (listFont != null)
            {
                components.Add(listFontComponent = new DisposableComponent(listFont));
                defaultGridFont = grid.Font;
                grid.Font       = listFont;
            }

            // TODO: This really needs testing. It could make things completely unusable...
            // I can't even remember if they're used...
            try {
                if (dictionary.FirstLanguageCode != null && dictionary.SecondLanguage != null)
                {
                    sourceCulture = new CultureInfo(dictionary.FirstLanguageCode);
                    targetCulture = new CultureInfo(dictionary.SecondLanguageCode);
                }
            } catch (ArgumentException) {
                // One of the cultures wasn't supported. In that case, set both cultures to null,
                // because it isn't worth having only one.
                sourceCulture = targetCulture = null;
            }

            InitialiseView();

            Load += delegate {
                UpdateResults();
            };
            Show();
        }