Exemplo n.º 1
0
		public void LinkTest ()
		{
			SWF.DataGridViewLinkColumn column = new SWF.DataGridViewLinkColumn ();
			column.HeaderText = "Link Column";
			
			SWF.DataGridViewLinkCell cell = new SWF.DataGridViewLinkCell ();
			cell.Value = "Link cell 1";

			SWF.DataGridViewLinkCell cell1 = new SWF.DataGridViewLinkCell ();
			cell1.Value = "Link cell 2";
			
			ColumnCellTest (column, cell, false, cell1);
		}
Exemplo n.º 2
0
        public void LinkTest()
        {
            SWF.DataGridViewLinkColumn column = new SWF.DataGridViewLinkColumn();
            column.HeaderText = "Link Column";

            SWF.DataGridViewLinkCell cell = new SWF.DataGridViewLinkCell();
            cell.Value = "Link cell 1";

            SWF.DataGridViewLinkCell cell1 = new SWF.DataGridViewLinkCell();
            cell1.Value = "Link cell 2";

            ColumnCellTest(column, cell, false, cell1);
        }
Exemplo n.º 3
0
		public void Defaults ()
		{
			DataGridViewLinkCell cell = new DataGridViewLinkCell ();

			Assert.AreEqual (Color.Red, cell.ActiveLinkColor, "A1");
			Assert.AreEqual (LinkBehavior.SystemDefault, cell.LinkBehavior, "A2");
			Assert.AreEqual (Color.FromArgb (0, 0, 255), cell.LinkColor, "A3");
			Assert.AreEqual (false, cell.LinkVisited, "A4");
			Assert.AreEqual (true, cell.TrackVisitedState, "A5");
			Assert.AreEqual (false, cell.UseColumnTextForLinkValue, "A6");
			Assert.AreEqual (Color.FromArgb (128, 0, 128), cell.VisitedLinkColor, "A7");
			
			Assert.AreEqual ("DataGridViewLinkCell { ColumnIndex=-1, RowIndex=-1 }", cell.ToString (), "A8");
		}
 public override object Clone()
 {
     DataGridViewLinkCell cell;
     System.Type type = base.GetType();
     if (type == cellType)
     {
         cell = new DataGridViewLinkCell();
     }
     else
     {
         cell = (DataGridViewLinkCell) Activator.CreateInstance(type);
     }
     base.CloneInternal(cell);
     if (base.Properties.ContainsObject(PropLinkCellActiveLinkColor))
     {
         cell.ActiveLinkColorInternal = this.ActiveLinkColor;
     }
     if (base.Properties.ContainsInteger(PropLinkCellUseColumnTextForLinkValue))
     {
         cell.UseColumnTextForLinkValueInternal = this.UseColumnTextForLinkValue;
     }
     if (base.Properties.ContainsInteger(PropLinkCellLinkBehavior))
     {
         cell.LinkBehaviorInternal = this.LinkBehavior;
     }
     if (base.Properties.ContainsObject(PropLinkCellLinkColor))
     {
         cell.LinkColorInternal = this.LinkColor;
     }
     if (base.Properties.ContainsInteger(PropLinkCellTrackVisitedState))
     {
         cell.TrackVisitedStateInternal = this.TrackVisitedState;
     }
     if (base.Properties.ContainsObject(PropLinkCellVisitedLinkColor))
     {
         cell.VisitedLinkColorInternal = this.VisitedLinkColor;
     }
     if (this.linkVisitedSet)
     {
         cell.LinkVisited = this.LinkVisited;
     }
     return cell;
 }
Exemplo n.º 5
0
      private DataGridViewRow _buildReferenceRow(BplReferenceValue data) {
         string label = null;
         if (data.Direction == LogicalDirection.Forward) {
            label = "{0} \u2192 {1}".Substitute(data.Property, data.Path);
         } else {
            label = "{0} \u2192 {1}".Substitute(data.Path, data.Property);
         }
         var cell0 = new DataGridViewTextBoxCell { Value = data.Kind.ToString().At(0) };
         var cell1 = new DataGridViewLinkCell { 
            Value = label, 
            Tag = data.Path,
            LinkBehavior = LinkBehavior.HoverUnderline,
            LinkColor = _linkColor,
            ActiveLinkColor = _activeLinkColor,
            VisitedLinkColor = _visitedLinkColor
         };
         if (data.Path.IsEmpty()) {
            cell1.LinkBehavior = LinkBehavior.NeverUnderline;
         }

         var row = new DataGridViewRow { Height = 18, Resizable = DataGridViewTriState.False};
         row.Cells.Add(cell0);
         row.Cells.Add(cell1);
         return row;
      }
Exemplo n.º 6
0
        private DataGridViewRow NewUpdateRow(Alert alert)
        {
            DataGridViewImageCell expanderCell = new DataGridViewImageCell();
            DataGridViewTextBoxCell messageCell = new DataGridViewTextBoxCell();
            DataGridViewTextBoxCell appliesToCell = new DataGridViewTextBoxCell();
            DataGridViewTextBoxCell dateCell = new DataGridViewTextBoxCell();
            DataGridViewLinkCell webPageCell = new DataGridViewLinkCell();

            DataGridViewRow newRow = new DataGridViewRow();
            newRow.Tag = alert;

            // Set the detail cell content and expanding arrow
            if (expandedState.ContainsKey(alert.uuid))
            {
                // show the expanded arrow and the body detail
                expanderCell.Value = Properties.Resources.expanded_triangle;
                messageCell.Value = String.Format("{0}\n\n{1}", alert.Title, alert.Description);
            }
            else
            {
                // show the expand arrow and just the title
                expanderCell.Value = Properties.Resources.contracted_triangle;
                messageCell.Value = alert.Title;
            }

            dateCell.Value = HelpersGUI.DateTimeToString(alert.Timestamp.ToLocalTime(), Messages.DATEFORMAT_DMY, true);
            webPageCell.Value = alert.WebPageLabel;
            appliesToCell.Value = alert.AppliesTo;

            newRow.Cells.AddRange(expanderCell, messageCell, appliesToCell, dateCell, webPageCell);
            return newRow;
        }
Exemplo n.º 7
0
        public IEnumerable<DataGridViewRow> ConstructModList(IEnumerable<GUIMod> modules)
        {
            full_list_of_mod_rows = new List<DataGridViewRow>();
            foreach (var mod in modules)
            {
                var item = new DataGridViewRow {Tag = mod};

                var installed_cell = mod.IsInstallable()
                    ? (DataGridViewCell) new DataGridViewCheckBoxCell()
                    : new DataGridViewTextBoxCell();

                installed_cell.Value = mod.IsInstallable()
                    ? (object) mod.IsInstalled
                    : (mod.IsAutodetected ? "AD" : "-");

                var update_cell = mod.HasUpdate && !mod.IsAutodetected
                    ? new DataGridViewCheckBoxCell()
                    : (DataGridViewCell) new DataGridViewTextBoxCell();

                update_cell.Value = !mod.IsInstallable() || !mod.HasUpdate
                    ? "-"
                    : (object) false;

                var name_cell = new DataGridViewTextBoxCell {Value = mod.Name};
                var author_cell = new DataGridViewTextBoxCell {Value = mod.Authors};
                var installed_version_cell = new DataGridViewTextBoxCell {Value = mod.InstalledVersion};
                var latest_version_cell = new DataGridViewTextBoxCell {Value = mod.LatestVersion};
                var description_cell = new DataGridViewTextBoxCell {Value = mod.Abstract};
                var homepage_cell = new DataGridViewLinkCell {Value = mod.Homepage};

                item.Cells.AddRange(installed_cell, update_cell,
                    name_cell, author_cell,
                    installed_version_cell, latest_version_cell,
                    description_cell, homepage_cell);

                installed_cell.ReadOnly = !mod.IsInstallable();
                update_cell.ReadOnly = !mod.IsInstallable() || !mod.HasUpdate;

                full_list_of_mod_rows.Add(item);
            }
            return full_list_of_mod_rows;
        }
Exemplo n.º 8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            /****************Code to select all check boxes*************/
            /************Uncomment durng live**/
            for (int i = 0; i < chkstorelist.Items.Count; i++)
            {
                chkstorelist.SetItemChecked(i, true);
            }
            /********************End*************************************/
            /***************Grid view************************************/
            totalrecord.Visible = false;
            _lblerror.Visible = false;
            _percent.Visible = false;
            DataGridViewColumn _Columns = new DataGridViewColumn();
            _Columns.Name = "RowID";
            _Columns.HeaderText = "RowID";
            _Columns.DataPropertyName = "RowID";
            _Columns.ValueType = Type.GetType("System.float");
            _Columns.SortMode = DataGridViewColumnSortMode.Automatic;
            DataGridViewCell cell = new DataGridViewLinkCell();

            _Columns.CellTemplate = cell;
            dataGridView1.Columns.Add(_Columns);
            dataGridView1.Columns.Add("SKU", "SKU");
            dataGridView1.Columns.Add("Product Name", "Product Name");
            dataGridView1.Columns.Add("Product Description", "Product Description");
            dataGridView1.Columns.Add("Bullet Points", "Bullet Points");
            dataGridView1.Columns.Add("Manufacturer", "Manufacturer");
            dataGridView1.Columns.Add("Brand Name", "Brand Name");
            dataGridView1.Columns.Add("Price", "Price");
            dataGridView1.Columns.Add("Currency", "Currency");
            dataGridView1.Columns.Add("In Stock", "In Stock");
            dataGridView1.Columns.Add("Image URL", "Image URL");
            dataGridView1.Columns.Add("URL", "URL");

            /****************BackGround worker *************************/
        }
