Esempio n. 1
0
        internal bool LoadUIThemeFromDisk(Theme theme)
        {
            string skinPath = Application.StartupPath + "\\Skins\\" + theme + "\\";

            string infoSkinPath = skinPath + "Info.png";
            string statsSkinPath = skinPath + "Stats.png";
            string skillsSkinPath = skinPath + "Skills.png";

            if (File.Exists(infoSkinPath) && File.Exists(statsSkinPath) && File.Exists(skillsSkinPath))
            {
                try
                {
                    heroInfoPanel.BackgroundImageLayout = ImageLayout.Zoom;
                    heroInfoPanel.BackgroundImage = Bitmap.FromFile(infoSkinPath);

                    heroSkillsPanel.BackgroundImageLayout = ImageLayout.Zoom;
                    heroSkillsPanel.BackgroundImage = Bitmap.FromFile(skillsSkinPath);

                    heroStatsPanel.BackgroundImageLayout = ImageLayout.Zoom;
                    heroStatsPanel.BackgroundImage = Bitmap.FromFile(statsSkinPath);

                    inventoryBgPanel.BackgroundImage = heroStatsPanel.BackgroundImage;
                }
                catch { return false; }

                return true;
            }
            else
                return false;
        }
Esempio n. 2
0
 public static void Init()
 {
     Application.EnableVisualStyles();
     _theme = Theme.Unspecified;
     OperatingSystem os = System.Environment.OSVersion;
     if(os.Platform==PlatformID.Win32NT && os.Version.CompareTo(new Version(5,1))>=0)
         SpecifyThemeUnderWinXP();
 }
 public KeyMenuItem(Theme theme, TextFormat font, float x, float y, float width, float height, Menu parentMenu, string text, string extraData, Keys key)
     : base(theme, font, x, y, width, height, parentMenu, text, extraData)
 {
     this.Key = key;
     this.acceptKey = false;
     if (Program.GameImplementation.HasKey(this.ExtraData))
         this.Key = Program.GameImplementation.GetValue<Keys>(this.ExtraData);
 }
Esempio n. 4
0
        internal bool IsThemeAvailableOnDisk(Theme theme)
        {
            if (theme == Theme.None) return false;

            string skinPath = Application.StartupPath + "\\Skins\\" + theme + "\\";

            string infoSkinPath = skinPath + "Info.png";
            string statsSkinPath = skinPath + "Stats.png";
            string skillsSkinPath = skinPath + "Skills.png";

            return (File.Exists(infoSkinPath) && File.Exists(statsSkinPath) && File.Exists(skillsSkinPath));
        }
Esempio n. 5
0
 private static void SpecifyThemeUnderWinXP()
 {
     try {
         char[] fn = new char[256];
         char[] cb = new char[256];
         char[] sz = new char[256];
         int r = GetCurrentThemeName(fn, 256, cb, 256, sz, 256);
         if(r==0) {
             string theme_name = new string(fn);
             if(theme_name.IndexOf("Luna")!=-1)
                 _theme = Theme.Luna;
         }
         //Debug.WriteLine(String.Format("FN={0} Color={1} Size={2}", new string(fn), new string(cb), new string(sz)));
     }
     catch(Exception) {
     }
 }
Esempio n. 6
0
		static ThemeEngine ()
		{
			string theme_var;

			theme_var = Environment.GetEnvironmentVariable("MONO_THEME");

			if (theme_var == null) {
				theme_var = "win32";
			} else {
				theme_var = theme_var.ToLower ();
			}

			if (Application.VisualStylesEnabled) {
				theme = new ThemeVisualStyles ();
			} else {
				theme = new ThemeWin32Classic ();
			}
		}
