Esempio n. 1
0
        public bool OlderParents(int minAge)
        {
            this.Text = "Parents aged " + minAge + "+ at time of child's birth";
            selectRow = true;
            SortableBindingList <IDisplayIndividual> dsInd = new SortableBindingList <IDisplayIndividual>();
            SortableBindingList <IDisplayFamily>     dsFam = new SortableBindingList <IDisplayFamily>();

            families = new Dictionary <IDisplayIndividual, IDisplayFamily>();
            foreach (Family f in ft.AllFamilies)
            {
                bool added = false;
                foreach (Individual child in f.Children)
                {
                    if (child.BirthDate.IsKnown)
                    {
                        if (f.Husband != null && f.Husband.BirthDate.IsKnown)
                        {
                            Age age = f.Husband.GetAge(child.BirthDate);
                            if (age.MinAge >= minAge && !dsInd.Contains(f.Husband))
                            {
                                dsInd.Add(f.Husband);
                                families.Add(f.Husband, f);
                                added = true;
                            }
                        }
                        if (f.Wife != null && f.Wife.BirthDate.IsKnown)
                        {
                            Age age = f.Wife.GetAge(child.BirthDate);
                            if (age.MinAge >= minAge && !dsInd.Contains(f.Wife))
                            {
                                dsInd.Add(f.Wife);
                                families.Add(f.Wife, f);
                                added = true;
                            }
                        }
                    }
                }
                if (added && !dsFam.Contains(f))
                {
                    dsFam.Add(f);
                }
            }
            if (dsInd.Count > 0)
            {
                dgIndividuals.DataSource = dsInd;
                SortIndividuals();
                dgIndividuals.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                dgFamilies.DataSource       = dsFam;
                SortFamilies();
                dgFamilies.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
                dgIndividuals.Rows[0].Selected = true; // force a selection to update both grids
                return(true);
            }
            else
            {
                MessageBox.Show("You have no parents older than " + minAge + " at time of children's birth.", "FTAnalyzer");
                return(false);
            }
        }
Esempio n. 2
0
 public void WatchAlarm(AlarmTime alarm)
 {
     if (!m_Alarms.Contains(alarm))
     {
         m_Alarms.Add(alarm);
     }
     alarm.OnAlarm -= new EventHandler(alarm_OnAlarm);
     alarm.OnAlarm += new EventHandler(alarm_OnAlarm);
 }
 private void AddSetting(SystemSetting setting)
 {
     if (!_settings.Contains(setting))
     {
         _context.AddToSystemSettings(setting);
         _settings.Add(setting);
     }
 }
Esempio n. 4
0
 void AddSources(DisplayFact fact)
 {
     foreach (FactSource s in fact.Sources)
     {
         if (!sources.Contains(s))
         {
             sources.Add(s);
         }
     }
     dgSources.DataSource = sources;
     reportFormHelper.LoadColumnLayout("SourcesColumns.xml");
     tsRecords.Text = sources.Count + " Records";
 }
Esempio n. 5
0
        /// <summary>
        /// Returns a sortable list of orders where one of the detail rows
        /// matches the filter criteria.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public SortableBindingList <dsSage.OrderRow> GetOrdersByDetailFilter(string filter)
        {
            var orderList = new SortableBindingList <dsSage.OrderRow>();

            foreach (dsSage.OrderDetailRow detailRow in GetTabelleOrderDetails().Where(o => o.VorgangspresetTemporaer == "D" || o.VorgangspresetTemporaer == "R"))
            {
                if (detailRow.Artikelnummer.ToUpperInvariant().Contains(filter.ToUpperInvariant()) ||
                    detailRow.Bezeichnung1.ToUpperInvariant().Contains(filter.ToUpperInvariant()) ||
                    detailRow.Bezeichnung2.ToUpperInvariant().Contains(filter.ToUpperInvariant()))
                {
                    {
                        foreach (dsSage.OrderRow orderRow in (detailRow.GetParentRows("Auftrag_Auftragsdetails") as dsSage.OrderRow[]).Where(o => o.Vorgang == "D" || o.Vorgang == "R"))
                        {
                            if (!orderList.Contains(orderRow))
                            {
                                orderList.Add(orderRow);
                            }
                        }
                    }
                }
            }
            return(orderList);
        }