Exemplo n.º 9
0
        private void ServiceListGamesCompleted( object sender, ListGamesCompletedEventArgs e )
        {
            if( e != null )
            {
                if( ( e.Error != null ) ||
                    ( e.Result == null ) )
                {
                    MessageBox.Show( this, "Unable to contact the service. Please try again later.", "PSP Player" );
                    return;
                }
                _gameList = e.Result;
            }
            Game[] games = _gameList;

            this.titleView.Rows.Clear();

            foreach( Game game in games )
            {
                DataGridViewRow row = new DataGridViewRow();
                row.Tag = game;

                {
                    DataGridViewLinkCell cell = new DataGridViewLinkCell();
                    cell.Value = game.Title;
                    row.Cells.Add( cell );
                }
                {
                    DataGridViewLinkCell cell = new DataGridViewLinkCell();
                    if( game.Website != null )
                    {
                        cell.Value = "Visit Website";
                    }
                    else
                    {
                    }
                    row.Cells.Add( cell );
                }
                {
                    DataGridViewImageCell cell = new DataGridViewImageCell();
                    cell.Value = _googleIcon;
                    row.Cells.Add( cell );
                }

                this.titleView.Rows.Add( row );
            }

            this.titleView.Sort( this.TitleColumn, ListSortDirection.Ascending );

            _outstandingRefresh = false;
        }
