Here are the examples of the csharp api int.ToString(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1876 Examples
19
Source : MainWindow.xaml.MachineStatus.cs
with MIT License
from 3RD-Dimension
with MIT License
from 3RD-Dimension
private void Machine_FileChanged()
{
try
{
ToolPath = GCodeFile.FromList(machine.File);
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); // prevents considerable increase in memory usage
}
catch (Exception ex)
{
MessageBox.Show("Could not parse GCode File, no preview/editing available\nrun this file at your own risk\n" + ex.Message + "\n\n\ninternal:\n" + ex.StackTrace);
}
if (ToolPath.Warnings.Count > 0)
{
if (Properties.Settings.Default.ShowWarningWindow) // If ShowWarningWindow == True, Display when file loaded
{
WarningWindow ww = new WarningWindow(@"Parsing this file resulted in some warnings!
Do not use GCode Sender's edit functions unless you are sure that these warnings can be ignored!
If you use edit functions, check the output file for errors before running the gcode!
Be aware that the affected lines will likely move when using edit functions." + "\n\n" + "The warning is only applicable to what will be displayed in the viewer, " +
"and will not affect the normal running of the code." + "\n\n", ToolPath.Warnings);
ww.ShowDialog();
}
}
if (Properties.Settings.Default.EnableCodePreview)
ToolPath.GetModel(ModelLine, ModelRapid, ModelArc);
RunFileLength.Text = machine.File.Count.ToString();
FileRunTime = TimeSpan.Zero;
RunFileDuration.Text = ToolPath.TotalTime.ToString(@"hh\:mm\:ss");
RunFileRunTime.Text = "00:00:00";
int digits = (int)Math.Ceiling(Math.Log10(machine.File.Count));
string format = "D" + digits;
ListViewFile.Items.Clear();
for (int line = 0; line < machine.File.Count; line++)
{
TextBlock tb = new TextBlock() { Text = $"{(line + 1).ToString(format)} : {machine.File[line]}" };
if (machine.PauseLines[line])
tb.Background = Brushes.YellowGreen;
ListViewFile.Items.Add(tb);
}
TextBlock tbFinal = new TextBlock() { Text = "-- FILE END --" };
ListViewFile.Items.Add(tbFinal);
if (ToolPath.ContainsMotion)
{
ModelFileBoundary.Points.Clear();
Point3DCollection boundary = new Point3DCollection();
Vector3 MinPoint = ToolPath.MinFeed;
Vector3 MaxPoint = ToolPath.MaxFeed;
for (int ax = 0; ax < 3; ax++)
{
for (int mask = 0; mask < 4; mask++)
{
Vector3 point = MinPoint;
for (int i = 0; i < 2; i++)
{
// binary integer logic? hell yeah!
if (((mask >> i) & 0x01) == 1)
{
point[(ax + i + 1) % 3] = MaxPoint[(ax + i + 1) % 3];
}
}
boundary.Add(point.ToPoint3D());
point[ax] = MaxPoint[ax];
boundary.Add(point.ToPoint3D());
}
}
ModelFileBoundary.Points = boundary;
ModelTextMinPoint.Text = string.Format(Constants.DecimalOutputFormat, "(-X {0:0.###}, -Y {1:0.###}, -Z {2:0.###})", MinPoint.X, MinPoint.Y, MinPoint.Z);
ModelTextMaxPoint.Text = string.Format(Constants.DecimalOutputFormat, "(+X {0:0.###}, +Y {1:0.###}, +Z {2:0.###})", MaxPoint.X, MaxPoint.Y, MaxPoint.Z);
ModelTextMinPoint.Position = MinPoint.ToPoint3D();
ModelTextMaxPoint.Position = MaxPoint.ToPoint3D();
ModelFileBoundaryPoints.Points.Clear();
ModelFileBoundaryPoints.Points.Add(MinPoint.ToPoint3D());
ModelFileBoundaryPoints.Points.Add(MaxPoint.ToPoint3D());
}
else
{
ModelFileBoundary.Points.Clear();
ModelFileBoundaryPoints.Points.Clear();
ModelTextMinPoint.Text = "";
ModelTextMaxPoint.Text = "";
}
}
19
Source : OVRScreenshotWizard.cs
with MIT License
from absurd-joy
with MIT License
from absurd-joy
void OnWizardCreate()
{
if ( !replacedetDatabase.IsValidFolder( cubeMapFolder ) )
{
if (!CreatereplacedetPath(cubeMapFolder))
{
Debug.LogError( "Created path failed: " + cubeMapFolder );
return;
}
}
bool existingCamera = true;
bool existingCameraStateSave = true;
Camera camera = renderFrom.GetComponent<Camera>();
if (camera == null)
{
camera = renderFrom.AddComponent<Camera>();
camera.farClipPlane = 10000f;
existingCamera = false;
}
else
{
existingCameraStateSave = camera.enabled;
camera.enabled = true;
}
// find the last screenshot saved
if (cubeMapFolder[cubeMapFolder.Length-1] != '/')
{
cubeMapFolder += "/";
}
int idx = 0;
string[] fileNames = Directory.GetFiles(cubeMapFolder);
foreach(string fileName in fileNames)
{
if (!fileName.ToLower().EndsWith(".cubemap"))
{
continue;
}
string temp = fileName.Replace(cubeMapFolder + "vr_screenshot_", string.Empty);
temp = temp.Replace(".cubemap", string.Empty);
int tempIdx = 0;
if (int.TryParse( temp, out tempIdx ))
{
if (tempIdx > idx)
{
idx = tempIdx;
}
}
}
string pathName = string.Format("{0}vr_screenshot_{1}.cubemap", cubeMapFolder, (++idx).ToString("d2"));
Cubemap cubemap = new Cubemap(size, TextureFormat.RGB24, false);
// render into cubemap
if ((camera != null) && (cubemap != null))
{
// set up cubemap defaults
OVRCubemapCapture.RenderIntoCubemap(camera, cubemap);
if (existingCamera)
{
camera.enabled = existingCameraStateSave;
}
else
{
DestroyImmediate(camera);
}
// generate a regular texture as well?
if ( ( saveMode == SaveMode.SaveCubemapScreenshot ) || ( saveMode == SaveMode.SaveBoth ) )
{
GenerateTexture(cubemap, pathName);
}
if ( ( saveMode == SaveMode.SaveUnityCubemap ) || ( saveMode == SaveMode.SaveBoth ) )
{
Debug.Log( "Saving: " + pathName );
// by default the unity cubemap isn't saved
replacedetDatabase.Createreplacedet( cubemap, pathName );
// reimport as necessary
replacedetDatabase.Savereplacedets();
// select it in the project tree so developers can find it
EditorGUIUtility.PingObject( cubemap );
Selection.activeObject = cubemap;
}
replacedetDatabase.Refresh();
}
}
19
Source : VRSL_LightGroupZone.cs
with MIT License
from AcChosen
with MIT License
from AcChosen
void UpdateStageLightAnims(VRSL_CardObject card)
{
switch (card.CardType)
{
case 1:
foreach(VRStageLighting_Animated stagelight in stageLightsList)
{
stagelight._colorAnimation = colorAnim;
stagelight._UpdateColorAnims();
}
foreach(VRStageLighting_Animated_Static stagelight in staticStageLightsList)
{
stagelight._colorAnimation = colorAnim;
stagelight._UpdateColorAnims();
}
string colorString = colorAnim.ToString("D3");
animSync = colorString + animSync.Substring(3, 9);
//lastColorCard = card;
break;
case 2:
foreach(VRStageLighting_Animated stagelight in stageLightsList)
{
stagelight._intensityAnimation = intensityAnim;
stagelight._UpdateIntensityAnims();
}
foreach(VRStageLighting_Animated_Static stagelight in staticStageLightsList)
{
stagelight._intensityAnimation = intensityAnim;
stagelight._UpdateIntensityAnims();
}
string intensitystring = intensityAnim.ToString("D3");
animSync = animSync.Substring(0,3) + intensitystring + animSync.Substring(6,6);
// lastIntensityCard = card;
break;
case 3:
foreach(VRStageLighting_Animated stagelight in stageLightsList)
{
stagelight._goboAnimation = gOBOAnim;
stagelight._UpdateGoboAnims();
}
foreach(VRStageLighting_Animated_Static stagelight in staticStageLightsList)
{
stagelight._goboAnimation = gOBOAnim;
stagelight._UpdateGoboAnims();
}
//lastGoboCard = card;
string gobostring = gOBOAnim.ToString("D3");
animSync = animSync.Substring(0,6) + gobostring + animSync.Substring(9,3);
break;
case 4:
// lastPanTiltCard = card;
switch (card.measureCount)
{
case 1:
foreach(VRStageLighting_Animated stagelight in stageLightsList)
{
stagelight._panTiltSingleMeasureAnim = card.CardID;
stagelight._panTiltMeasureCount = card.measureCount;
stagelight._UpdatePanTiltAnims();
}
foreach(VRStageLighting_Animated_Static stagelight in staticStageLightsList)
{
stagelight._panTiltSingleMeasureAnim = card.CardID;
stagelight._panTiltMeasureCount = card.measureCount;
stagelight._UpdatePanTiltAnims();
}
// if(Networking.GetOwner(gameObject) == Networking.LocalPlayer)
// {
followDefaultTargetSync = true;
// }
break;
case 2:
foreach(VRStageLighting_Animated stagelight in stageLightsList)
{
stagelight._panTiltDualMeasureAnim = card.CardID;
stagelight._panTiltMeasureCount = card.measureCount;
stagelight._UpdatePanTiltAnims();
}
foreach(VRStageLighting_Animated_Static stagelight in staticStageLightsList)
{
stagelight._panTiltDualMeasureAnim = card.CardID;
stagelight._panTiltMeasureCount = card.measureCount;
stagelight._UpdatePanTiltAnims();
}
// if(Networking.GetOwner(gameObject) == Networking.LocalPlayer)
// {
followDefaultTargetSync = true;
// }
break;
case 4:
foreach(VRStageLighting_Animated stagelight in stageLightsList)
{
stagelight._panTiltQuadMeasureAnim = card.CardID;
stagelight._panTiltMeasureCount = card.measureCount;
stagelight._UpdatePanTiltAnims();
}
foreach(VRStageLighting_Animated_Static stagelight in staticStageLightsList)
{
stagelight._panTiltQuadMeasureAnim = card.CardID;
stagelight._panTiltMeasureCount = card.measureCount;
stagelight._UpdatePanTiltAnims();
}
// if(Networking.GetOwner(gameObject) == Networking.LocalPlayer)
// {
followDefaultTargetSync = true;
// }
break;
case 8:
foreach(VRStageLighting_Animated stagelight in stageLightsList)
{
stagelight._panTiltQuadMeasureAnim = card.CardID;
stagelight._UpdatePanTiltAnims();
}
foreach(VRStageLighting_Animated_Static stagelight in staticStageLightsList)
{
stagelight._panTiltQuadMeasureAnim = card.CardID;
stagelight._UpdatePanTiltAnims();
}
// if(Networking.GetOwner(gameObject) == Networking.LocalPlayer)
// {
followDefaultTargetSync = false;
// }
break;
default:
Debug.Log("Measure Count unrecogniable, aborting...");
break;
}
string pantiltstring = panTiltAnim.ToString("D3");
animSync = animSync.Substring(0,9) + pantiltstring;
break;
default:
Debug.Log("Could not identify animation type, aborting...");
break;
}
// if(Networking.GetOwner(gameObject) == Networking.LocalPlayer)
// {
// string currentAnims = colorAnim.ToString("D3") + intensityAnim.ToString("D3") + gOBOAnim.ToString("D3") + panTiltAnim.ToString("D3");
//animSync = colorAnim.ToString("D3") + intensityAnim.ToString("D3") + gOBOAnim.ToString("D3") + panTiltAnim.ToString("D3");
// }
}
19
Source : VRSL_LightGroupZone.cs
with MIT License
from AcChosen
with MIT License
from AcChosen
void Start()
{
hasColorAnim = hasIntensityAnim = hasGOBOAnim = false;
//UpdateSliders();
countDownToInitialize = 10;
isCounting = true;
animSync = colorAnim.ToString("D3") + intensityAnim.ToString("D3") + gOBOAnim.ToString("D3") + panTiltAnim.ToString("D3");
}
19
Source : MiniJson.cs
with MIT License
from AdamCarballo
with MIT License
from AdamCarballo
void SerializeString(string str) {
builder.Append('\"');
char[] charArray = str.ToCharArray();
foreach (var c in charArray) {
switch (c) {
case '"':
builder.Append("\\\"");
break;
case '\\':
builder.Append("\\\\");
break;
case '\b':
builder.Append("\\b");
break;
case '\f':
builder.Append("\\f");
break;
case '\n':
builder.Append("\\n");
break;
case '\r':
builder.Append("\\r");
break;
case '\t':
builder.Append("\\t");
break;
default:
int codepoint = Convert.ToInt32(c);
if ((codepoint >= 32) && (codepoint <= 126)) {
builder.Append(c);
} else {
builder.Append("\\u");
builder.Append(codepoint.ToString("x4"));
}
break;
}
}
builder.Append('\"');
}
19
Source : Formatter.cs
with MIT License
from adrianoc
with MIT License
from adrianoc
private static string FormatLabel(int offset)
{
var label = "000" + offset.ToString("x");
return "IL_" + label.Substring(label.Length - 4);
}
19
Source : Program.cs
with GNU General Public License v3.0
from AdvancedHacker101
with GNU General Public License v3.0
from AdvancedHacker101
private void recvAsync(IAsyncResult ar)
{
IPEndPoint currentClient = new IPEndPoint(IPAddress.Any, 0);
byte[] cMsg = listener.EndReceive(ar, ref currentClient);
Console.WriteLine("[" + cMsg.Length.ToString() + " bytes] Data Size");
string plain = Encoding.ASCII.GetString(cMsg);
Console.WriteLine("Data Payload: \n");
int counter = 0;
string fullDump = "";
foreach (int byt in cMsg)
{
if (counter > 15)
{
counter = 0;
Console.Write("\n");
}
string hex = byt.ToString("X");
if (hex.Length == 1) hex = "0" + hex;
Console.Write(hex);
Console.Write(" ");
fullDump += hex;
counter++;
}
dnsRequest request = new dnsRequest();
request.serialize(fullDump);
//Mofify request here
editor.setRequest(request);
request = editor.runXML();
Console.WriteLine("\nDeserialize test\n");
string payload = request.deserialize(request);
formatHex(payload);
byte[] entropy = request.ToArray(payload);
Client google = new Client();
google.start();
google.write(entropy);
byte[] resp = google.directRead();
dnsRequest response = new dnsRequest();
string hx = byteToHex(resp);
response.serialize(hx);
editor.setRequest(response);
response = editor.runXML();
Console.WriteLine(response.ToString());
string strResponse = response.deserialize(response);
formatHex(strResponse);
byte[] rsp = response.ToArray(strResponse);
write(rsp, currentClient);
Console.WriteLine("Dns Req - Rsp sequence done");
if (!clients.Contains(currentClient)) clients.Add(currentClient);
listener.BeginReceive(new AsyncCallback(recvAsync), null);
}
19
Source : Program.cs
with GNU General Public License v3.0
from AdvancedHacker101
with GNU General Public License v3.0
from AdvancedHacker101
private String byteToHex(byte[] cMsg)
{
int counter = 0;
string fullDump = "";
foreach (int byt in cMsg)
{
if (counter > 15)
{
counter = 0;
Console.Write("\n");
}
string hex = byt.ToString("X");
if (hex.Length == 1) hex = "0" + hex;
Console.Write(hex);
Console.Write(" ");
fullDump += hex;
counter++;
}
return fullDump;
}
19
Source : Program.cs
with GNU General Public License v3.0
from AdvancedHacker101
with GNU General Public License v3.0
from AdvancedHacker101
private String deserializeLabel(String labels)
{
String des = "";
String flush = "";
//bool first = true;
int partCounter = 0;
for (int i = 0; i < labels.Length; i++ )
{
if (labels[i] == '.')
{
flush = (partCounter).ToString("X2") + flush;
des += flush;
flush = "";
partCounter = 0;
continue;
}
byte chr = Encoding.ASCII.GetBytes(labels[i].ToString())[0];
int ichr = Convert.ToInt32(chr);
string xchr = ichr.ToString("X2");
flush += xchr;
partCounter++;
if ((i + 1) == labels.Length)
{
flush = (partCounter).ToString("X2") + flush;
des += flush;
flush = "";
partCounter = 0;
continue;
}
}
return des;
}
19
Source : Program.cs
with GNU General Public License v3.0
from AdvancedHacker101
with GNU General Public License v3.0
from AdvancedHacker101
private String deserializeIP(String ip, String ipv6 = "")
{
String des = "";
if (ip.Contains("."))
{
foreach (String octet in ip.Split('.'))
{
des += int.Parse(octet).ToString("X2");
}
}
else if (ip.Contains(":") && ipv6 != "" && ipv6 != null)
{
des = ipv6;
}
return des;
}
19
Source : Program.cs
with GNU General Public License v3.0
from AdvancedHacker101
with GNU General Public License v3.0
from AdvancedHacker101
public String deserialize(dnsRequest request)
{
string result = "";
//Append request count
result += reqCount.ToString("X4");
//Build and append flags
int flags = 0;
flags = (response << 15) | (opcode << 11) | (AuthAnswer << 10) | (truncation << 9) | (recursion_desired << 8) | (recursion_available << 7) | (reserved << 4) | return_code;
result += flags.ToString("X4");
//Append resource record counts
result += question_resource_record_count.ToString("X4");
result += answer_resource_record_count.ToString("X4");
result += authority_resource_record_count.ToString("X4");
result += additional_resource_record_count.ToString("X4");
//Deserialize records
foreach (GeneralRecord gr in request.records)
{
if (gr.resource_type == DnsResourceType.Query)
{
string name = deserializeLabel(gr.rName);
string type = gr.rType.ToString("X4");
string rclreplaced = gr.rClreplaced.ToString("X4");
result += name;
result += "00";
result += type;
result += rclreplaced;
}
if (gr.resource_type == DnsResourceType.Answer)
{
AnswerRecord ar = (AnswerRecord)gr;
string name = deserializeLabel(ar.rName);
string type = ar.rType.ToString("X4");
string rclreplaced = ar.rClreplaced.ToString("X4");
string ttl = ar.ttl.ToString("X8");
string aresult = deserializeIP(ar.result, ar.ipv6Hex);
string length = (aresult.Length / 2).ToString("X4");
result += name + "00";
result += type;
result += rclreplaced;
result += ttl;
result += length;
result += aresult;
}
if (gr.resource_type == DnsResourceType.Authority)
{
AuthoritiveRecord ar = (AuthoritiveRecord)gr;
string name = deserializeLabel(ar.rName);
string type = ar.rType.ToString("X4");
string rclreplaced = ar.rClreplaced.ToString("X4");
string ttl = ar.ttl.ToString("X8");
string pDnsSrv = deserializeLabel(ar.primaryNS);
string mailbox = deserializeLabel(ar.authorityMailbox);
string serial = ar.serialNum.ToString("X8");
string refresh = ar.refreshInterval.ToString("X8");
string retry = ar.retryInterval.ToString("X8");
string expire = ar.expireLimit.ToString("X8");
string minttl = ar.minttl.ToString("X8");
string length = ((pDnsSrv.Length + mailbox.Length + 40) / 2).ToString("X4");
result += name + "00";
result += type;
result += rclreplaced;
result += ttl;
result += length;
result += pDnsSrv + "00";
result += mailbox + "00";
result += serial;
result += refresh;
result += retry;
result += expire;
result += minttl;
}
if (gr.resource_type == DnsResourceType.Additional)
{
AdditionalRecord ar = (AdditionalRecord)gr;
result += ar.hexDump;
}
}
//Deserialize done :)
return result;
}
19
Source : Renamer.cs
with GNU General Public License v3.0
from Aekras1a
with GNU General Public License v3.0
from Aekras1a
private string ToString(int id)
{
return id.ToString("x");
}
19
Source : NGUIMath.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static string DecimalToHex(int num)
{
num &= 16777215;
return num.ToString("X6");
}
19
Source : MainForm.cs
with GNU General Public License v3.0
from AgentRev
with GNU General Public License v3.0
from AgentRev
void SaveSettings()
{
if (saveSettings && !currentlyReading)
{
try
{
StreamWriter sw = null;
try
{
if (!Directory.Exists(settingsPath))
Directory.CreateDirectory(settingsPath);
using (sw = new StreamWriter(settingsFile))
{
sw.WriteLine("ToolVersion=" + c_toolVer);
sw.WriteLine("Beep=" + chkBeep.Checked);
sw.WriteLine("FoV=" + fFoV);
sw.WriteLine("FoVOffset=" + pFoV.ToString("x"));
sw.WriteLine("UpdateNotify=" + chkUpdate.Checked);
sw.WriteLine("DisableHotkeys=" + chkHotkeys.Checked);
sw.WriteLine("HotkeyIncrease=" + (int)catchKeys[0]);
sw.WriteLine("HotkeyDecrease=" + (int)catchKeys[1]);
sw.WriteLine("HotkeyReset=" + (int)catchKeys[2]);
}
}
catch
{
if (sw != null)
sw.Close();
File.Delete(settingsFile);
throw;
}
SaveGameMode();
}
catch
{
saveSettings = false;
}
}
}
19
Source : MainForm.cs
with GNU General Public License v3.0
from AgentRev
with GNU General Public License v3.0
from AgentRev
private void TimerVerif_Tick(object sender, EventArgs e)
{
if (proc != null && mem != null && isRunning(false))
{
if (btnStartGame.Enabled) ToggleButton(false);
proc.Refresh();
if (proc.PagedMemorySize64 > 0x2000000)
{
byte step = 0;
try
{
mem.FindFoVOffset(ref pFoV, ref step);
if (!isOffsetWrong(pFoV)) progStart();
else if (proc.PagedMemorySize64 > memSearchRange)
{
TimerVerif.Stop();
TimerCheck.Stop();
//bool offsetFound = false;
//int ptrSize = IntPtr.Size * 4;
/*for (int i = -0x50000; i < 0x50000 && !offsetFound; i += 16)
{
if (mem.ReadFloat(true, pFoV + i) == 65f && !isOffsetWrong(pFoV + i))
{
pFoV += i;
offsetFound = true;
}
if (i % 50000 == 0)
{
label1.Text = i.ToString();
Update();
}
}*/
//Console.Beep(5000, 100);
//MessageBox.Show("find " + pFoV.ToString("X8"));
if (isRunning(false) && !mem.FindFoVOffset(ref pFoV, ref step))
{
string memory = BitConverter.ToString(BitConverter.GetBytes(mem.ReadFloat(pFoV)));
MessageBox.Show("The memory research pattern wasn't able to find the FoV offset in your " + c_supportMessage + ".\n" +
"Please look for an updated version of this FoV Changer tool.\n\n" +
"If you believe this might be a bug, please send me an email at [email protected], and include a screenshot of this:\n\n" + c_toolVer +
"\n0x" + Convert.ToInt32(proc.WorkingSet64).ToString("X8") +
"\n0x" + Convert.ToInt32(proc.PagedMemorySize64).ToString("X8") +
"\n0x" + Convert.ToInt32(proc.VirtualMemorySize64).ToString("X8") +
"\nStep = " + step.ToString() +
"\n0x" + (pFoV - 0xC).ToString("X8") + " = " + memory,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
pFoV = c_pFoV;
Application.Exit();
}
else
{
//Console.Beep(5000, 100);
SaveData();
proc = null;
TimerCheck.Start();
}
}
}
catch (Exception err)
{
ErrMessage(err);
Application.Exit();
}
}
}
}
19
Source : LayoutDescriptionEx.cs
with GNU General Public License v3.0
from aglab2
with GNU General Public License v3.0
from aglab2
static public LayoutDescriptionEx GenerateDefault()
{
List<LineDescriptionEx> courseLD = new LineDescriptionEx[16].ToList();
List<LineDescriptionEx> secretLD = new LineDescriptionEx[16].ToList();
int[] linesForSecrets = { 0, 1, 2, 3, 9, 5, 6, 7, 13, 14, 15, 11 };
int[] offsetForSecrets = { 0, 0xb, 0xb, 0, 0, 0xb, 0xb, 0xb, 0, 0, 0, 0 };
byte[] highlightForSecrets = { 0, 1 << 4 | 1 << 6, 1 << 5 | 1 << 7, 0, 0, 1 << 2, 1 << 1, 1 << 3, 0, 0, 0, 0 };
string[] namesForSecrets = { "--", "B1", "B2", "B3", "Sl", "MC", "WC", "VC", "S1", "S2", "S3", "OW" };
courseLD[0] = new TextOnlyLineDescription("Main Courses");
for (int course = 1; course <= 15; course++)
{
string drawString = course.ToString("D2");
courseLD[course] = new StarsLineDescription(drawString, 255, course + 11, 0, 0);
}
for (int course = 1; course <= 10; course++) //Secret course
{
secretLD[linesForSecrets[course]] = new StarsLineDescription(namesForSecrets[course], 255, course + 26, highlightForSecrets[course], offsetForSecrets[course]);
}
secretLD[linesForSecrets[11]] = new StarsLineDescription(namesForSecrets[11], 255, 8, 0, 0);
secretLD[0] = new TextOnlyLineDescription("Bowser Courses");
secretLD[4] = new TextOnlyLineDescription("Cap Levels");
secretLD[8] = new TextOnlyLineDescription("Slide");
secretLD[10] = new TextOnlyLineDescription("Overworld Stars");
secretLD[12] = new TextOnlyLineDescription("Secret Stars");
return new LayoutDescriptionEx(courseLD, secretLD, Resource.gold_star, "182", 7);
}
19
Source : MainForm.cs
with GNU General Public License v3.0
from AgentRev
with GNU General Public License v3.0
from AgentRev
private void TimerVerif_Tick(object sender, EventArgs e)
{
if (proc != null && mem != null && isRunning(false))
{
if (btnStartGame.Enabled) ToggleButton(false);
proc.Refresh();
try
{
if (proc.PagedMemorySize64 > 0x2000000)
{
byte step = 0;
try
{
mem.FindFoVOffset(ref pFoV, ref step);
if (!isOffsetWrong(pFoV)) progStart();
else if (proc.PagedMemorySize64 > (dword_ptr)gameMode.GetValue("c_memSearchRange"))
{
TimerVerif.Stop();
TimerCheck.Stop();
//bool offsetFound = false;
//int ptrSize = IntPtr.Size * 4;
/*for (int i = -0x50000; i < 0x50000 && !offsetFound; i += 16)
{
if (mem.ReadFloat(true, pFoV + i) == 65f && !isOffsetWrong(pFoV + i))
{
pFoV += i;
offsetFound = true;
}
if (i % 50000 == 0)
{
label1.Text = i.ToString();
Update();
}
}*/
//Console.Beep(5000, 100);
//MessageBox.Show("find " + pFoV.ToString("X8"));
if (isRunning(false) && !mem.FindFoVOffset(ref pFoV, ref step))
{
string memory = BitConverter.ToString(BitConverter.GetBytes(mem.ReadFloat(pFoV)));
MessageBox.Show(this, "The memory research pattern wasn't able to find the FoV offset in your " + gameMode.GetValue("c_supportMessage") + ".\n" +
"Please look for an updated version of this FoV Changer tool.\n\n" +
"If you believe this might be a bug, please send me an email at [email protected], and include a screenshot of this:\n" +
"\n" + c_toolVer +
"\nWorking Set: 0x" + proc.WorkingSet64.ToString("X8") +
"\nPaged Memory: 0x" + proc.PagedMemorySize64.ToString("X8") +
"\nVirtual Memory: 0x" + proc.VirtualMemorySize64.ToString("X8") +
"\nStep: " + step.ToString() +
"\nFoV pointer: 0x" + (pFoV - c_pOffset).ToString("X8") + " = " + memory,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
pFoV = (dword_ptr)gameMode.GetValue("c_pFoV");
Application.Exit();
}
else
{
//Console.Beep(5000, 100);
SaveSettings();
proc = null;
TimerCheck.Start();
}
}
}
catch (Exception ex)
{
ErrMessage(ex);
Application.Exit();
}
}
}
catch (InvalidOperationException) { }
}
}
19
Source : MainForm.cs
with GNU General Public License v3.0
from AgentRev
with GNU General Public License v3.0
from AgentRev
void SaveSettings()
{
if (saveSettings && !currentlyReading)
{
try
{
StreamWriter sw = null;
try
{
if (!Directory.Exists(settingsPath))
Directory.CreateDirectory(settingsPath);
using (sw = new StreamWriter(settingsFile))
{
sw.WriteLine("ToolVersion=" + c_toolVer);
sw.WriteLine("Beep=" + chkBeep.Checked);
sw.WriteLine("FoV=" + fFoV);
sw.WriteLine("FoVOffset=" + pFoV.ToString("x"));
sw.WriteLine("UpdatePopup=" + chkUpdate.Checked);
sw.WriteLine("DisableHotkeys=" + chkHotkeys.Checked);
sw.WriteLine("HotkeyIncrease=" + (int)catchKeys[0]);
sw.WriteLine("HotkeyDecrease=" + (int)catchKeys[1]);
sw.WriteLine("HotkeyReset=" + (int)catchKeys[2]);
}
}
catch
{
if (sw != null)
sw.Close();
File.Delete(settingsFile);
throw;
}
}
catch
{
saveSettings = false;
}
}
}
19
Source : MainForm.cs
with GNU General Public License v3.0
from AgentRev
with GNU General Public License v3.0
from AgentRev
private void TimerVerif_Tick(object sender, EventArgs e)
{
if (proc != null && mem != null && isRunning(false))
{
if (btnStartGame.Enabled) ToggleButton(false);
proc.Refresh();
if (proc.PagedMemorySize64 > 0x2000000)
{
byte step = 0;
try
{
mem.FindFoVOffset(ref pFoV, ref step);
if (!isOffsetWrong(pFoV)) progStart();
else if (proc.PagedMemorySize64 > (long)gameMode.GetValue("c_memSearchRange"))
{
TimerVerif.Stop();
TimerCheck.Stop();
//bool offsetFound = false;
//int ptrSize = IntPtr.Size * 4;
/*for (int i = -0x50000; i < 0x50000 && !offsetFound; i += 16)
{
if (mem.ReadFloat(true, pFoV + i) == 65f && !isOffsetWrong(pFoV + i))
{
pFoV += i;
offsetFound = true;
}
if (i % 50000 == 0)
{
label1.Text = i.ToString();
Update();
}
}*/
//Console.Beep(5000, 100);
//MessageBox.Show("find " + pFoV.ToString("X8"));
if (isRunning(false) && !mem.FindFoVOffset(ref pFoV, ref step))
{
string memory = BitConverter.ToString(BitConverter.GetBytes(mem.ReadFloat(pFoV)));
MessageBox.Show(this, "The memory research pattern wasn't able to find the FoV offset in your " + gameMode.GetValue("c_supportMessage") + ".\n" +
"Please look for an updated version of this FoV Changer tool.\n\n" +
"If you believe this might be a bug, please send me an email at [email protected], and include a screenshot of this:\n\n" + c_toolVer +
"\n0x" + Convert.ToInt32(proc.WorkingSet64).ToString("X8") +
"\n0x" + Convert.ToInt32(proc.PagedMemorySize64).ToString("X8") +
"\n0x" + Convert.ToInt32(proc.VirtualMemorySize64).ToString("X8") +
"\nStep = " + step.ToString() +
"\n0x" + (pFoV - 0xC).ToString("X8") + " = " + memory,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
pFoV = (int)gameMode.GetValue("c_pFoV");
Application.Exit();
}
else
{
//Console.Beep(5000, 100);
SaveSettings();
proc = null;
TimerCheck.Start();
}
}
}
catch (Exception ex)
{
ErrMessage(ex);
Application.Exit();
}
}
}
}
19
Source : CISS.cs
with GNU General Public License v3.0
from akmadian
with GNU General Public License v3.0
from akmadian
public int GetValue() {
string concatenated = evaluatedIndex.ToString("X") + speed.ToString();
return int.Parse(concatenated, System.Globalization.NumberStyles.HexNumber);
}
19
Source : Extensions.cs
with GNU General Public License v3.0
from akmadian
with GNU General Public License v3.0
from akmadian
public static int DecimalToByte(this int toConvert) {
return Convert.ToInt32(toConvert.ToString("X"));
}
19
Source : PetrolTheft.cs
with GNU General Public License v3.0
from Albo1125
with GNU General Public License v3.0
from Albo1125
private void DrawCCTVText(System.Object sender, Rage.GraphicsEventArgs e)
{
if (CCTVShowing)
{
Rectangle drawRect = new Rectangle(0, 0, 200, 130);
e.Graphics.DrawRectangle(drawRect, Color.FromArgb(100, Color.Black));
e.Graphics.DrawText("CCTV #" + CCTVCamNumber.ToString("00"), "Aharoni Bold", 35.0f, new PointF(1, 6), Color.White);
e.Graphics.DrawText(DateTime.Now.Day.ToString("00") + "/" + DateTime.Now.Month.ToString("00") + "/" + DateTime.Now.Year.ToString(), "Aharoni Bold", 35.0f, new PointF(1, 46), Color.White, drawRect);
e.Graphics.DrawText(DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00") + ":" + DateTime.Now.Second.ToString("00"), "Aharoni Bold", 35.0f, new PointF(1, 86), Color.White, drawRect);
}
else
{
Game.FrameRender -= DrawCCTVText;
}
}
19
Source : ColorPickerPopup.cs
with MIT License
from alelievr
with MIT License
from alelievr
void DrawHexComponents()
{
byte a = (byte)(int)(currentColor.a * 255);
int hex = ColorUtils.ColorToHex(currentColor, false); //get color without alpha
EditorGUIUtility.labelWidth = 80;
EditorGUI.BeginChangeCheck();
string hexColor = EditorGUILayout.TextField("Hex color", hex.ToString("X6"));
if (EditorGUI.EndChangeCheck())
a = 255;
EditorGUIUtility.labelWidth = 0;
Regex reg = new Regex(@"[^A-F0-9 -]");
hexColor = reg.Replace(hexColor, "");
hexColor = hexColor.Substring(0, Mathf.Min(hexColor.Length, 6));
if (hexColor == "")
hexColor = "0";
hex = int.Parse(a.ToString("X2") + hexColor, System.Globalization.NumberStyles.HexNumber);
currentColor = (SerializableColor)ColorUtils.HexToColor(hex, false);
}
19
Source : PersistentSettings.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
public void SetValue(string name, Color color) {
settings[name] = color.ToArgb().ToString("X8");
}
19
Source : PerformanceAnalyzer.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
public static string GenerateReport(double totalTime)
{
StringBuilder sb = new StringBuilder();
int len = 0;
foreach (PerformanceInfo info in Performances)
len = Math.Max(info.Name.Length, len);
sb.AppendLine("Name".PadRight(len) + " Count Total Time, ms Avg. Time, ms Percentage, %");
sb.AppendLine("----------------------------------------------------------------------------------------------");
foreach (PerformanceInfo info in Performances)
{
sb.Append(info.Name.PadRight(len));
double p = 0;
double avgt = 0;
if (totalTime != 0)
p = info.TotalTime / totalTime;
if (info.Count > 0)
avgt = info.TotalTime * 1000 / info.Count;
string c = info.Count.ToString("0,0").PadRight(20);
string tt = (info.TotalTime * 1000).ToString("0,0.00").PadRight(20);
string t = avgt.ToString("0.0000").PadRight(20);
string sp = (p * 100).ToString("###").PadRight(20);
sb.AppendFormat(" " + c + tt + t + sp + "\n");
}
return sb.ToString();
}
19
Source : DateTimeAxis.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
public override string FormatValue(double x)
{
// convert the double value to a DateTime
var time = ToDateTime(x);
string fmt = this.ActualStringFormat;
if (fmt == null)
{
return time.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern);
}
int week = this.GetWeek(time);
fmt = fmt.Replace("ww", week.ToString("00"));
fmt = fmt.Replace("w", week.ToString(CultureInfo.InvariantCulture));
return time.ToString(fmt, this.ActualCulture);
}
19
Source : TimeAxis.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
public override string FormatValue(double x)
{
var span = TimeSpan.FromSeconds(x);
string s = ActualStringFormat ?? "h:mm:ss";
s = s.Replace("mm", span.Minutes.ToString("00"));
s = s.Replace("ss", span.Seconds.ToString("00"));
s = s.Replace("hh", span.Hours.ToString("00"));
s = s.Replace("msec", span.Milliseconds.ToString("000"));
s = s.Replace("m", ((int)span.TotalMinutes).ToString("0"));
s = s.Replace("s", ((int)span.TotalSeconds).ToString("0"));
s = s.Replace("h", ((int)span.TotalHours).ToString("0"));
return s;
}
19
Source : TimeSpanAxis.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
public override string FormatValue(double x)
{
TimeSpan span = TimeSpan.FromSeconds(x);
string s = this.ActualStringFormat ?? "h:mm:ss";
s = s.Replace("mm", span.Minutes.ToString("00"));
s = s.Replace("ss", span.Seconds.ToString("00"));
s = s.Replace("hh", span.Hours.ToString("00"));
s = s.Replace("msec", span.Milliseconds.ToString("000"));
s = s.Replace("m", ((int)span.TotalMinutes).ToString("0"));
s = s.Replace("s", ((int)span.TotalSeconds).ToString("0"));
s = s.Replace("h", ((int)span.TotalHours).ToString("0"));
return s;
}
19
Source : ChatController.cs
with MIT License
from AlexLemminG
with MIT License
from AlexLemminG
void AddToChatOutput(string newText)
{
// Clear Input Field
TMP_ChatInput.text = string.Empty;
var timeNow = System.DateTime.Now;
TMP_ChatOutput.text += "[<#FFFF80>" + timeNow.Hour.ToString("d2") + ":" + timeNow.Minute.ToString("d2") + ":" + timeNow.Second.ToString("d2") + "</color>] " + newText + "\n";
TMP_ChatInput.ActivateInputField();
// Set the scrollbar to the bottom when next text is submitted.
ChatScrollbar.value = 0;
}
19
Source : StringExtensions.cs
with Apache License 2.0
from alexreinert
with Apache License 2.0
from alexreinert
internal static string ToMasterfileLabelRepresentation(this string s, bool encodeDots = false)
{
if (s == null)
return null;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.Length; i++)
{
char c = s[i];
if ((c < 32) || (c > 126))
{
sb.Append(@"\" + ((int) c).ToString("000"));
}
else if (c == '"')
{
sb.Append(@"\""");
}
else if (c == '\\')
{
sb.Append(@"\\");
}
else if ((c == '.') && encodeDots)
{
sb.Append(@"\.");
}
else
{
sb.Append(c);
}
}
return sb.ToString();
}
19
Source : FormatHelper.cs
with Apache License 2.0
from alexyakunin
with Apache License 2.0
from alexyakunin
public static string ToString(this int? value, string format, string unit) =>
value.HasValue ? (value.Value.ToString(format) + " " + unit) : "n/a";
19
Source : Extensions.cs
with Apache License 2.0
from Algoryx
with Apache License 2.0
from Algoryx
public static string ToHexStringRGBA( this Color color )
{
string result;
if ( m_colorTagCache.TryGetValue( color, out result ) )
return result;
result = "#" + ( (int)( 255 * color.r ) ).ToString( "X2" ) + ( (int)( 255 * color.g ) ).ToString( "X2" ) + ( (int)( 255 * color.b ) ).ToString( "X2" ) + ( (int)( 255 * color.a ) ).ToString( "X2" );
m_colorTagCache.Add( color, result );
return result;
}
19
Source : Extensions.cs
with Apache License 2.0
from Algoryx
with Apache License 2.0
from Algoryx
public static string ToHexStringRGB( this Color color )
{
return "#" + ( (int)( 255 * color.r ) ).ToString( "X2" ) + ( (int)( 255 * color.g ) ).ToString( "X2" ) + ( (int)( 255 * color.b ) ).ToString( "X2" );
}
19
Source : Utils.cs
with MIT License
from aliprogrammer69
with MIT License
from aliprogrammer69
public static string GetRandomHexNumber(int digits) {
byte[] buffer = new byte[digits / 2];
random.NextBytes(buffer);
string result = String.Concat(buffer.Select(x => x.ToString("X2")).ToArray());
if (digits % 2 == 0)
return result;
return result + random.Next(16).ToString("X");
}
19
Source : GeneratorWorker.cs
with MIT License
from AliTsuki
with MIT License
from AliTsuki
public static void CreateNormalMap(IProgress<string> progressLabelText, IProgress<int> progressBarValue, IProgress<string> progressLabelDetailText)
{
CurrentProgress = 0;
MaximumPixelsToCheck = (nmg.ImageWidth * nmg.ImageHeight) + 1;
progressLabelText.Report("In Progress...");
try
{
CurrentProgress = 1;
for(int x = 0; x < nmg.ImageWidth; x++)
{
for(int y = 0; y < nmg.ImageHeight; y++)
{
nmg.cToken.ThrowIfCancellationRequested();
Color currentPixelColor = nmg.OriginalImageBitmap.GetPixel(x, y);
if(IsColorWithinColorDistance(currentPixelColor, ColorType.Background))
{
nmg.NormalMapImageBitmap.SetPixel(x, y, nmg.DefaultNormalMapBGColor);
}
else if(IsColorWithinColorDistance(currentPixelColor, ColorType.Separator))
{
nmg.NormalMapImageBitmap.SetPixel(x, y, nmg.DefaultNormalMapBGColor);
}
else if(IsColorWithinColorDistance(currentPixelColor, ColorType.Individual))
{
if(HasPixelAlreadyBeenAdded(x, y) == false)
{
ConvexObject co = new ConvexObject();
FloodFill(co, x, y);
co.CalculateBounds(nmg.ImageWidth, nmg.ImageHeight);
AddToTile(co);
}
}
CurrentProgress++;
}
progressBarValue.Report(CurrentProgress);
float percent = (float)CurrentProgress / (float)MaximumPixelsToCheck * 100f;
progressLabelDetailText.Report($@"{percent.ToString("00.00")}% --- {CurrentProgress.ToString("0,0")} / {MaximumPixelsToCheck.ToString("0,0")}");
}
foreach(KeyValuePair<Vector2Int, Tile> tile in nmg.Tiles)
{
foreach(ConvexObject co in tile.Value.ConvexObjects)
{
CreateNormalMapForConvexObject(co);
}
}
progressLabelText.Report("Finished");
nmg.CreatingNormalMap = false;
}
catch(OperationCanceledException)
{
MessageBox.Show($@"Operation cancelled!{Environment.NewLine}");
nmg.CreatingNormalMap = false;
progressLabelText.Report("Stopped");
}
catch(Exception e)
{
MessageBox.Show($@"Error creating Normal Map!{Environment.NewLine}{e.ToString()}");
Console.WriteLine(e.ToString());
nmg.CreatingNormalMap = false;
progressLabelText.Report("Error!");
}
}
19
Source : EncodeVideo.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
public static void Encode()
{
// Main Encoding Function
// Creates a new Thread Pool
using (SemapreplacedSlim concurrencySemapreplaced = new SemapreplacedSlim(Worker_Count))
{
// Creates a tasks list
List<Task> tasks = new List<Task>();
// Iterates over all args in VideoChunks list
foreach (var command in Global.Video_Chunks)
{
concurrencySemapreplaced.Wait();
var task = Task.Factory.StartNew(() =>
{
try
{
if (!SmallFunctions.Cancel.CancelAll)
{
// We need the index of the command in the array
var index = Array.FindIndex(Global.Video_Chunks, row => row.Contains(command));
// Logic for resume mode - skips already encoded files
if (File.Exists(Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + ".ivf" + "_finished.log")) == false)
{
// One Preplaced Encoding
Process ffmpegProcess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
UseShellExecute = true,
FileName = "cmd.exe",
WorkingDirectory = Global.FFmpeg_Path
};
if (!Show_Terminal)
{
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
}
string InputVideo = "";
if (Splitting.split_type >= 1)
{
// FFmpeg Scene Detect or PySceneDetect
InputVideo = " -i " + '\u0022' + Global.Video_Path + '\u0022' + " " + command;
}
else if (Splitting.split_type == 0)
{
// Chunk based splitting
InputVideo = " -i " + '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", command) + '\u0022';
}
// Saves encoder progress to log file
string ffmpeg_progress = " -an -progress " + '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Progress", "split" + index.ToString("D5") + "_progress.log") + '\u0022';
string ffmpeg_input = InputVideo + " " + MainWindow.FilterCommand + Pixel_Format + " " + MainWindow.VSYNC + " ";
// Process Exit Code
int exit_code = 0;
// Logic to skip first preplaced encoding if "_finished" log file exists
if (File.Exists(Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + "_stats.log" + "_finished.log")) == false)
{
string encoderCMD = "";
if (MainWindow.OnePreplaced)
{
// One Preplaced Encoding
encoderCMD = " -y " + Final_Encoder_Command + " ";
encoderCMD += '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + ".webm") + '\u0022';
}
else
{
// Two Preplaced Encoding - First Preplaced
encoderCMD = " -y " + Final_Encoder_Command + " -preplaced 1 -preplacedlogfile ";
encoderCMD += '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + "_stats.log") + '\u0022' + " -f webm NUL";
}
startInfo.Arguments = "/C ffmpeg.exe " + ffmpeg_progress + ffmpeg_input + encoderCMD;
Helpers.Logging("Encoding Video: " + startInfo.Arguments);
ffmpegProcess.StartInfo = startInfo;
ffmpegProcess.Start();
// Sets the process priority
if (!Process_Priority)
ffmpegProcess.PriorityClreplaced = ProcessPriorityClreplaced.BelowNormal;
// Get launched Process ID
int temp_pid = ffmpegProcess.Id;
// Add Process ID to Array, inorder to keep track / kill the instances
Global.Launched_PIDs.Add(temp_pid);
ffmpegProcess.WaitForExit();
// Get Exit Code
exit_code = ffmpegProcess.ExitCode;
if (exit_code != 0)
Helpers.Logging("Chunk " + command + " Failed with Exit Code: " + exit_code.ToString());
// Remove PID from Array after Exit
Global.Launched_PIDs.RemoveAll(i => i == temp_pid);
if (MainWindow.OnePreplaced == false && SmallFunctions.Cancel.CancelAll == false && exit_code == 0)
{
// Writes log file if first preplaced is finished, to be able to skip them later if in resume mode
Helpers.WriteToFileThreadSafe("", Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + "_stats.log" + "_finished.log"));
}
}
if (!MainWindow.OnePreplaced)
{
// Creates a different progress file for the second preplaced (avoids negative frame progressbar)
ffmpeg_progress = " -an -progress " + '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Progress", "split" + index.ToString("D5") + "_progress_2nd.log") + '\u0022';
string encoderCMD = " -preplaced 2 " + Final_Encoder_Command;
encoderCMD += " -preplacedlogfile " + '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + "_stats.log") + '\u0022';
encoderCMD += " " + '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + ".webm") + '\u0022';
startInfo.Arguments = "/C ffmpeg.exe " + ffmpeg_progress + ffmpeg_input + encoderCMD;
Helpers.Logging("Encoding Video: " + startInfo.Arguments);
ffmpegProcess.StartInfo = startInfo;
ffmpegProcess.Start();
// Sets the process priority
if (!Process_Priority)
ffmpegProcess.PriorityClreplaced = ProcessPriorityClreplaced.BelowNormal;
// Get launched Process ID
int temp_pid = ffmpegProcess.Id;
// Add Process ID to Array, inorder to keep track / kill the instances
Global.Launched_PIDs.Add(temp_pid);
ffmpegProcess.WaitForExit();
// Get Exit Code
exit_code = ffmpegProcess.ExitCode;
if (exit_code != 0)
Helpers.Logging("Chunk " + command + " Failed with Exit Code: " + exit_code.ToString());
// Remove PID from Array after Exit
Global.Launched_PIDs.RemoveAll(i => i == temp_pid);
}
if (SmallFunctions.Cancel.CancelAll == false && exit_code == 0)
{
// This function will write finished encodes to a log file, to be able to skip them if in resume mode
Helpers.WriteToFileThreadSafe("", Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + ".ivf" + "_finished.log"));
}
}
}
}
finally { concurrencySemapreplaced.Release(); }
});
tasks.Add(task);
}
Task.WaitAll(tasks.ToArray());
}
}
19
Source : EncodeVideoPipe.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
public static void Encode()
{
// Main Encoding Function
// Creates a new Thread Pool
using (SemapreplacedSlim concurrencySemapreplaced = new SemapreplacedSlim(EncodeVideo.Worker_Count))
{
// Creates a tasks list
List<Task> tasks = new List<Task>();
// Iterates over all args in VideoChunks list
foreach (var command in Global.Video_Chunks)
{
concurrencySemapreplaced.Wait();
var task = Task.Factory.StartNew(() =>
{
try
{
if (!SmallFunctions.Cancel.CancelAll)
{
// We need the index of the command in the array
var index = Array.FindIndex(Global.Video_Chunks, row => row.Contains(command));
// Logic for resume mode - skips already encoded files
if (File.Exists(Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + ".ivf" + "_finished.log")) == false)
{
// One Preplaced Encoding
Process ffmpegProcess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
UseShellExecute = true,
FileName = "cmd.exe",
WorkingDirectory = Global.FFmpeg_Path
};
if (!EncodeVideo.Show_Terminal)
{
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
}
string InputVideo = "";
if (Splitting.split_type >= 1)
{
// FFmpeg Scene Detect or PySceneDetect
InputVideo = " -i " + '\u0022' + Global.Video_Path + '\u0022' + " " + command;
}
else if (Splitting.split_type == 0)
{
// Chunk based splitting
InputVideo = " -i " + '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", command) + '\u0022';
}
// Saves encoder progress to log file
string ffmpeg_progress = " -progress " + '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Progress", "split" + index.ToString("D5") + "_progress.log") + '\u0022';
// FFmpeg Pipe
string ffmpeg_input = InputVideo + " " + MainWindow.FilterCommand + EncodeVideo.Pixel_Format + " -color_range 0 " + MainWindow.VSYNC + " -f yuv4mpegpipe - | ";
// Process Exit Code
int exit_code = 0;
// Logic to skip first preplaced encoding if "_finished" log file exists
if (File.Exists(Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + "_stats.log" + "_finished.log")) == false)
{
string encoderCMD = "";
if (MainWindow.OnePreplaced)
{
// One Preplaced Encoding
if (MainWindow.EncodeMethod == 5)
{
// aomenc
encoderCMD = '\u0022' + Path.Combine(Global.Aomenc_Path, "aomenc.exe") + '\u0022' + " - --preplacedes=1 " + EncodeVideo.Final_Encoder_Command + " --output=";
}
else if (MainWindow.EncodeMethod == 6)
{
// rav1e
encoderCMD = '\u0022' + Path.Combine(Global.Rav1e__Path, "rav1e.exe") + '\u0022' + " - " + EncodeVideo.Final_Encoder_Command + " --output ";
}
else if (MainWindow.EncodeMethod == 7)
{
// svt-av1
ffmpeg_input = InputVideo + " " + MainWindow.FilterCommand + EncodeVideo.Pixel_Format + " -color_range 0 -nostdin " + MainWindow.VSYNC + " -f yuv4mpegpipe - | ";
encoderCMD = '\u0022' + Path.Combine(Global.SvtAv1_Path, "SvtAv1EncApp.exe") + '\u0022' + " -i stdin " + EncodeVideo.Final_Encoder_Command + " --preplacedes 1 -b ";
}
encoderCMD += '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + ".ivf") + '\u0022';
}
else
{
// Two Preplaced Encoding - First Preplaced
if (MainWindow.EncodeMethod == 5)
{
// aomenc
encoderCMD = '\u0022' + Path.Combine(Global.Aomenc_Path, "aomenc.exe") + '\u0022' + " - --preplacedes=2 --preplaced=1 " + EncodeVideo.Final_Encoder_Command + " --fpf=";
encoderCMD += '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + "_stats.log") + '\u0022' + " --output=NUL";
}
else if (MainWindow.EncodeMethod == 7)
{
// svt-av1
ffmpeg_input = InputVideo + " " + MainWindow.FilterCommand + EncodeVideo.Pixel_Format + " -color_range 0 -nostdin " + MainWindow.VSYNC + " -f yuv4mpegpipe - | ";
encoderCMD = '\u0022' + Path.Combine(Global.SvtAv1_Path, "SvtAv1EncApp.exe") + '\u0022' + " -i stdin " + EncodeVideo.Final_Encoder_Command + " --irefresh-type 2 --preplaced 1 -b NUL --stats ";
encoderCMD += '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + "_stats.log") + '\u0022';
}
}
startInfo.Arguments = "/C ffmpeg.exe " + ffmpeg_progress + ffmpeg_input + encoderCMD;
Helpers.Logging("Encoding Video: " + startInfo.Arguments);
ffmpegProcess.StartInfo = startInfo;
ffmpegProcess.Start();
// Sets the process priority
if (!EncodeVideo.Process_Priority)
ffmpegProcess.PriorityClreplaced = ProcessPriorityClreplaced.BelowNormal;
// Get launched Process ID
int temp_pid = ffmpegProcess.Id;
// Add Process ID to Array, inorder to keep track / kill the instances
Global.Launched_PIDs.Add(temp_pid);
ffmpegProcess.WaitForExit();
// Get Exit Code
exit_code = ffmpegProcess.ExitCode;
if (exit_code != 0)
Helpers.Logging("Chunk " + command + " Failed with Exit Code: " + exit_code.ToString());
// Remove PID from Array after Exit
Global.Launched_PIDs.RemoveAll(i => i == temp_pid);
if (MainWindow.OnePreplaced == false && SmallFunctions.Cancel.CancelAll == false && exit_code == 0)
{
// Writes log file if first preplaced is finished, to be able to skip them later if in resume mode
Helpers.WriteToFileThreadSafe("", Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + "_stats.log" + "_finished.log"));
}
}
if (!MainWindow.OnePreplaced)
{
// Creates a different progress file for the second preplaced (avoids negative frame progressbar)
ffmpeg_progress = " -progress " + '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Progress", "split" + index.ToString("D5") + "_progress_2nd.log") + '\u0022';
string encoderCMD = "";
if (MainWindow.EncodeMethod == 5)
{
// aomenc
encoderCMD = '\u0022' + Path.Combine(Global.Aomenc_Path, "aomenc.exe") + '\u0022' + " - --preplacedes=2 --preplaced=2 " + EncodeVideo.Final_Encoder_Command + " --fpf=";
encoderCMD += '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + "_stats.log") + '\u0022' + " --output=";
}
else if (MainWindow.EncodeMethod == 7)
{
// svt-av1
ffmpeg_input = InputVideo + " " + MainWindow.FilterCommand + EncodeVideo.Pixel_Format + " -color_range 0 -nostdin " + MainWindow.VSYNC + " -f yuv4mpegpipe - | ";
encoderCMD = '\u0022' + Path.Combine(Global.SvtAv1_Path, "SvtAv1EncApp.exe") + '\u0022' + " -i stdin " + EncodeVideo.Final_Encoder_Command + " --irefresh-type 2 --preplaced 2 --stats ";
encoderCMD += '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + "_stats.log") + '\u0022' + " -b ";
}
encoderCMD += '\u0022' + Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + ".ivf") + '\u0022';
startInfo.Arguments = "/C ffmpeg.exe " + ffmpeg_progress + ffmpeg_input + encoderCMD;
Helpers.Logging("Encoding Video: " + startInfo.Arguments);
ffmpegProcess.StartInfo = startInfo;
ffmpegProcess.Start();
// Sets the process priority
if (!EncodeVideo.Process_Priority)
ffmpegProcess.PriorityClreplaced = ProcessPriorityClreplaced.BelowNormal;
// Get launched Process ID
int temp_pid = ffmpegProcess.Id;
// Add Process ID to Array, inorder to keep track / kill the instances
Global.Launched_PIDs.Add(temp_pid);
ffmpegProcess.WaitForExit();
// Get Exit Code
exit_code = ffmpegProcess.ExitCode;
if (exit_code != 0)
Helpers.Logging("Chunk " + command + " Failed with Exit Code: " + exit_code.ToString());
// Remove PID from Array after Exit
Global.Launched_PIDs.RemoveAll(i => i == temp_pid);
}
if (SmallFunctions.Cancel.CancelAll == false && exit_code == 0)
{
// This function will write finished encodes to a log file, to be able to skip them if in resume mode
Helpers.WriteToFileThreadSafe("", Path.Combine(Global.temp_path, Global.temp_path_folder, "Chunks", "split" + index.ToString("D5") + ".ivf" + "_finished.log"));
}
}
}
}
finally { concurrencySemapreplaced.Release(); }
});
tasks.Add(task);
}
Task.WaitAll(tasks.ToArray());
}
}
19
Source : GamePadState.cs
with MIT License
from allenwp
with MIT License
from allenwp
public override string ToString()
{
if (!IsConnected)
return "[GamePadState: IsConnected = 0]";
return "[GamePadState: IsConnected=" + (IsConnected ? "1" : "0") +
", PacketNumber=" + PacketNumber.ToString("00000") +
", Buttons=" + Buttons +
", DPad=" + DPad +
", ThumbSticks=" + ThumbSticks +
", Triggers=" + Triggers +
"]";
}
19
Source : JoystickState.cs
with MIT License
from allenwp
with MIT License
from allenwp
public override string ToString()
{
var ret = new StringBuilder(54 - 2 + Axes.Length * 7 + Buttons.Length + Hats.Length * 5);
ret.Append("[JoystickState: IsConnected=" + (IsConnected ? 1 : 0));
if (IsConnected)
{
ret.Append(", Axes=");
foreach (var axis in Axes)
ret.Append((axis > 0 ? "+" : "") + axis.ToString("00000") + " ");
ret.Length--;
ret.Append(", Buttons=");
foreach (var button in Buttons)
ret.Append((int)button);
ret.Append(", Hats=");
foreach (var hat in Hats)
ret.Append(hat + " ");
ret.Length--;
}
ret.Append("]");
return ret.ToString();
}
19
Source : MemoryEditor.cs
with MIT License
from allenwp
with MIT License
from allenwp
private static string FixedHex(int v, int count)
{
return v.ToString("X").PadLeft(count, '0');
}
19
Source : ServiceInfo.cs
with MIT License
from AlphaYu
with MIT License
from AlphaYu
public static ServiceInfo Create(replacedembly replacedembly)
{
var description = replacedembly.GetCustomAttribute<replacedemblyDescriptionAttribute>().Description;
var replacedemblyName = replacedembly.GetName();
var version = replacedemblyName.Version;
var fullName = replacedemblyName.Name.ToLower();
//var startIndex = fullName.IndexOf('.') + 1;
//var endIndex = fullName.IndexOf('.', startIndex);
//var shortName = fullName.Substring(startIndex, endIndex - startIndex);
var splitFullName = fullName.Split(".");
var shortName = splitFullName[^2];
return new ServiceInfo
{
FullName = fullName
,
ShortName = shortName
,
replacedemblyName = replacedemblyName.Name
,
replacedemblyFullName = replacedembly.FullName
,
Description = description
,
Version = string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision.ToString("00"))
};
}
19
Source : YoloAnnotationExportProvider.cs
with MIT License
from AlturosDestinations
with MIT License
from AlturosDestinations
public void Export(string path, AnnotationPackage[] packages, ObjectClreplaced[] objectClreplacedes)
{
// Create folders
var dataPath = Path.Combine(path, DataFolderName);
if (!Directory.Exists(dataPath))
{
Directory.CreateDirectory(dataPath);
}
var backupPath = Path.Combine(path, BackupFolderName);
if (!Directory.Exists(backupPath))
{
Directory.CreateDirectory(backupPath);
}
var imagePath = Path.Combine(dataPath, ImageFolderName);
if (!Directory.Exists(imagePath))
{
Directory.CreateDirectory(imagePath);
}
// Split images randomly into two lists
// Training list contains the images Yolo uses for training. "_trainingPercentage" dictates how many percent of all images are used for this.
// Testing list contains all remaining images that Yolo uses to validate how well it performs based on the training data.
// Unannotated images are not taken into account and will not be exported.
var images = new List<AnnotationImage>();
var trainingImages = new List<AnnotationImage>();
var testingImages = new List<AnnotationImage>();
var yoloControl = this.Control as YoloExportControl;
foreach (var package in packages)
{
var availableImages = package.Images.Where(o => o.BoundingBoxes != null && o.BoundingBoxes.Count != 0).ToList();
availableImages.RemoveAll(o => !o.BoundingBoxes.Any(p => objectClreplacedes.Select(q => q.Id).Contains(p.ObjectIndex)));
var rng = new Random();
var shuffledImages = availableImages.OrderBy(o => rng.Next()).ToList();
var count = (int)(shuffledImages.Count * (yoloControl.TrainingPercentage / 100.0));
trainingImages.AddRange(shuffledImages.Take(count));
testingImages.AddRange(shuffledImages.Skip(count));
images.AddRange(availableImages);
}
this._exportedNames = new Dictionary<AnnotationImage, string>();
for (var i = 0; i < images.Count; i++)
{
var image = images[i];
var newName = $"export{i.ToString("D5")}{Path.GetExtension(image.ImageName)}";
this._exportedNames[image] = newName;
}
this.CreateFiles(dataPath, imagePath, images.ToArray(), objectClreplacedes);
this.CreateMetaData(dataPath, trainingImages.ToArray(), testingImages.ToArray(), objectClreplacedes);
var yoloConfigPath = yoloControl.UseTinyYoloConfig ? TinyYoloConfigPath : YoloConfigPath;
this.CreateYoloConfig(path, yoloConfigPath, objectClreplacedes);
this.CreateCommandFile(path);
}
19
Source : TMP_CharacterPropertyDrawer.cs
with MIT License
from Alword
with MIT License
from Alword
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
SerializedProperty prop_Unicode = property.FindPropertyRelative("m_Unicode");
SerializedProperty prop_GlyphIndex = property.FindPropertyRelative("m_GlyphIndex");
SerializedProperty prop_Scale = property.FindPropertyRelative("m_Scale");
GUIStyle style = new GUIStyle(EditorStyles.label);
style.richText = true;
EditorGUIUtility.labelWidth = 40f;
EditorGUIUtility.fieldWidth = 50;
Rect rect = new Rect(position.x + 50, position.y, position.width, 49);
// Display non-editable fields
if (GUI.enabled == false)
{
int unicode = prop_Unicode.intValue;
EditorGUI.LabelField(new Rect(rect.x, rect.y, 120f, 18), new GUIContent("Unicode: <color=#FFFF80>0x" + unicode.ToString("X") + "</color>"), style);
EditorGUI.LabelField(new Rect(rect.x + 115, rect.y, 120f, 18), unicode <= 0xFFFF ? new GUIContent("UTF16: <color=#FFFF80>\\u" + unicode.ToString("X4") + "</color>") : new GUIContent("UTF32: <color=#FFFF80>\\U" + unicode.ToString("X8") + "</color>"), style);
EditorGUI.LabelField(new Rect(rect.x, rect.y + 18, 120, 18), new GUIContent("Glyph ID: <color=#FFFF80>" + prop_GlyphIndex.intValue + "</color>"), style);
EditorGUI.LabelField(new Rect(rect.x, rect.y + 36, 80, 18), new GUIContent("Scale: <color=#FFFF80>" + prop_Scale.floatValue + "</color>"), style);
// Draw Glyph (if exists)
DrawGlyph(position, property);
}
else // Display editable fields
{
EditorGUIUtility.labelWidth = 55f;
GUI.SetNextControlName("Unicode Input");
EditorGUI.BeginChangeCheck();
string unicode = EditorGUI.TextField(new Rect(rect.x, rect.y, 120, 18), "Unicode:", prop_Unicode.intValue.ToString("X"));
if (GUI.GetNameOfFocusedControl() == "Unicode Input")
{
//Filter out unwanted characters.
char chr = Event.current.character;
if ((chr < '0' || chr > '9') && (chr < 'a' || chr > 'f') && (chr < 'A' || chr > 'F'))
{
Event.current.character = '\0';
}
}
if (EditorGUI.EndChangeCheck())
{
// Update Unicode value
prop_Unicode.intValue = TMP_TextUtilities.StringHexToInt(unicode);
}
// Cache current glyph index in case it needs to be restored if the new glyph index is invalid.
int currentGlyphIndex = prop_GlyphIndex.intValue;
EditorGUIUtility.labelWidth = 59f;
EditorGUI.BeginChangeCheck();
EditorGUI.DelayedIntField(new Rect(rect.x, rect.y + 18, 100, 18), prop_GlyphIndex, new GUIContent("Glyph ID:"));
if (EditorGUI.EndChangeCheck())
{
// Get a reference to the font replacedet
TMP_Fontreplacedet fontreplacedet = property.serializedObject.targetObject as TMP_Fontreplacedet;
// Make sure new glyph index is valid.
int elementIndex = fontreplacedet.glyphTable.FindIndex(item => item.index == prop_GlyphIndex.intValue);
if (elementIndex == -1)
prop_GlyphIndex.intValue = currentGlyphIndex;
else
fontreplacedet.m_IsFontreplacedetLookupTablesDirty = true;
}
int glyphIndex = prop_GlyphIndex.intValue;
// Reset glyph selection if new character has been selected.
if (GUI.enabled && m_GlyphSelectedForEditing != glyphIndex)
m_GlyphSelectedForEditing = -1;
// Display button to edit the glyph data.
if (GUI.Button(new Rect(rect.x + 120, rect.y + 18, 75, 18), new GUIContent("Edit Glyph")))
{
if (m_GlyphSelectedForEditing == -1)
m_GlyphSelectedForEditing = glyphIndex;
else
m_GlyphSelectedForEditing = -1;
// Button clicks should not result in potential change.
GUI.changed = false;
}
// Show the glyph property drawer if selected
if (glyphIndex == m_GlyphSelectedForEditing && GUI.enabled)
{
// Get a reference to the font replacedet
TMP_Fontreplacedet fontreplacedet = property.serializedObject.targetObject as TMP_Fontreplacedet;
if (fontreplacedet != null)
{
// Get the index of the glyph in the font replacedet glyph table.
int elementIndex = fontreplacedet.glyphTable.FindIndex(item => item.index == glyphIndex);
if (elementIndex != -1)
{
SerializedProperty prop_GlyphTable = property.serializedObject.FindProperty("m_GlyphTable");
SerializedProperty prop_Glyph = prop_GlyphTable.GetArrayElementAtIndex(elementIndex);
SerializedProperty prop_GlyphMetrics = prop_Glyph.FindPropertyRelative("m_Metrics");
SerializedProperty prop_GlyphRect = prop_Glyph.FindPropertyRelative("m_GlyphRect");
Rect newRect = EditorGUILayout.GetControlRect(false, 115);
EditorGUI.DrawRect(new Rect(newRect.x + 52, newRect.y - 20, newRect.width - 52, newRect.height - 5), new Color(0.1f, 0.1f, 0.1f, 0.45f));
EditorGUI.DrawRect(new Rect(newRect.x + 53, newRect.y - 19, newRect.width - 54, newRect.height - 7), new Color(0.3f, 0.3f, 0.3f, 0.8f));
// Display GlyphRect
newRect.x += 55;
newRect.y -= 18;
newRect.width += 5;
EditorGUI.PropertyField(newRect, prop_GlyphRect);
// Display GlyphMetrics
newRect.y += 45;
EditorGUI.PropertyField(newRect, prop_GlyphMetrics);
rect.y += 120;
}
}
}
EditorGUIUtility.labelWidth = 39f;
EditorGUI.PropertyField(new Rect(rect.x, rect.y + 36, 80, 18), prop_Scale, new GUIContent("Scale:"));
// Draw Glyph (if exists)
DrawGlyph(position, property);
}
}
19
Source : TMP_EditorUtility.cs
with MIT License
from Alword
with MIT License
from Alword
public static string GetUnicodeCharacterSequence(int[] characterSet)
{
if (characterSet == null || characterSet.Length == 0)
return string.Empty;
string characterSequence = string.Empty;
int count = characterSet.Length;
int first = characterSet[0];
int last = first;
for (int i = 1; i < count; i++)
{
if (characterSet[i - 1] + 1 == characterSet[i])
{
last = characterSet[i];
}
else
{
if (first == last)
characterSequence += first.ToString("X2") + ",";
else
characterSequence += first.ToString("X2") + "-" + last.ToString("X2") + ",";
first = last = characterSet[i];
}
}
// handle the final group
if (first == last)
characterSequence += first.ToString("X2");
else
characterSequence += first.ToString("X2") + "-" + last.ToString("X2");
return characterSequence;
}
19
Source : ParameterController.cs
with GNU General Public License v2.0
from AmanoTooko
with GNU General Public License v2.0
from AmanoTooko
public override string ToString()
{
return string.Format($"StartTime: {StartTime.ToString("HH:mm:ss.fff")}, Note: {Note.ToString("X2")}");
}
19
Source : TimelineCanvas.cs
with MIT License
from ambleside138
with MIT License
from ambleside138
private void InitializeHourText()
{
Children.Clear();
for(var t = StartHour; t<=EndHour; t++)
{
var text = new TextBlock
{
Text = t.ToString("00")
};
var yPosi = (t - StartHour) * HourHeight;
SetTop(text, yPosi + 8);
SetLeft(text, 8);
Children.Add(text);
var hLine = new Line
{
X1 = _HeaderWidth,
X2 = 500,
Y1 = yPosi + HourHeight / 2,
Y2 = yPosi + HourHeight / 2,
StrokeThickness = 1,
Stroke = Brushes.LightGray
};
Children.Add(hLine);
hLine = new Line
{
X1 = 0,
X2 = 500,
Y1 = yPosi + HourHeight,
Y2 = yPosi + HourHeight,
StrokeThickness = 1,
Stroke = Brushes.Black
};
Children.Add(hLine);
}
Height = (EndHour - StartHour) * HourHeight;
// 縦棒
var vline = new Line
{
X1 = _HeaderWidth,
X2 = _HeaderWidth,
Y1 = 0,
Y2 = Height,
StrokeThickness = 1,
Stroke = Brushes.Black
};
Children.Add(vline);
}
19
Source : NetworkClass.cs
with GNU General Public License v2.0
from AmanoTooko
with GNU General Public License v2.0
from AmanoTooko
public override string ToString()
{
return string.Format($"StartTime: {StartTime.ToString("HH:mm:ss.fff")}, Note: {Note.ToString("X2")}");
}
19
Source : Logger.cs
with MIT License
from AmigoCap
with MIT License
from AmigoCap
void Start() {
DateTime now = DateTime.Now;
string dir = "ReViVD Output/" + now.Day.ToString("00") + '-' + now.Month.ToString("00") + '-' + now.Year.ToString().Substring(2, 2) + "_" + now.Hour.ToString("00") + 'h' + now.Minute.ToString("00");
Directory.CreateDirectory(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), dir));
dirname = new FileInfo(dir).FullName;
nfi.NumberDecimalSeparator = ".";
InvokeRepeating("LogPosition", 0, 0.5f);
}
19
Source : Visualization.cs
with MIT License
from AmigoCap
with MIT License
from AmigoCap
public static void ExportResults() {
DateTime now = DateTime.Now;
string dir = Logger.Instance.dirname;
string path = System.IO.Path.Combine(dir, "export_" + now.Day.ToString("00") + '-' + now.Month.ToString("00") + '-' + now.Year.ToString().Substring(2, 2) + "_" + now.Hour.ToString("00") + 'h' + now.Minute.ToString("00") + ".csv");
try {
using (StreamWriter displayExport = new StreamWriter(path)) {
string s = "Displayed,";
HashSet<Path> pathsToKeep = new HashSet<Path>();
foreach (Path p in Visualization.Instance.paths) {
foreach (Atom a in p.atoms) {
if (a.ShouldDisplay)
pathsToKeep.Add(a.path);
}
}
foreach (Path p in pathsToKeep) {
s += p.name + ',';
}
displayExport.WriteLine(s);
for (int c = 0; c < SelectorManager.colors.Length; c++) {
pathsToKeep.Clear();
foreach (Atom a in SelectorManager.Instance.selectedRibbons[c]) {
if (a.ShouldDisplay)
pathsToKeep.Add(a.path);
}
string s_color = Logger.colorString[c] + ',';
foreach (Path p in pathsToKeep) {
s_color += p.name + ',';
}
displayExport.WriteLine(s_color);
}
}
}
catch (System.Exception e) {
ControlPanel.Instance.MakeErrorWindow("Error exporting results\n\n" + e.Message);
}
ControlPanel.Instance.MakeMessageWindow("Results export", "Successfully exported selection results to " + path);
}
19
Source : MeshProjection.cs
with MIT License
from Anatta336
with MIT License
from Anatta336
static Mesh BuildMesh(IEnumerable<Triangle> triangles, Float3 localScale)
{
List<Vector3> positions = new List<Vector3>();
List<Vector2> uvs = new List<Vector2>();
List<Vector3> normals = new List<Vector3>();
List<int> indices = new List<int>();
int triangleIndex = 0;
bool tooManyTrianglesForUInt16 = false;
foreach (Triangle triangle in triangles)
{
int vertexIndexWithinTriangle = 0;
foreach (Vertex vertex in triangle)
{
positions.Add(vertex.Position.AsVector3);
normals.Add((vertex.Normal * localScale).AsVector3);
uvs.Add(new Vector2(
vertex.Position.x + 0.5f,
vertex.Position.y + 0.5f
));
indices.Add(triangleIndex * 3 + vertexIndexWithinTriangle);
++vertexIndexWithinTriangle;
}
++triangleIndex;
if (triangleIndex > maxUInt16VertexCount / 3)
{
tooManyTrianglesForUInt16 = true;
if (triangleIndex > int.MaxValue / 3)
{
Debug.LogWarning($"MeshProjection attempting to create extremely large mesh with over {triangleIndex.ToString("N0")} triangles, which cannot be represented in a single mesh. The excess triangles will be discarded.");
break;
}
}
}
var mesh = new Mesh();
if (tooManyTrianglesForUInt16)
{
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
// when using UInt32 as index format the max index should be 4.2 billion,
// but Unity stores mesh.triangles as an int[] so actual limit is 2.1 billion
// (that is still a very large number of vertices)
}
mesh.vertices = positions.ToArray();
mesh.normals = normals.ToArray();
mesh.uv = uvs.ToArray();
mesh.triangles = indices.ToArray();
//TODO: could roll this into the overall mesh generation rather than separating it out
CalculateMeshTangents(mesh);
return mesh;
}
See More Examples