Here are the examples of the csharp api System.Collections.ObjectModel.Collection.Clear() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2284 Examples
19
View Source File : ChartXY.cs
License : MIT License
Project Creator : a1xd
License : MIT License
Project Creator : a1xd
public static void SetupChart(Chart chart)
{
ChartArea area = chart.ChartAreas[0];
Legend legend = chart.Legends[0];
replacedle replacedle = chart.replacedles[0];
area.AxisX.RoundAxisValues();
area.AxisX.ScaleView.Zoomable = true;
area.AxisY.ScaleView.Zoomable = true;
area.AxisY.ScaleView.MinSize = 0.01;
area.AxisY.ScaleView.SmallScrollSize = 0.001;
area.AxisX.LabelStyle.Format = "0.##";
area.AxisY.LabelStyle.Format = "0.##";
area.CursorY.Interval = 0.001;
area.CursorX.AutoScroll = true;
area.CursorY.AutoScroll = true;
area.CursorX.IsUserSelectionEnabled = true;
area.CursorY.IsUserSelectionEnabled = true;
area.CursorX.IsUserEnabled = true;
area.CursorY.IsUserEnabled = true;
chart.Series[1].Points.Clear();
chart.Series[1].Points.AddXY(0, 0);
area.AxisX.replacedleFont = new System.Drawing.Font(area.AxisX.replacedleFont.Name, Constants.ChartAxisFontSize, System.Drawing.FontStyle.Bold);
area.AxisY.replacedleFont = area.AxisX.replacedleFont;
replacedle.Font = new System.Drawing.Font(replacedle.Font.Name, Constants.ChartreplacedleFontSize, System.Drawing.FontStyle.Italic | System.Drawing.FontStyle.Bold);
chart.Series[0].BorderWidth = Constants.ChartSeriesLineWidth;
chart.Series[0].MarkerSize = Constants.ChartSeriesLineWidth * 2;
chart.Series[2].BorderWidth = Constants.ChartSeriesLineWidth;
chart.Series[2].MarkerSize = Constants.ChartSeriesLineWidth * 2;
for (int i = 1; i < chart.Series.Count; i += 2)
{
chart.Series[i].MarkerSize = Constants.DotMarkerSize;
}
area.AxisX.MinorGrid.Enabled = true;
area.AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
replacedle.Alignment = System.Drawing.ContentAlignment.MiddleCenter;
legend.DockedToChartArea = area.Name;
legend.LegendStyle = LegendStyle.Row;
legend.IsTextAutoFit = true;
legend.MaximumAutoSize = 100;
legend.AutoFitMinFontSize = 5;
ElementPosition legendPosNew = DefaultLegendPosition;
legend.Position = legendPosNew;
System.Drawing.Color bgTrans = System.Drawing.Color.Transparent;
area.BackColor = bgTrans;
legend.BackColor = bgTrans;
}
19
View Source File : ChartXY.cs
License : MIT License
Project Creator : a1xd
License : MIT License
Project Creator : a1xd
public void ClearLastValue()
{
ChartX.Series[1].Points.Clear();
ChartY.Series[1].Points.Clear();
}
19
View Source File : ChartXY.cs
License : MIT License
Project Creator : a1xd
License : MIT License
Project Creator : a1xd
public void Bind(IDictionary data)
{
ChartX.Series[0].Points.DataBindXY(data.Keys, data.Values);
ChartX.Series[2].IsVisibleInLegend = false;
ChartX.Series[2].Points.Clear();
}
19
View Source File : ChartXY.cs
License : MIT License
Project Creator : a1xd
License : MIT License
Project Creator : a1xd
public void BindXY(IDictionary dataX, IDictionary dataY)
{
ChartX.Series[0].Points.DataBindXY(dataX.Keys, dataX.Values);
ChartY.Series[0].Points.DataBindXY(dataY.Keys, dataY.Values);
ChartX.Series[2].IsVisibleInLegend = false;
ChartX.Series[2].Points.Clear();
}
19
View Source File : ChartXY.cs
License : MIT License
Project Creator : a1xd
License : MIT License
Project Creator : a1xd
public void ClearSecondDots()
{
ChartX.Series[3].Points.Clear();
}
19
View Source File : DigitalAnalyzerExampleViewModel.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private async Task AddChannels(int digitalChannelsCount, int replacedogChannelsCount)
{
List<byte[]> digitalChannels = new List<byte[]>();
List<float[]> replacedogChannels = new List<float[]>();
// Force GC to free memory
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
try
{
// Allocate memory first
await Task.Run(() =>
{
for (var i = 0; i < digitalChannelsCount; i++)
{
var newArray = new byte[SelectedPointCount];
digitalChannels.Add(newArray);
}
for (var i = 0; i < replacedogChannelsCount; i++)
{
var newArray = new float[SelectedPointCount];
replacedogChannels.Add(newArray);
}
});
// Generate random data and fill channels
await GenerateData(digitalChannels, replacedogChannels);
}
catch (OutOfMemoryException)
{
await Application.Current.Dispatcher.BeginInvoke(new Action(() => ChannelViewModels.Clear()));
MessageBox.Show(string.Format($"There is not enough RAM memory to allocate {SelectedChannelCount} channels with {SelectedPointCount} points each. Please select less channels or less points and try again."));
}
finally
{
OnPropertyChanged(nameof(IsEmpty));
OnPropertyChanged(nameof(ChannelViewModels));
OnPropertyChanged(nameof(SelectedPointCount));
OnPropertyChanged(nameof(TotalPoints));
OnPropertyChanged(nameof(XRange));
IsLoading = false;
}
}
19
View Source File : FifoBillionPointsPageViewModel.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void OnStop()
{
if (IsStopped) return;
lock (Series)
{
_timer.Stop();
IsStopped = true;
Series.ForEachDo(x => x.DataSeries.FifoCapacity = 1);
Series.Clear();
}
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
}
19
View Source File : DigitalAnalyzerExampleViewModel.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private async Task AddChannels(int digitalChannelsCount)
{
var digitalChannels = new List<byte[]>();
// Force GC to free memory
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
try
{
// Allocate memory first
await Task.Run(() =>
{
for (var i = 0; i < digitalChannelsCount; i++)
{
var newArray = new byte[SelectedPointCount];
digitalChannels.Add(newArray);
}
});
// Generate random data and fill channels
await GenerateData(digitalChannels);
}
catch (OutOfMemoryException)
{
await Application.Current.Dispatcher.BeginInvoke(new Action(() => ChannelViewModels.Clear()));
MessageBox.Show(string.Format($"There is not enough RAM memory to allocate {SelectedChannelCount} channels with {SelectedPointCount} points each. Please select less channels or less points and try again."));
}
finally
{
OnPropertyChanged(nameof(IsEmpty));
OnPropertyChanged(nameof(ChannelViewModels));
OnPropertyChanged(nameof(SelectedPointCount));
OnPropertyChanged(nameof(TotalPoints));
OnPropertyChanged(nameof(XRange));
IsLoading = false;
}
}
19
View Source File : MainViewModel.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void OnStop()
{
lock (Series)
{
_timer.Stop();
IsStopped = true;
Series.ForEachDo(x => x.DataSeries.FifoCapacity = 1);
Series.Clear();
}
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
}
19
View Source File : DataGridExtension.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private static void OnDataGridColumnsPropertyChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
if (d.GetType() == typeof(DataGrid))
{
DataGrid myGrid = d as DataGrid;
var Columns = (ObservableCollection<DataGridColumn>)e.NewValue;
if (Columns != null)
{
myGrid.Columns.Clear();
if (Columns != null && Columns.Count > 0)
{
foreach (DataGridColumn dataGridColumn in Columns)
{
myGrid.Columns.Add(dataGridColumn);
}
}
Columns.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs args)
{
if (args.NewItems != null)
{
foreach (DataGridColumn column in args.NewItems.Cast<DataGridColumn>())
{
myGrid.Columns.Add(column);
}
}
if (args.OldItems != null)
{
foreach (DataGridColumn column in args.OldItems.Cast<DataGridColumn>())
{
myGrid.Columns.Remove(column);
}
}
};
}
}
}
19
View Source File : BindableDownloader.cs
License : MIT License
Project Creator : Accelerider
License : MIT License
Project Creator : Accelerider
private void SubscribesDownloader(ITransferInfo<DownloadContext> downloader, Dispatcher dispatcher)
{
var observable = dispatcher != null ? downloader.ObserveOn(dispatcher) : downloader;
// Updates the Status.
observable
.Where(item => Status != item.Status)
.Subscribe(item => Status = item.Status);
// Initializes this BindableDownloader.
observable
.Distinct(item => item.Status)
.Where(item => item.Status == TransferStatus.Transferring)
.Subscribe(item =>
{
Progress.TotalSize = downloader.GetTotalSize();
var notifiers = downloader.BlockContexts.Values.Select(blockItem =>
{
var block = new BindableBlockTransferItem(blockItem.Offset);
block.Progress.CompletedSize = blockItem.CompletedSize;
block.Progress.TotalSize = blockItem.TotalSize;
return block;
});
lock (_lockObject)
{
BlockDownloadItems.Clear();
BlockDownloadItems.AddRange(notifiers);
}
});
// Updates the progress.
observable
.Where(item => item.Status == TransferStatus.Transferring)
.Sample(TimeSpan.FromMilliseconds(SampleIntervalBasedMilliseconds))
.Subscribe(item =>
{
Progress.CompletedSize = downloader.GetCompletedSize();
lock (_lockObject)
{
var block = BlockDownloadItems.FirstOrDefault(blockItem => blockItem.Offset == item.Offset);
if (block != null)
{
block.Progress.CompletedSize += item.Bytes;
}
}
});
}
19
View Source File : DatabasePerfTest.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
private void Run(Session session, int biotasPerTest)
{
CommandHandlerHelper.WriteOutputInfo(session, $"Starting Shard Database Performance Tests.\nBiotas per test: {biotasPerTest}\nThis may take several minutes to complete...\nCurrent database queue count: {DatabaseManager.Shard.QueueCount}");
// Get the current queue wait time
bool responseReceived = false;
DatabaseManager.Shard.GetCurrentQueueWaitTime(result =>
{
CommandHandlerHelper.WriteOutputInfo(session, $"Current database queue wait time: {result.TotalMilliseconds:N0} ms");
responseReceived = true;
});
while (!responseReceived)
Thread.Sleep(1);
// Generate Individual WorldObjects
var biotas = new Collection<(Biota biota, ReaderWriterLockSlim rwLock)>();
for (int i = 0; i < biotasPerTest; i++)
{
var worldObject = WorldObjectFactory.CreateNewWorldObject(testWeenies[i % testWeenies.Count]);
// TODO fix this
//biotas.Add((worldObject.Biota, worldObject.BiotaDatabaseLock));
}
// Add biotasPerTest biotas individually
long trueResults = 0;
long falseResults = 0;
var startTime = DateTime.UtcNow;
var initialQueueWaitTime = TimeSpan.Zero;
var totalQueryExecutionTime = TimeSpan.Zero;
foreach (var biota in biotas)
{
/* todo
DatabaseManager.Shard.SaveBiota(biota.biota, biota.rwLock, result =>
{
if (result)
Interlocked.Increment(ref trueResults);
else
Interlocked.Increment(ref falseResults);
}, (queueWaitTime, queryExecutionTime) =>
{
if (initialQueueWaitTime == TimeSpan.Zero)
initialQueueWaitTime = queueWaitTime;
totalQueryExecutionTime += queryExecutionTime;
});*/
}
while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < biotas.Count)
Thread.Sleep(1);
var endTime = DateTime.UtcNow;
ReportResult(session, "individual add", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);
// Update biotasPerTest biotas individually
if (session == null || SessionIsStillInWorld(session))
{
ModifyBiotas(biotas);
trueResults = 0;
falseResults = 0;
startTime = DateTime.UtcNow;
initialQueueWaitTime = TimeSpan.Zero;
totalQueryExecutionTime = TimeSpan.Zero;
foreach (var biota in biotas)
{
/* todo
DatabaseManager.Shard.SaveBiota(biota.biota, biota.rwLock, result =>
{
if (result)
Interlocked.Increment(ref trueResults);
else
Interlocked.Increment(ref falseResults);
}, (queueWaitTime, queryExecutionTime) =>
{
if (initialQueueWaitTime == TimeSpan.Zero)
initialQueueWaitTime = queueWaitTime;
totalQueryExecutionTime += queryExecutionTime;
});*/
}
while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < biotas.Count)
Thread.Sleep(1);
endTime = DateTime.UtcNow;
ReportResult(session, "individual save", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);
}
// Delete biotasPerTest biotas individually
trueResults = 0;
falseResults = 0;
startTime = DateTime.UtcNow;
initialQueueWaitTime = TimeSpan.Zero;
totalQueryExecutionTime = TimeSpan.Zero;
foreach (var biota in biotas)
{
DatabaseManager.Shard.RemoveBiota(biota.biota.Id, result =>
{
if (result)
Interlocked.Increment(ref trueResults);
else
Interlocked.Increment(ref falseResults);
}, (queueWaitTime, queryExecutionTime) =>
{
if (initialQueueWaitTime == TimeSpan.Zero)
initialQueueWaitTime = queueWaitTime;
totalQueryExecutionTime += queryExecutionTime;
});
}
while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < biotas.Count)
Thread.Sleep(1);
endTime = DateTime.UtcNow;
ReportResult(session, "individual remove", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);
if (session != null && !SessionIsStillInWorld(session))
return;
// Generate Bulk WorldObjects
biotas.Clear();
for (int i = 0; i < biotasPerTest; i++)
{
var worldObject = WorldObjectFactory.CreateNewWorldObject(testWeenies[i % testWeenies.Count]);
// TODO fix this
//biotas.Add((worldObject.Biota, worldObject.BiotaDatabaseLock));
}
// Add biotasPerTest biotas in bulk
trueResults = 0;
falseResults = 0;
startTime = DateTime.UtcNow;
initialQueueWaitTime = TimeSpan.Zero;
totalQueryExecutionTime = TimeSpan.Zero;
/* todo
DatabaseManager.Shard.SaveBiotasInParallel(biotas, result =>
{
if (result)
Interlocked.Increment(ref trueResults);
else
Interlocked.Increment(ref falseResults);
}, (queueWaitTime, queryExecutionTime) =>
{
if (initialQueueWaitTime == TimeSpan.Zero)
initialQueueWaitTime = queueWaitTime;
totalQueryExecutionTime += queryExecutionTime;
});*/
while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < 1)
Thread.Sleep(1);
endTime = DateTime.UtcNow;
ReportResult(session, "bulk add", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);
// Update biotasPerTest biotas in bulk
if (session == null || SessionIsStillInWorld(session))
{
ModifyBiotas(biotas);
trueResults = 0;
falseResults = 0;
startTime = DateTime.UtcNow;
initialQueueWaitTime = TimeSpan.Zero;
totalQueryExecutionTime = TimeSpan.Zero;
/* todo
DatabaseManager.Shard.SaveBiotasInParallel(biotas, result =>
{
if (result)
Interlocked.Increment(ref trueResults);
else
Interlocked.Increment(ref falseResults);
}, (queueWaitTime, queryExecutionTime) =>
{
if (initialQueueWaitTime == TimeSpan.Zero)
initialQueueWaitTime = queueWaitTime;
totalQueryExecutionTime += queryExecutionTime;
});*/
while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < 1)
Thread.Sleep(1);
endTime = DateTime.UtcNow;
ReportResult(session, "bulk save", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);
}
// Delete biotasPerTest biotas in bulk
trueResults = 0;
falseResults = 0;
startTime = DateTime.UtcNow;
initialQueueWaitTime = TimeSpan.Zero;
totalQueryExecutionTime = TimeSpan.Zero;
var ids = biotas.Select(r => r.biota.Id).ToList();
DatabaseManager.Shard.RemoveBiotasInParallel(ids, result =>
{
if (result)
Interlocked.Increment(ref trueResults);
else
Interlocked.Increment(ref falseResults);
}, (queueWaitTime, queryExecutionTime) =>
{
if (initialQueueWaitTime == TimeSpan.Zero)
initialQueueWaitTime = queueWaitTime;
totalQueryExecutionTime += queryExecutionTime;
});
while (Interlocked.Read(ref trueResults) + Interlocked.Read(ref falseResults) < 1)
Thread.Sleep(1);
endTime = DateTime.UtcNow;
ReportResult(session, "bulk remove", biotasPerTest, (endTime - startTime), initialQueueWaitTime, totalQueryExecutionTime, trueResults, falseResults);
if (session != null && !SessionIsStillInWorld(session))
return;
CommandHandlerHelper.WriteOutputInfo(session, "Database Performance Tests Completed");
}
19
View Source File : FeaturesListViewModel.cs
License : Microsoft Public License
Project Creator : achimismaili
License : Microsoft Public License
Project Creator : achimismaili
public void Load()
{
_eventAggregator.GetEvent<SetStatusBarEvent>()
.Publish("Loading Feature Definitions ...");
if (!_backgroundWorker.IsBusy)
{
Features.Clear();
_backgroundWorker.RunWorkerAsync();
}
return;
}
19
View Source File : LocationsListViewModel.cs
License : Microsoft Public License
Project Creator : achimismaili
License : Microsoft Public License
Project Creator : achimismaili
public void Load()
{
if (!_backgroundWorker.IsBusy)
{
Locations.Clear();
_backgroundWorker.RunWorkerAsync();
}
return;
}
19
View Source File : ExportManager.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
internal void LoadConfigFile()
{
FileNameTypes.Clear();
//// Load config from project if it exists
var settingsOne = Doc.ProjectInformation.LookupParameter("Primary SCexport Settings Name");
var formatOne = Doc.ProjectInformation.LookupParameter("Primary SCexport Settings Format");
var pdfSettingsOne = Doc.ProjectInformation.LookupParameter("Primary SCexport PDF Settings Name");
var dwgSettingsOne = Doc.ProjectInformation.LookupParameter("Primary SCexport DWG Settings Name");
var settingsTwo = Doc.ProjectInformation.LookupParameter("Secondary SCexport Settings Name");
var formatTwo = Doc.ProjectInformation.LookupParameter("Secondary SCexport Settings Format");
var pdfSettingsTwo = Doc.ProjectInformation.LookupParameter("Secondary SCexport PDF Settings Name");
var dwgSettingsTwo = Doc.ProjectInformation.LookupParameter("Secondary SCexport DWG Settings Name");
if (settingsOne != null && formatOne != null)
{
var name = new SegmentedSheetName();
name.Name = settingsOne.replacedtring();
name.NameFormat = formatOne.replacedtring();
FileNameTypes.Add(name);
}
if (settingsTwo != null && formatTwo != null)
{
var name = new SegmentedSheetName();
name.Name = settingsTwo.replacedtring();
name.NameFormat = formatTwo.replacedtring();
FileNameTypes.Add(name);
}
//// Load config settings from file if available
var config = GetConfigFileName(Doc);
var b = ImportXMLinfo(config);
/// Set a default config if none are found
if (!b || FileNameTypes.Count <= 0)
{
var name = new SegmentedSheetName();
name.Name = "YYYYMMDD-AD-NNN";
name.NameFormat = "$projectNumber-$sheetNumber[$sheetRevision] - $sheetDescription";
#if REVIT2022
name.PDFExportOptions = CreateDefaultPDFExportOptions(name.NameFormat, Doc);
name.DWGExportOptions = name.PDFExportOptions;
#endif
FileNameTypes.Add(name);
FileNameScheme = name;
FileNameScheme = FileNameTypes[0];
} else
{
FileNameScheme = FileNameTypes[0];
}
}
19
View Source File : ExportManager.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
internal void PopulateSheets(ObservableCollection<ExportSheet> s)
{
s.Clear();
using (var collector = new FilteredElementCollector(Doc))
{
collector.OfCategory(BuiltInCategory.OST_Sheets);
collector.OfClreplaced(typeof(ViewSheet));
foreach (var element in collector)
{
var v = (ViewSheet)element;
var scxSheet = new ExportSheet(v, Doc, FileNameTypes[0], VerifyOnStartup, this);
s.Add(scxSheet);
}
}
}
19
View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
private void OnClearAllClick(object sender, RoutedEventArgs e) {
people.Clear();
}
19
View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
private void OnResetClick(object sender, RoutedEventArgs e) {
people.Clear();
foreach (var person in People.All)
people.Add(person);
}
19
View Source File : Settings.cs
License : MIT License
Project Creator : adlez27
License : MIT License
Project Creator : adlez27
public void LoadRecList()
{
if (init && File.Exists(RecListFile))
{
RecList.Clear();
HashSet<string> uniqueStrings = new HashSet<string>();
Encoding e;
if (ReadUnicode)
{
e = Encoding.UTF8;
}
else
{
e = CodePagesEncodingProvider.Instance.GetEncoding(932);
}
var ext = Path.GetExtension(RecListFile);
if (ext == ".txt")
{
if (Path.GetFileName(RecListFile) == "OREMO-comment.txt")
{
var rawText = File.ReadAllLines(RecListFile, e);
foreach(string rawLine in rawText)
{
var line = rawLine.Split("\t");
if (!uniqueStrings.Contains(line[0]))
{
RecList.Add(new RecLisreplacedem(this, line[0], line[1]));
uniqueStrings.Add(line[0]);
}
}
}
else
{
string[] textArr;
if (SplitWhitespace)
{
var rawText = File.ReadAllText(RecListFile, e);
rawText = Regex.Replace(rawText, @"\s{2,}", " ");
textArr = Regex.Split(rawText, @"\s");
}
else
{
textArr = File.ReadAllLines(RecListFile, e);
}
foreach (string line in textArr)
{
if (!uniqueStrings.Contains(line))
{
RecList.Add(new RecLisreplacedem(this, line));
uniqueStrings.Add(line);
}
}
}
}
else if (ext == ".arl")
{
var rawText = File.ReadAllText(RecListFile, e);
var deserializer = new Deserializer();
var tempDict = deserializer.Deserialize<Dictionary<string, string>>(rawText);
foreach (var item in tempDict)
{
RecList.Add(new RecLisreplacedem(this, item.Key, item.Value));
}
}
else if (ext == ".csv")
{
using (TextFieldParser parser = new TextFieldParser(RecListFile))
{
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");
while (!parser.EndOfData)
{
string[] line = parser.ReadFields();
var text = line[0].Substring(0,line[0].Length - 4);
if (!uniqueStrings.Contains(text))
{
RecList.Add(new RecLisreplacedem(this, text, line[1]));
uniqueStrings.Add(text);
}
}
}
CopyIndex();
}
else if (ext == ".reclist")
{
var rawText = File.ReadAllText(RecListFile, e);
var deserializer = new Deserializer();
var reclist = deserializer.Deserialize<WCTReclist>(rawText);
foreach(var line in reclist.Files)
{
if (!uniqueStrings.Contains(line.Filename))
{
RecList.Add(new RecLisreplacedem(this, line.Filename, line.Description));
uniqueStrings.Add(line.Filename);
}
}
}
else if (ext == ".ust"){
var rawText = File.ReadAllLines(RecListFile, e);
foreach (var line in rawText)
{
if (line.StartsWith("Lyric="))
{
var lyric = line.Substring(6);
if (lyric != "R" && lyric != "r" && lyric != "" && !uniqueStrings.Contains(lyric))
{
RecList.Add(new RecLisreplacedem(this, lyric));
uniqueStrings.Add(lyric);
}
}
}
}
}
}
19
View Source File : Models.cs
License : MIT License
Project Creator : ADeltaX
License : MIT License
Project Creator : ADeltaX
public void RemoveDummyChild()
{
Children.Clear();
IsDummy = false;
}
19
View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : ADeltaX
License : MIT License
Project Creator : ADeltaX
private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
if (e.NewValue == e.OldValue)
return;
keyVals.Clear();
void PopulateListView(RegistryKey registryKey, RegistryHive registryBase)
{
if (registryKey.ValueCount > 0)
{
foreach (var keyval in registryKey.GetValueNames())
{
keyVals.Add(new KeyVal
{
Name = keyval,
DataTypeEnum = (DataTypeEnum)registryKey.GetValueType(keyval),
Data = registryKey.GetValueRaw(keyval),
Path = registryKey.Name,
Hive = registryBase
});
}
}
}
if (e.NewValue is RegistryKeyTreeView registryKeyTreeView)
{
RegistryKey currKey = registryKeyTreeView.AttachedHive.Root.OpenSubKey(registryKeyTreeView.Path);
if (currKey == null)
Debugger.Break();
currentPathTxt.Text = "Computer" + "\\" + registryKeyTreeView.Root.Name + "\\" + registryKeyTreeView.Path;
selectedIconImage.Source = registryKeyTreeView.ImageSource;
PopulateListView(currKey, registryKeyTreeView.AttachedHive);
}
else if (e.NewValue is RegistryHiveTreeView registryHiveTreeView)
{
RegistryKey currKey = registryHiveTreeView.AttachedHive.Root;
currentPathTxt.Text = "Computer" + "\\" + registryHiveTreeView.Name;
selectedIconImage.Source = new BitmapImage(new Uri("replacedets/RegistryIcon.png", UriKind.Relative));
PopulateListView(currKey, registryHiveTreeView.AttachedHive);
}
else
{
currentPathTxt.Text = "Computer";
selectedIconImage.Source = computerBitmap;
}
}
19
View Source File : MainPage.xaml.cs
License : MIT License
Project Creator : adenearnshaw
License : MIT License
Project Creator : adenearnshaw
private async Task RefreshShortcutsList()
{
var shortcuts = await CrossAppShortcuts.Current.GetShortcuts();
Device.BeginInvokeOnMainThread(() =>
{
Shortcuts.Clear();
foreach (var sc in shortcuts)
{
Shortcuts.Add(sc);
}
});
ShortcutsListView.IsRefreshing = false;
}
19
View Source File : Settings.cs
License : MIT License
Project Creator : adlez27
License : MIT License
Project Creator : adlez27
public void LoadSettings(string path)
{
ProjectFile = path;
var raw = File.ReadAllText(path);
var deserializer = new Deserializer();
var newSettings = deserializer.Deserialize<Settings>(raw);
recListFile = "List loaded from project file.";
LastLine = newSettings.LastLine;
DestinationFolder = newSettings.DestinationFolder;
AudioDriver = newSettings.AudioDriver;
AudioInputDevice = newSettings.AudioInputDevice;
AudioInputLevel = newSettings.AudioInputLevel;
AudioOutputDevice = newSettings.AudioOutputDevice;
AudioOutputLevel = newSettings.AudioOutputLevel;
FontSize = newSettings.FontSize;
WaveformEnabled = newSettings.WaveformEnabled;
WaveformColor = newSettings.WaveformColor;
recList.Clear();
foreach (RecLisreplacedem item in newSettings.RecList)
{
item.CreateAudio(this);
RecList.Add(item);
}
}
19
View Source File : CrmDataSourceView.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
private void InitializeParameters(out string fetchXml, out QueryByAttribute query)
{
// merge the select parameters
IOrderedDictionary parameters = QueryParameters.GetValues(_context, _owner);
fetchXml = GetNonNullOrEmpty(
parameters[_fetchXmlParameterName] as string,
_owner.FetchXml);
if (!string.IsNullOrEmpty(fetchXml))
{
IOrderedDictionary selectParameters = SelectParameters.GetValues(_context, _owner);
// apply select parameters replacement to the FetchXml
foreach (DictionaryEntry entry in selectParameters)
{
if (entry.Key != null)
{
string key = entry.Key.ToString().Trim();
if (!key.StartsWith("@"))
{
key = "@" + key;
}
string value = "{0}".FormatWith(entry.Value);
if (Owner.EncodeParametersEnabled)
{
value = AntiXssEncoder.XmlEncode(value);
}
fetchXml = Regex.Replace(fetchXml, key, value, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
}
}
}
// process the QueryByAttribute
query = null;
if (_owner.QueryByAttribute != null && !string.IsNullOrEmpty(_owner.QueryByAttribute.EnreplacedyName))
{
IOrderedDictionary selectParameters = SelectParameters.GetValues(_context, _owner);
query = new QueryByAttribute();
query.EnreplacedyName = LookupParameter(selectParameters, _owner.QueryByAttribute.EnreplacedyName);
query.Attributes.AddRange(CopyParameters(selectParameters, _owner.QueryByAttribute.Attributes));
query.Values.AddRange(CopyParameters(selectParameters, _owner.QueryByAttribute.Values));
if (_owner.QueryByAttribute.ColumnSet != null && _owner.QueryByAttribute.ColumnSet.Count > 0)
{
// specify individual columns to load
query.ColumnSet = new ColumnSet(CopyParameters(selectParameters, _owner.QueryByAttribute.ColumnSet));
}
else
{
// default to all columns
query.ColumnSet = new ColumnSet(true);
}
if (_owner.QueryByAttribute.Orders != null && _owner.QueryByAttribute.Orders.Count > 0)
{
for (int i = 0; i < _owner.QueryByAttribute.Orders.Count; ++i)
{
OrderExpression order = new OrderExpression();
order.AttributeName = LookupParameter(selectParameters, _owner.QueryByAttribute.Orders[i].Value);
string orderText = LookupParameter(selectParameters, _owner.QueryByAttribute.Orders[i].Text);
if (orderText.StartsWith("desc", StringComparison.InvariantCultureIgnoreCase))
{
order.OrderType = OrderType.Descending;
}
query.Orders.Add(order);
}
}
// merge the select parameters
string enreplacedyName = parameters[_enreplacedyNameParameterName] as string;
if (!string.IsNullOrEmpty(enreplacedyName))
{
query.EnreplacedyName = enreplacedyName;
}
// comma delimited
string attributes = parameters[_attributesParameterName] as string;
if (!string.IsNullOrEmpty(attributes))
{
query.Attributes.Clear();
query.Attributes.AddRange(attributes.Split(','));
}
// comma delimited
string values = parameters[_valuesParameterName] as string;
if (!string.IsNullOrEmpty(values))
{
query.Values.Clear();
query.Values.AddRange(values.Split(','));
}
// comma delimited
string columnSet = parameters[_columnSetParameterName] as string;
if (!string.IsNullOrEmpty(columnSet))
{
if (string.Compare(columnSet, _allColumnsParameterValue, StringComparison.InvariantCultureIgnoreCase) == 0)
{
query.ColumnSet = new ColumnSet(true);
}
else
{
string[] parts = columnSet.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length > 0)
{
for (int i = 0; i < parts.Length; i++)
{
parts[i] = parts[i].Trim();
}
query.ColumnSet.AddColumns(parts);
}
else
{
query.ColumnSet = new ColumnSet(true);
}
}
}
// comma delimited
string orders = parameters[_ordersParameterName] as string;
if (!string.IsNullOrEmpty(orders))
{
QueryByAttribute queryByAttribute = query;
AppendSortExpressionToQuery(orders, order => queryByAttribute.Orders.Add(order));
query = queryByAttribute;
}
// all remaining parameters are treated as key/value pairs
Dictionary<string, object> extendedParameters = new Dictionary<string, object>();
if (query.Attributes != null)
{
for (int i = 0; i < query.Attributes.Count; ++i)
{
extendedParameters[query.Attributes[i]] = query.Values[i];
}
}
bool changed = false;
foreach (string key in parameters.Keys)
{
// ignore special parameters
if (!Array.Exists(_keywords, delegate(string value) { return string.Compare(value, key, StringComparison.InvariantCultureIgnoreCase) == 0; }))
{
extendedParameters[key] = parameters[key];
changed = true;
}
}
if (changed)
{
query.Attributes.Clear();
query.Values.Clear();
int i = 0;
foreach (KeyValuePair<string, object> extendedParameter in extendedParameters)
{
query.Attributes[i] = extendedParameter.Key;
query.Values[i] = extendedParameter.Value;
++i;
}
}
}
}
19
View Source File : CrmDataSourceView.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
private void InitializeParameters(out string fetchXml, out QueryByAttribute query)
{
// merge the select parameters
IOrderedDictionary parameters = QueryParameters.GetValues(_context, _owner);
fetchXml = GetNonNullOrEmpty(
parameters[_fetchXmlParameterName] as string,
_owner.FetchXml);
if (!string.IsNullOrEmpty(fetchXml))
{
IOrderedDictionary selectParameters = SelectParameters.GetValues(_context, _owner);
// apply select parameters replacement to the FetchXml
foreach (DictionaryEntry entry in selectParameters)
{
if (entry.Key != null)
{
string key = entry.Key.ToString().Trim();
if (!key.StartsWith("@"))
{
key = "@" + key;
}
string value = "{0}".FormatWith(entry.Value);
if (Owner.EncodeParametersEnabled)
{
value = Encoder.XmlEncode(value);
}
fetchXml = Regex.Replace(fetchXml, key, value, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
}
}
}
// process the QueryByAttribute
query = null;
if (_owner.QueryByAttribute != null && !string.IsNullOrEmpty(_owner.QueryByAttribute.EnreplacedyName))
{
IOrderedDictionary selectParameters = SelectParameters.GetValues(_context, _owner);
query = new QueryByAttribute();
query.EnreplacedyName = LookupParameter(selectParameters, _owner.QueryByAttribute.EnreplacedyName);
query.Attributes.AddRange(CopyParameters(selectParameters, _owner.QueryByAttribute.Attributes));
query.Values.AddRange(CopyParameters(selectParameters, _owner.QueryByAttribute.Values));
if (_owner.QueryByAttribute.ColumnSet != null && _owner.QueryByAttribute.ColumnSet.Count > 0)
{
// specify individual columns to load
query.ColumnSet = new ColumnSet(CopyParameters(selectParameters, _owner.QueryByAttribute.ColumnSet));
}
else
{
// default to all columns
query.ColumnSet = new ColumnSet(true);
}
if (_owner.QueryByAttribute.Orders != null && _owner.QueryByAttribute.Orders.Count > 0)
{
for (int i = 0; i < _owner.QueryByAttribute.Orders.Count; ++i)
{
OrderExpression order = new OrderExpression();
order.AttributeName = LookupParameter(selectParameters, _owner.QueryByAttribute.Orders[i].Value);
string orderText = LookupParameter(selectParameters, _owner.QueryByAttribute.Orders[i].Text);
if (orderText.StartsWith("desc", StringComparison.InvariantCultureIgnoreCase))
{
order.OrderType = OrderType.Descending;
}
query.Orders.Add(order);
}
}
// merge the select parameters
string enreplacedyName = parameters[_enreplacedyNameParameterName] as string;
if (!string.IsNullOrEmpty(enreplacedyName))
{
query.EnreplacedyName = enreplacedyName;
}
// comma delimited
string attributes = parameters[_attributesParameterName] as string;
if (!string.IsNullOrEmpty(attributes))
{
query.Attributes.Clear();
query.Attributes.AddRange(attributes.Split(','));
}
// comma delimited
string values = parameters[_valuesParameterName] as string;
if (!string.IsNullOrEmpty(values))
{
query.Values.Clear();
query.Values.AddRange(values.Split(','));
}
// comma delimited
string columnSet = parameters[_columnSetParameterName] as string;
if (!string.IsNullOrEmpty(columnSet))
{
if (string.Compare(columnSet, _allColumnsParameterValue, StringComparison.InvariantCultureIgnoreCase) == 0)
{
query.ColumnSet = new ColumnSet(true);
}
else
{
string[] parts = columnSet.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length > 0)
{
for (int i = 0; i < parts.Length; i++)
{
parts[i] = parts[i].Trim();
}
query.ColumnSet.AddColumns(parts);
}
else
{
query.ColumnSet = new ColumnSet(true);
}
}
}
// comma delimited
string orders = parameters[_ordersParameterName] as string;
if (!string.IsNullOrEmpty(orders))
{
QueryByAttribute queryByAttribute = query;
AppendSortExpressionToQuery(orders, order => queryByAttribute.Orders.Add(order));
query = queryByAttribute;
}
// all remaining parameters are treated as key/value pairs
Dictionary<string, object> extendedParameters = new Dictionary<string, object>();
if (query.Attributes != null)
{
for (int i = 0; i < query.Attributes.Count; ++i)
{
extendedParameters[query.Attributes[i]] = query.Values[i];
}
}
bool changed = false;
foreach (string key in parameters.Keys)
{
// ignore special parameters
if (!Array.Exists(_keywords, delegate(string value) { return string.Compare(value, key, StringComparison.InvariantCultureIgnoreCase) == 0; }))
{
extendedParameters[key] = parameters[key];
changed = true;
}
}
if (changed)
{
query.Attributes.Clear();
query.Values.Clear();
int i = 0;
foreach (KeyValuePair<string, object> extendedParameter in extendedParameters)
{
query.Attributes[i] = extendedParameter.Key;
query.Values[i] = extendedParameter.Value;
++i;
}
}
}
}
19
View Source File : AduDatePicker.cs
License : GNU General Public License v3.0
Project Creator : aduskin
License : GNU General Public License v3.0
Project Creator : aduskin
private void ClearSelectedDates()
{
this.SelectedDates.Clear();
this.SelectedDateStart = null;
this.SelectedDateEnd = null;
this.SelectedDateTime = null;
if (this.PART_Calendar != null)
{
this.SelectedDate = null;
this.PART_Calendar.SelectedDate = null;
this.PART_Calendar.SelectedDates.Clear();
}
if (this.PART_Calendar_Second != null)
{
this.SelectedDate = null;
this.PART_Calendar_Second.SelectedDate = null;
this.PART_Calendar_Second.SelectedDates.Clear();
}
}
19
View Source File : RatingBar.cs
License : GNU General Public License v3.0
Project Creator : aduskin
License : GNU General Public License v3.0
Project Creator : aduskin
private void CreateRatingButtons()
{
this.RatingButtonsInternal.Clear();
for (var i = this.Minimum; i <= this.Maximum; i++)
{
RatingBarButton button = new RatingBarButton()
{
Content = i,
Value = i,
IsSelected = i <= Math.Ceiling(this.Value),
IsHalf = this.IsInt(this.Value) ? false : Math.Ceiling(this.Value) == i,
ContentTemplate = this.ValueItemTemplate,
Style = this.ValueItemStyle
};
button.ItemMouseEnter += (o, n) =>
{
this.mOldValue = this.Value;
this.Value = button.Value;
this.mIsConfirm = false;
};
button.ItemMouseLeave += (o, n) =>
{
if (!this.mIsConfirm)
{
this.Value = this.mOldValue;
this.mIsConfirm = false;
}
};
this.RatingButtonsInternal.Add(button);
}
this.RatingButtons = this.RatingButtonsInternal;
}
19
View Source File : AduDatePicker.cs
License : GNU General Public License v3.0
Project Creator : aduskin
License : GNU General Public License v3.0
Project Creator : aduskin
private void HandleSingleDateRange(AduCalendar calendar)
{
DateTime? dateTime = calendar.SelectedDate;
if (this.SelectedDateStart != null && this.SelectedDateEnd != null)
{
this.SelectedDates.Clear();
this.PART_Calendar.SelectedDates.Clear();
this.PART_Calendar_Second.SelectedDates.Clear();
this.SelectedDateStart = null;
this.SelectedDateEnd = null;
this.PART_Calendar.SelectedDate = null;
this.PART_Calendar_Second.SelectedDate = null;
}
if (this.SelectedDateStart == null)
{
this.SelectedDateStart = dateTime;
calendar.SelectedDate = dateTime;
}
else if (calendar.SelectedDate < this.SelectedDateStart)
{
this.SelectedDates.Clear();
this.PART_Calendar.SelectedDates.Clear();
this.PART_Calendar_Second.SelectedDates.Clear();
this.SelectedDateStart = dateTime;
this.PART_Calendar.SelectedDate = null;
this.PART_Calendar_Second.SelectedDate = null;
calendar.SelectedDate = dateTime;
}
else
{
this.SelectedDateEnd = dateTime;
this.SetSelectedDates(this.SelectedDateStart, this.SelectedDateEnd);
this.SetRangeDateToTextBox(this.SelectedDateStart, this.SelectedDateEnd);
}
}
19
View Source File : AduDatePicker.cs
License : GNU General Public License v3.0
Project Creator : aduskin
License : GNU General Public License v3.0
Project Creator : aduskin
private void PART_Btn_AnWeekAgo_Click(object sender, RoutedEventArgs e)
{
this.SelectedDates.Clear();
this.PART_Calendar.SelectedDates.Clear();
this.PART_Calendar_Second.SelectedDates.Clear();
this.SelectedDateStart = null;
this.SelectedDateEnd = null;
this.PART_Calendar.SelectedDate = null;
this.PART_Calendar_Second.SelectedDate = null;
this.SetSelectedDate(DateTime.Today.AddDays(-7));
}
19
View Source File : AduDatePicker.cs
License : GNU General Public License v3.0
Project Creator : aduskin
License : GNU General Public License v3.0
Project Creator : aduskin
private void SetSelectedDates(DateTime? selectedDateStart, DateTime? selectedDateEnd)
{
this.SelectedDates.Clear();
DateTime? dtTemp = selectedDateStart;
while (dtTemp <= selectedDateEnd)
{
this.SelectedDates.Add(dtTemp.Value);
dtTemp = dtTemp.Value.AddDays(1);
}
this.HandleSelectedDatesChanged();
if (this.PART_TextBox_New != null && selectedDateStart.HasValue && selectedDateEnd.HasValue)
{
this.SetRangeDateToTextBox(selectedDateStart, selectedDateEnd);
}
}
19
View Source File : FileExplorerViewModel.cs
License : MIT License
Project Creator : afxw
License : MIT License
Project Creator : afxw
private void HandleGetDirectory(IPacket packet)
{
Application.Current.Dispatcher.Invoke(() =>
{
Files.Clear();
});
var previousDirectory = CurrentDirectory;
var directoryResponse = (GetDirectoryResponsePacket)packet;
CurrentDirectory = new FileSystemEntry(directoryResponse.Name, directoryResponse.Path, 0, FileType.Directory);
if (previousDirectory != null)
{
BackHistory.Push(previousDirectory);
}
OnPropertyChanged(() => CanGoForward);
OnPropertyChanged(() => CanGoBackward);
for (int i = 0; i < directoryResponse.Folders.Length; i++)
{
Application.Current.Dispatcher.Invoke(() =>
{
Files.Add(new FileSystemEntry
(
directoryResponse.Folders[i],
System.IO.Path.Combine(CurrentDirectory.Path, directoryResponse.Folders[i]),
0,
FileType.Directory
));
});
}
for (int i = 0; i < directoryResponse.Files.Length; i++)
{
Application.Current.Dispatcher.Invoke(() =>
{
Files.Add(new FileSystemEntry
(
directoryResponse.Files[i],
System.IO.Path.Combine(CurrentDirectory.Path, directoryResponse.Files[i]),
directoryResponse.FileSizes[i],
FileType.File
));
});
}
}
19
View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : AFei19911012
License : MIT License
Project Creator : AFei19911012
private void ButtonAscending_OnClick(object sender, RoutedEventArgs e)
{
if (sender is ToggleButton button && button.Tag is ItemsControl itemsControl)
{
if (button.IsChecked == true)
{
itemsControl.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
}
else
{
itemsControl.Items.SortDescriptions.Clear();
}
}
}
19
View Source File : MainViewModel.cs
License : MIT License
Project Creator : ahopper
License : MIT License
Project Creator : ahopper
public void CreateSelectedIcons()
{
// convert StyleSourceCode to a collection of drawings
try
{
SelectedIcons.Clear();
if (!String.IsNullOrEmpty(StyleSourceCode))
{
var xaml = "<Styles xmlns=\"https://github.com/avaloniaui\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" >"
+ StyleSourceCode
+ "</Styles>";
loadIcons(new MemoryStream(Encoding.UTF8.GetBytes(xaml)), SelectedIcons);
}
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
19
View Source File : ItemsViewModel.cs
License : MIT License
Project Creator : aimore
License : MIT License
Project Creator : aimore
async Task ExecuteLoadItemsCommand()
{
if (IsBusy)
return;
IsBusy = true;
try
{
Items.Clear();
var items = await DataStore.GereplacedemsAsync(true);
foreach (var item in items)
{
Items.Add(item);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
finally
{
IsBusy = false;
}
}
19
View Source File : DataGridEx.cs
License : MIT License
Project Creator : AkiniKites
License : MIT License
Project Creator : AkiniKites
private void CustomSort(DataGridColumn column)
{
var path = column.SortMemberPath;
if (String.IsNullOrEmpty(path))
return;
var newSort = (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift;
var direction = column.SortDirection == ListSortDirection.Ascending ?
ListSortDirection.Descending : ListSortDirection.Ascending;
var sort = new SortDescription(path, direction);
try
{
using (Items.DeferRefresh())
{
if (newSort)
{
Items.SortDescriptions.Clear();
Items.SortDescriptions.Add(sort);
ApplyDefaultSorts();
}
else
{
var existingSortIdx = 0;
//check existing non-default sorts to see if we already sorted on this column
for (int i = 0; i < Items.SortDescriptions.Count - _defaultSorts.Count; i++)
{
if (Items.SortDescriptions[i].PropertyName == path)
{
existingSortIdx = i;
break;
}
}
if (existingSortIdx >= 0)
Items.SortDescriptions[existingSortIdx] = sort;
else
{
//insert before all the default sorts
Items.SortDescriptions.Insert(Items.SortDescriptions.Count - 1 - _defaultSorts.Count, sort);
}
}
}
column.SortDirection = direction;
}
catch (InvalidOperationException ex)
{
Items.SortDescriptions.Clear();
}
}
19
View Source File : NpcPlugin.cs
License : MIT License
Project Creator : AkiniKites
License : MIT License
Project Creator : AkiniKites
public override async Task Initialize()
{
ResetSelected.Enabled = false;
IoC.Notif.ShowUnknownProgress();
Models.Clear();
await UpdateModelList(x => Models.Add(x));
Npcs.Clear();
await UpdateModelList(x => Npcs.Add(new ValuePair<Model>(x, x)));
Npcs.Add(AllNpcStub);
LoadSettings();
}
19
View Source File : ObservableCollectionExtensions.cs
License : Apache License 2.0
Project Creator : AKruimink
License : Apache License 2.0
Project Creator : AKruimink
public static void UpdateCollection<T>(this ObservableCollection<T> collection, IList<T> newCollection)
{
if (newCollection == null || newCollection.Count == 0)
{
collection.Clear();
return;
}
var i = 0;
foreach (var item in newCollection)
{
if (collection.Count > i)
{
var itemIndex = collection.IndexOf(collection.Where(i => Comparer<T>.Default.Compare(i, item) == 0).FirstOrDefault());
if (itemIndex < 0)
{
// Item doesn't exist
collection.Insert(i, item);
}
else if (itemIndex > i || itemIndex < i)
{
// Item exists, but has moved up or down
collection.Move(itemIndex, i);
}
else
{
if ((!collection[i]?.Equals(item)) ?? false)
{
// Item has changed, replace it
if (item != null)
{
foreach (var sourceProperty in item.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
var targetProperty = collection[i]?.GetType().GetProperty(sourceProperty.Name);
if (targetProperty != null && targetProperty.CanWrite)
{
targetProperty.SetValue(collection[i], sourceProperty.GetValue(item, null), null);
}
}
}
}
}
}
else
{
// Item doesn't exist
collection.Add(item);
}
i++;
}
// Remove all old items
while (collection.Count > newCollection.Count)
{
collection.RemoveAt(i);
}
}
19
View Source File : ContentsBrowser.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
public void Load(string path, bool forced = false)
{
if (!Folder && !forced) return;
if (Parent.Container != null)
{
Parent.Path = path;
int x;
Parent.Container.Disable();
var d = new DirectoryInfo(path); //replaceduming Test is your Folder
var files = d.GetFiles(); //Getting Text files
var dirs = d.GetDirectories();
x = files.Length + dirs.Length;
Parent.Items.Clear();
if (x == 0)
{
Parent.Container.Enable();
Parent.Container.UpdateFoldersTree();
return;
}
foreach (var dirr in dirs)
Task.Factory.StartNew(() =>
{
Dispatcher.BeginInvoke(DispatcherPriority.Input,
new Action(() =>
{
if (Parent.Path == Directory.GetParent(dirr.FullName).FullName)
Parent.AddFolder(dirr.Name, dirr.Extension, dirr.FullName);
if (x == Parent.Items.Count)
{
Parent.Container.Enable();
Parent.Container.UpdateFoldersTree();
}
}));
});
foreach (var file in files)
Task.Factory.StartNew(() =>
{
Dispatcher.BeginInvoke(DispatcherPriority.Input,
new Action(() =>
{
if (Parent.Path == Directory.GetParent(file.FullName).FullName)
Parent.AddFile(file.Name, file.Extension, file.FullName);
if (x == Parent.Items.Count)
{
Parent.Container.Enable();
Parent.Container.UpdateFoldersTree();
}
}));
});
}
}
19
View Source File : NodesTree.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
private void ClearAll()
{
if (VariablesTreeRootIndex() != -1) VariablesNode = Roots[VariablesTreeRootIndex()];
Roots.Clear();
_backUpRoots.Clear();
if (VariablesNode != null)
{
Roots.Add(VariablesNode);
_backUpRoots.Add(VariablesNode);
}
_categories?.Clear();
}
19
View Source File : VariablesList.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
private void Filter(string token)
{
Task.Factory.StartNew(() =>
{
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
{
if (token != "")
{
var l = _backupVariables.Where(i => i.Name.ToUpper().Contains(token.ToUpper())).ToList();
_variables.Clear();
foreach (var item in l)
_variables.Add(item);
}
else
{
_variables.Clear();
foreach (var item in _backupVariables)
_variables.Add(item);
}
}));
});
}
19
View Source File : ContentsBrowser.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
private void Contents_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (var i in _selectedItems)
i.IsSelected = false;
_selectedItems.Clear();
foreach (ExplorerItem i in Contents.SelectedItems)
_selectedItems.Add(i);
e.Handled = true;
}
19
View Source File : NodesTree.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
public void RefreshBackUp()
{
var x = new ObservableCollection<NodeItem>(Roots.ToList());
_backUpRoots.Clear();
_backUpRoots = x;
}
19
View Source File : NodesTree.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
private void Filter(string filterstring)
{
Task.Factory.StartNew(() =>
{
Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() =>
{
filterstring = filterstring.ToUpper();
foreach (var root in _backUpRoots)
{
if (root.BackUpNodes.Count == 0)
{
root.BackUpNodes = new List<NodeItem>();
foreach (var item in root.Nodes)
root.BackUpNodes.Add(item);
}
if (filterstring != "")
{
foreach (var item in root.BackUpNodes)
if (!item.NodeName.ToUpper().Contains(filterstring))
{
root.Nodes.Remove(item);
}
else
{
if (!item.NodeName.ToUpper().Contains(filterstring)) continue;
root.Nodes.Remove(item);
root.Nodes.Add(item);
}
}
else
{
root.Nodes.Clear();
foreach (var item in root.BackUpNodes)
root.Nodes.Add(item);
}
}
Roots.Sort();
SelectNext();
Expand();
_tb.Focus();
}));
});
}
19
View Source File : ListUtilities.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
public void ClearConnectors()
{
for (var i = Count - 1; i >= 0; i--)
if (Count > i)
switch (this[i].Type)
{
case ConnectorTypes.Execution:
this[i].Delete();
break;
case ConnectorTypes.Object:
var objectsConnector = this[i] as ObjectsConnector;
objectsConnector?.Delete();
break;
}
Clear();
}
19
View Source File : ViewManager.cs
License : MIT License
Project Creator : AlexanderPro
License : MIT License
Project Creator : AlexanderPro
public void CreateViews()
{
var windows = 0;
_views.Clear();
_viewModels.Clear();
foreach (var window in _windows)
{
window.AllowClose = true;
window.Hide();
}
WindowUtils.RefreshDesktop();
EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, (IntPtr hMonitor, IntPtr hdcMonitor, ref Native.Rect rect, IntPtr data) =>
{
if (Settings.Monitor == null || Settings.Monitor == windows)
{
var info = new MonitorInfo();
info.Init();
GetMonitorInfo(hMonitor, ref info);
var viewModel = Settings.WallpaperType == WallpaperType.SystemInformation ? new SystemInformationViewModel(info, Settings) :
Settings.WallpaperType == WallpaperType.Video ? new VideoViewModel(info, Settings) :
Settings.WallpaperType == WallpaperType.Image ? new ImageViewModel(info, Settings) :
Settings.WallpaperType == WallpaperType.Web ? new WebViewModel(info, Settings) :
(BaseViewModel)new GalleryViewModel(info, Settings);
var view = Settings.WallpaperType == WallpaperType.SystemInformation ? new SystemInformationView() :
Settings.WallpaperType == WallpaperType.Video ? new VideoView() :
Settings.WallpaperType == WallpaperType.Image ? new ImageView() :
Settings.WallpaperType == WallpaperType.Web ? new WebView() :
(UserControl)new GalleryView();
var mainWindow = new MainWindow (Settings, info.rcMonitor)
{
DataContext = viewModel,
};
mainWindow.GridContainer.Children.Add(view);
_viewModels.Add(viewModel);
_views.Add(view);
mainWindow.Show();
_windows.Add(mainWindow);
if (Settings.WallpaperType == WallpaperType.Video && Settings.VideoAutoPlay)
{
VideoPlay();
}
}
windows++;
return true;
}, IntPtr.Zero);
foreach (var window in _windows)
{
if (window.AllowClose)
{
window.Close();
}
}
_windows.RemoveAll(x => x.AllowClose == true);
}
19
View Source File : MultiLikeControlViewModel.cs
License : GNU General Public License v3.0
Project Creator : alexdillon
License : GNU General Public License v3.0
Project Creator : alexdillon
private void DisableMultiLike()
{
this.IsEnabled = false;
this.GroupContentsControlViewModel.IsSelectionAllowed = false;
var itemList = this.GroupContentsControlViewModel.CurrentlySelectedMessages as ObservableCollection<object>;
itemList?.Clear();
this.GroupContentsControlViewModel.SmallDialogManager.ClosePopup();
}
19
View Source File : PaginatedMessagesControlViewModel.cs
License : GNU General Public License v3.0
Project Creator : alexdillon
License : GNU General Public License v3.0
Project Creator : alexdillon
private void DisposeClearPage()
{
foreach (var msg in this.CurrentPage)
{
(msg as IDisposable).Dispose();
}
this.CurrentPage.Clear();
}
19
View Source File : MessageEffectsControlViewModel.cs
License : GNU General Public License v3.0
Project Creator : alexdillon
License : GNU General Public License v3.0
Project Creator : alexdillon
private void GenerateResults(CancellationToken cancellationToken)
{
var uiDispatcher = Ioc.Default.GetService<IUserInterfaceDispatchService>();
uiDispatcher.Invoke(() =>
{
this.GeneratedMessages.Clear();
});
var parallelOptions = new ParallelOptions()
{
CancellationToken = cancellationToken,
};
// Run all generators in parallel in case one plugin hangs or runs very slowly
var pluginManager = Ioc.Default.GetService<IPluginManagerService>();
Parallel.ForEach(pluginManager.MessageComposePlugins, parallelOptions, async (plugin) =>
{
if (parallelOptions.CancellationToken.IsCancellationRequested)
{
return;
}
try
{
var results = await plugin.ProvideOptions(this.TypedMessageContents);
foreach (var text in results.TextOptions)
{
if (parallelOptions.CancellationToken.IsCancellationRequested)
{
return;
}
var textResults = new SuggestedMessage { Message = text, Plugin = plugin.EffectPluginName };
uiDispatcher.Invoke(() =>
{
this.GeneratedMessages.Add(textResults);
});
}
}
catch (Exception)
{
}
});
}
19
View Source File : UpdatePluginsViewModel.cs
License : GNU General Public License v3.0
Project Creator : alexdillon
License : GNU General Public License v3.0
Project Creator : alexdillon
private async Task UpdateAllPlugins()
{
this.IsUpdatingPlugins = true;
foreach (var update in this.AvailableUpdates)
{
await this.PluginInstaller.UpdatePlugin(update);
}
this.AvailableUpdates.Clear();
this.IsUpdatingPlugins = false;
}
19
View Source File : ViewReleaseNotesControlViewModel.cs
License : GNU General Public License v3.0
Project Creator : alexdillon
License : GNU General Public License v3.0
Project Creator : alexdillon
private async Task LoadReleases()
{
var releases = await this.UpdateService.GetVersionsAsync();
this.Releases.Clear();
foreach (var release in releases)
{
this.Releases.Add(release);
}
}
See More Examples