Exemplo n.º 10
0
        private void RunSearch()
        {
            DB.SitesRow currentSite = data.Sites.FindBySiteID(int.Parse(ddlSites.SelectedValue.ToString()));

            if (currentSite != null)
            {
                resultsDataGridView.Columns.Clear();

                resultsTable.Clear();
                resultsTable.Columns.Clear();

                resultsTable.Columns.Add("resultsID", typeof(Int32));

                resultsTable.Columns["resultsID"].AutoIncrement = true;
                resultsTable.Columns["resultsID"].AutoIncrementSeed = 0;
                resultsTable.Columns["resultsID"].AutoIncrementStep = 1;

                DB.ResultSetsRow currentResultSet = data.ResultSets.NewResultSetsRow();
                currentResultSet.SearchID = int.Parse(ddlSearches.SelectedValue.ToString());
                currentResultSet.StartTime = DateTime.Now;
                data.ResultSets.AddResultSetsRow(currentResultSet);

                //TODO: Allow the user to change the expiration.
                //These Results expire 7 days from now
                currentResultSet.Expiration = new TimeSpan(7, 0, 0, 0);

                //Get current site's params.
                DB.SearchParamsRow[] parameters = (DB.SearchParamsRow[])(data.SearchParams.Select("SearchID = " + currentResultSet.SearchID));

                //Build the initial search URL
                string searchURL = currentSite.baseURL;

                if (!searchURL.EndsWith(currentSite.FirstSeparator))
                {
                    searchURL += currentSite.FirstSeparator;
                }

                foreach (DB.SearchParamsRow row in parameters)
                {
                    if (parameters.First().SearchID == row.SearchID && parameters.First().ParamID == row.ParamID) searchURL += String.Format(data.Parameters.FindByParamID(row.ParamID).FormatString, row.Value);
                    else searchURL += (currentSite.ParamSeparator + String.Format(data.Parameters.FindByParamID(row.ParamID).FormatString, row.Value));
                }

                //Make a request to the website without anything else in the URL to extablish cookies.
                HtmlAgilityPack.HtmlDocument document = GetHTML(currentSite.baseURL.Substring(0, currentSite.baseURL.IndexOf('/', 8)));

                //Retrieve the first page
                document = GetHTML(searchURL);

                if (document == null) return;

                //Check to see if we want to save the search HTML to a file.
                DB.SearchesRow currentSearch = data.Searches.FindBySearchID(currentResultSet.SearchID);
                if (currentSearch != null && currentSearch.SaveHTMLtoFile) document.Save(currentSite.Name + " - " + ddlSearches.SelectedText + DateTime.Now.ToString(" ddmmyyyy-hhmm") + ".html");

                /*
                 * Process all the pages!
                 */

                //find link for next page
                //find the max number of pages
                //loop through each page
                    //Process first page
                    //Update search URL or cookie to get next page
                    //Update Progress bar?

                DB.SitePagesDetailsRow paging = data.SitePagesDetails.FindBySiteID(currentSite.SiteID);

                string maxPagesSearch = "";
                int numPages = -1;

                string nextPageSearch = "";

                if (paging != null)
                {
                    if (paging.NextPageExact) nextPageSearch = "//*[@" + paging.NextPageAttribute + "='" + paging.NextPageValue + "']";
                    else nextPageSearch = "//*[contains(@" + paging.NextPageAttribute + ", '" + paging.NextPageValue + "')]";

                    if (paging.MaxPagesExact) maxPagesSearch = "//*[@" + paging.MaxPagesAttribute + "='" + paging.MaxPagesValue + "']";
                    else maxPagesSearch = "//*[contains(@" + paging.MaxPagesAttribute + ", '" + paging.MaxPagesValue + "')]";
                }

                HtmlNode foundMaxPages = null;
                if (maxPagesSearch != "") foundMaxPages= document.DocumentNode.SelectSingleNode(maxPagesSearch);

                if (foundMaxPages != null)
                {
                    if (paging.MaxPagesProp != null && foundMaxPages.Attributes.Contains(paging.MaxPagesProp))
                    {
                        if (!int.TryParse(foundMaxPages.Attributes[paging.MaxPagesProp].Value.Trim(), out numPages)) MessageBox.Show("Couldn't find the max number of pages");
                    }
                    else
                    {
                        if (!int.TryParse(foundMaxPages.InnerText.Trim(), out numPages)) MessageBox.Show("Couldn't find the max number of pages");
                    }
                }
                else numPages = 1;

                int rowNum = 0;

                for (int currentPage = 1; currentPage <= numPages; currentPage++)
                {

                    /*
                     *  Cycle through all the groups
                     */
                    DB.ResultFieldGroupsRow[] groups = (DB.ResultFieldGroupsRow[])data.ResultFieldGroups.Select("SiteID = " + currentSite.SiteID);
                    if (groups != null)
                    {
                        foreach (DB.ResultFieldGroupsRow group in groups)
                        {//In those Groups, cycle through all the results found on the page

                            string groupSearch = "";

                            if (group.ExactMatch) groupSearch = "//*[@" + group.Attribute + "='" + group.Value + "']";
                            else groupSearch = "//*[contains(@" + group.Attribute + ", '" + group.Value + "')]";

                            HtmlNodeCollection foundGroups;
                            if (groupSearch != "") foundGroups = document.DocumentNode.SelectNodes(groupSearch);
                            else
                            {
                                MessageBox.Show("Couldn't generate a group search string");
                                return;
                            }

                            if (foundGroups != null)
                            {
                                DB.ResultFieldsRow[] fields = (DB.ResultFieldsRow[])data.ResultFields.Select("RFG_ID = " + group.RFG_ID);

                                if (fields != null)
                                {
                                    //Prep-populate resultsTable with all the fields (columns)
                                    foreach (DB.ResultFieldsRow field in fields)
                                    {

                                        switch (data.ResultFieldType.FindByRFT_ID(field.RFT_ID).Type)
                                        {
                                            case "Link":
                                                if (!resultsTable.Columns.Contains(field.Name)) resultsTable.Columns.Add(field.Name, typeof(string));
                                                DataGridViewLinkColumn link = new DataGridViewLinkColumn();
                                                link.Name = field.Name;
                                                //link.Text = field.Name;
                                                link.DataPropertyName = field.Name;
                                                //link.UseColumnTextForLinkValue = true;
                                                if (!resultsDataGridView.Columns.Contains(field.Name)) resultsDataGridView.Columns.Add(link);
                                                break;
                                            case "Picture":
                                                if (!resultsTable.Columns.Contains(field.Name)) resultsTable.Columns.Add(field.Name, typeof(Bitmap));
                                                DataGridViewImageColumn pic = new DataGridViewImageColumn(false);
                                                pic.Name = field.Name;
                                                if (!resultsDataGridView.Columns.Contains(field.Name)) resultsDataGridView.Columns.Add(pic);
                                                break;
                                            default:
                                                if (!resultsTable.Columns.Contains(field.Name)) resultsTable.Columns.Add(field.Name, typeof(string));
                                                if (!resultsDataGridView.Columns.Contains(field.Name)) resultsDataGridView.Columns.Add(field.Name, field.Name);
                                                break;
                                        }

                                        resultsDataGridView.Columns[field.Name].DataPropertyName = field.Name;
                                        resultsDataGridView.Columns[field.Name].ToolTipText = field.Description;
                                    }

                                    foreach (HtmlNode node in foundGroups)
                                    {//For each of those results found on the page, search for all the fields

                                        DataRow displayResult = resultsTable.NewRow();
                                        resultsTable.Rows.Add(displayResult);

                                        foreach (DB.ResultFieldsRow field in fields)
                                        {//For each of those fields, cycle through all the found results.

                                            string fieldSearch = "";

                                            if (field.ExactMatch) fieldSearch = ".//*[@" + field.Attribute + "='" + field.Value + "']";
                                            else fieldSearch = ".//*[contains(@" + field.Attribute + ", '" + field.Value + "')]";

                                            HtmlNode foundField;
                                            if (fieldSearch != "") foundField = node.SelectSingleNode(fieldSearch);
                                            else
                                            {
                                                MessageBox.Show("Couldn't generate a field search string");
                                                return;
                                            }

                                            if (foundField != null)
                                            {
                                                //Only bother adding to the results table is the field was actually found (after the null-check)
                                                DB.ResultsRow foundResult = data.Results.NewResultsRow();
                                                foundResult.ResultSetID = currentResultSet.ResultSetID;
                                                foundResult.ResultFieldID = field.ResultFieldID;
                                                foundResult.RowNumber = rowNum;

                                                //Get the desired Xpath (sometimes the data is in a tag that isn't
                                                //uniquely serachable, hence the "foundField" and then a further XPath)
                                                HtmlNode foundNode = foundField.SelectSingleNode(field.XPath);

                                                //Verify the XPath found a node.
                                                if (foundNode != null)
                                                {
                                                    if (field.Property != null && foundNode.Attributes.Contains(field.Property)) foundResult.Value = foundNode.Attributes[field.Property].Value.Trim();
                                                    else foundResult.Value = foundNode.InnerText.Trim();

                                                    //Split Text if set
                                                    if (foundResult.Value != null && field.SplitRegex != null && field.SplitIndex >= 0)
                                                    {
                                                        string[] results = Regex.Split(foundResult.Value, field.SplitRegex);
                                                        if (results.Length >= field.SplitIndex - 1) foundResult.Value = results[field.SplitIndex].Trim();
                                                    }

                                                    //Replace Text if set
                                                    if (foundResult.Value != null && field.FindRegex != null && field.ReplaceRegex != null)
                                                    {
                                                        foundResult.Value = Regex.Replace(foundResult.Value, field.FindRegex, field.ReplaceRegex);
                                                    }

                                                    //foundResult.TimeStamp = DateTime.Now;
                                                    data.Results.AddResultsRow(foundResult);

                                                    //Added data to the main database, now to add it to the dataGridView table.
                                                    switch (data.ResultFieldType.FindByRFT_ID(field.RFT_ID).Type)
                                                    {
                                                        case "Link":
                                                            DataGridViewLinkCell linkcell = new DataGridViewLinkCell();
                                                            linkcell.Tag = foundResult.Value.ToString();
                                                            linkcell.UseColumnTextForLinkValue = true;
                                                            displayResult[field.Name] = foundResult.Value.ToString();
                                                            break;
                                                        case "Picture":
                                                            System.Drawing.Bitmap bmp = new Bitmap(1, 1);
                                                            try
                                                            {
                                                                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(foundResult.Value);
                                                                myRequest.Method = "GET";
                                                                HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                                                                bmp = new System.Drawing.Bitmap(myResponse.GetResponseStream());
                                                                myResponse.Close();

                                                                displayResult[field.Name] = bmp;
                                                            }
                                                            catch
                                                            {
                                                                bmp = Properties.Resources.Delete_d.ToBitmap();
                                                            }
                                                            finally
                                                            {
                                                                displayResult[field.Name]  = bmp;
                                                            }
                                                            break;
                                                        default:
                                                            //This should be "Text"
                                                            displayResult[field.Name] = foundResult.Value.ToString();
                                                            break;
                                                    }
                                                }
                                            }
                                        }
                                        rowNum++;
                                    }
                                }
                            }
                        }
                    }

                    //Processed one page, time to get the next one (if configured).
                    if (paging != null)
                    {
                        searchURL = "";

                        HtmlNode foundNextPage = document.DocumentNode.SelectSingleNode(nextPageSearch);
                        if (foundNextPage != null)
                        {
                            if (paging.NextPageProp != null && foundNextPage.Attributes.Contains(paging.NextPageProp)) searchURL = foundNextPage.Attributes[paging.NextPageProp].Value.Trim();
                            else searchURL = foundNextPage.InnerText.Trim();
                        }

                        //Split Text if set
                        if (paging.SplitRegex != null && paging.SplitIndex >= 0)
                        {
                            string[] results = Regex.Split(searchURL, paging.SplitRegex);
                            if (results.Length >= paging.SplitIndex - 1) searchURL = results[paging.SplitIndex].Trim();
                        }

                        //Replace Text if set
                        if (paging.FindRegex != null && paging.ReplaceRegex != null) searchURL = Regex.Replace(searchURL, paging.FindRegex, paging.ReplaceRegex);

                        if (searchURL != "")
                        {
                            document = GetHTML(searchURL);
                            if (document == null) return;
                        }
                    }
                }

                currentResultSet.EndTime = DateTime.Now;
            }

            resultsBindingSource.DataSource = resultsTable;
        }
        public void prepareGrid4Feature(IFeature currentFeature)
        {
            if (m_inspector == null)
            {
                //this is the default inspector shipped with the editor
                m_inspector = new FeatureInspector();

                SetParent(dataGridView1.Handle.ToInt32(), this.Handle.ToInt32());
            }

            DataGridView featureGridView = this.dataGridView1;

            string featureString = String.Empty;

            //let's get the first domain entry and use it as the main feature theme

            for (int fieldIndex = 0; fieldIndex < currentFeature.Fields.FieldCount; fieldIndex++)
            {
                if (String.IsNullOrEmpty(featureString))
                {
                    if (currentFeature.Fields.get_Field(fieldIndex).Type == esriFieldType.esriFieldTypeString)
                    {
                        System.Object attributeValue = currentFeature.get_Value(fieldIndex);

                        if (attributeValue != System.DBNull.Value)
                        {
                            foreach (string lookingforDomain in m_domainDictionary.Keys)
                            {
                                if (currentFeature.Fields.get_Field(fieldIndex).Name == lookingforDomain)
                                {
                                    featureString = lookingforDomain + "=" + attributeValue.ToString();
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            ESRI.ArcGIS.OSM.OSMClassExtension.osmfeature currentFeatureType = null;

            if (m_editFeatures.Keys.Contains(featureString))
            {
                currentFeatureType = m_editFeatures[featureString];
            }


            // reset the feature grid
            featureGridView.Rows.Clear();


            // rehydrate the tag from the container field
            Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tag> tagList = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tag>();
            ESRI.ArcGIS.OSM.OSMClassExtension.tag[] storedTags = null;

            Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey> localTags = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey>();

            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagkey tagKeyItem in m_editTags.Values)
            {
                localTags.Add(tagKeyItem.name, tagKeyItem);
            }

            int tagCollectionFieldIndex = currentFeature.Fields.FindField("osmTags");

            storedTags = _osmUtility.retrieveOSMTags((IRow)currentFeature, tagCollectionFieldIndex, m_editor.EditWorkspace);

            if (storedTags != null)
            {
                foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tag currenttag in storedTags)
                {
                    tagList.Add(currenttag.k, currenttag);
                }
            }

            // if we have a known entity of tag - OSM map feature that is
            if (currentFeatureType != null)
            {
                DataGridViewRow currentRow = new DataGridViewRow();

                // the feature itself is the main osm key value pair
                string[] osmkeyvalue = null;

                try
                {
                    osmkeyvalue = currentFeatureType.name.Split("=".ToCharArray());
                }
                catch { }


                if (osmkeyvalue != null && osmkeyvalue.Length > 1)
                {
                    // name of the tag - tag type
                    DataGridViewCell currentTagCell = new DataGridViewTextBoxCell();
                    currentTagCell.Value = osmkeyvalue[0];

                    // for localization include the translated language into a tooltip
                    if (m_editTags.ContainsKey(osmkeyvalue[0]))
                    {
                        if (!String.IsNullOrEmpty(m_editTags[osmkeyvalue[0]].displayname))
                        {
                            currentTagCell.ToolTipText = m_editTags[osmkeyvalue[0]].displayname;
                        }
                    }

                    currentRow.Cells.Insert(0, currentTagCell);
                    currentRow.Cells[0].ReadOnly = true;

                    // value of the tag
                    DataGridViewCell currentValueCell = null;
                    currentValueCell = new DataGridViewComboBoxCell();
                    foreach (var domainvalue in m_domainDictionary[osmkeyvalue[0]].domainvalue)
                    {
                        if (IsGeometryTypeEqual(currentFeature.Shape.GeometryType, domainvalue.geometrytype))
                        {
                            ((DataGridViewComboBoxCell)currentValueCell).Items.Add(domainvalue.value);
                        }
                    }
                    currentValueCell.Value = osmkeyvalue[1];

                    // for localization include the translated language into a tooltip
                    if (m_editTags.ContainsKey(osmkeyvalue[0]))
                    {
                        ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue[] possibleValues = m_editTags[osmkeyvalue[0]].tagvalue;

                        if (possibleValues != null)
                        {
                            for (int valueIndex = 0; valueIndex < possibleValues.Length; valueIndex++)
                            {
                                if (osmkeyvalue[1].Equals(possibleValues[valueIndex].name) == true)
                                {
                                    if (!String.IsNullOrEmpty(possibleValues[valueIndex].displayname))
                                    {
                                        currentValueCell.ToolTipText = possibleValues[valueIndex].displayname;
                                    }
                                }
                            }
                        }
                    }

                    currentRow.Cells.Insert(1, currentValueCell);
                    currentRow.Cells[1].ReadOnly = false;


                    DataGridViewLinkCell currentInfoCell = new DataGridViewLinkCell();
                    currentInfoCell.LinkBehavior = LinkBehavior.SystemDefault;
                    currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Tag:" + currentFeatureType.name));
                    currentRow.Cells.Insert(2, currentInfoCell);

                    featureGridView.Rows.Add(currentRow);

                    if (tagList.Keys.Contains(osmkeyvalue[0]))
                    {
                        tagList.Remove(osmkeyvalue[0]);
                    }

                    if (localTags.ContainsKey(osmkeyvalue[0]))
                    {
                        localTags.Remove(osmkeyvalue[0]);
                    }
                }

                if (currentFeatureType.tag != null)
                {
                    foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tag osmTagValuePair in currentFeatureType.tag)
                    {
                        try
                        {
                            currentRow = new DataGridViewRow();

                            // name of the tag - tag type
                            DataGridViewCell currentTagCell = new DataGridViewTextBoxCell();
                            currentTagCell.Value = osmTagValuePair.@ref;

                            // for localization include the translated language into a tooltip
                            if (m_editTags.ContainsKey(osmTagValuePair.@ref))
                            {
                                if (!String.IsNullOrEmpty(m_editTags[osmTagValuePair.@ref].displayname))
                                {
                                    currentTagCell.ToolTipText = m_editTags[osmTagValuePair.@ref].displayname;
                                }
                            }

                            currentRow.Cells.Insert(0, currentTagCell);

                            // the default case is not to allow the user change the key field
                            bool canEdit = false;

                            if (m_editTags.ContainsKey(osmTagValuePair.@ref))
                            {
                                if (m_editTags[osmTagValuePair.@ref].editableSpecified)
                                {
                                    canEdit = m_editTags[osmTagValuePair.@ref].editable;
                                }
                            }

                            currentRow.Cells[0].ReadOnly = !canEdit;

                            // value of the tag
                            // depending on the tag type we'll need to create a different cell type
                            DataGridViewCell currentValueCell = null;

                            if (m_editTags.ContainsKey(osmTagValuePair.@ref))
                            {
                                switch (m_editTags[osmTagValuePair.@ref].tagtype)
                                {
                                    case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_list:
                                        currentValueCell = new DataGridViewComboBoxCell();
                                        try
                                        {
                                            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue value in m_editTags[osmTagValuePair.@ref].tagvalue)
                                            {
                                                ((DataGridViewComboBoxCell)currentValueCell).Items.Add(value.name);
                                            }
                                        }

                                        catch (Exception ex)
                                        {
                                            System.Diagnostics.Debug.WriteLine(ex.Message);
                                        }
                                        break;
                                    case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_integer:
                                        currentValueCell = new DataGridViewTextBoxCell();
                                        break;
                                    case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_double:
                                        currentValueCell = new DataGridViewTextBoxCell();
                                        break;
                                    case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_string:
                                        currentValueCell = new DataGridViewTextBoxCell();
                                        break;
                                    default:
                                        currentValueCell = new DataGridViewTextBoxCell();
                                        break;
                                }
                            }
                            else
                            { // unkown keys are treated as strings
                                currentValueCell = new DataGridViewTextBoxCell();
                            }

                            if (tagList.Keys.Contains(osmTagValuePair.@ref))
                            {
                                currentValueCell.Value = tagList[osmTagValuePair.@ref].v;
                            }
                            else
                            {
                                if (osmTagValuePair.value != null)
                                {
                                    currentValueCell.Value = osmTagValuePair.value;
                                }
                            }

                            // for localization include the translated language into a tooltip
                            if (m_editTags.ContainsKey((string)currentTagCell.Value))
                            {
                                if (!String.IsNullOrEmpty((string)currentValueCell.Value))
                                {
                                    ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue[] possibleValues = m_editTags[(string)currentTagCell.Value].tagvalue;

                                    if (possibleValues != null)
                                    {
                                        for (int valueIndex = 0; valueIndex < possibleValues.Length; valueIndex++)
                                        {
                                            if (currentValueCell.Value.Equals(possibleValues[valueIndex].name) == true)
                                            {
                                                if (!String.IsNullOrEmpty(possibleValues[valueIndex].displayname))
                                                {
                                                    currentValueCell.ToolTipText = possibleValues[valueIndex].displayname;
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            currentRow.Cells.Insert(1, currentValueCell);

                            // the assumption here is that values are usually open to user edits
                            canEdit = true;
                            currentRow.Cells[1].ReadOnly = !canEdit;

                            DataGridViewLinkCell currentInfoCell = new DataGridViewLinkCell();
                            currentInfoCell.LinkBehavior = LinkBehavior.SystemDefault;

                            if (m_editTags.ContainsKey(osmTagValuePair.@ref))
                            {
                                if (String.IsNullOrEmpty(m_editTags[osmTagValuePair.@ref].infoURL))
                                {
                                    currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + osmTagValuePair.@ref));
                                }
                                else
                                {
                                    currentInfoCell.Value = new Uri(m_editTags[osmTagValuePair.@ref].infoURL);
                                }
                                currentRow.Cells.Insert(2, currentInfoCell);
                            }
                            else
                            {
                                currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + osmTagValuePair.@ref));
                            }

                            featureGridView.Rows.Add(currentRow);

                            tagList.Remove(osmTagValuePair.@ref);

                            if (localTags.ContainsKey(osmTagValuePair.@ref))
                            {
                                localTags.Remove(osmTagValuePair.@ref);
                            }
                        }
                        catch { }
                    }
                }
            }


            // for all the remaining tags of whatever is passed into this function - known or unkown
            // list the remaining tag key/value pairs
            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tag currentTag in tagList.Values)
            {
                DataGridViewRow currentRow = new DataGridViewRow();

                DataGridViewCell currentTagCell = new DataGridViewTextBoxCell();
                currentTagCell.Value = currentTag.k;


                // for localization include the translated language into a tooltip
                if (m_editTags.ContainsKey(currentTag.k))
                {
                    if (!String.IsNullOrEmpty(m_editTags[currentTag.k].displayname))
                    {
                        currentTagCell.ToolTipText = m_editTags[currentTag.k].displayname;
                    }
                }


                currentRow.Cells.Insert(0, currentTagCell);

                DataGridViewCell currentValueCell = null;
                if (m_editTags.ContainsKey(currentTag.k))
                {
                    switch (m_editTags[currentTag.k].tagtype)
                    {
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_list:
                            currentValueCell = new DataGridViewComboBoxCell();
                            try
                            {
                                foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue value in m_editTags[currentTag.k].tagvalue)
                                {
                                    ((DataGridViewComboBoxCell)currentValueCell).Items.Add(value.name);
                                }

                                currentValueCell.Value = currentTag.v;
                            }
                            catch (Exception ex)
                            {
                                System.Diagnostics.Debug.WriteLine(ex.Message);
                            }
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_integer:
                            currentValueCell = new DataGridViewTextBoxCell();
                            currentValueCell.Value = Convert.ToInt32(currentTag.v);
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_double:
                            currentValueCell = new DataGridViewTextBoxCell();
                            currentValueCell.Value = Convert.ToDouble(currentTag.v);
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_string:
                            currentValueCell = new DataGridViewTextBoxCell();
                            currentValueCell.Value = Convert.ToString(currentTag.v);
                            break;
                        default:
                            currentValueCell = new DataGridViewTextBoxCell();
                            break;
                    }
                }
                else
                {
                    currentValueCell = new DataGridViewTextBoxCell();
                    currentValueCell.Value = Convert.ToString(currentTag.v);
                }

                try
                {
                    // for localization include the translated language into a tooltip
                    if (m_editTags.ContainsKey(currentTag.k))
                    {
                        if (!String.IsNullOrEmpty(Convert.ToString(currentValueCell.Value)))
                        {
                            ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue[] possibleValues = m_editTags[currentTag.k].tagvalue;

                            if (possibleValues != null)
                            {
                                for (int valueIndex = 0; valueIndex < possibleValues.Length; valueIndex++)
                                {
                                    if (currentTag.v.Equals(possibleValues[valueIndex].name) == true)
                                    {
                                        if (!String.IsNullOrEmpty(possibleValues[valueIndex].displayname))
                                        {
                                            currentValueCell.ToolTipText = possibleValues[valueIndex].displayname;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch { }

                currentRow.Cells.Insert(1, currentValueCell);

                DataGridViewLinkCell currentInfoCell = new DataGridViewLinkCell();
                currentInfoCell.LinkBehavior = LinkBehavior.SystemDefault;

                if (m_editTags.ContainsKey(currentTag.k))
                {
                    if (String.IsNullOrEmpty(m_editTags[currentTag.k].infoURL))
                    {
                        currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + currentTag.k));
                    }
                    else
                    {
                        currentInfoCell.Value = new Uri(m_editTags[currentTag.k].infoURL);
                    }
                    currentRow.Cells.Insert(2, currentInfoCell);
                }
                else
                {
                    currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + currentTag.k));
                }

                featureGridView.Rows.Add(currentRow);

                if (localTags.ContainsKey(currentTag.k))
                {
                    localTags.Remove(currentTag.k);
                }
            }

            // add the list of remaning known tags in the first column of the last row in ascending order
            DataGridViewRow lastRow = new DataGridViewRow();
            DataGridViewComboBoxCell currentKeyCell = new DataGridViewComboBoxCell();
            try
            {
                // show a sorted list of tags to the user
                IEnumerable<string> sortedKeys = localTags.Keys.OrderBy(myKey => myKey);

                foreach (string currentKey in sortedKeys)
                {
                    currentKeyCell.Items.Add(currentKey);
                }

            }
            catch { }

            lastRow.Cells.Insert(0, currentKeyCell);

            featureGridView.Rows.Add(lastRow);

        }
Exemplo n.º 12
0
        private DataGridViewRow NewUpdateRow(Alert alert)
        {
            DataGridViewTextBoxCell nameCell = new DataGridViewTextBoxCell();
            DataGridViewTextBoxCell detailsCell = new DataGridViewTextBoxCell();
            DataGridViewTextBoxCell dateCell = new DataGridViewTextBoxCell();
            DataGridViewLinkCell webPageCell = new DataGridViewLinkCell();
            DataGridViewTextBoxCell appliesToCell = new DataGridViewTextBoxCell();

            DataGridViewRow newRow = new DataGridViewRow();
            newRow.Tag = alert;

            nameCell.Value = GetName(alert);
            detailsCell.Value = GetDetails(alert);
            dateCell.Value = HelpersGUI.DateTimeToString(alert.Timestamp.ToLocalTime(), Messages.DATEFORMAT_DMY, true);
            webPageCell.Value = GetWebPageLabel(alert);
            appliesToCell.Value = alert.AppliesTo;

            newRow.Cells.Add(nameCell);
            newRow.Cells.Add(detailsCell);
            newRow.Cells.Add(dateCell);
            newRow.Cells.Add(webPageCell);
            newRow.Cells.Add(appliesToCell);

            return newRow;
        }
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            string cellValueString = String.Empty;

            if (e.ColumnIndex == -1 || e.RowIndex == -1)
            {
                return;
            }


            try
            {
                // handle the event when the value in the first column changed
                // -- if an existing tag key was selected populate the 2nd column and the info 3rd column
                // -- add a new last row with the remaining tag key entries
                if (e.ColumnIndex == 0)
                {
                    Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey> localTags = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey>();
                    foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagkey tagKey in m_editTags.Values)
                    {
                        localTags.Add(tagKey.name, tagKey);
                    }

                    string keyValue = string.Empty;
                    // remove the once already used
                    for (int rowIndex = 0; rowIndex < dataGridView1.Rows.Count; rowIndex++)
                    {
                        keyValue = dataGridView1[0, rowIndex].Value as string;
                        if (!String.IsNullOrEmpty(keyValue))
                        {
                            if (localTags.ContainsKey(keyValue))
                            {
                                localTags.Remove(keyValue);
                            }
                        }
                    }


                    keyValue = dataGridView1[e.ColumnIndex, e.RowIndex].Value as string;
                    int deletedRow = -1;

                    // if the 
                    if (string.IsNullOrEmpty(keyValue))
                    {
                        if (!string.IsNullOrEmpty(m_ChangeTagString))
                        {
                            keyValue = m_ChangeTagString;
                            m_ChangeTagString = string.Empty;
                        }
                    }
                    else
                    {
                        try
                        {
                            deletedRow = e.RowIndex;
                            dataGridView1.Rows.RemoveAt(e.RowIndex);
                        }
                        catch
                        {

                        }
                    }

                    if (!string.IsNullOrEmpty(keyValue))
                    {
                        DataGridViewRow newRow = new DataGridViewRow();

                        // name of the tag - tag type
                        DataGridViewCell currentTagCell = new DataGridViewTextBoxCell();
                        currentTagCell.Value = keyValue;

                        // for localization include the translated language into a tooltip
                        if (m_editTags.ContainsKey(keyValue))
                        {
                            if (!String.IsNullOrEmpty(m_editTags[keyValue].displayname))
                            {
                                currentTagCell.ToolTipText = m_editTags[keyValue].displayname;
                            }
                        }

                        newRow.Cells.Insert(0, currentTagCell);

                        // the default case is not to allow the user change the key field
                        bool canEdit = false;

                        if (m_editTags.ContainsKey(keyValue))
                        {
                            if (m_editTags[keyValue].editableSpecified)
                            {
                                canEdit = m_editTags[keyValue].editable;
                            }
                        }

                        newRow.Cells[0].ReadOnly = !canEdit;


                        if (m_editTags.ContainsKey(keyValue))
                        {
                            DataGridViewCell currentValueCell = null;
                            switch (m_editTags[keyValue].tagtype)
                            {
                                case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_list:
                                    currentValueCell = new DataGridViewComboBoxCell();
                                    try
                                    {
                                        foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue value in m_editTags[keyValue].tagvalue)
                                        {
                                            ((DataGridViewComboBoxCell)currentValueCell).Items.Add(value.name);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        System.Diagnostics.Debug.WriteLine(ex.Message);
                                    }
                                    break;
                                case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_integer:
                                    currentValueCell = new DataGridViewTextBoxCell();
                                    break;
                                case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_double:
                                    currentValueCell = new DataGridViewTextBoxCell();
                                    break;
                                case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_string:
                                    currentValueCell = new DataGridViewTextBoxCell();
                                    break;
                                default:
                                    currentValueCell = new DataGridViewTextBoxCell();
                                    break;
                            }
                            try
                            {
                                newRow.Cells.Insert(1, currentValueCell);
                            }
                            catch
                            {

                            }

                            DataGridViewLinkCell currentInfoCell = new DataGridViewLinkCell();
                            currentInfoCell.LinkBehavior = LinkBehavior.SystemDefault;

                            if (m_editTags.ContainsKey(keyValue))
                            {
                                if (String.IsNullOrEmpty(m_editTags[keyValue].infoURL))
                                {
                                    currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + keyValue));
                                }
                                else
                                {
                                    currentInfoCell.Value = new Uri(m_editTags[keyValue].infoURL);
                                }
                            }
                            else
                            {
                                currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + keyValue));
                            }

                            try
                            {
                                newRow.Cells.Insert(2, currentInfoCell);
                            }
                            catch
                            {
                            }
                        }

                        dataGridView1.Rows.Add(newRow);

                        // add a new last row
                        DataGridViewRow lastRow = new DataGridViewRow();
                        DataGridViewComboBoxCell currentKeyCell = new DataGridViewComboBoxCell();
                        try
                        {
                            // show a sorted list of tags to the user
                            IEnumerable<string> sortedKeys = localTags.Keys.OrderBy(myKey => myKey);

                            foreach (string currentKey in sortedKeys)
                            {
                                currentKeyCell.Items.Add(currentKey);
                            }
                        }
                        catch { }

                        lastRow.Cells.Insert(0, currentKeyCell);

                        dataGridView1.Rows.Add(lastRow);

                        dataGridView1.FirstDisplayedScrollingRowIndex = e.RowIndex;
                        dataGridView1.Refresh();
                        dataGridView1.CurrentCell = dataGridView1.Rows[e.RowIndex].Cells[1];
                    }

                    return;
                }


                // ensure that we have values in the first and the second column before we commit an edit operation
                if (e.ColumnIndex == 0)
                {
                    cellValueString = dataGridView1[1, e.RowIndex].Value as string;
                }
                else if (e.ColumnIndex == 1)
                {
                    cellValueString = dataGridView1[0, e.RowIndex].Value as string;
                }

                if (String.IsNullOrEmpty(cellValueString))
                {
                    return;
                }

                if (m_editor == null)
                {
                    return;
                }

                if (((IWorkspaceEdit2)m_editor.EditWorkspace).IsInEditOperation)
                {
                }
                else
                //MessageBox.Show(resourceManager.GetString("OSMEditor_FeatureInspector_operationwarningcaption"), resourceManager.GetString("OSMClassExtension_FeatureInspector_operationwarningcaption"));
                {

                    m_editor.StartOperation();
                }

                ESRI.ArcGIS.OSM.OSMClassExtension.tag newTag = null;

                string tagString = dataGridView1[0, e.RowIndex].Value as string;
                string valueString = dataGridView1[1, e.RowIndex].Value as string;

                if (String.IsNullOrEmpty(tagString) || String.IsNullOrEmpty(valueString))
                {
                }
                else
                {
                    newTag = new ESRI.ArcGIS.OSM.OSMClassExtension.tag();
                    newTag.k = tagString;
                    newTag.v = valueString;
                }


                if (m_enumRow != null)
                {
                    m_enumRow.Reset();

                    // persist the collection in the blob/xml field
                    IFeature currentFeature = null;

                    while ((currentFeature = m_enumRow.Next() as IFeature) != null)
                    {
                        int tagCollectionFieldIndex = currentFeature.Fields.FindField("osmTags");

                        if (tagCollectionFieldIndex != -1)
                        {

                            ESRI.ArcGIS.OSM.OSMClassExtension.tag[] existingTags = _osmUtility.retrieveOSMTags((IRow)currentFeature, tagCollectionFieldIndex, m_editor.EditWorkspace);

                            if (existingTags != null)
                            {
                                // let's rebuild the tags from scratch based on the items that we found in the UI and the existing feature
                                Dictionary<string, string> existingTagsList = new Dictionary<string, string>();
                                for (int index = 0; index < existingTags.Length; index++)
                                {
                                    if (String.IsNullOrEmpty(existingTags[index].k) == false && String.IsNullOrEmpty(existingTags[index].v) == false)
                                    {
                                        existingTagsList.Add(existingTags[index].k, existingTags[index].v);
                                    }
                                }

                                if (newTag != null)
                                {
                                    if (existingTagsList.ContainsKey(newTag.k))
                                    {
                                        existingTagsList[newTag.k] = newTag.v;
                                    }
                                    else
                                    {
                                        if (!String.IsNullOrEmpty(newTag.v))
                                        {
                                            existingTagsList.Add(newTag.k, newTag.v);
                                        }
                                    }
                                }


                                int tagIndex = 0;

                                // convert the newly assembled tag list into a tag array that can be serialized into the osmtag field
                                existingTags = new ESRI.ArcGIS.OSM.OSMClassExtension.tag[existingTagsList.Count];
                                foreach (KeyValuePair<string, string> item in existingTagsList)
                                {
                                    if (!String.IsNullOrEmpty(item.Key) && !String.IsNullOrEmpty(item.Value))
                                    {
                                        ESRI.ArcGIS.OSM.OSMClassExtension.tag insertTag = new ESRI.ArcGIS.OSM.OSMClassExtension.tag();
                                        insertTag.k = item.Key;
                                        insertTag.v = item.Value;

                                        existingTags[tagIndex] = insertTag;
                                        tagIndex = tagIndex + 1;
                                    }
                                }

                                _osmUtility.insertOSMTags(tagCollectionFieldIndex, (IRow)currentFeature, existingTags, m_editor.EditWorkspace);

                                currentFeature.Store();
                            }
                        }
                    }
                }

                m_editor.StopOperation(resourceManager.GetString("OSMClassExtension_FeatureInspector_operationmenu"));

            }
            catch
            {
            }
        }
