本文整理汇总了C#中BindingList.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# BindingList.Clear方法的具体用法?C# BindingList.Clear怎么用?C# BindingList.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BindingList
的用法示例。
在下文中一共展示了BindingList.Clear方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public static void Load(GeneralSettings generalSettings, BindingList<Action> actions, string fileName)
{
var lines = new List<string>();
using (var stream = new StreamReader(fileName))
{
string line;
while ((line = stream.ReadLine()) != null)
{
lines.Add(line);
}
}
var generalSettingsSections = GetSections(Strings.GeneralSettings, lines);
var actionSections = GetSections(Strings.Action, lines);
if (generalSettingsSections.Count > 0)
{
generalSettings.LoadFromStringList(generalSettingsSections[0]);
}
actions.Clear();
foreach (var actionSection in actionSections)
{
var action = Action.CreateFromActionName(actionSection);
actions.Add(action);
}
}
示例2: Form1
public Form1()
{
InitializeComponent();
FormClosing += new FormClosingEventHandler(Form1_FormClosing);
_configuration = new BindingList<IPConfiguration>();
_configuration.Clear();
foreach (var s in Properties.Settings.Default.ConfigurationStrings )
{
var cmd = new CmdLineHelper();
cmd.ParseString(s);
var config = new IPConfiguration();
config.Configure(cmd);
_configuration.Add(config);
}
UpdateContextMenu();
}
示例3: MainViewModel
public MainViewModel()
{
if (MainViewModel.instance == null)
{
Width = 525;
Height = 350;
Threads = new BindingList<DownloadThread>();
fetch = new DelegateCommand<object>((s) =>
{
Threads.Clear();
DownloadThread.Clear();
Downloader.count = 0;
new DownloadThread(RootURL);
}, (s) => { return !string.IsNullOrWhiteSpace(RootURL); });
RootURL = "http://www.apple.com";
MainViewModel.Instance = this;
}
else throw new Exception("There can only be one!!!!!");
}
示例4: GetShipsOfClassInOrbit
/// <summary>
/// Now I want a list of the ships of a specific class that are in orbit. these will potentially be targets for repair, refit, or scrap operations.
/// </summary>
/// <param name="CurrentFaction">Economics handler selected faction.</param>
/// <param name="CurrentPopulation">Population from the economics handler.</param>
/// <param name="CurrentShipClass">Shipclass selected via the RepairRefitScrapClassComboBox</param>
/// <param name="ShipsOfClassInOrbit">List of ships in the selected shipclass in orbit around CurrentPopulation.</param>
private static void GetShipsOfClassInOrbit(Faction CurrentFaction, Population CurrentPopulation, ShipClassTN CurrentShipClass, ref BindingList<ShipTN> ShipsOfClassInOrbit)
{
ShipsOfClassInOrbit.Clear();
foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit)
{
if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction)
{
foreach (ShipTN CurrentShip in CurrentTaskGroup.Ships)
{
if (CurrentShip.ShipClass == CurrentShipClass)
ShipsOfClassInOrbit.Add(CurrentShip);
}
}
}
}
示例5: GetShipClassesInOrbit
/// <summary>
/// Get a list of the shipclasses in orbit. this wll be needed to help prune repair/refit/scrap operation options.
/// </summary>
/// <param name="CurrentFaction">Current faction from the economics handler</param>
/// <param name="CurrentPopulation">Current Population from the economics handler.</param>
/// <param name="ClassesInOrbit">List of shipclasses in orbit around CurrentPopulation.</param>
private static void GetShipClassesInOrbit(Faction CurrentFaction, Population CurrentPopulation, ref BindingList<ShipClassTN> ClassesInOrbit)
{
ClassesInOrbit.Clear();
foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit)
{
if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction)
{
foreach (ShipTN CurrentShip in CurrentTaskGroup.Ships)
{
if (ClassesInOrbit.Contains(CurrentShip.ShipClass) == false)
ClassesInOrbit.Add(CurrentShip.ShipClass);
}
}
}
}
示例6: RefreshSYCGroupBox
/// <summary>
/// Need an updater function for this groupbox since the retool list can and will change.
/// </summary>
/// <param name="m_oSummaryPanel">Panel from economics</param>
/// <param name="CurrentFaction">Current Faction</param>
/// <param name="CurrentPopulation">Current Population</param>
/// <param name="SYInfo">Shipyard information for the selected shipyard.</param>
/// <param name="RetoolList">List of ships that this shipyard can be retooled to.</param>
private static void RefreshSYCGroupBox(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation,
Installation.ShipyardInformation SYInfo, BindingList<ShipClassTN> RetoolList)
{
#warning this doesn't update when a new shipclass is added on its own. the econ page is "shared" by all factions so an event may not be possible there.
if (RetoolList != null && CurrentFaction != null && SYInfo != null)
{
m_oSummaryPanel.NewShipClassComboBox.Items.Clear();
RetoolList.Clear();
foreach (ShipClassTN Ship in CurrentFaction.ShipDesigns)
{
/// <summary>
/// Ships that are too big may not be in the retool list, and military ships may not be built at commercial yards.
/// Naval yards may build all classes of ships, but cap expansion for naval yards is very expensive.
/// </summary>
if (Ship.SizeTons <= SYInfo.Tonnage && !(Ship.IsMilitary == true && SYInfo.ShipyardType == Constants.ShipyardInfo.SYType.Commercial))
{
RetoolList.Add(Ship);
}
}
foreach (ShipClassTN Ship in RetoolList)
{
m_oSummaryPanel.NewShipClassComboBox.Items.Add(Ship);
}
if (RetoolList.Count != 0)
m_oSummaryPanel.NewShipClassComboBox.SelectedIndex = 0;
}
}
示例7: GetEligibleClassList
/// <summary>
/// This function gets the list of shipclasses this shipyard can build. In order to be considered eligible the class must be locked, and thus not alterable.
/// eligible classes are those that would cost within 20% of cost to refit this shipclass towards.
/// </summary>
/// <param name="CurrentFaction">Current faction from the economics handler.</param>
/// <param name="SYInfo">Currently selected shipyard.</param>
/// <param name="EligibleClassList">List of shipclasses that this shipyard can produce.</param>
private static void GetEligibleClassList(Faction CurrentFaction, Installation.ShipyardInformation SYInfo, ref BindingList<ShipClassTN> EligibleClassList)
{
if (SYInfo.AssignedClass == null)
{
return;
}
EligibleClassList.Clear();
/// <summary>
/// Shipyards may always build the ship that they are tooled for.
/// </summary>
EligibleClassList.Add(SYInfo.AssignedClass);
/// <summary>
/// If the total refit cost is less than this, the CurrentClass is eligible.
/// </summary>
decimal RefitThreshold = SYInfo.AssignedClass.BuildPointCost * 0.2m;
/// <summary>
/// component definition and count lists for the assigned class. for refit purposes we don't care about any specialized component functionality, just cost here.
/// </summary>
BindingList<ComponentDefTN> AssignedClassComponents = SYInfo.AssignedClass.ListOfComponentDefs;
BindingList<short> AssignedClassComponentCounts = SYInfo.AssignedClass.ListOfComponentDefsCount;
foreach (ShipClassTN CurrentClass in CurrentFaction.ShipDesigns)
{
/// <summary>
/// Assigned class is already set to be built, and shouldn't ever be an "eligible class"
/// </summary>
if (CurrentClass == SYInfo.AssignedClass)
continue;
/// <summary>
/// Military ships are not buildable at commercial yards. Naval yards can build commercial ships however.
/// </summary>
if (CurrentClass.IsMilitary == true && SYInfo.ShipyardType == Constants.ShipyardInfo.SYType.Commercial)
continue;
/// <summary>
/// unlocked classes can be edited so I do not wish to have them included here.
/// </summary>
if(CurrentClass.IsLocked == true)
{
decimal TotalRefitCost = SYInfo.AssignedClass.GetRefitCost(CurrentClass);
if (TotalRefitCost <= RefitThreshold)
EligibleClassList.Add(CurrentClass);
}
}
}
示例8: GetDamagedShipList
/// <summary>
/// This function produces a list of ships that have taken Armor or component damage. repair will need this.
/// </summary>
/// <param name="CurrentPopulation">Population selected by the economics handler.</param>
/// <param name="DamagedShipsInOrbit">list of damaged ships this function will produce.</param>
private static void GetDamagedShipList(Faction CurrentFaction, Population CurrentPopulation, ref BindingList<ShipTN> DamagedShipList)
{
DamagedShipList.Clear();
foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit)
{
if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction)
{
foreach (ShipTN CurrentShip in CurrentTaskGroup.Ships)
{
/// <summary>
/// Either a component is destroyed or the ship has taken armour damage.
/// </summary>
if (CurrentShip.DestroyedComponents.Count != 0 || CurrentShip.ShipArmor.isDamaged == true)
DamagedShipList.Add(CurrentShip);
}
}
}
}
示例9: DataSource_BindingList2
[Test] // bug #81771
public void DataSource_BindingList2 ()
{
BindingList<string> list1 = new BindingList<string> ();
list1.Add ("item 1");
BindingList<string> list2 = new BindingList<string> ();
ListControlChild lc = new ListControlChild ();
lc.DataSourceChanged += new EventHandler (ListControl_DataSourceChanged);
Form form = new Form ();
form.Controls.Add (lc);
Assert.AreEqual (0, dataSourceChanged, "#1");
Assert.IsNull (lc.DataSource, "#2");
lc.DataSource = list1;
Assert.AreEqual (1, dataSourceChanged, "#3");
Assert.AreSame (list1, lc.DataSource, "#4");
lc.DataSource = list2;
Assert.AreEqual (2, dataSourceChanged, "#5");
Assert.AreSame (list2, lc.DataSource, "#6");
lc.DataSource = null;
Assert.AreEqual (3, dataSourceChanged, "#7");
Assert.IsNull (lc.DataSource, "#8");
list1.Add ("item");
list1.Clear ();
form.Dispose ();
}
示例10: CheckLabelsListWithXml
private bool CheckLabelsListWithXml(out string summary_results)
{
TextWriter summary_file_csv = null;
TextWriter summary_file_html = null;
bool Is_LabelsList_Valid = true;
summary_results = "";
string[] str_temp;
try
{
DateTime start_time, end_time;
TimeSpan ts, ts_start, ts_end, total_time, total_time_inv;
string category, current_label, readline;
//Create Summary Lists
BindingList<string> List_Annotated = new BindingList<string>();
BindingList<string> List_NoAnnotated = new BindingList<string>();
BindingList<string> List_Invalid = new BindingList<string>();
BindingList<TimeSpan> List_Time = new BindingList<TimeSpan>();
BindingList<TimeSpan> List_Time_Inv = new BindingList<TimeSpan>();
BindingList<string> List_Current_XML;
//Create the files for summarizing results
// Create the csv file
if (File.Exists(Folder_audioannotation + "AnnotationSummary.csv"))
{ File.Delete(Folder_audioannotation + "AnnotationSummary.csv"); }
summary_file_csv = new StreamWriter(Folder_audioannotation + "AnnotationSummary.csv");
summary_file_csv.WriteLine("Label,Time(hh:mm:ss)");
// Create the html file
if (File.Exists(Folder_audioannotation + "AnnotationSummary.html"))
{ File.Delete(Folder_audioannotation + "AnnotationSummary.html"); }
summary_file_html = new StreamWriter(Folder_audioannotation + "AnnotationSummary.html");
summary_file_html.WriteLine("<table border=\"1\">\n");
summary_file_html.WriteLine("<tr><td>Label</td><td>Time(hh:mm:ss)</td></tr>");
// ---------- Load labels ------------------
int count = 0;
int index = 0;
for (int c = 1; c <= 2; c++)
{
//Initialize lists
List_Annotated.Clear();
List_NoAnnotated.Clear();
List_Invalid.Clear();
List_Time.Clear();
List_Time_Inv.Clear();
total_time = TimeSpan.Zero;
total_time_inv = TimeSpan.Zero;
//Indicate the category
if (c == 1)
{
count = LabelsList_1.Count;
List_Current_XML = list_category_1;
//category = "Postures";
category = list_category_name[0];
}
else
{
count = LabelsList_2.Count;
List_Current_XML = list_category_2;
//category = "Activities";
category = list_category_name[1];
}
//Read each item from the list
for (int i = 0; i < count; i++)
{
if (c == 1)
{ readline = LabelsList_1[i]; }
else
{ readline = LabelsList_2[i]; }
string[] tokens = readline.Split(';');
//Check the row has valid start/end times
if (tokens[0].CompareTo("ok") == 0)
{
current_label = tokens[5];
//filter labels comming from blank rows
if (current_label.Trim().CompareTo("") != 0)
{
//Check if the label is valid according to the Xml protocol list
//if not, flag the label as invalid
if (List_Current_XML.Contains(current_label))
//.........这里部分代码省略.........
示例11: ReloadDebitNotes
void ReloadDebitNotes(BindingList<PaymentNote> target)
{
target.Clear();
PaymentNote.ClearCategoryList();
using (System.Data.SQLite.SQLiteDataReader reader = DataBase.Instance.ExecuteReader("SELECT * FROM DebitNotes"))
{
while (reader.Read())
{
reader.GetValue(0);
PaymentNote debitNote = new PaymentNote(
reader.GetInt32(0), //Id
reader.GetInt32(1), //OwnerId
reader.IsDBNull(2) ? string.Empty : reader.GetString(2), //Category
reader.GetDateTime(3), //Date
reader.IsDBNull(4) ? string.Empty : reader.GetString(4), //Services
reader.IsDBNull(5) ? string.Empty : reader.GetString(5), //Advances
reader.GetInt32(6), //Tax
reader.GetInt32(7), //Total
reader.IsDBNull(8) ? (Nullable<DateTime>)null : reader.GetDateTime(8)
);
target.Add(debitNote);
}
}
filterCategory.DataSource = null;
filterCategory.DataSource = PaymentNote.CategoryList;
filters_Changed(null, null);
}
示例12: BuildShips
//.........这里部分代码省略.........
/// <summary>
/// Add in the "new" ship.
/// </summary>
Task.AssignedTaskGroup.AddShip(Task.ConstructRefitTarget,Task.CurrentShip.Name);
Task.AssignedTaskGroup.Ships[Task.AssignedTaskGroup.Ships.Count - 1].TFTraining = Task.CurrentShip.TFTraining;
Task.AssignedTaskGroup.Ships[Task.AssignedTaskGroup.Ships.Count - 1].ShipGrade = Task.CurrentShip.ShipGrade;
CurrentPopulation.FuelStockpile = Task.AssignedTaskGroup.Ships[Task.AssignedTaskGroup.Ships.Count - 1].Refuel(CurrentPopulation.FuelStockpile);
break;
case Constants.ShipyardInfo.Task.Scrap:
/// <summary>
/// All non-destroyed components from the ship need to be put into the population stockpile.
/// This further includes fuel, MSP, and ordnance as well as eventually officers and crew.
/// </summary>
#warning Handle officers and crew on ship scrapping.
BindingList<ComponentDefTN> CompDefList = Task.CurrentShip.ShipClass.ListOfComponentDefs;
BindingList<short> CompDefCount = Task.CurrentShip.ShipClass.ListOfComponentDefsCount;
BindingList<ComponentTN> ShipCompList = Task.CurrentShip.ShipComponents;
BindingList<ushort> ComponentDefIndex = Task.CurrentShip.ComponentDefIndex;
int DefCount = Task.CurrentShip.ShipClass.ListOfComponentDefs.Count;
for (int CompDefIndex = 0; CompDefIndex < DefCount; CompDefIndex++)
{
ComponentDefTN CurrentCompDef = CompDefList[CompDefIndex];
short CurrentCompCount = CompDefCount[CompDefIndex];
int destCount = 0;
for (int CompIndex = 0; CompIndex < CurrentCompCount; CompIndex++)
{
if (ShipCompList[ComponentDefIndex[CompDefIndex] + CompIndex].isDestroyed == true)
{
destCount++;
}
}
if (destCount != CurrentCompCount)
{
CurrentPopulation.AddComponentsToStockpile(CurrentCompDef, (float)(CurrentCompCount - destCount));
}
}
CurrentPopulation.FuelStockpile = CurrentPopulation.FuelStockpile + Task.CurrentShip.CurrentFuel;
CurrentPopulation.MaintenanceSupplies = CurrentPopulation.MaintenanceSupplies + Task.CurrentShip.CurrentMSP;
foreach (KeyValuePair<OrdnanceDefTN, int> OrdnancePair in Task.CurrentShip.ShipOrdnance)
{
CurrentPopulation.LoadMissileToStockpile(OrdnancePair.Key, (float)OrdnancePair.Value);
}
/// <summary>
/// Finally destroy the ship. just use the existing code to remove the ship from the simulation, no point in reduplicating all of it.
/// </summary>
Task.CurrentShip.IsDestroyed = true;
if (CurrentFaction.RechargeList.ContainsKey(Task.CurrentShip) == true)
{
if ((CurrentFaction.RechargeList[Task.CurrentShip] & (int)Faction.RechargeStatus.Destroyed) != (int)Faction.RechargeStatus.Destroyed)
{
CurrentFaction.RechargeList[Task.CurrentShip] = CurrentFaction.RechargeList[Task.CurrentShip] + (int)Faction.RechargeStatus.Destroyed;
}
}
else
{
CurrentFaction.RechargeList.Add(Task.CurrentShip, (int)Faction.RechargeStatus.Destroyed);
}
break;
}
}
else
{
/// <summary>
/// Update the timer since this project won't finish just yet.
/// </summary>
decimal CostLeft = Task.Cost * (1.0m - Task.Progress);
float YearsOfProduction = (float)CostLeft / Task.ABR;
DateTime EstTime = GameState.Instance.GameDateTime;
if (YearsOfProduction < Constants.Colony.TimerYearMax)
{
float DaysInYear = (float)Constants.TimeInSeconds.RealYear / (float)Constants.TimeInSeconds.Day;
int TimeToBuild = (int)Math.Floor(YearsOfProduction * DaysInYear);
TimeSpan TS = new TimeSpan(TimeToBuild, 0, 0, 0);
EstTime = EstTime.Add(TS);
}
Task.CompletionDate = EstTime;
}
}
/// <summary>
/// Remove all the tasks that are now completed.
/// </summary>
foreach (Installation.ShipyardInformation.ShipyardTask Task in TasksToRemove)
{
/// <summary>
/// Sanity check here.
/// </summary>
if (Task.Progress >= 1.0m)
{
Installation.ShipyardInformation SYI = CurrentPopulation.ShipyardTasks[Task];
SYI.BuildingShips.Remove(Task);
CurrentPopulation.ShipyardTasks.Remove(Task);
}
}
TasksToRemove.Clear();
}
示例13: Build
public static void Build(BindingList<PnlPosRow> structure_, ReturnsEval.DataSeriesEvaluator parentEval_, ConstructGen<double> wts_, string[] wtsKeys_)
{
structure_.Clear();
if (parentEval_.InnerSeries.Count != wts_.ArrayLength)
return;
List<DateTime> pnlDates = new List<DateTime>(parentEval_.Daily.Dates);
for(int i=0;i<parentEval_.InnerSeries.Count;++i)
{
ReturnsEval.DataSeriesEvaluator eval = parentEval_.InnerSeries[i];
PnlPosRow row = new PnlPosRow(eval.Name);
int indexInWts = -1;
for(int j=0;j<wtsKeys_.Length;++j)
if (string.Compare(eval.Name, wtsKeys_[j]) == 0)
{
indexInWts = j;
break;
}
if (indexInWts == -1)
continue;
double[] wtsColumn = wts_.GetColumnValues(indexInWts);
DateTime startOfPeriod = wts_.Dates[0];
for (int j = 1; j < wts_.Dates.Count; ++j)
{
// has weight flipped
if (Statistics.AreSameSign(wtsColumn[j], wtsColumn[j - 1]) == false)
{
DateTime endOfPeriod = wts_.Dates[j];
int indexOfStart = (startOfPeriod==wts_.Dates[0]) ? 0 : pnlDates.IndexOf(startOfPeriod);
int indexOfEnd = pnlDates.IndexOf(endOfPeriod);
double pnlOverPeriod = eval.Daily.CumulativeReturnSeries[indexOfEnd] - eval.Daily.CumulativeReturnSeries[indexOfStart];
row.Add(new PnlPosPeriodRow(
getSide(wtsColumn[j-1]),
pnlDates[indexOfStart],
pnlDates[indexOfEnd],
pnlOverPeriod), false);
startOfPeriod = endOfPeriod;
}
}
int indStart = pnlDates.IndexOf(startOfPeriod);
int indEnd = pnlDates.Count-1;
// need to add int last item
row.Add(new PnlPosPeriodRow(
getSide(wtsColumn[wtsColumn.Length - 1]),
pnlDates[indStart],
pnlDates[indEnd],
eval.Daily.CumulativeReturnSeries[indEnd] - eval.Daily.CumulativeReturnSeries[indStart]), true);
structure_.Add(row);
}
}