Exemplo n.º 1
0
        void m_nav_close_OnMouseUpEvent(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (m_ciaForm != null)
            {
                m_ciaForm.Visible = false;

                for (int i = 0; i < m_wavingFlagsList.ChildObjects.Count; i++)
                {
                    if (m_wavingFlagsList.ChildObjects[i] is WavingFlagLayer)
                    {
                        WavingFlagLayer wavingFlag = (WavingFlagLayer)m_wavingFlagsList.ChildObjects[i];
                        wavingFlag.ShowHighlight = false;
                    }
                }
            }
        }
Exemplo n.º 2
0
        void flag_OnMouseEnterEvent(object sender, EventArgs e)
        {
            System.Windows.Forms.MouseEventArgs mea = new System.Windows.Forms.MouseEventArgs(
                System.Windows.Forms.MouseButtons.None,
                0,
                DrawArgs.LastMousePosition.X,
                DrawArgs.LastMousePosition.Y,
                0);

            // hack check to make sure that a widget isn't in the way
            if (DrawArgs.NewRootWidget.OnMouseMove(mea) || DrawArgs.RootWidget.OnMouseMove(mea))
            {
                return;
            }

            WavingFlagLayer flag = (WavingFlagLayer)sender;

            if (m_wavingFlagsList.IsOn && flag.Initialized && flag.IsOn)
            {
                ChangeForm(flag.Name, m_currentCategoryIndex);
                //m_ciaForm.Visible = true;
            }

            for (int i = 0; i < m_wavingFlagsList.ChildObjects.Count; i++)
            {
                if (m_wavingFlagsList.ChildObjects[i] is WavingFlagLayer)
                {
                    WavingFlagLayer wavingFlag = (WavingFlagLayer)m_wavingFlagsList.ChildObjects[i];
                    if (wavingFlag.Name != flag.Name)
                    {
                        wavingFlag.ShowHighlight = false;
                    }
                    else
                    {
                        wavingFlag.ShowHighlight = true;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Plugin entry point - All plugins must implement this function
        /// </summary>
        public override void Load()
        {
            FileInfo savedFile = new FileInfo(SavedFilePath);

            if (!savedFile.Exists)
            {
                if (!savedFile.Directory.Exists)
                {
                    savedFile.Directory.Create();
                }

                try
                {
                    WorldWind.Net.WebDownload download = new WorldWind.Net.WebDownload(DataFileUri);
                    download.DownloadFile(savedFile.FullName);
                    download.Dispose();
                }
                catch { }
            }

            m_wavingFlagsList      = new RenderableObjectList("Waving Flags");
            m_wavingFlagsList.IsOn = false;
            System.Collections.Hashtable countryHash = new System.Collections.Hashtable();

            using (StreamReader reader = savedFile.OpenText())
            {
                string   header  = reader.ReadLine();
                string[] headers = header.Split('\t');

                string line = reader.ReadLine();
                while (line != null)
                {
                    System.Collections.Hashtable fieldHash = new System.Collections.Hashtable();
                    string[] lineParts = line.Split('\t');

                    //Log.Write(string.Format("{0}\t{1}", lineParts[0], lineParts[1]));
                    try
                    {
                        double latitude  = double.Parse(lineParts[3], System.Globalization.CultureInfo.InvariantCulture);
                        double longitude = double.Parse(lineParts[4], System.Globalization.CultureInfo.InvariantCulture);

                        if (lineParts[1].Length == 2)
                        {
                            string   flagFileUri   = FlagTextureDirectoryUri + "/" + lineParts[1] + FlagSuffix;
                            FileInfo savedFlagFile = new FileInfo(SavedFlagsDirectory + "\\" + lineParts[1] + ".dds");

                            WavingFlagLayer flag = new WavingFlagLayer(
                                lineParts[0],
                                ParentApplication.WorldWindow.CurrentWorld,
                                latitude,
                                longitude,
                                flagFileUri);

                            flag.SavedImagePath = savedFlagFile.FullName;
                            flag.ScaleX         = 100000;
                            flag.ScaleY         = 100000;
                            flag.ScaleZ         = 100000;
                            flag.Bar3D          = new Bar3D(flag.Name, flag.World, latitude, longitude, 0, flag.ScaleZ, System.Drawing.Color.Red);
                            flag.Bar3D.ScaleX   = 0.3f * flag.ScaleX;
                            flag.Bar3D.ScaleY   = 0.3f * flag.ScaleY;
                            flag.Bar3D.IsOn     = false;
                            flag.RenderPriority = RenderPriority.Custom;

                            flag.OnMouseEnterEvent += new EventHandler(flag_OnMouseEnterEvent);
                            flag.OnMouseLeaveEvent += new EventHandler(flag_OnMouseLeaveEvent);
                            flag.OnMouseUpEvent    += new System.Windows.Forms.MouseEventHandler(flag_OnMouseUpEvent);
                            m_wavingFlagsList.Add(flag);

                            for (int i = 0; i < lineParts.Length; i++)
                            {
                                try
                                {
                                    double value = double.Parse(lineParts[i], System.Globalization.CultureInfo.InvariantCulture);
                                    fieldHash.Add(headers[i], value);
                                }
                                catch
                                {
                                    fieldHash.Add(headers[i], lineParts[i]);
                                }
                            }
                            countryHash.Add(lineParts[0], fieldHash);
                        }
                        else
                        {
                            //Log.Write(Log.Levels.Debug, "blank: " + lineParts[0]);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Write(Log.Levels.Warning, string.Format("Exception: {0} - {1}", lineParts[0], ex.ToString()));
                    }

                    line = reader.ReadLine();
                }
                Headers = headers;
            }

            CountryHash = countryHash;

            InitializeCiaForm();

            ParentApplication.WorldWindow.CurrentWorld.RenderableObjects.Add(m_wavingFlagsList);
        }
Exemplo n.º 4
0
        void ChangeForm(string country, int category)
        {
            m_countryNameLabel.Text     = country;
            m_currentCategoryLabel.Text = Headers[category];

            System.Collections.Hashtable fieldHash = (System.Collections.Hashtable)CountryHash[country];

            object value = fieldHash[Headers[category]];

            if (value is double)
            {
                if (!SortedFieldData.Contains(Headers[category]))
                {
                    SortField(Headers[category]);
                }
                List <KeyDataPair> sortedDataList = (List <KeyDataPair>)SortedFieldData[Headers[category]];

                int    index    = -1;
                double minValue = -1;
                double maxValue = -1;

                for (int i = 0; i < sortedDataList.Count; i++)
                {
                    if (sortedDataList[i].Key == country)
                    {
                        index = i;
                    }

                    if (minValue == -1 || sortedDataList[i].Data < minValue)
                    {
                        minValue = sortedDataList[i].Data;
                    }
                    if (maxValue == -1 || sortedDataList[i].Data > maxValue)
                    {
                        maxValue = sortedDataList[i].Data;
                    }
                }

                for (int i = 0; i < m_wavingFlagsList.ChildObjects.Count; i++)
                {
                    if (m_wavingFlagsList.ChildObjects[i] is WavingFlagLayer)
                    {
                        WavingFlagLayer wavingFlag = (WavingFlagLayer)m_wavingFlagsList.ChildObjects[i];
                        wavingFlag.Bar3D.UseScaling    = true;
                        wavingFlag.Bar3D.ScalarMinimum = minValue;
                        wavingFlag.Bar3D.ScalarMaximum = maxValue;
                        bool foundScalar = false;

                        for (int j = 0; j < sortedDataList.Count; j++)
                        {
                            if (sortedDataList[j].Key == wavingFlag.Name)
                            {
                                wavingFlag.Bar3D.ScalarValue = sortedDataList[j].Data;
                                foundScalar = true;
                                break;
                            }
                        }
                        if (!foundScalar)
                        {
                            wavingFlag.Bar3D.IsOn = false;
                        }
                        else
                        {
                            wavingFlag.Bar3D.IsOn = true;
                        }
                    }
                }

                m_currentBodyText.Text = "";
                int startIndex = index - (index % 2 == 0 ? 5 : 4);

                if (startIndex > sortedDataList.Count - 10)
                {
                    startIndex = sortedDataList.Count - 10;
                }

                int counter = 0;
                while (counter < 10)
                {
                    if (startIndex < 0)
                    {
                        startIndex++;
                        continue;
                    }

                    m_scrollbars[counter].Visible = true;
                    m_scrollbars[counter].Minimum = minValue;
                    m_scrollbars[counter].Maximum = maxValue;
                    m_scrollbars[counter].Value   = sortedDataList[startIndex].Data;

                    m_listLabels[counter].Visible = true;
                    m_listLabels[counter].Text    = string.Format("{0}.   {1}\n", startIndex + 1, sortedDataList[startIndex].Key);
                    counter++;
                    startIndex++;
                }
            }
            else
            {
                for (int i = 0; i < m_scrollbars.Length; i++)
                {
                    m_scrollbars[i].Visible = false;
                }

                for (int i = 0; i < m_listLabels.Length; i++)
                {
                    m_listLabels[i].Visible = false;
                }

                for (int i = 0; i < m_wavingFlagsList.ChildObjects.Count; i++)
                {
                    if (m_wavingFlagsList.ChildObjects[i] is WavingFlagLayer)
                    {
                        WavingFlagLayer wavingFlag = (WavingFlagLayer)m_wavingFlagsList.ChildObjects[i];
                        wavingFlag.Bar3D.IsOn = false;
                    }
                }
                m_currentBodyText.Text = (string)value;
            }
        }
Exemplo n.º 5
0
        void flag_OnMouseLeaveEvent(object sender, EventArgs e)
        {
            WavingFlagLayer wavingFlag = (WavingFlagLayer)sender;

            wavingFlag.ShowHighlight = false;
        }