Exemplo n.º 14
0
        //
        // Get the list of recent workspaces
        //
        private void api_ws_btn_Click(object sender, EventArgs e)
        {
            this.tp_datagridview.Columns.Clear();
            this.tp_datagridview.Refresh();
            string error_msg = null;
            List<tpModels.Workspace> workspaces = null;

            showMessage("Connecting ...");

            //
            // Visit https://github.com/vispower/teamplatform-api for more options
            //
            // Following codes fetches recently updated active workspaces.
            // The number of workspaces retrieved at each call is 30
            //
            List<QueryParameter> options = new List<QueryParameter>();
            options.Add(new QueryParameter("status", "active"));
            options.Add(new QueryParameter("deleted", "false"));

            //
            // If you need to get next 30 more active workspaces,
            // use 'page' option ('page' is the shortform of the 'pagination')
            //
            // options.Add(new QueryParameter("page", "2"));
            // options.Add(new QueryParameter("page", "3"));
            //

            if (!_oauth.tpGetWorkspaces(options, out error_msg, out workspaces))
            {
                showMessage(error_msg);
                return;
            }
            showMessage(workspaces.Count.ToString() + " workspaces found.");

            //
            //Add workspaces data to the grid view
            //
            try
            {
                setupWSViewTable(this.tp_datagridview);
                foreach (tpModels.Workspace ws in workspaces)
                {
                    bool ws_deleted = !is_blank(ws.deleted_at);
                    string ws_content = truncate(ws.description, 100) + "\n"
                                    + "Comments:" + ws.comments_count
                                    + ", Files:" + ws.files_count
                                    + ", Pages:" + ws.pages_count
                                    + ", Tasks:" + ws.tasks_count
                                    + ", Members:" + ws.members_count;
                    string ws_state = ws.status + "  " + (ws_deleted ? "deleted" : "") + "\n"
                                    + convertDateTime(ws.updated_at) + "\n" + convertDateTime(ws.created_at);
                    string[] row = { ws.owner.name, ws.title, ws_content, ws_state };
                    this.tp_datagridview.Rows.Add(row);
                    DataGridViewRow lastRow = this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2];

                    //
                    // Workspace link
                    //
                    DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
                    linkCell.Value = _oauth.APIHost + "/workspaces/" + ws.id + "#tab-overview-s";
                    linkCell.ToolTipText = "Open the workspace in a web browser";
                    lastRow.Cells[4] = linkCell;
                    if (ws_deleted || ws.status == "archived")
                        this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2].DefaultCellStyle.ForeColor = Color.DarkGray;
                }

                //
                // Clicking a cell opens the workspace in a Web browser
                //
                this.tp_datagridview.CellContentClick += new DataGridViewCellEventHandler(tp_datagridview_CellContentClick);
            }
            catch (Exception err)
            {
                showMessage("Error while fetching the list of workspaces.");
                return;
            }
        }