Esempio n. 7
0
        internal void LoadUITheme(Theme theme)
        {
            if (theme == Theme.None)
            {
                heroInfoPanel.BackgroundImage = Properties.Resources.defaultInfoBox;
                heroStatsPanel.BackgroundImage = Properties.Resources.defaultMainPanel;
                heroSkillsPanel.BackgroundImage = Properties.Resources.defaultSkillTable;
                inventoryBgPanel.BackgroundImage = heroStatsPanel.BackgroundImage;
                return;
            }

            if (!LoadUIThemeFromDisk(theme))
            {
                if (!Current.sessionHasWar3DB)
                {
                    MessageBox.Show("The theme '" + theme + "' requires WarCraft location to be known." +
                        "\nYou can specify WarCraft location in Options->Settings...", "Cannot load selected theme");
                    return;
                }
                LoadUIThemeFromWar3(theme);
            }
        }
        /// <summary>
        /// Shows the specified text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="useWPFMessageBox">if set to <c>true</c> [use WPF message box].</param>
        /// <param name="theme">The theme.</param>
        /// <param name="themeColor">Color of the theme.</param>
        public void Show(
            string text, 
            string caption,
            bool useWPFMessageBox,
            Theme theme,
            string themeColor)
        {
            if (useWPFMessageBox)
            {
                MessageBoxView view = new MessageBoxView
                                          {
                                              Title = caption,
                                              Message = { Text = text }
                                          };

                view.ChangeTheme(theme, themeColor);

                view.ShowDialog();
            }
            else
            {
                MessageBox.Show(text, caption);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Loads a preview of the specified theme.
        /// </summary>
        /// <param name="theme">The theme to load a preview of.</param>
        private void LoadThemePreview(Theme theme)
        {
            if (this.WebView != null && this.webViewIsReady && !this.WebView.IsLoading)
            {
                string style = File.ReadAllText(theme.Path);

                style = style.Replace("\r", " ").Replace("\n", " ").Replace("'", @"\'");
                string script = @"setStyle('" + style + "')";

                this.WebView.ExecuteScript(script);
                this.WebView.ExecuteScript("$(window).scrollTop(document.body.scrollHeight);");
                this.pendingTheme = null;
            }
            else
            {
                this.pendingTheme = theme;
            }
        }
Esempio n. 10
0
        /// <summary>
        /// force everything to redraw to apply a new theme
        /// </summary>
        public static void RefreshApplicationWithTheme(Theme theme)
        {
            Current = theme;
            Config.Instance.AccentColor = theme.AccentColor;

            // force the autocomplete to redraw
            AutoComplete.ForceClose();
            CodeExplorer.ApplyColorSettings();
            FileExplorer.ApplyColorSettings();
            Application.DoEvents();
            Appli.Refresh();
        }
Esempio n. 11
0
        /// <summary>
        /// Adds a node to represent the theme to the tree view.
        /// </summary>
        /// <param name="theme">The theme to create a node from.</param>
        private void AddTheme(Theme theme)
        {
            TreeNode node = new TreeNode();
            TreeNode parent = theme.IsOfficial ? this.themesTreeView.Nodes[0] : this.themesTreeView.Nodes[1];
            string imageKey = "layout";

            if (theme.Path.Equals(GlobalSettings.Instance.ThemeFileName))
            {
                imageKey = "tick";
            }

            node.Text = theme.Name;
            node.SelectedImageKey = imageKey;
            node.ImageKey = imageKey;
            node.Tag = theme;

            parent.Nodes.Add(node);
        }
Esempio n. 12
0
 void IView.ForceTheme(Theme theme)
 {
     if (_settings.Theme != theme)
     {
         _settings.Theme = theme;
         ApplyTheme();
     }
 }
Esempio n. 13
0
 /// <summary>
 /// Called when the list of themes is imported
 /// </summary>
 public static void ImportList()
 {
     _listOfThemes.Clear();
     _currentTheme = null;
     Current.AccentColor = Color.Empty;
     RefreshApplicationWithTheme(Current);
     Config.Instance.AccentColor = Current.AccentColor;
 }
Esempio n. 14
0
        internal void LoadUIThemeFromWar3(Theme theme)
        {
            try
            {
                // Example path: UI\Console\Human\HumanUITile01.blp

                Bitmap bmp01 = DHRC.GetImage(@"UI\Console\" + theme + "\\" + theme + "UITile01.blp", PixelFormat.Format32bppArgb);
                Bitmap bmp02 = DHRC.GetImage(@"UI\Console\" + theme + "\\" + theme + "UITile02.blp", PixelFormat.Format32bppArgb);
                Bitmap bmp03 = DHRC.GetImage(@"UI\Console\" + theme + "\\" + theme + "UITile03.blp", PixelFormat.Format32bppArgb);
                Bitmap bmp04 = DHRC.GetImage(@"UI\Console\" + theme + "\\" + theme + "UITile04.blp", PixelFormat.Format32bppArgb);

                Brush brush = new SolidBrush(Color.Black);

                int w = 361;
                int h = 339;
                Bitmap bmpInfo = new Bitmap(w, h, bmp01.PixelFormat);

                Graphics gInfo = Graphics.FromImage(bmpInfo);

                // fill rectangle inside the info panel with black color, to make it nontransparent
                gInfo.FillRectangle(brush, 0, 74, bmpInfo.Width, bmpInfo.Height);

                // now draw the transparent image of the info panel
                gInfo.DrawImageUnscaled(bmp01,
                    new Point(0, -(bmp01.Height - h)));

                heroInfoPanel.BackgroundImageLayout = ImageLayout.Zoom;
                heroInfoPanel.BackgroundImage = bmpInfo;

                w = 372;
                Bitmap bmpSkill = new Bitmap(w, h, bmp03.PixelFormat);

                Graphics gSkill = Graphics.FromImage(bmpSkill);

                // fill rectangle inside the skill panel with black color, to make it nontransparent
                gSkill.FillRectangle(brush, 0, 74, bmpSkill.Width, bmpSkill.Height);

                // now draw the transparent image of the skill panel
                gSkill.DrawImageUnscaled(bmp04,
                    new Point(bmpSkill.Width - bmp04.Width, bmpSkill.Height - bmp04.Height));

                gSkill.DrawImage(bmp03, 0, 0,
                    new Rectangle(
                    bmp03.Width - (bmpSkill.Width - bmp04.Width), bmp03.Height - bmpSkill.Height,
                    (bmpSkill.Width - bmp04.Width), bmpSkill.Height),
                    GraphicsUnit.Pixel);

                heroSkillsPanel.BackgroundImageLayout = ImageLayout.Zoom;
                heroSkillsPanel.BackgroundImage = bmpSkill;

                w = 867;
                Bitmap bmpMain = new Bitmap(w, h, PixelFormat.Format32bppRgb);

                Graphics gMain = Graphics.FromImage(bmpMain);

                gMain.DrawImageUnscaled(bmp01,
                    new Point(-bmpInfo.Width, -(bmp01.Height - bmpMain.Height)));

                gMain.DrawImageUnscaled(bmp02,
                    new Point(bmp01.Width - bmpInfo.Width, -(bmp02.Height - bmpMain.Height)));

                gMain.DrawImageUnscaled(bmp03,
                    new Point((bmp01.Width - bmpInfo.Width) + bmp02.Width, -(bmp03.Height - bmpMain.Height)));

                heroStatsPanel.BackgroundImageLayout = ImageLayout.Zoom;
                heroStatsPanel.BackgroundImage = new Bitmap(bmpMain, heroStatsPanel.Size);

                inventoryBgPanel.BackgroundImage = heroStatsPanel.BackgroundImage;

                // save images to disk

                string skinPath = Application.StartupPath + "\\Skins\\" + theme;

                if (!Directory.Exists(skinPath))
                    Directory.CreateDirectory(skinPath);

                heroInfoPanel.BackgroundImage.Save(skinPath + "\\Info.png");
                heroSkillsPanel.BackgroundImage.Save(skinPath + "\\Skills.png");
                heroStatsPanel.BackgroundImage.Save(skinPath + "\\Stats.png");
            }
            catch
            {
                MessageBox.Show("An error occured while loading theme '" + theme + "' from WarCraft datafiles", "Error");
            }
        }
 public KeyMenuItem(Theme theme, TextFormat font, Menu parentMenu, string text, string extraData, Keys key)
     : this(theme, font, 0f, 0f, 100f, 20f, parentMenu, text, extraData, key) { }
Esempio n. 16
0
        private void RefreshTheme(Theme newTheme)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            if (newTheme != Theme.NULL)
                Properties.Settings.Default.Theme = newTheme.ToString();

            Theme theme = (Theme)Enum.Parse(typeof(Theme), Properties.Settings.Default.Theme);

            switch (theme)
            {
                case (Theme.DARK):

                    textColor               = ColorTranslator.FromHtml(ColorTextDark);
                    formBackColor           = ColorTranslator.FromHtml(ColorFormBackDark);
                    menuStripsColor         = ColorTranslator.FromHtml(ColorMenuStripDark);
                    toolStripsForeColor     = ColorTranslator.FromHtml(ColorToolStripDark);
                    pBarBackColor           = ColorTranslator.FromHtml(ColorProgBarBackDark);
                    pBarForeColor           = ColorTranslator.FromHtml(ColorProgBarForeDark);
                    buttonsHoverColor       = ColorTranslator.FromHtml(ColorButtonsHoverDark);
                    buttonsNoHoverColor     = ColorTranslator.FromHtml(ColorButtonsNoHoverDark);
                    buttonsHoverUnloadColor = ColorTranslator.FromHtml(ColorButtonsHoverUnloadDark);

                    imgXButton        = Properties.Resources.X;
                    imgXButtonHover   = Properties.Resources.X_Hover;
                    imgMinButton      = Properties.Resources.Minimize;
                    imgMinButtonHover = Properties.Resources.Minimize_Hover;

                    break;

                case (Theme.LIGHT):

                    textColor               = ColorTranslator.FromHtml(ColorTextLight);
                    formBackColor           = ColorTranslator.FromHtml(ColorFormBackLight);
                    menuStripsColor         = ColorTranslator.FromHtml(ColorMenuStripLight);
                    toolStripsForeColor     = ColorTranslator.FromHtml(ColorToolStripLight);
                    pBarBackColor           = ColorTranslator.FromHtml(ColorProgBarBackLight);
                    pBarForeColor           = ColorTranslator.FromHtml(ColorProgBarForeLight);
                    buttonsHoverColor       = ColorTranslator.FromHtml(ColorButtonsHoverLight);
                    buttonsNoHoverColor     = ColorTranslator.FromHtml(ColorButtonsNoHoverLight);
                    buttonsHoverUnloadColor = ColorTranslator.FromHtml(ColorButtonsHoverUnloadLight);

                    imgXButton        = DocEdit.Properties.Resources.XLight;
                    imgXButtonHover   = DocEdit.Properties.Resources.X_HoverLight;
                    imgMinButton      = DocEdit.Properties.Resources.MinimizeLight;
                    imgMinButtonHover = DocEdit.Properties.Resources.Minimize_HoverLight;

                    break;
            }

            Properties.Settings.Default.Save();

            BackColor = formBackColor;
            foreach (Control c in this.Controls)
            {
                if (c is Button)
                {
                    c.BackColor = buttonsNoHoverColor;
                    c.ForeColor = Color.Black;
                }
                else if (c is MenuStrip)
                {
                    foreach (ToolStripMenuItem t in menuStrip1.Items)
                    {
                        foreach (ToolStripMenuItem i in t.DropDownItems)
                        {
                            t.BackColor = menuStripsColor;
                            t.ForeColor = textColor;
                            i.BackColor = menuStripsColor;
                            i.ForeColor = textColor;
                        }
                    }
                    c.BackColor = menuStripsColor;
                }

                c.ForeColor = textColor;
            }

            foreach (CheckBox c in groupBox1.Controls)
            {
                c.ForeColor = textColor;
            }

            pBar1.BackColor        = pBarBackColor;
            pBar1.ForeColor        = pBarForeColor;
            statusStrip1.BackColor = menuStripsColor;
            statusStrip1.ForeColor = textColor;
            closeFormButtton.Image = imgXButton;
            minimizeBox.Image      = imgMinButton;
        }
 public KeyMenuItem(Theme theme, TextFormat font, float x, float y, Menu parentMenu, Keys key)
     : this(theme, font, x, y, 100f, 20f, parentMenu, key) { }
Esempio n. 18
0
        // scaleIndex 0-24 from m_scales[], or -1 for automatic
        public static bool calcScaleIndex(Theme theme, double elev, int scaleIndexHint, out int scaleIndex, out Scale tileScale)
        {
            scaleIndex = scaleIndexHint;
            tileScale = 0;

            // each tile scale has it's threshold, after which the next tile scale is used.
            // the idea is to use the tile while it maps closely to 1:1 in pixels, and when
            // the mapping requires too much magnification (i.e. tile 200x200 --> 300x300 on the picture),
            // then use the next level

            // here are the real experimental numbers:
            //  64      -- from 43.6 to 87   km
            //  32      -- from 21.9 to 43.5 km
            //  16      -- from 11.0 to 21.8 km
            //   8      -- from 5.46 to 10.9 km
            //   4      -- from 2.75 to 5.45 km
            //   2      -- from 1.36 to 2.70 km
            //   1      -- from 0.25 to 1.35 km

            if(scaleIndexHint == -1)
            {
                // figure out optimal scale for this camera height:

                double cameraHeight = elev;	// m

                // 1 km height translates to 1km X 1km coverage.
                // At 1000 pixels on screen the closest scale is 1m

                Int64 iScale = (Int64)(cameraHeight * 0.75d);		// mm

                scaleIndex = 0;
                while(iScale != 0 && scaleIndex < m_scales.Length - 1)
                {
                    iScale = iScale >> 1;
                    scaleIndex++;
                }
            }

            bool supported = false;
            switch(theme)
            {
                case Theme.Photo:
                    // see http://terraserver.homeadvisor.msn.com/addressimage.aspx?t=4&s=8&Lon=-122.19993897&Lat=47.86114017&Alon=-122.19993897&Alat=47.86114017&w=2&opt=0&ref=A%7c2403+150th+Ct+SE%2c+Bothell%2c+WA+98012
                    if(scaleIndex < 10)		// color actually goes to s=8, but I don't know how to get a tile via http with s < 10
                    {
                        scaleIndex = 10;
                        supported = true;
                    }
                    else
                    {
                        supported = m_scales[scaleIndex].supportedPhoto;
                    }
                    break;
                case Theme.Topo:
                    if(scaleIndex < 11)
                    {
                        scaleIndex = 11;
                        supported = true;
                    }
                    else
                    {
                        supported = m_scales[scaleIndex].supportedTopo;
                    }
                    break;
                case Theme.Relief:
                    supported = m_scales[scaleIndex].supportedRelief;
                    break;
            }

            if(supported)
            {
                tileScale = m_scales[scaleIndex].scale;
            }
            return supported;
        }
Esempio n. 19
0
		/// <summary>
		/// Applies the given theme to the form.
		/// </summary>
		/// <param name="p_thmTheme">The theme to apply.</param>
		protected void ApplyTheme(Theme p_thmTheme)
		{
			Icon = p_thmTheme.Icon;
		}
Esempio n. 20
0
        public void CreateNewLevel(Theme theme, int width, int height, string name)
        {
            tile = new Tile[width, height];
            this.Width = width;
            this.Height = height;
            this.Theme = theme;
            this.Name = name;
            this.PlayerSpawn = Vector2.Zero;
            CurrentLevel = this;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    SetEmptyTile(x, y);
                }
            }

            ScreenManagers.GameScreen gs = (ScreenManagers.GameScreen)ScreenManagers.ScreenManager.CurrentScreen;
            gs.RemoveAllEntities();
            gs.RemoveAllGameObjects();
            gs.Player.Position = PlayerSpawn;
            gs.Player.AllowMovement = true;
            gs.camera.LevelWidth = Width * Tile.WIDTH;
            gs.camera.LevelHeight = Height * Tile.HEIGHT;
        }
Esempio n. 21
0
        public void CreateNewLevel(Theme theme, int width, int height, string name, int waterLevel)
        {
            if (waterLevel < 0)
                waterLevel = 0;
            if (waterLevel > MAX_WATER_LEVEL)
                waterLevel = MAX_WATER_LEVEL;

            ScreenManagers.GameScreen gs = (ScreenManagers.GameScreen)ScreenManagers.ScreenManager.CurrentScreen;
            CreateNewLevel(theme, width, height, name);

            for(int x = 0; x < gs.level.Width; x++)
            {
                for(int y = waterLevel; y >= 0; y--)
                {
                    GameObjects.Water waterObj = new GameObjects.Water(new Vector2(x * Tile.WIDTH, (height - y) * Tile.HEIGHT));
                    if(y == waterLevel)
                    {
                        waterObj.WaterType = GameObjects.WaterType.Top;
                    }

                    gs.AddWater(waterObj);
                }
            }
        }
Esempio n. 22
0
        private void SetObjectsMasterPage(string tipo, bool ar, HPatternInstance wwInstance, InstanceObjectsGroup group, WebPanel masterPage, Theme tTema, string ATema, string AMP)
        {
            if (group != null && tipo == "p")
            {
                foreach (WebPanel webPanel in group.GetObjects<WebPanel>())
                {
                    webPanel.SetPropertyValue(Properties.WBP.EncryptUrlParameters, Properties.WBP.EncryptUrlParameters_Values.No);
                }
            }

            if (group != null)
            {
                foreach (WebPanel webPanel in group.GetObjects<WebPanel>())
                {
                    if (webPanel.IsPropertyDefault(Properties.WBP.MasterPage) || AMP == SettingsThemeElement.SetObjectThemeValue.Force)
                    {
                        if (masterPage == null)
                        {
                            webPanel.SetPropertyValue(Properties.WBP.MasterPage, new WebPanelReference());
                        }
                        else
                        {
                            webPanel.SetPropertyValue(Properties.WBP.MasterPage, new WebPanelReference(masterPage));
                        }
                    }

                    if (tTema != null)
                    {
                        if (webPanel.IsPropertyDefault(Properties.WBP.Theme) || ATema == SettingsThemeElement.SetObjectThemeValue.Force)
                        {
                            webPanel.SetPropertyValue(Properties.WBP.Theme, new KBObjectReference(tTema));
                        }
                    }

                    if (tipo == "p") {

                        foreach (LevelElement l in wwInstance.Levels) {
                            foreach (PromptElement p in l.Prompts) {
                                bool ari = ar;
                                if (p.AutomaticRefresh.ToLower() == "true")
                                    ari = true;
                                if (p.AutomaticRefresh.ToLower() == "false")
                                    ari = false;

                                if (webPanel.Name.ToLower() == p.Name.ToLower()) {
                                    if (ari)
                                    {
                                        webPanel.SetPropertyValue(Properties.WBP.AutomaticRefresh, Properties.WBP.AutomaticRefresh_Values.WhenVariablesInConditionsChange);
                                    }
                                    else
                                    {
                                        webPanel.SetPropertyValue(Properties.WBP.AutomaticRefresh, Properties.WBP.AutomaticRefresh_Values.No);
                                    }
                                }

                            }

                        }
                    }

                    if (tipo == "s") {
                        InstanceObject sl = group.Objects.Find(delegate(InstanceObject iobj) { return iobj.Object == HPatternObject.Selection; });

                        if (sl != null)
                        {
                            if (webPanel.Name == sl.Name) {
                                foreach (LevelElement l in wwInstance.Levels) {
                                    bool ari = ar;
                                    if (l.Selection.AutomaticRefresh.ToLower() == "true")
                                        ari = true;
                                    if (l.Selection.AutomaticRefresh.ToLower() == "false")
                                        ari = false;

                                    if (ari)
                                    {
                                        webPanel.SetPropertyValue(Properties.WBP.AutomaticRefresh, Properties.WBP.AutomaticRefresh_Values.WhenVariablesInConditionsChange);
                                    }
                                    else
                                    {
                                        webPanel.SetPropertyValue(Properties.WBP.AutomaticRefresh, Properties.WBP.AutomaticRefresh_Values.No);
                                    }

                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 23
0
        protected void queryTerraserver()
        {
            LonLatPt centerPoint = new LonLatPt();
            centerPoint.Lat = m_cameraManager.Location.Lat;
            centerPoint.Lon = m_cameraManager.Location.Lng;

            bool isValidAbb = false;
            int retriesMax = 2;

            #if DEBUG
            LibSys.StatusBar.Trace("IP: TileSetTerra.queryTerraserver() Fetching Area Bounding Box from TerraServer");
            #endif
            bool canReuseAbb = false;
            try
            {
                if(abb != null && m_savedCurTheme == m_curTheme && m_savedCurThemeColor == m_curThemeColor && m_savedTileScale == m_tileScale
                    && m_savedImageWidth == m_imageWidth && m_savedImageHeight == m_imageHeight
                    && m_savedCenterPointLat == centerPoint.Lat && m_savedCenterPointLon == centerPoint.Lon)
                {
                    canReuseAbb = true;
                    isValidAbb = true;
            #if DEBUG
                    LibSys.StatusBar.Trace("IP: TileSetTerra.queryTerraserver() reusing Area Bounding Box");
            #endif
                }
            }
            catch {}

            int retries = 0;
            while (!canReuseAbb && retries <= retriesMax && Project.serverAvailable)
            {
                try
                {
                    abb = TerraserverCache.ts.GetAreaFromPt(centerPoint, (int)m_curTheme, m_tileScale, m_imageWidth, m_imageHeight);
            #if DEBUG
                    LibSys.StatusBar.Trace("IP: TileSetTerra.queryTerraserver() Got the Area Bounding Box from TerraServer");
            #endif
                    // make a real quick sanity check of acquired abb here:
                    isValidAbb = abb != null;
                    if(isValidAbb)
                    {
                        TileMeta tmm = abb.Center.TileMeta;
                        if(tmm.Capture.CompareTo(date1970) < 0)
                        {
                            m_placeDescription = abb.NearestPlace;
                            abbMessage = (m_placeDescription == null ? "" : (m_placeDescription + " - ")) + "this area not covered by Terraserver";
                            isValidAbb = false;
                            break;
                        }
                    }

                    // react if abb is invalid:
                    if(isValidAbb)
                    {
                        abbMessage = "terraserver reached";
                        break;
                    }
                    else if (retries++ < retriesMax)
                    {
            #if DEBUG
                        LibSys.StatusBar.Error("TileSetTerra.queryTerraserver() while getting abb, retry # " + retries + " abb=null");
            #endif
                        continue;
                    }
                    else
                    {
                        abbMessage = "terraserver not reached";
                        warningCantReachServer("");
                        break;
                    }
                }
                catch (Exception ie)
                {
                    if (retries++ < retriesMax)
                    {
            #if DEBUG
                        LibSys.StatusBar.Error("TileSetTerra.queryTerraserver() while getting abb, retry # " + retries + " " + ie.Message);
            #endif
                        // compensate for currently present bug around Seattle:
                        if(ie.Message.IndexOf("There is an error in XML document") >= 0)
                        {
                            abbMessage = "terraserver ws failed";
                            break;
                        }
                        continue;
                    }
                    else
                    {
                        abbMessage = "terraserver not reached";
                        warningCantReachServer(ie.Message);
                        break;
                    }
                }
            }

            if(!isValidAbb)
            {
                LibSys.StatusBar.Error("TileSetTerra.queryTerraserver() couldn't get abb - working offline [" + abbMessage + "]");
                Project.terraserverDisconnected = true;
                cleanTiles();
                m_formText = Project.PROGRAM_NAME_HUMAN + " - [" + Project.drawTerraserverMode + " map not available - " + abbMessage + "]";
                abb = null;
                return;
            }

            m_savedCurTheme = m_curTheme;
            m_savedCurThemeColor = m_curThemeColor;
            m_savedTileScale = m_tileScale;
            m_savedImageWidth = m_imageWidth;
            m_savedImageHeight = m_imageHeight;
            m_savedCenterPointLat = centerPoint.Lat;
            m_savedCenterPointLon = centerPoint.Lon;

            // calculate abb corners geo coordinates, keeping in mind that not all corner tiles exist (actually all four may be missing):
            double topLeftLng = 0.0d;
            double topLeftLat = 0.0d;
            double bottomRightLng = 0.0d;
            double bottomRightLat = 0.0d;

            if(abb.NorthWest.TileMeta.TileExists)
            {
                topLeftLng = abb.NorthWest.TileMeta.NorthWest.Lon;
                topLeftLat = abb.NorthWest.TileMeta.NorthWest.Lat;
            }
            else
            {
                if(abb.SouthWest.TileMeta.TileExists)
                {
                    topLeftLng = abb.SouthWest.TileMeta.NorthWest.Lon;
                    if(abb.NorthEast.TileMeta.TileExists)
                    {
                        topLeftLat = abb.NorthEast.TileMeta.NorthEast.Lat;
                    }
                    else
                    {
                        // both top corners are missing, go get the top lat by Utm to LonLat conversion:
                        LonLatPt llpt = getTopLeftByTileId(abb.NorthWest.TileMeta.Id);
                        topLeftLat = llpt.Lat;
                    }
                }
                else
                {
                    // both left side corners are missing, go get the top left corner by Utm to LonLat conversion:
                    LonLatPt llpt = getTopLeftByTileId(abb.NorthWest.TileMeta.Id);
                    topLeftLng = llpt.Lon;
                    topLeftLat = llpt.Lat;
                }
            }

            if(abb.SouthEast.TileMeta.TileExists)
            {
                bottomRightLng = abb.SouthEast.TileMeta.SouthEast.Lon;
                bottomRightLat = abb.SouthEast.TileMeta.SouthEast.Lat;
            }
            else
            {
                if(abb.NorthEast.TileMeta.TileExists)
                {
                    bottomRightLng = abb.NorthEast.TileMeta.SouthEast.Lon;
                    if(abb.SouthWest.TileMeta.TileExists)
                    {
                        bottomRightLat = abb.SouthWest.TileMeta.SouthWest.Lat;
                    }
                    else
                    {
                        // both bottom corners are missing, go get the bottom lat by Utm to LonLat conversion:
                        LonLatPt llpt = getBottomRightByTileId(abb.SouthEast.TileMeta.Id);
                        bottomRightLat = llpt.Lat;
                    }
                }
                else
                {
                    // both right side corners are missing, go get the bottom right corner by Utm to LonLat conversion:
                    LonLatPt llpt = getBottomRightByTileId(abb.SouthEast.TileMeta.Id);
                    bottomRightLng = llpt.Lon;
                    bottomRightLat = llpt.Lat;
                }
            }

            // more sanity check - in unlikely case we were unable to figure out abb corners:
            if(topLeftLng == 0.0d || topLeftLat == 0.0d || bottomRightLng == 0.0d || bottomRightLat == 0.0d)
            {
                abbMessage = "response from terraserver cannot be mapped";
                LibSys.StatusBar.Error("TileSetTerra.queryTerraserver() couldn't get abb - working offline [" + abbMessage + "]");
                Project.terraserverDisconnected = true;
                cleanTiles();
                m_formText = Project.PROGRAM_NAME_HUMAN + " - [" + Project.drawTerraserverMode + " map not available - " + abbMessage + "]";
                return;
            }

            m_placeDescription = abb.NearestPlace;
            TileMeta tm = abb.Center.TileMeta;
            /*
            if(tm.Capture.CompareTo(date1970) < 0)
            {
                // we won't get here as date is checked before, in sanity check
                m_placeDescription += " [" + Project.drawTerraserverMode + " map]";
            }
            else
            { */
            m_placeDescription += " [" + Project.drawTerraserverMode + " map from " + tm.Capture.ToString("D", null) + "]";
            //}

            #if DEBUG
            LibSys.StatusBar.Trace("IP: retrieved info for " + m_placeDescription);
            #endif

            m_scale = abb.Center.TileMeta.Id.Scale;
            m_metersPerPixel = (1 << ((Int32) m_scale - 10));

            int factor = 200 * m_metersPerPixel;

            m_lastFactor = factor;

            // even if a corner tile does not exist, the Id is filled with valid information:
            xStart = abb.NorthWest.TileMeta.Id.X;
            int yyStart = abb.NorthWest.TileMeta.Id.Y;

            // actually superframe is computed in offline mode, so the saved xStart...yEnd values will be used in queryDisconnected()
            yStart = yyStart + 1;

            xEnd = abb.NorthEast.TileMeta.Id.X + 1;
            int yyEnd = abb.SouthWest.TileMeta.Id.Y;

            yEnd = yyEnd;

            // we need to remember UTMP coordinates for Projection operation:
            screenUtmZone	 = abb.Center.TileMeta.Id.Scene;
            screenUtmX		 = xStart * factor;
            screenUtmY		 = yyStart * factor;

            cleanTiles();		// dispose of previous tile array, if any

            m_hCount = xEnd - xStart;
            m_vCount = yyStart - yyEnd + 1;

            #if DEBUG
            LibSys.StatusBar.Trace("TileSetTerra:queryTerraserver() m_vCount=" + m_vCount + " m_hCount=" + m_hCount);
            #endif

            int themeCode = getThemeCode();

            lock(tilesLock)
            {
                m_tiles = new TileTerra[m_vCount, m_hCount];

            #if DEBUG
                LibSys.StatusBar.Trace("TileSetTerra:queryTerraserver() ----------------- before " + TileCache.ToString());
            #endif
                GeoCoord covTL = m_cameraManager.CoverageTopLeft;
                GeoCoord covBR = m_cameraManager.CoverageBottomRight;

                m_cameraManager.terraTopLeft = new GeoCoord(topLeftLng, topLeftLat);
                m_cameraManager.terraBottomRight = new GeoCoord(bottomRightLng, bottomRightLat);

                m_tileResolutionDegreesH = Math.Abs(bottomRightLng - topLeftLng) / m_hCount;
                m_tileResolutionDegreesV = Math.Abs(bottomRightLat - topLeftLat) / m_vCount;

            #if DEBUG
                LibSys.StatusBar.Trace("abb: topleft=" + topLeftLat + "," + topLeftLng + "  bottomRight=" + bottomRightLat + "," + bottomRightLng);
                LibSys.StatusBar.Trace("   : m_tileResolutionDegreesH=" + m_tileResolutionDegreesH + "  m_tileResolutionDegreesV=" + m_tileResolutionDegreesV);
            #endif
                SnapList snapLat = new SnapList(m_tileResolutionDegreesV, true);
                SnapList snapLng = new SnapList(m_tileResolutionDegreesH, true);

                int x = 0;
                int y = 0;
                int vv = 0;
                int hh = 0;

                // for corners of the current tile:
                double tileTopLeftLng = topLeftLng;
                double tileBottomRightLng = tileTopLeftLng + m_tileResolutionDegreesH;
                double tileTopLeftLat;
                double tileBottomRightLat;

                TileId tid = new TileId(); // we need to clone abb.NorthWest.TileMeta.Id and leave abb intact

                for ( x = xStart; hh < m_hCount; x++, hh++)
                {
                    vv = 0;
                    tileTopLeftLat = topLeftLat;
                    tileBottomRightLat = tileTopLeftLat - m_tileResolutionDegreesV;

                    for ( y = yyStart; vv < m_vCount; y--, vv++)
                    {
                        tid.X = x;
                        tid.Y = y;
                        tid.Scale = abb.NorthWest.TileMeta.Id.Scale;
                        tid.Scene = abb.NorthWest.TileMeta.Id.Scene;
                        tid.Theme = (int)m_curTheme;	// why isn't Theme already set?

                        String baseName = String.Format("T{0}-S{1}-Z{2}-X{3}-Y{4}", themeCode, (Int32)tid.Scale, tid.Scene, tid.X, tid.Y);
                        //String baseName = "T" + themeCode + "-S" + (Int32)tid.Scale + "-Z" + tid.Scene + "-X" + tid.X + "-Y" + tid.Y;

                        // adding to snap lists prepares them for calculating snap points:
                        snapLat.Add(tileTopLeftLat);
                        snapLat.Add(tileBottomRightLat);
                        snapLng.Add(tileTopLeftLng);
                        snapLng.Add(tileBottomRightLng);

                        GeoCoord tileTopLeft = new GeoCoord(tileTopLeftLng, tileTopLeftLat, 0.0d);
                        GeoCoord tileBottomRight = new GeoCoord(tileBottomRightLng, tileBottomRightLat, 0.0d);

                        m_tiles[vv, hh] = new TileTerra(this, m_tileScale, tileTopLeft, tileBottomRight);
                        m_tiles[vv, hh].baseName = baseName;
                        m_tiles[vv, hh].init();		// gets backdrop, or starts the process of loading backdrop

            #if DEBUG
                        //LibSys.StatusBar.Trace("[" + vv + "," + hh + "]  " + baseName);
                        //LibSys.StatusBar.Trace("        -- topLeft=" + tileTopLeft + " bottomRight=" + tileBottomRight);
            #endif
                        // we know a lot about this tile now.
                        // register the tile with local database for disconnected operation.
                        // it may turn out to be a cottage cheese or non-arrival though, and the registration would stay there.
                        //TerraserverCache.registerTerraTile(baseName, m_curTheme, m_tileScale, tileTopLeft, tileBottomRight);

                        tileTopLeftLat -= m_tileResolutionDegreesV;
                        tileBottomRightLat -= m_tileResolutionDegreesV;
                    }
                    tileTopLeftLng += m_tileResolutionDegreesH;
                    tileBottomRightLng += m_tileResolutionDegreesH;
                }

                // snap to the grid (corrects small gaps at maximum zoom):
                for(int vvv=0; vvv < m_vCount ;vvv++)
                {
                    for(int hhh=0; hhh < m_hCount ;hhh++)
                    {
                        TileTerra tile = m_tiles[vvv, hhh];
                        // snap the tile's corners to grid:
                        tile.getBottomRight().X = snapLng.snap(tile.getBottomRight().X);
                        tile.getBottomRight().Y = snapLat.snap(tile.getBottomRight().Y);
                        tile.getTopLeft().X = snapLng.snap(tile.getTopLeft().X);
                        tile.getTopLeft().Y = snapLat.snap(tile.getTopLeft().Y);
                    }
                }

                // we need topleft tile for Projection:
                m_topLeftTile = m_tiles[0, 0];

                Project.terraserverAvailable = true;
            } // end lock

            calcRatios();

            hasRenderedTiles = true;

            // compute visible magnification ratio:
            double ratio = (m_ratioX + m_ratioY) / 2.0d;
            string overzoom = ("1m".Equals(m_tileScaleName) && ratio > 1.1d) ? " (overzoom)" : "";

            m_formText = Project.PROGRAM_NAME_HUMAN + " - " + m_placeDescription + "   " + m_tileScaleName + "/pixel  x" + ratio + overzoom; // + " (" + m_tileScale + ")";

            if(Project.drawLandmarks)
            {
                TerraserverCache.initLandmarkService();
                if(TerraserverCache.ls != null && TerraserverCache.landmarkPointTypes != null && TerraserverCache.landmarkPointTypes.Length > 0)
                {

                    // retrieve lanfdmarks information:
                    BoundingRect br = new BoundingRect();

                    LonLatPt tmp = abb.SouthEast.TileMeta.SouthEast;
                    br.LowerRight = new LibNet.LandmarkServer.LonLatPt();
                    br.LowerRight.Lon = tmp.Lon;
                    br.LowerRight.Lat = tmp.Lat;

                    tmp = abb.NorthWest.TileMeta.NorthWest;
                    br.UpperLeft = new LibNet.LandmarkServer.LonLatPt();
                    br.UpperLeft.Lon = tmp.Lon;
                    br.UpperLeft.Lat = tmp.Lat;

                    m_hasPutOnMap = false;

                    bool isValidLps = false;
                    retries = 0;

                    //string[] types = new string[] { "Building", "Cemetery", "Church", "Encarta Article",
                    //								"Golf Course", "Hospital", "Institution", "Landmark", "Locale",
                    //								"Parks", "Populated Place", "Recreation Area", "Retail Center",
                    //								"Stream Gauge", "Summit", "Transportation Terminal", "Unknown Type" };

                    /*
                    string[] types = new string[] { "Building", "Cemetery", "Church", "Encarta Article",
                                                      "Golf Course", "Hospital", "Landmark", "Locale",
                                                      "Parks", "Populated Place", "Retail Center",
                                                      "Stream Gauge", "Summit", "Transportation Terminal", "Unknown Type"};
                    */

                    // as of May 31,03 , "Institution" and "Recreation Area" cause exception:
                    //          Server was unable to process request. --> Data is Null. This method or property cannot be called on Null values.
                    // see TerraserverCache:295 correcting this.

                    /*
                    string[] types = new string[TerraserverCache.landmarkPointTypes.Length];
                    for(int i=0; i < types.Length ;i++)
                    {
                        types[i] = "" + TerraserverCache.landmarkPointTypes[i];
                    }
                    */

                    while (retries <= retriesMax)
                    {
                        try
                        {
                            lps = TerraserverCache.ls.GetLandmarkPointsByRect(br, TerraserverCache.landmarkPointTypes);		// ,types);
                            // make a sanity check of acquired lps here:
                            isValidLps = lps != null;
                            break;
                        }
                        catch (Exception e)
                        {
                            if (retries == retriesMax)
                            {
                                MessageBox.Show("Unable to get landmark information" + e.Message, "TerraService Error");
                                break;
                            }
                            else
                            {
                                retries++;
                            }
                        }
                        catch
                        {
                            if (retries == retriesMax)
                            {
                                MessageBox.Show("Unable to get landmark information", "TerraService Error");
                                break;
                            }
                            else
                            {
                                retries++;
                            }
                        }

                    }

                    if (isValidLps)
                    {
                        int lpsCount = lps.Length;
                        foreach (LandmarkPoint lp in lps)
                        {
                            GeoCoord location = new GeoCoord(lp.Point.Lon, lp.Point.Lat);
                            string name = lp.Name;
                            string type = lp.Type;
                            Landmark lm = new Landmark(name, location, type);
                            TerraserverCache.AddLandmark(lm);			// to ArrayList, for this immediate display
                            TerraserverCache.RegisterLandmark(lm);		// add to DataSet, for disconnected operation
                        }
                    }
                }
            }
        }
 public KeyMenuItem(Theme theme, TextFormat font, Menu parentMenu, Keys key)
     : this(theme, font, 0f, 0f, parentMenu, key) { }
Esempio n. 25
0
        // scaleIndex 0-24 from m_scales[], or -1 for automatic
        //private GeoCoord m_topLeftTileCorner = null;
        //private GeoCoord m_bottomRightTileCorner = null;
        private void ReTile(int scaleIndex)
        {
            #if DEBUG
            LibSys.StatusBar.Trace("IP: TileSetTerra.ReTile(" + scaleIndex + ")  drawableReady=" + Project.drawableReady);
            #endif
            hasRenderedTiles = false;
            m_topLeftTile = null;
            abbMessage = "offline";
            if(!Project.drawableReady)	// when starting, we get several resize events with different sizes, as
                // layout settles. We want to ignore these and retile after the first paint.
            {
                return;
            }

            if(isPassiveSecond)
            {
                return;
            }

            lps = null;
            m_placeDescription = "";
            Project.terraserverDisconnected = false;
            Project.terraserverAvailable = false;
            m_cameraManager.terraTopLeft = new GeoCoord(0.0d, 0.0d);		// make sure we don't have stale values there for EarthquakesDisplayed
            m_cameraManager.terraBottomRight = new GeoCoord(0.0d, 0.0d);

            TerraserverCache.Landmarks.Clear();

            if(!Project.drawTerraserver)
            {
                m_formText = Project.PROGRAM_NAME_HUMAN;
                return;
            }

            if(Project.terraserverUseServices)
            {
                // try to create ts and ls and to make connection, if they are missing:
                TerraserverCache.initTerraService();
                if(TerraserverCache.ts == null)
                {
                    // no connection, can't query terraserver data. Use disconnected mode.
                    m_formText = Project.PROGRAM_NAME_HUMAN;
                    Project.terraserverDisconnected = true;
                }
            }

            // what is the picture area in degrees?
            // use CameraManager.m_coverageXDegrees, m_coverageYDegrees for span in degrees

            if(m_isSecond)
            {
                m_curTheme = Theme.Topo;
                m_curThemeColor = false;
            }
            else
            {
                switch(Project.drawTerraserverMode)
                {
                    default:
                    case "aerial":
                        m_curTheme = Theme.Photo;
                        m_curThemeColor = false;
                        break;
                    case "color aerial":
                        m_curTheme = Theme.Photo;
                        m_curThemeColor = true;
                        break;
                    case "topo":
                        m_curTheme = Theme.Topo;
                        m_curThemeColor = false;
                        break;
                    case "relief":
                        m_curTheme = Theme.Relief;
                        m_curThemeColor = false;
                        break;
                }
            }

            // what is appropriate tile resolution?
            if(!calcScale(scaleIndex))
            {
                // sorry, no sense in aerial/topo at small scale
                if(Project.serverAvailable)
                {
                    m_formText = Project.PROGRAM_NAME_HUMAN + " - [" + Project.drawTerraserverMode + " map not available at this scale]";
                }
                else
                {
                    m_formText = Project.PROGRAM_NAME_HUMAN + " - [" + abbMessage + "]";
                }
                cleanTiles();
                return;
            }

            // account for scaling of 200x200 pixel tiles into actual tile frame:
            m_imageWidth = (int)Math.Round(m_pictureManager.Width * m_cameraManager.MetersPerPixelX() * 1.1d / m_metersPerPixelTileExpected);
            m_imageHeight = (int)Math.Round(m_pictureManager.Height * m_cameraManager.MetersPerPixelY() * 1.1d / m_metersPerPixelTileExpected);

            if(Project.terraserverUseServices && Project.serverAvailable && scaleIndex == -1)
            {
                m_formText = Project.PROGRAM_NAME_HUMAN + " - reaching terraserver...";
                setMainFormText();
                queryTerraserver();		// will set Project.terraserverDisconnected on failure

                if(Project.terraserverDisconnected)
                {
                    queryDisconnected();
                }
            }
            else
            {
                if(Project.serverAvailable)
                {
                    abbMessage = "no ws";
                }
                queryDisconnected();
            }

            #if DEBUG
            //LibSys.StatusBar.Trace("TileSetTerra:ReTile() ----------------- after " + TileCache.ToString());
            #endif
            TerraserverCache.purge();

            logCamtrackFrame();

            if(m_needsRefresh)
            {
                m_needsRefresh = false;
                m_pictureManager.Refresh();
            }
        }
Esempio n. 26
0
        internal void SetUITheme(Theme theme)
        {
            if (theme == Current.theme)
                return;

            Current.theme = theme;

            switch (theme)
            {
                case Theme.NightElf:
                    nightElfToolStripMenuItem.Checked = true;
                    humanToolStripMenuItem.Checked = false;
                    orcToolStripMenuItem.Checked = false;
                    undeadToolStripMenuItem.Checked = false;
                    noneDefaultToolStripMenuItem.Checked = false;
                    break;

                case Theme.Human:
                    nightElfToolStripMenuItem.Checked = false;
                    humanToolStripMenuItem.Checked = true;
                    orcToolStripMenuItem.Checked = false;
                    undeadToolStripMenuItem.Checked = false;
                    noneDefaultToolStripMenuItem.Checked = false;
                    break;

                case Theme.Orc:
                    nightElfToolStripMenuItem.Checked = false;
                    humanToolStripMenuItem.Checked = false;
                    orcToolStripMenuItem.Checked = true;
                    undeadToolStripMenuItem.Checked = false;
                    noneDefaultToolStripMenuItem.Checked = false;
                    break;

                case Theme.Undead:
                    nightElfToolStripMenuItem.Checked = false;
                    humanToolStripMenuItem.Checked = false;
                    orcToolStripMenuItem.Checked = false;
                    undeadToolStripMenuItem.Checked = true;
                    noneDefaultToolStripMenuItem.Checked = false;
                    break;

                case Theme.None: // default
                    nightElfToolStripMenuItem.Checked = false;
                    humanToolStripMenuItem.Checked = false;
                    orcToolStripMenuItem.Checked = false;
                    undeadToolStripMenuItem.Checked = false;
                    noneDefaultToolStripMenuItem.Checked = true;
                    break;
            }

            LoadUITheme(theme);
        }
Esempio n. 27
0
 void IView.ForceTheme(Theme theme)
 {
     if (_settings.Theme != theme)
     {
         _settings.Theme = theme;
         ApplyTheme();
         _changeSoundUI?.ForceTheme(theme);
     }
 }
 public KeyMenuItem(Theme theme, TextFormat font, float x, float y, float width, float height, Menu parentMenu, string text, Keys key)
     : this(theme, font, x, y, width, height, parentMenu, text, "", key) { }
		private void EnsureCustomThemeCreated(RibbonOrbStyle orbStyle, RibbonTheme theme)
		{
			if (_theme == null && Theme.StandardThemeIsGlobal == false && UseAlwaysStandardTheme == false)
			{
				_theme = new Theme(orbStyle, theme);
			}
		}
 public KeyMenuItem(Theme theme, TextFormat font, float x, float y, float width, float height, Menu parentMenu, Keys key)
     : this(theme, font, x, y, width, height, parentMenu, "KeyMenuValue", key) { }