Posts

Showing posts with the label c#

XML Mass Changing Type Hexadecimal

XML Mass Changing Type Hexadecimal So I have 80 000 lines of XML. They follow this general structure: <Object type="0xa14" id="Steel Dagger"> <Class>Equipment</Class> <Item/> <Texture> <File>lofiObj5</File> <Index>0x60</Index> </Texture> <SlotType>2</SlotType> <Tier>0</Tier> <Description>{equip.A_sharp_dagger_made_of_steel.}</Description> <RateOfFire>1</RateOfFire> <Sound>weapon/blunt_dagger</Sound> <Projectile> <ObjectId>Blade</ObjectId> <Speed>140</Speed> <MinDamage>20</MinDamage> <MaxDamage>60</MaxDamage> <LifetimeMS>400</LifetimeMS> </Projectile> <BagType>1</BagType> <OldSound>daggerSwing</OldSound> <feedPower>5</feedPower> <DisplayId>{equip.Steel_Dagger}</Displa...

How to resolve this System.IO.FileNotFoundException

How to resolve this System.IO.FileNotFoundException Event Viewer Application: The.Application.Name.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException Stack: at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen( System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl( System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) at System.Windows.Threading.Dispatcher.PushFrameImpl( System.Windows.Threading.DispatcherFrame) at System.Windows.Threading.Dispatcher.PushFrame( System.Windows.Threading.DispatcherFrame) at System.Windows.Threading.Dispatcher.Run() at Sy...

Reading a .txt file in C++ [on hold]

Reading a .txt file in C++ [on hold] So im trying to write a program in C++ that takes input line by line from a text file and give it as and output but im running into errors that I cant find very good answers to. Thanks in advance for the help Code is: 1 #include "stdafx.h" 2 #include <iostream> 3 #include <fstream> 4 #include <string> 5 using namespace std; 6 int main() 7 { 8 string line; 9 ifstream file("INPUT.txt"); 10 if (file.is_open()) 11 { 12 while(getline(file,line) 13 { 14 cout << line << 'n' 15 } 16 file.close(); 17 18 } 19 else 20 { 21 cout << "file is not open" << 'n'; 22 } 23 24 return 0; 25 } The errors from the compiler read: line(15): error C2064: term does not evaluate to a fun...

Ask user to Save data code review

Ask user to Save data code review When user clicks to exit form, and data are unsaved, I would like to ask user does he wants to save data. Can below code be more simplified, to be easier to read this method SaveOrRejectChanges(). private bool SaveOrRejectChanges() { if (MsgBox("do you want to save data") == true) { if (ValidateIsEmptyOrNullValue()) return false; //here I check is required field not entered SaveChanges(); // if validation passes (data are entered), save it } else RejectChanges(); // cancel changes by setting EntityState.Unchanged on DBContext for each entity return true; } private void iExit_ItemClick(object sender, ItemClickEventArgs e) { _isFormClosing = true; // close form if data are not modified (no saving required). Or close form when data are saved or changes are canceled if (_isDataModified == false || SaveOrRejectChanges()) this.Close(); } I am still sort of beginner, so please share your...

Default route at startup with ASP.NET Core [duplicate]

Default route at startup with ASP.NET Core [duplicate] This question already has an answer here: With a brand new ASP.NET Core API application, how do you set the default route to navigate to when F5 debugging? I have the SPA being served correctly but every time the application is started with Visual Studio, it defaults to https://localhost:44323/api/values https://localhost:44323/api/values There appears to be nowhere in Visual Studio to configure this. In previous versions of ASP.NET this was an option under project properties. (The /api/values route being the route of the default controller setup by the template.) /api/values This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. Go to the project properties, Debug tab, look to the right of the checkbox that is labelled "Launch browser:" Hiding in plain sight. – JamieMeyer ...

Search String- Search text file using a textbox

Search String- Search text file using a textbox I presently have a multi line textBox that has acquired a list from another source.This list looks like this: 48:5D:36:4E:63:F8 00:24:1D:23:97:CF 4C:CC:6A:F4:42:2C My Goal is: I am trying to use the line items in this textBox list to find a match in a text file. What is important is when it does not find a line match in the text file, a messagebox appears saying "Item is not on list'...and include the actual textBox line item that wasn't found in the text file. I am presently trying to work the following: string find = textBox16.Text; foreach (string line in File.ReadAllLines("watcher.txt")) { if (line.Contains(find)) { //Do nothing } else { MessageBox.Show("Item not on list"); } } I've also tried this: foreach (string line in textBox16.Lines) { if (File.ReadAllLines("watcher.txt").Contains(textBox16.Text)) { //do nothing } else...

C++ vector not storing class

C++ vector not storing class I am writing a simple feed-forward neural network in c++, however when I try to store my neuron class in my layer structure, it crashes and gives this output: terminate called after throwing an instance of 'std::bad_array_new_length' terminate called after throwing an instance of 'std::bad_array_new_length' what(): std::bad_array_new_length what(): std::bad_array_new_length This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Here is my program: #include <iostream> #include <random> #include <vector> using namespace std; random_device e; int randomG(int min, int max){ return (e()%(max-min))+min; } int f(int v){ return v+5; } class neuron{ public: neuron(int _insN, int _funt...

How do I bind to an image from an api endpoint?

How do I bind to an image from an api endpoint? Currently, I have an app where I want to display a list of image thumbnails on my layout. I'm able to get the json response from the api endpoint and deserialize it. Now, I have an image object and in that object, I have an image preview url (the thumbnail image). My question is how do I display a list of thumbnail images in my layout? Here's the method that gets called to display images and some property setup: private List<string> images; public List<string> Images { get { return images; } set { SetProperty(ref images, value); } } private async Task DisplayImages() { var imageObj = await _mediaService.GetCatImages(); //imageObj.Hits[i].PreviewUrl; <-- how to a reference to the previewurl but what property should it bind to? } Here's my layout at the moment: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" ...

Convert Json to String Arrays

Convert Json to String Arrays This is my code for my form: product name: product detail: <button id="btn" type="submit" class="btn btn-default">Submit</button> This is my javascript $(function postProduct() { $('#btn').click(function () { var productName = document.getElementById("name").value; var productDetail = document.getElementById("detail").value; var dimensions = [ productName, productDetail]; var keys = $.map(dimensions, function (value, key) { return key; }); if (productName == '' || productDetail == '') { alert("Please Fill All Fields"); } else { $.ajax({ type: 'post', url: "api/product/addproduct", data: keys, dataType: 'j...

Compile code ported from Linux to windows and MingW-w64

Compile code ported from Linux to windows and MingW-w64 Can anyone tell me how can I compile code using POSIX headers in windows system? OS: Windows 10 installed: MingW-w64 MingW Code:Blocks Version 17.12 MSVS 2017 free version No Cgywin The code was developed in Linux system and uses a lot of POSIX stuff. such as #include <sys/types.h> #include <sys/fcntl.h> #include <sys/mman.h> #include <sys/time.h> #include <sys/ipc.h> #include <sys/shm.h> I want to compile it under windows system. Is there any win32 version of those POSIX lib/header that ported to windows? Someone told me MinGW-w64 could but I cannot find any of those headers. If you can't use Cygwin, or any other POSIX emulating environment you might want to consider doing a proper port, using the Windows API. Note that MinGW is just a port of the GCC compilers , not of the POSIX environment. You could maybe use MSYS for some parts, but considering the headers ...

LoginForm hides or closes automatically when the ShowInTaskBar property is false

LoginForm hides or closes automatically when the ShowInTaskBar property is false I am developing an application in C# Winforms with system login where I have two forms, one being the main MainForm and the other which is for the login LoginForm . MainForm LoginForm This application has a Modern Flat UI Design interface, so it wants the LoginForm form is displayed in front of the MainForm form, to not display its icon in the taskbar and not allow the user to interact with MainForm to display it's been use of the method ShowDialog(); . Modern Flat UI Design LoginForm form MainForm MainForm ShowDialog(); LoginForm compacted code: LoginForm public partial class LoginForm : Form { protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.ShowInTaskbar = this.ShowIcon = false; } } MainForm compacted code: MainForm public partial class MainForm : Form { protected override void OnLoad(EventArgs e) { base.OnLoad(e); new Logi...

SQL query to select everything from 1 table and 1 column(same name as in table 1) from another table

SQL query to select everything from 1 table and 1 column(same name as in table 1) from another table I have 3 tables. table1 : Products: ProductId Category Model Price Quantity table2: OrderLines: OrderId ProductId Quantity table3: Orders: OrderId CustomerId (theres also a customer table but it doesnt matter) Now I want to select all the products data from Products table that have ProductId = ProductId in OrderLines table, but get the quantity data (of those same products) from the OrderLines table. Tried all kinds of queries, couldn't find one that works. heres the last thing i kind of tried: SELECT tb1.* ,tb2.[Quantity] FROM [Products] tb1, [OrderLines] tb2 WHERE tb1.[ProductId] IN ( SELECT [ProductId] FROM [OrderLines] WHERE OrderId = @orderId) INNER JOIN [OrderLines] tb2 ON[Products].Quantity = [OrderLines].Quantity"; didn't worked. any suggestions? Thanks a lot. sample data: Orders: OrderId CustomerId 1 2 OrderLines: OrderId ProductId Quantity 1...

C# Method to Compare DateTime Fields Specified During Execution?

C# Method to Compare DateTime Fields Specified During Execution? My project has many objects with date fields, and I often need to select everything where one such field is within a date range. For example: public class Contract { public DateTime SignDate { get; set; } public DateTime ReleaseDate { get; set; } } public class PersonalCheck { public DateTime SignDate { get; set; } public DateTime ProcessDate { get; set; } public DateTime VoidDate { get; set; } } If I only cared about SignDate, it would be easy. I would declare an Interface... public interface IObjectWithSignDate { DateTime SignDate { get; set; } } ...change my other objects to inherit from it, then create a method like this: public static IQueryable<T> SignedWithin<T>(this IQueryable<T> items, DateTime start, DateTime end) where T : IObjectWithSignDate { return items.Where(q => q.SignDate >= start && q.SignDate <= end); } How can I avoid rewr...