Exemplo n.º 15
0
        //
        // Get the list of recent tasks
        //
        private void api_task_btn_Click(object sender, EventArgs e)
        {
            this.tp_datagridview.Columns.Clear();
            this.tp_datagridview.Refresh();
            string error_msg = null;
            List<tpModels.Task> tasks = null;

            showMessage("Connecting ...");

            //
            // Visit https://github.com/vispower/teamplatform-api for more options
            //
            // Following codes fetches recently finished tasks.
            // The number of tasks retrieved at each call is 30
            //

            List<QueryParameter> options = new List<QueryParameter>();
            options.Add(new QueryParameter("state", "finished"));

            if (!_oauth.tpGetTasks(options, out error_msg, out tasks))
            {
                showMessage(error_msg);
                return;
            }
            showMessage(tasks.Count.ToString() + " finished tasks found.");

            //
            // Add tasks data to the grid view
            //
            try
            {
                setupTaskViewTable(this.tp_datagridview);
                foreach (tpModels.Task task in tasks)
                {
                    bool task_finished = (task.state == "finished") ? true : false;
                    string task_content = task.description + "\n" + truncate(task.details, 100);
                    string task_users = task.assigner.name + "\n" + ((task.assignee == null) ? "" : task.assignee.name);
                    string[] row = { task_content, task_users, convertDateTime(task.due), task.state };
                    this.tp_datagridview.Rows.Add(row);
                    DataGridViewRow lastRow = this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2];

                    //
                    // Workspace hyper link
                    //
                    DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
                    linkCell.Value = _oauth.APIHost + "/workspaces/" + task.workspace_id + "#tab-tasks-s";
                    linkCell.ToolTipText = "Open Workspace in web browser";
                    lastRow.Cells[4] = linkCell;
                    if (task_finished)
                        this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2].DefaultCellStyle.ForeColor = Color.DarkGray;
                }

                //
                // Clicking a cell opens the task data in a Web browser
                //
                this.tp_datagridview.CellContentClick += new DataGridViewCellEventHandler(tp_datagridview_CellContentClick);
            }
            catch (Exception err)
            {
                showMessage("Error while fetching the list of tasks.");
                return;
            }
        }
