Click here to Skip to main content
15,881,852 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
Richard MacCutchan18-Jul-16 4:51
mveRichard MacCutchan18-Jul-16 4:51 
GeneralRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
turbosupramk318-Jul-16 4:58
turbosupramk318-Jul-16 4:58 
GeneralRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
Richard MacCutchan18-Jul-16 6:15
mveRichard MacCutchan18-Jul-16 6:15 
GeneralRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
turbosupramk318-Jul-16 7:49
turbosupramk318-Jul-16 7:49 
GeneralRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
turbosupramk319-Jul-16 4:10
turbosupramk319-Jul-16 4:10 
QuestionClose Form Popup before opening MessageBox.Show and the form use delegate ? Pin
Member 245846717-Jul-16 22:47
Member 245846717-Jul-16 22:47 
AnswerRe: Close Form Popup before opening MessageBox.Show and the form use delegate ? Pin
OriginalGriff17-Jul-16 22:51
mveOriginalGriff17-Jul-16 22:51 
Questionc# parser questions. Pin
elfenliedtopfan517-Jul-16 13:13
elfenliedtopfan517-Jul-16 13:13 
hello people of code project i have the following code.

C#
private String header;
    private Dictionary<String, String> tokens;

    public DevExpress.XtraEditors.TextEdit txtDisplayName;
    public DevExpress.XtraEditors.ListBoxControl lstwep;
    public DevExpress.XtraEditors.SimpleButton elfenliedbutton;
    public DevExpress.XtraEditors.TextEdit txtmaxammo;
    public LauncherForm elfform;
    private String file;



    public Parser(String file, DevExpress.XtraEditors.ListBoxControl lstelfen, LauncherForm elfform1)
    {
        elfform = elfform1;
        lstwep = lstelfen;

        this.file = file;
        String plainText;
        using (StreamReader sr = new StreamReader(file))
        {
            plainText = sr.ReadToEnd();
        }

        String[] tokens = plainText.Split('\\');
        this.tokens = new Dictionary<string, string>(tokens.Length + 10);

        header = tokens[0];
        for (int i = 1; i < tokens.Length; i += 2)
        {
            String key = tokens[i];
            String val = (i + 1 <= tokens.Length) ? tokens[i + 1] : "";

            this.tokens.Add(key, val);
        }


    }

    public String Search(String name)
    {
        foreach (KeyValuePair<String, String> pair in tokens)
        {
            if (pair.Key == name)
                return pair.Value;
        }

        return null;
    }

    public void Set(String key, String val)
    {
        tokens[key] = val;
    }

    public void Save(String file)
    {
        using (StreamWriter sw = new StreamWriter(File.OpenWrite(file)))
        {
            sw.Write(header);
            foreach (KeyValuePair<String, String> pair in tokens)
            {
                sw.Write("\\" + pair.Key + "\\" + pair.Value);
            }
        }
    }

    public void Save()
    {
        this.Save(file);
    }

}


what i want to do is generate a list box with all weapon files in a mod and when one is selected it will execute the parse code

here is a little muck up i made in gui to explain better what i mean

http://i.imgur.com/khoG06h.png[^]

as you can see form below code i can get the file to parse but i want to load all the weapon file names form directory and list them all in the listbox then when i select a name it will load the weapon file into selected boxes

but im not sure how to do this i managed to get it to work with push of a button but i cant seem to get it to list weapon files into the listbox and then on a select it will run the code to load the selected weapon file and then display its values to text box then save it out. and here is the one example weapon file so its easy to understand what im trying to do.

MEGA[^]

so form example weapon file for example displayName/weaponname/ thats how they are layied out

thank you in advance elfenliedtopfan5
AnswerRe: c# parser questions. Pin
OriginalGriff17-Jul-16 21:42
mveOriginalGriff17-Jul-16 21:42 
GeneralRe: c# parser questions. Pin
elfenliedtopfan518-Jul-16 3:31
elfenliedtopfan518-Jul-16 3:31 
GeneralRe: c# parser questions. Pin
OriginalGriff18-Jul-16 4:11
mveOriginalGriff18-Jul-16 4:11 
GeneralRe: c# parser questions. Pin
elfenliedtopfan518-Jul-16 7:24
elfenliedtopfan518-Jul-16 7:24 
GeneralRe: c# parser questions. Pin
OriginalGriff18-Jul-16 8:02
mveOriginalGriff18-Jul-16 8:02 
GeneralRe: c# parser questions. Pin
elfenliedtopfan518-Jul-16 9:28
elfenliedtopfan518-Jul-16 9:28 
GeneralRe: c# parser questions. Pin
OriginalGriff18-Jul-16 9:33
mveOriginalGriff18-Jul-16 9:33 
GeneralRe: c# parser questions. Pin
elfenliedtopfan518-Jul-16 10:31
elfenliedtopfan518-Jul-16 10:31 
QuestionContextMenu on a MenuItem in ContextMenu possible in WPF? Pin
Imagiv16-Jul-16 4:08
Imagiv16-Jul-16 4:08 
QuestionRe: ContextMenu on a MenuItem in ContextMenu possible in WPF? Pin
User 1106097916-Jul-16 7:53
User 1106097916-Jul-16 7:53 
AnswerRe: ContextMenu on a MenuItem in ContextMenu possible in WPF? Pin
Imagiv18-Jul-16 1:19
Imagiv18-Jul-16 1:19 
GeneralRe: ContextMenu on a MenuItem in ContextMenu possible in WPF? Pin
User 1106097918-Jul-16 1:28
User 1106097918-Jul-16 1:28 
GeneralRe: ContextMenu on a MenuItem in ContextMenu possible in WPF? Pin
Imagiv18-Jul-16 2:02
Imagiv18-Jul-16 2:02 
GeneralRe: ContextMenu on a MenuItem in ContextMenu possible in WPF? Pin
Pete O'Hanlon18-Jul-16 2:18
mvePete O'Hanlon18-Jul-16 2:18 
AnswerRe: ContextMenu on a MenuItem in ContextMenu possible in WPF? Pin
Mycroft Holmes16-Jul-16 13:43
professionalMycroft Holmes16-Jul-16 13:43 
Questionno parameterless constructor defined for this object Pin
Gilbert Consellado15-Jul-16 17:36
professionalGilbert Consellado15-Jul-16 17:36 
AnswerRe: no parameterless constructor defined for this object Pin
OriginalGriff15-Jul-16 20:04
mveOriginalGriff15-Jul-16 20:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.