Esempio n. 6
0
        private async Task UpdateFilteredList()
        {
            int previousIndex              = songGrid.FirstDisplayedScrollingRowIndex;
            var previousSelected           = songGrid.SelectedRows;
            List <GuildSong> selectedSongs = new List <GuildSong>();

            foreach (DataGridViewRow row in previousSelected)
            {
                selectedSongs.Add((GuildSong)row.DataBoundItem);
            }

            string searchString = "";

            if (!string.IsNullOrWhiteSpace(searchBox.Text))
            {
                searchString = searchBox.Text.ToLower();
            }
            else
            {
                return;
            }
            SortableBindingList <GuildSong> filteredBindingList;

            // Populate the list with a Guild Library query
            searchString = WebUtility.UrlEncode(searchString);
            string url = $"https://us-central1-bards-guild-midi-project.cloudfunctions.net/query?key=A52eAaSKhnQiXyVYtoqZLj4tVycc5U4HtY56S4Ha&find={searchString}";

            using (WebClient client = new WebClient())
            {
                string results = await client.DownloadStringTaskAsync(url).ConfigureAwait(true);

                var songArray = JsonConvert.DeserializeObject <GuildSong[]>(results);
                filteredBindingList = new SortableBindingList <GuildSong>(songArray);
            }


            if (filteredBindingList.Count == 0)
            {
                GuildSong infoSong = new GuildSong
                {
                    filename    = $"No songs found, select and add this to try searching Google for {searchString}",
                    contributor = "Make sure to include a full song name and artist for best results, and don't expect good quality"
                };
                filteredBindingList.Add(infoSong);
            }

            songGrid.DataSource = filteredBindingList;
            if (previousIndex > -1 && songGrid.RowCount > previousIndex)
            {
                songGrid.FirstDisplayedScrollingRowIndex = previousIndex;
            }
            // Seems to always select the first row, let's remove it and re-add if necessary
            if (songGrid.RowCount > 0)
            {
                songGrid.Rows[0].Selected = false;
            }
            foreach (GuildSong s in selectedSongs)
            {
                if (filteredBindingList.Contains(s))
                {
                    foreach (DataGridViewRow row in songGrid.Rows)
                    {
                        if ((GuildSong)row.DataBoundItem == s)
                        {
                            row.Selected = true;
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        private void AddAdditionalFieldsFilters()
        {
            AdditionalField1.HeaderText = Settings.Default.AdditionaField1Name;
            AdditionalField2.HeaderText = Settings.Default.AdditionaField2Name;
            AdditionalField3.HeaderText = Settings.Default.AdditionaField3Name;
            AdditionalField4.HeaderText = Settings.Default.AdditionaField4Name;
            AdditionalField5.HeaderText = Settings.Default.AdditionaField5Name;

            ComboBoxFilter additionalField1Filter = CreateComboBoxFilter(Settings.Default.AdditionaField1Name, BlackTheme.ColorDarkGray2);
            ComboBoxFilter additionalField2Filter = CreateComboBoxFilter(Settings.Default.AdditionaField2Name, BlackTheme.ColorDarkGray2);
            ComboBoxFilter additionalField3Filter = CreateComboBoxFilter(Settings.Default.AdditionaField3Name, BlackTheme.ColorDarkGray2);
            ComboBoxFilter additionalField4Filter = CreateComboBoxFilter(Settings.Default.AdditionaField4Name, BlackTheme.ColorDarkGray2);
            ComboBoxFilter additionalField5Filter = CreateComboBoxFilter(Settings.Default.AdditionaField5Name, BlackTheme.ColorDarkGray2);

            SortableBindingList <string> allAdditionalField1Values = new SortableBindingList <string>();
            SortableBindingList <string> allAdditionalField2Values = new SortableBindingList <string>();
            SortableBindingList <string> allAdditionalField3Values = new SortableBindingList <string>();
            SortableBindingList <string> allAdditionalField4Values = new SortableBindingList <string>();
            SortableBindingList <string> allAdditionalField5Values = new SortableBindingList <string>();
            SortableBindingList <Todo>   allTodos = (SortableBindingList <Todo>)todoBindingSource.DataSource;

            foreach (Todo todo in allTodos)
            {
                if (!allAdditionalField1Values.Contains(todo.AdditionalField1))
                {
                    if (todo.AdditionalField1 != null)
                    {
                        allAdditionalField1Values.Add(todo.AdditionalField1);
                    }
                }
                if (!allAdditionalField2Values.Contains(todo.AdditionalField2))
                {
                    if (todo.AdditionalField2 != null)
                    {
                        allAdditionalField2Values.Add(todo.AdditionalField2);
                    }
                }
                if (!allAdditionalField3Values.Contains(todo.AdditionalField3))
                {
                    if (todo.AdditionalField3 != null)
                    {
                        allAdditionalField3Values.Add(todo.AdditionalField3);
                    }
                }
                if (!allAdditionalField4Values.Contains(todo.AdditionalField4))
                {
                    if (todo.AdditionalField4 != null)
                    {
                        allAdditionalField4Values.Add(todo.AdditionalField4);
                    }
                }
                if (!allAdditionalField5Values.Contains(todo.AdditionalField5))
                {
                    if (todo.AdditionalField5 != null)
                    {
                        allAdditionalField5Values.Add(todo.AdditionalField5);
                    }
                }
            }
            additionalField1Filter.ComboBox.DataSource = allAdditionalField1Values;
            additionalField2Filter.ComboBox.DataSource = allAdditionalField2Values;
            additionalField3Filter.ComboBox.DataSource = allAdditionalField3Values;
            additionalField4Filter.ComboBox.DataSource = allAdditionalField4Values;
            additionalField5Filter.ComboBox.DataSource = allAdditionalField5Values;
        }
Esempio n. 8
0
        private async Task UpdateFilteredList()
        {
            int previousIndex              = songGrid.FirstDisplayedScrollingRowIndex;
            var previousSelected           = songGrid.SelectedRows;
            List <GuildSong> selectedSongs = new List <GuildSong>();

            foreach (DataGridViewRow row in previousSelected)
            {
                selectedSongs.Add((GuildSong)row.DataBoundItem);
            }

            string searchString = "";

            if (searchBox.Text != null && !string.IsNullOrWhiteSpace(searchBox.Text))
            {
                searchString = searchBox.Text.ToLower();
            }
            else
            {
                return; // Give up, he won't respond to empty queries
            }
            SortableBindingList <GuildSong> filteredBindingList;

            // Populate the list with a Guild Library query
            searchString = WebUtility.UrlEncode(searchString);
            string url = $"http://api.bardsguild.life/?key=0Tk-seyqLFwn5qCH2YzrYA&find={searchString}";

            try
            {
                using (WebClient client = new WebClient())
                {
                    string results = await client.DownloadStringTaskAsync(url).ConfigureAwait(true);

                    var songArray = JsonConvert.DeserializeObject <GuildSong[]>(results);
                    filteredBindingList = new SortableBindingList <GuildSong>(songArray);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Log("Failed to query API");
                return;
            }


            if (filteredBindingList.Count == 0)
            {
                GuildSong infoSong = new GuildSong
                {
                    filename    = $"No songs found, select and add this to try searching Google for {searchString}",
                    contributor = "Make sure to include a full song name and artist for best results, and don't expect good quality"
                };
                filteredBindingList.Add(infoSong);
            }

            songGrid.DataSource = filteredBindingList;
            if (previousIndex > -1 && songGrid.RowCount > previousIndex)
            {
                songGrid.FirstDisplayedScrollingRowIndex = previousIndex;
            }
            // Seems to always select the first row, let's remove it and re-add if necessary
            if (songGrid.RowCount > 0)
            {
                songGrid.Rows[0].Selected = false;
            }
            foreach (GuildSong s in selectedSongs)
            {
                if (filteredBindingList.Contains(s))
                {
                    foreach (DataGridViewRow row in songGrid.Rows)
                    {
                        if ((GuildSong)row.DataBoundItem == s)
                        {
                            row.Selected = true;
                        }
                    }
                }
            }
        }
    /// <summary>
    /// Revit external command to list all valid
    /// built-in parameters for a given selected
    /// element.
    /// </summary>
    public Result Execute(
      ExternalCommandData commandData,
      ref string message,
      ElementSet elements )
    {
      UIApplication uiapp = commandData.Application;
      UIDocument uidoc = uiapp.ActiveUIDocument;
      Document doc = uidoc.Document;

      // Select element

      Element e
        = Util.GetSingleSelectedElementOrPrompt(
          uidoc );

      if( null == e )
      {
        return Result.Cancelled;
      }

      bool isSymbol = false;

      // For a family instance, ask user whether to
      // display instance or type parameters; in a
      // similar manner, we could add dedicated
      // switches for Wall --> WallType,
      // Floor --> FloorType etc. ...

      if( e is FamilyInstance )
      {
        FamilyInstance inst = e as FamilyInstance;
        if( null != inst.Symbol )
        {
          string symbol_name = Util.ElementDescription(
            inst.Symbol, true );

          string family_name = Util.ElementDescription(
            inst.Symbol.Family, true );

          string msg = string.Format( _type_prompt,
            "is a family instance" );

          if( !Util.QuestionMsg( msg ) )
          {
            e = inst.Symbol;
            isSymbol = true;
          }
        }
      }
      else if( e.CanHaveTypeAssigned() )
      {
        ElementId typeId = e.GetTypeId();
        if( null == typeId )
        {
          Util.InfoMsg( "Element can have a type,"
            + " but the current type is null." );
        }
        else if( ElementId.InvalidElementId == typeId )
        {
          Util.InfoMsg( "Element can have a type,"
            + " but the current type id is the"
            + " invalid element id." );
        }
        else
        {
          Element type = doc.GetElement( typeId );

          if( null == type )
          {
            Util.InfoMsg( "Element has a type,"
              + " but it cannot be accessed." );
          }
          else
          {
            string msg = string.Format( _type_prompt,
              "has an element type" );

            if( !Util.QuestionMsg( msg ) )
            {
              e = type;
              isSymbol = true;
            }
          }
        }
      }

      // Retrieve parameter data

      SortableBindingList<ParameterData> data
        = new SortableBindingList<ParameterData>();

      {
        WaitCursor waitCursor = new WaitCursor();

        ParameterSet set = e.Parameters;
        bool containedInCollection;

        /* 
         * Edited by Chekalin Victor 13.12.2012
         * !!! This implemention does not work properly
         * if enum has the same integer value
         * For example, BuiltInParameter.All_MODEL_COST and
         * BuiltInParameter.DOOR_COST have -1001205 integer value
         * 
           Array bips = Enum.GetValues(
             typeof( BuiltInParameter ) );
         
           int n = bips.Length;
         * 
         */

        /*
         * Edited by Chekalin Victor 13.12.2012
         */
        var bipNames =
            Enum.GetNames( typeof( BuiltInParameter ) );

        Parameter p;

        /*
         * Edited by Chekalin Victor 13.12.2012
         */
        //foreach( BuiltInParameter a in bips )
        foreach( var bipName in bipNames )
        {
          BuiltInParameter a;

          if( !Enum.TryParse( bipName, out a ) )
            continue;

          try
          {
            p = e.get_Parameter( a );

            #region Check for external definition
#if CHECK_FOR_EXTERNAL_DEFINITION
            Definition d = p.Definition;
            ExternalDefinition e = d as ExternalDefinition; // this is never possible
            string guid = ( null == e ) ? null : e.GUID.ToString();
#endif // CHECK_FOR_EXTERNAL_DEFINITION
            #endregion // Check for external definition

            if( null != p )
            {
              string valueString =
                ( StorageType.ElementId == p.StorageType )
                  ? Util.GetParameterValue2( p, doc )
                  : p.AsValueString();

              //containedInCollection = set.Contains( p ); // this does not work
              containedInCollection = ContainedInCollection( p, set );

              data.Add( new ParameterData( a, p,
                valueString,
                containedInCollection,
                bipName ) );
            }
          }
          catch( Exception ex )
          {
            Debug.Print(
              "Exception retrieving built-in parameter {0}: {1}",
              a, ex );
          }
        }
      }

      // Retrieve parameters from Element.Parameters collection

      foreach( Parameter p in e.Parameters )
      {
        string valueString =
          ( StorageType.ElementId == p.StorageType )
            ? Util.GetParameterValue2( p, doc )
            : p.AsValueString();

        ParameterData parameterData = new ParameterData(
          ( p.Definition as InternalDefinition ).BuiltInParameter,
          p,
          valueString,
          true,
          null );

        if( !data.Contains( parameterData ) )
          data.Add( parameterData );
      }

      // Display form

      string description
        = Util.ElementDescription( e, true )
        + ( isSymbol
          ? " Type"
          : " Instance" );

#if USE_LIST_VIEW
      using( BuiltInParamsCheckerFormListView form
        = new BuiltInParamsCheckerFormListView( e,
          description, data ) )
#else
      using (BuiltInParamsCheckerForm form
        = new BuiltInParamsCheckerForm(
          description, data))
#endif // USE_LIST_VIEW
      {
        form.ShowDialog();
      }
      return Result.Succeeded;
    }