Exemplo n.º 16
0
        //
        // Get the list of recent files
        //
        private void api_file_btn_Click(object sender, EventArgs e)
        {
            this.tp_datagridview.Columns.Clear();
            this.tp_datagridview.Refresh();
            string error_msg = null;
            List<tpModels.File> files = null;

            showMessage("Connecting ...");

            //
            // Visit https://github.com/vispower/teamplatform-api for more options
            //
            // Following codes fetches recently updated files excluding folderes.
            // The number of files retrieved at each call is 30
            //
            List<QueryParameter> options = new List<QueryParameter>();
            options.Add(new QueryParameter("ftype", "file"));

            //
            // If you need to get next 30 more files,
            // use 'page' option ('page' is the shortform of the 'pagination')
            //
            // options.Add(new QueryParameter("page", "2"));
            //

            if (!_oauth.tpGetFiles(options, out error_msg, out files))
            {
                showMessage(error_msg);
                return;
            }
            showMessage(files.Count.ToString() + " recent files found.");

            //
            //Add files data to the grid view
            //
            try
            {
                setupFileViewTable(this.tp_datagridview);
                foreach (tpModels.File file in files)
                {
                    bool file_deleted = !is_blank(file.deleted_at);
                    string desc = "";
                    if (file.workspace_id != null) desc = "Workspace:" + file.key.Split('/').First();
                    else desc = "Attached to a discussion";

                    string file_content = desc + "\n"
                                    + "Owner:" + file.owner.name + ", Comments:" + file.comments_count;
                    string file_state = convertDateTime(file.updated_at) + "\n" + convertDateTime(file.created_at);
                    string[] row = { null, file.filename, file_content, file_state };
                    this.tp_datagridview.Rows.Add(row);
                    DataGridViewRow lastRow = this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2];

                    //
                    // Get thumbnail images from the TeamPlatform images storage
                    //
                    if (!is_blank(file.small))
                    {
                        try
                        {
                            DataGridViewImageCell imageCell = new DataGridViewImageCell();
                            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(file.small.ToString());
                            myRequest.Method = "GET";
                            HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                            Bitmap bmp = new System.Drawing.Bitmap(myResponse.GetResponseStream());
                            Bitmap resized = new Bitmap(bmp, new Size(100, 100));
                            myResponse.Close();
                            imageCell.Value = resized;
                            lastRow.Cells[0] = imageCell;
                        }
                        catch { }
                    }

                    //
                    // Clicking a cell opens the file data in a Web browser
                    //
                    if (file.workspace_id != null)
                    {
                        DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
                        linkCell.Value = _oauth.APIHost + "/workspaces/" + file.workspace_id + "#tab-files-" + file.id + "-s";
                        linkCell.ToolTipText = "Open the file in a web browser";
                        lastRow.Cells[4] = linkCell;
                    }

                    if (file_deleted)
                        this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2].DefaultCellStyle.ForeColor = Color.DarkGray;
                }
                //bind cell click to open in browser
                this.tp_datagridview.CellContentClick += new DataGridViewCellEventHandler(tp_datagridview_CellContentClick);
            }
            catch (Exception err)
            {
                showMessage("Error while fetching the list of files.");
                return;
            }
        }
