Ejemplo n.º 1
0
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            // add icons to the combobox
            comboBoxIcon.Items.Clear();
            _noIconItem = new IconImage("None");
            comboBoxIcon.Items.Add(_noIconItem);
            foreach (System.Collections.Generic.KeyValuePair <string, IconImage> icon in annoCanvas.Icons)
            {
                comboBoxIcon.Items.Add(icon.Value);
            }
            comboBoxIcon.SelectedIndex = 0;
            // check for updates on startup
            MenuItemVersion.Header     = "Version: " + Constants.Version;
            MenuItemFileVersion.Header = "File version: " + Constants.FileVersion;
            CheckForUpdates(false);
            // load color presets
            colorPicker.StandardColors.Clear();
            //This is currently disabled
            //try
            //{
            //    ColorPresets colorPresets = DataIO.LoadFromFile<ColorPresets>(Path.Combine(App.ApplicationPath, Constants.ColorPresetsFile));
            //    foreach (ColorScheme colorScheme in colorPresets.ColorSchemes)
            //    {
            //        foreach (ColorInfo colorInfo in colorScheme.ColorInfos)
            //        {
            //            colorPicker.StandardColors.Add(new ColorItem(colorInfo.Color, string.Format("{0} ({1})", colorInfo.ColorTarget, colorScheme.Name)));
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, "Loading of the color presets failed");
            //}
            // load presets
            treeViewPresets.Items.Clear();
            // manually add a road tile preset
            treeViewPresets.Items.Add(new AnnoObject {
                Label = "Road tile", Size = new Size(1, 1), Radius = 0, Road = true
            });
            treeViewPresets.Items.Add(new AnnoObject {
                Label = "Borderless road tile", Size = new Size(1, 1), Radius = 0, Borderless = true, Road = true
            });
            BuildingPresets presets = annoCanvas.BuildingPresets;

            if (presets != null)
            {
                presets.AddToTree(treeViewPresets);
                GroupBoxPresets.Header        = string.Format("Building presets - loaded v{0}", presets.Version);
                MenuItemPresetsVersion.Header = "Presets version: " + presets.Version;
            }
            else
            {
                GroupBoxPresets.Header = "Building presets - load failed";
            }
            // load file given by argument
            if (!string.IsNullOrEmpty(App.FilenameArgument))
            {
                annoCanvas.OpenFile(App.FilenameArgument);
            }
        }
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            // add icons to the combobox
            comboBoxIcon.Items.Clear();
            _noIconItem = new IconImage("None");
            comboBoxIcon.Items.Add(_noIconItem);
            foreach (var icon in annoCanvas.Icons)
            {
                comboBoxIcon.Items.Add(icon.Value);
            }
            comboBoxIcon.SelectedIndex = 0;

            string language = Localization.Localization.GetLanguageCodeFromName(SelectedLanguage);

            //add localized influence types to combo box
            comboxBoxInfluenceType.Items.Clear();
            string[] rangeTypes = Enum.GetNames(typeof(BuildingInfluenceType));
            foreach (string rangeType in rangeTypes)
            {
                comboxBoxInfluenceType.Items.Add(new KeyValuePair <BuildingInfluenceType, string>((BuildingInfluenceType)Enum.Parse(typeof(BuildingInfluenceType), rangeType), Localization.Localization.Translations[language][rangeType]));
            }
            comboxBoxInfluenceType.SelectedIndex = 0;

            // check for updates on startup
            _mainWindowLocalization.VersionValue     = Constants.Version.ToString("0.0#", CultureInfo.InvariantCulture);
            _mainWindowLocalization.FileVersionValue = Constants.FileVersion.ToString("0.#", CultureInfo.InvariantCulture);

            CheckForUpdates(false);

            // load color presets
            colorPicker.StandardColors.Clear();
            //This is currently disabled
            colorPicker.ShowStandardColors = false;
            //try
            //{
            //    ColorPresets colorPresets = DataIO.LoadFromFile<ColorPresets>(Path.Combine(App.ApplicationPath, Constants.ColorPresetsFile));
            //    foreach (ColorScheme colorScheme in colorPresets.ColorSchemes)
            //    {
            //        foreach (ColorInfo colorInfo in colorScheme.ColorInfos)
            //        {
            //            colorPicker.StandardColors.Add(new ColorItem(colorInfo.Color, string.Format("{0} ({1})", colorInfo.ColorTarget, colorScheme.Name)));
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, "Loading of the color presets failed");
            //}

            // load presets
            treeViewPresets.Items.Clear();
            // manually add a road tile preset
            treeViewPresets.Items.Add(new AnnoObject {
                Label = "Road tile", Size = new Size(1, 1), Radius = 0, Road = true, Identifier = "Road"
            });
            treeViewPresets.Items.Add(new AnnoObject {
                Label = "Borderless road tile", Size = new Size(1, 1), Radius = 0, Borderless = true, Road = true, Identifier = "Road"
            });
            BuildingPresets presets = annoCanvas.BuildingPresets;

            if (presets != null)
            {
                presets.AddToTree(treeViewPresets);
                GroupBoxPresets.Header = string.Format("Building presets - loaded v{0}", presets.Version);
                _mainWindowLocalization.PresetsVersionValue = presets.Version;
            }
            else
            {
                GroupBoxPresets.Header = "Building presets - load failed";
            }

            // load file given by argument
            if (!string.IsNullOrEmpty(App.FilenameArgument))
            {
                annoCanvas.OpenFile(App.FilenameArgument);
            }
        }