Exemplo n.º 17
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            try{
                //取得MySQLConnection
                MySqlConnection connection = new MySqlConnection(conString);

                connection.Open();
                string sSubjectType = "";

                if(this.cbTypeCondt.Text == "ALL")
                {
                    sSubjectType = "";
                }
                else
                {
                    sSubjectType = this.cbTypeCondt.Text;
                }
                StringBuilder sSql = new StringBuilder(@"select  no as 編號, subject_type as 類別, subject as 主題, content as 課程內容, 
                                   teacher as 主講者, SEC_TO_TIME(audio_len) as 音檔長度,
                                   audio_finish as 音檔, dvd as 歸檔DVD櫃,text_finish as 逐字稿,
                                   file_path as 電子影音檔 from youngclass.BuddhaTeaching where 1=1 and delete_flag = 'N'");
                if(sSubjectType.Length !=0)
                {
                    sSql.Append(" and subject_type ='" + sSubjectType + "'");
                }
                if(this.tbSubjectCondt.Text.Trim().Length != 0)
                {
                    sSql.Append(" and subject like '%" + this.tbSubjectCondt.Text.Replace("*", "%") + "%'");
                }
                if (this.tbTeacherCondt.Text.Trim().Length != 0)
                {
                    sSql.Append(" and teacher like '%" + this.tbTeacherCondt.Text.Replace("*", "%") + "%'");
                }
                MySqlCommand cmd = new MySqlCommand(sSql.ToString(), connection);
                
                //Data ResultSet
                using (MySqlDataReader data_reader = cmd.ExecuteReader())
                {
                    DataTable dtCustomers = new DataTable();
                    dtCustomers.Load(data_reader);
                    dgvStudentData.DataSource = dtCustomers;
                    //if (data_reader.HasRows)
                    //{
                    //    while (data_reader.Read())
                    //    {
                    //        //連線成功的話會輸出totrec的值1
                    //       // MessageBox.Show(data_reader.GetString("totrec"));
                    //    }
                    //}
                    pathIndex = dtCustomers.Columns.IndexOf("電子影音檔");
                }
                
                //AddLinkColumn("電子影音檔路徑");
                foreach (DataGridViewRow dr in this.dgvStudentData.Rows)
                {
                    DataGridViewLinkCell lc = new DataGridViewLinkCell();
                    lc.Value = dr.Cells[pathIndex].Value;
                    dgvStudentData[pathIndex, dr.Index] = lc;
                }
            }
            catch (Exception ex)
            {
                //失敗會有錯誤訊息
                MessageBox.Show(ex.ToString());
                Console.WriteLine(ex);
            }
            //this.dgvStudentData.Columns[26].Width = 500;
            //this.dgvStudentData.Rows[1].Height = 500;
        }
        public void prepareGrid4Features(IEnumRow currentFeatures)
        {
            if (m_inspector == null)
            {
                //this is the default inspector shipped with the editor
                m_inspector = new FeatureInspector();

                SetParent(dataGridView1.Handle.ToInt32(), this.Handle.ToInt32());
            }


            DataGridView featureGridView = this.dataGridView1;

            // reset the feature grid
            featureGridView.Rows.Clear();


            if (currentFeatures == null)
            {
                return;
            }

            currentFeatures.Reset();

            IFeature currentFeature = currentFeatures.Next() as IFeature;

            Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey> potentialTags = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey>();


            // determine a unique collection of proposed and existing tags
            List<string> uniqueListofTags = new List<string>();
            Dictionary<string, string> commonTags = new Dictionary<string, string>();
            Geometry.esriGeometryType currentGeometryType = esriGeometryType.esriGeometryNull;
            IEnumerable<ESRI.ArcGIS.OSM.OSMClassExtension.tag> sameTags = null;

            while (currentFeature != null)
            {
                int osmTagsFieldIndex = currentFeature.Fields.FindField("osmTags");
                currentGeometryType = currentFeature.Shape.GeometryType;

                if (osmTagsFieldIndex != -1)
                {
                    ESRI.ArcGIS.OSM.OSMClassExtension.tag[] tagsOnCurrentFeature = _osmUtility.retrieveOSMTags((IRow)currentFeature, osmTagsFieldIndex, m_editor.EditWorkspace);

                    if (sameTags == null && tagsOnCurrentFeature != null)
                    {
                        sameTags = tagsOnCurrentFeature.ToArray<ESRI.ArcGIS.OSM.OSMClassExtension.tag>();
                    }
                    else if (sameTags != null && tagsOnCurrentFeature != null)
                    {
                        IEnumerable<ESRI.ArcGIS.OSM.OSMClassExtension.tag> both = tagsOnCurrentFeature.Intersect(sameTags, new ESRI.ArcGIS.OSM.OSMClassExtension.TagKeyComparer());
                        sameTags = both.ToArray<ESRI.ArcGIS.OSM.OSMClassExtension.tag>();
                    }

                    if (tagsOnCurrentFeature != null)
                    {
                        for (int index = 0; index < tagsOnCurrentFeature.Length; index++)
                        {
                            if (uniqueListofTags.Contains(tagsOnCurrentFeature[index].k) == false)
                            {
                                uniqueListofTags.Add(tagsOnCurrentFeature[index].k);
                            }

                            // check if the tag key already exists
                            if (commonTags.ContainsKey(tagsOnCurrentFeature[index].k) == true)
                            {
                                if (commonTags[tagsOnCurrentFeature[index].k] == tagsOnCurrentFeature[index].v)
                                {
                                    // the tag values still match - don't do anything
                                }
                                else
                                {
                                    // the values are different - purge the existing value
                                    commonTags[tagsOnCurrentFeature[index].k] = String.Empty;
                                }
                            }
                            else
                            {
                                // the tag doesn't exist yet in the overall collection, 
                                // add the first entry
                                commonTags.Add(tagsOnCurrentFeature[index].k, tagsOnCurrentFeature[index].v);
                            }
                        }
                    }
                }

                // determine potential tag candidates based on the osmfeature schema
                string featureString = String.Empty;

                //let's get the first domain entry and use it as the main feature theme

                for (int fieldIndex = 0; fieldIndex < currentFeature.Fields.FieldCount; fieldIndex++)
                {
                    if (String.IsNullOrEmpty(featureString))
                    {
                        if (currentFeature.Fields.get_Field(fieldIndex).Type == esriFieldType.esriFieldTypeString)
                        {
                            System.Object attributeValue = currentFeature.get_Value(fieldIndex);

                            if (attributeValue != System.DBNull.Value)
                            {
                                foreach (string lookingforDomain in m_domainDictionary.Keys)
                                {
                                    if (currentFeature.Fields.get_Field(fieldIndex).Name == lookingforDomain)
                                    {
                                        featureString = lookingforDomain + "=" + attributeValue.ToString();
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                ESRI.ArcGIS.OSM.OSMClassExtension.osmfeature OSMInspectorFeatureType = null;

                if (m_editFeatures.Keys.Contains(featureString))
                {
                    OSMInspectorFeatureType = m_editFeatures[featureString];
                }

                if (OSMInspectorFeatureType != null)
                {
                    if (OSMInspectorFeatureType.tag != null)
                    {
                        for (int index = 0; index < OSMInspectorFeatureType.tag.Length; index++)
                        {
                            if (commonTags.ContainsKey(OSMInspectorFeatureType.tag[index].@ref) == false)
                            {
                                commonTags.Add(OSMInspectorFeatureType.tag[index].@ref, String.Empty);
                            }
                        }
                    }
                }

                currentFeature = currentFeatures.Next() as IFeature;
            }


            // get a listing of all possible tags
            Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey> localTags = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey>();

            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagkey tagKeyItem in m_editTags.Values)
            {
                localTags.Add(tagKeyItem.name, tagKeyItem);
            }


            // now let's go through our unique list of proposed and existing tags
            // and fill the grid accordingly

            DataGridViewRow currentRow = null;

            foreach (KeyValuePair<string, string> osmTagValuePair in commonTags)
            {
                currentRow = new DataGridViewRow();

                // name of the tag - tag type
                DataGridViewCell currentTagCell = new DataGridViewTextBoxCell();
                currentTagCell.Value = osmTagValuePair.Key;

                // for localization include the translated language into a tooltip
                if (m_editTags.ContainsKey(osmTagValuePair.Key))
                {
                    if (!String.IsNullOrEmpty(m_editTags[osmTagValuePair.Key].displayname))
                    {
                        currentTagCell.ToolTipText = m_editTags[osmTagValuePair.Key].displayname;
                    }
                }


                currentRow.Cells.Insert(0, currentTagCell);

                // the default case is not to allow the user change the key field
                bool canEdit = false;

                if (m_editTags.ContainsKey(osmTagValuePair.Key))
                {
                    if (m_editTags[osmTagValuePair.Key].editableSpecified)
                    {
                        canEdit = m_editTags[osmTagValuePair.Key].editable;
                    }
                }

                currentRow.Cells[0].ReadOnly = !canEdit;

                // value of the tag
                // depending on the tag type we'll need to create a different cell type
                DataGridViewCell currentValueCell = null;

                if (m_editTags.ContainsKey(osmTagValuePair.Key))
                {
                    switch (m_editTags[osmTagValuePair.Key].tagtype)
                    {
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_list:
                            currentValueCell = new DataGridViewComboBoxCell();
                            try
                            {
                                foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue value in m_editTags[osmTagValuePair.Key].tagvalue)
                                {
                                    ((DataGridViewComboBoxCell)currentValueCell).Items.Add(value.name);
                                }
                            }
                            catch (Exception ex)
                            {
                                System.Diagnostics.Debug.WriteLine(ex.Message);
                            }
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_integer:
                            currentValueCell = new DataGridViewTextBoxCell();
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_double:
                            currentValueCell = new DataGridViewTextBoxCell();
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_string:
                            currentValueCell = new DataGridViewTextBoxCell();
                            break;
                        default:
                            currentValueCell = new DataGridViewTextBoxCell();
                            break;
                    }
                }
                else if (m_domainDictionary.ContainsKey(osmTagValuePair.Key))
                {
                    currentValueCell = new DataGridViewComboBoxCell();
                    ESRI.ArcGIS.OSM.OSMClassExtension.domain currentDomain = null;

                    switch (currentGeometryType)
                    {
                        case esriGeometryType.esriGeometryAny:
                            break;
                        case esriGeometryType.esriGeometryBag:
                            break;
                        case esriGeometryType.esriGeometryBezier3Curve:
                            break;
                        case esriGeometryType.esriGeometryCircularArc:
                            break;
                        case esriGeometryType.esriGeometryEllipticArc:
                            break;
                        case esriGeometryType.esriGeometryEnvelope:
                            break;
                        case esriGeometryType.esriGeometryLine:
                            break;
                        case esriGeometryType.esriGeometryMultiPatch:
                            break;
                        case esriGeometryType.esriGeometryMultipoint:
                            break;
                        case esriGeometryType.esriGeometryNull:
                            break;
                        case esriGeometryType.esriGeometryPath:
                            break;
                        case esriGeometryType.esriGeometryPoint:
                            currentDomain = m_domainDictionary[osmTagValuePair.Key];

                            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.domainvalue item in currentDomain.domainvalue)
                            {
                                for (int geometryIndex = 0; geometryIndex < item.geometrytype.Length; geometryIndex++)
                                {
                                    if (item.geometrytype[geometryIndex] == ESRI.ArcGIS.OSM.OSMClassExtension.geometrytype.point)
                                    {
                                        try
                                        {
                                            ((DataGridViewComboBoxCell)currentValueCell).Items.Add(item.value);
                                        }
                                        catch (Exception ex)
                                        {
                                            System.Diagnostics.Debug.WriteLine(ex.Message);
                                        }
                                    }
                                }
                            }
                            break;
                        case esriGeometryType.esriGeometryPolygon:
                            currentDomain = m_domainDictionary[osmTagValuePair.Key];

                            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.domainvalue item in currentDomain.domainvalue)
                            {
                                for (int geometryIndex = 0; geometryIndex < item.geometrytype.Length; geometryIndex++)
                                {
                                    if (item.geometrytype[geometryIndex] == ESRI.ArcGIS.OSM.OSMClassExtension.geometrytype.polygon)
                                    {
                                        try
                                        {
                                            ((DataGridViewComboBoxCell)currentValueCell).Items.Add(item.value);
                                        }
                                        catch (Exception ex)
                                        {
                                            System.Diagnostics.Debug.WriteLine(ex.Message);
                                        }
                                    }
                                }
                            }
                            break;
                        case esriGeometryType.esriGeometryPolyline:
                            currentDomain = m_domainDictionary[osmTagValuePair.Key];

                            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.domainvalue item in currentDomain.domainvalue)
                            {
                                for (int geometryIndex = 0; geometryIndex < item.geometrytype.Length; geometryIndex++)
                                {
                                    if (item.geometrytype[geometryIndex] == ESRI.ArcGIS.OSM.OSMClassExtension.geometrytype.line)
                                    {
                                        try
                                        {
                                            ((DataGridViewComboBoxCell)currentValueCell).Items.Add(item.value);
                                        }
                                        catch (Exception ex)
                                        {
                                            System.Diagnostics.Debug.WriteLine(ex.Message);
                                        }
                                    }
                                }
                            }
                            break;
                        case esriGeometryType.esriGeometryRay:
                            break;
                        case esriGeometryType.esriGeometryRing:
                            break;
                        case esriGeometryType.esriGeometrySphere:
                            break;
                        case esriGeometryType.esriGeometryTriangleFan:
                            break;
                        case esriGeometryType.esriGeometryTriangleStrip:
                            break;
                        case esriGeometryType.esriGeometryTriangles:
                            break;
                        default:
                            break;
                    }
                }
                else
                { // unkown keys are treated as strings
                    currentValueCell = new DataGridViewTextBoxCell();
                }

                // add the value only we have a value and if the tag is common among all features
                if (String.IsNullOrEmpty(osmTagValuePair.Value) == false)
                {
                    ESRI.ArcGIS.OSM.OSMClassExtension.tag compareTag = new ESRI.ArcGIS.OSM.OSMClassExtension.tag();
                    compareTag.k = osmTagValuePair.Key;

                    if (sameTags.Contains(compareTag, new ESRI.ArcGIS.OSM.OSMClassExtension.TagKeyComparer()))
                    {
                        currentValueCell.Value = osmTagValuePair.Value;
                    }
                }

                // for localization include the translated language into a tooltip
                if (m_editTags.ContainsKey((string)currentTagCell.Value))
                {
                    if (!String.IsNullOrEmpty((string)currentValueCell.Value))
                    {
                        ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue[] possibleValues = m_editTags[(string)currentTagCell.Value].tagvalue;

                        if (possibleValues != null)
                        {
                            for (int valueIndex = 0; valueIndex < possibleValues.Length; valueIndex++)
                            {
                                if (currentValueCell.Value.Equals(possibleValues[valueIndex].name) == true)
                                {
                                    if (!String.IsNullOrEmpty(possibleValues[valueIndex].displayname))
                                    {
                                        currentValueCell.ToolTipText = possibleValues[valueIndex].displayname;
                                    }
                                }
                            }
                        }
                    }
                }

                currentRow.Cells.Insert(1, currentValueCell);

                // the assumption here is that values are usually open to user edits
                canEdit = true;
                currentRow.Cells[1].ReadOnly = !canEdit;

                DataGridViewLinkCell currentInfoCell = new DataGridViewLinkCell();
                currentInfoCell.LinkBehavior = LinkBehavior.SystemDefault;

                if (m_editTags.ContainsKey(osmTagValuePair.Key))
                {
                    if (String.IsNullOrEmpty(m_editTags[osmTagValuePair.Key].infoURL))
                    {
                        currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + osmTagValuePair.Key));
                    }
                    else
                    {
                        currentInfoCell.Value = new Uri(m_editTags[osmTagValuePair.Key].infoURL);
                    }
                    currentRow.Cells.Insert(2, currentInfoCell);
                }
                else
                {
                    currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + osmTagValuePair.Key));
                }

                featureGridView.Rows.Add(currentRow);

                if (localTags.ContainsKey(osmTagValuePair.Key))
                {
                    localTags.Remove(osmTagValuePair.Key);
                }
            }

            // add the list in the first column of the last row
            DataGridViewRow lastRow = new DataGridViewRow();
            DataGridViewComboBoxCell currentKeyCell = new DataGridViewComboBoxCell();
            try
            {
                // show a sorted list of tags to the user
                IEnumerable<string> sortedKeys = localTags.Keys.OrderBy(myKey => myKey);

                foreach (string currentKey in sortedKeys)
                {
                    currentKeyCell.Items.Add(currentKey);
                }
            }
            catch { }

            lastRow.Cells.Insert(0, currentKeyCell);

            featureGridView.Rows.Add(lastRow);

        }
Exemplo n.º 19
0
		public static void ConvertToLinkColumn( DataGridViewColumn column ) {
			var cellTemplate = new DataGridViewLinkCell { TrackVisitedState = false, UseColumnTextForLinkValue = true, LinkBehavior = LinkBehavior.NeverUnderline };
			column.CellTemplate = cellTemplate;
			column.DefaultCellStyle.NullValue = String.Empty;
		}
Exemplo n.º 20
0
        /// <summary>
        /// Add the property to PropertyWindow.
        /// </summary>
        /// <param name="d">EcellData of property.</param>
        /// <param name="type">Type of property.</param>
        /// <returns>Row in DataGridView.</returns>
        DataGridViewRow AddProperty(EcellData d, string type)
        {
            DataGridViewRow row = new DataGridViewRow();
            DataGridViewTextBoxCell propNameCell = new DataGridViewTextBoxCell();
            DataGridViewCell propValueCell;
            propNameCell.Value = d.Name;
            row.Cells.Add(propNameCell);
            if (m_propDic == null || m_current.Type != Constants.xpathProcess
                || m_propDic.ContainsKey(d.Name))
            {
                propNameCell.Style.BackColor = Color.LightGray;
                propNameCell.Style.SelectionBackColor = Color.LightGray;
                propNameCell.ReadOnly = true;
            }
            else
            {
                propNameCell.ReadOnly = false;
                propNameCell.Style.BackColor = SystemColors.Window;
                propNameCell.Style.ForeColor = SystemColors.WindowText;
                propNameCell.Style.SelectionBackColor = SystemColors.Highlight;
                propNameCell.Style.SelectionForeColor = SystemColors.HighlightText;
            }

            if (d.Value == null) return null;

            if (d.Name == Constants.xpathExpression)
            {
                propValueCell = new DataGridViewOutOfPlaceEditableCell();
                propValueCell.Value = (string)d.Value;
                ((DataGridViewOutOfPlaceEditableCell)propValueCell).OnOutOfPlaceEditRequested =
                    delegate(DataGridViewOutOfPlaceEditableCell c)
                    {
                        string retval = ShowFormulatorDialog(c.Value == null ? "" : c.Value.ToString());
                        if (retval != null)
                        {
                            propValueCell.Value = retval;
                            UpdateExpression(retval);
                            return true;
                        }
                        return false;
                    };
            }
            else if (d.Name == Constants.xpathVRL)
            {
                propValueCell = new DataGridViewLinkCell();
                propValueCell.Value = MessageResources.LabelEdit;
            }
            else if (d.Name == Constants.xpathStepperID)
            {
                propValueCell = new DataGridViewComboBoxCell();
                bool isexist = false;
                string stepperName = d.Value.ToString();
                foreach (EcellObject obj in m_env.DataManager.GetStepper(m_current.ModelID))
                {
                    if (!string.IsNullOrEmpty(stepperName) &&
                        stepperName.Equals(obj.Key))
                    {
                        isexist = true;
                    }
                    ((DataGridViewComboBoxCell)propValueCell).Items.Add(obj.Key);
                }
                if (isexist)
                    propValueCell.Value = d.Value.ToString();
                m_stepperIDComboBox = (DataGridViewComboBoxCell)propValueCell;
            }
            else
            {
                propValueCell = new DataGridViewTextBoxCell();
                if (d.Value.IsDouble)
                {
                    propValueCell.Value = ((double)d.Value).ToString(m_env.DataManager.DisplayStringFormat);
                }
                else
                {
                    propValueCell.Value = (string)d.Value;
                }
            }
            row.Cells.Add(propValueCell);
            m_dgv.Rows.Add(row);

            if (d.Settable && !d.Name.Equals(Constants.xpathVRL))
            {
                propValueCell.ReadOnly = false;
            }
            else
            {
                propValueCell.ReadOnly = true;
                propValueCell.Style.ForeColor = SystemColors.GrayText;
            }
            propValueCell.Tag = d;

            return row;
        }
Exemplo n.º 21
0
        /// <include file='doc\DataGridViewLinkCell.uex' path='docs/doc[@for="DataGridViewLinkCell.Clone"]/*' />
        public override object Clone()
        {
            DataGridViewLinkCell dataGridViewCell;
            Type thisType = this.GetType ();

            if (thisType == cellType) //performance improvement
            {
                dataGridViewCell = new DataGridViewLinkCell();
            }
            else
            {
                // SECREVIEW : Late-binding does not represent a security thread, see bug#411899 for more info..
                //
                dataGridViewCell = (DataGridViewLinkCell)System.Activator.CreateInstance(thisType);
            }
            base.CloneInternal(dataGridViewCell);

            if (this.Properties.ContainsObject(PropLinkCellActiveLinkColor))
            {
                dataGridViewCell.ActiveLinkColorInternal = this.ActiveLinkColor;
            }

            if (this.Properties.ContainsInteger(PropLinkCellUseColumnTextForLinkValue))
            {
                dataGridViewCell.UseColumnTextForLinkValueInternal = this.UseColumnTextForLinkValue;
            }

            if (this.Properties.ContainsInteger(PropLinkCellLinkBehavior))
            {
                dataGridViewCell.LinkBehaviorInternal = this.LinkBehavior;
            }

            if (this.Properties.ContainsObject(PropLinkCellLinkColor))
            {
                dataGridViewCell.LinkColorInternal = this.LinkColor;
            }

            if (this.Properties.ContainsInteger(PropLinkCellTrackVisitedState))
            {
                dataGridViewCell.TrackVisitedStateInternal = this.TrackVisitedState;
            }

            if (this.Properties.ContainsObject(PropLinkCellVisitedLinkColor))
            {
                dataGridViewCell.VisitedLinkColorInternal = this.VisitedLinkColor;
            }

            if (this.linkVisitedSet)
            {
                dataGridViewCell.LinkVisited = this.LinkVisited;
            }

            return dataGridViewCell;
        }