Ejemplo n.º 1
0
    public void Function()
    {
        string projectPath = PathMap.SubstitutePath("$(PROJECTPATH)");

        // Save
        FileSelectDecisionContext fsdcSave = new FileSelectDecisionContext();

        fsdcSave.Title             = "Datei auswählen";
        fsdcSave.OpenFileFlag      = false;
        fsdcSave.CustomDefaultPath = projectPath;
        fsdcSave.AllowMultiSelect  = false;
        fsdcSave.DefaultExtension  = "txt";
        fsdcSave.AddFilter("Textdatei (*.txt)", "*.txt");
        fsdcSave.AddFilter("Alle Dateien (*.*)", "*.*");

        Decider            deciderSave  = new Decider();
        EnumDecisionReturn decisionSave = deciderSave.Decide(fsdcSave);

        if (decisionSave == EnumDecisionReturn.eCANCEL)
        {
            return;
        }

        string     fullFileNameSave = fsdcSave.GetFiles()[0];
        FileStream fileStream       = File.Create(fullFileNameSave);

        fileStream.Dispose();
        MessageBox.Show("Datei wurde gespeichert:" + Environment.NewLine +
                        fullFileNameSave);

        // Open
        FileSelectDecisionContext fsdcOpen = new FileSelectDecisionContext();

        fsdcOpen.Title             = "Datei auswählen";
        fsdcOpen.OpenFileFlag      = true;
        fsdcOpen.CustomDefaultPath = projectPath;
        fsdcOpen.AllowMultiSelect  = false;
        fsdcOpen.DefaultExtension  = "txt";
        fsdcOpen.AddFilter("Textdatei (*.txt)", "*.txt");
        fsdcOpen.AddFilter("Alle Dateien (*.*)", "*.*");

        Decider            deciderOpen  = new Decider();
        EnumDecisionReturn decisionOpen = deciderOpen.Decide(fsdcOpen);

        if (decisionOpen == EnumDecisionReturn.eCANCEL)
        {
            return;
        }

        string fullFileNameOpen = fsdcOpen.GetFiles()[0];

        MessageBox.Show("Datei wurde geöffnet:" + Environment.NewLine +
                        fullFileNameOpen);
    }
Ejemplo n.º 2
0
 public OpenMacroDialog()
 {
     decider = new Decider();
     fileSelectDecisionContext                  = new FileSelectDecisionContext("WindowMacroSelector", EnumDecisionReturn.eCANCEL);
     fileSelectDecisionContext.Title            = "Makro auswählen";
     fileSelectDecisionContext.AllowMultiSelect = false;
     fileSelectDecisionContext.DefaultExtension = "ema";
     fileSelectDecisionContext.AddFilter("Fenstermakro (*.ema)", "*.ema");
     fileSelectDecisionContext.AddFilter("Alle Dateien (*.*)", "*.*");
     fileSelectDecisionContext.CustomDefaultPath = PathMap.SubstitutePath("$(MD_MACROS)");
     this.File = "";
 }
    public void Function()
    {
        #region Decider
        Decider            decider  = new Decider();
        EnumDecisionReturn decision = decider.Decide(
            EnumDecisionType.eOkCancelDecision, // type
            "This is the text",
            "Title",
            EnumDecisionReturn.eOK,  // selected Answer
            EnumDecisionReturn.eOK); // Answer if quite-mode on

        switch (decision)
        {
        case EnumDecisionReturn.eOK:
            // OK
            break;

        case EnumDecisionReturn.eCANCEL:
            // Cancel
            break;
        }
        #endregion


        #region FileSelector
        FileSelectDecisionContext fileContext = new FileSelectDecisionContext("MySelector", EnumDecisionReturn.eCANCEL);
        fileContext.Title             = "Title";
        fileContext.CustomDefaultPath = @"C:\MyDefaultPath";
        fileContext.OpenFileFlag      = true; // true=Open, false=save
        fileContext.AllowMultiSelect  = true;
        fileContext.DefaultExtension  = "xml";
        fileContext.AddFilter("XML files (*.xml)", "*.xml");
        fileContext.AddFilter("All files (*.*)", "*.*");

        Decider            oDecision = new Decider();
        EnumDecisionReturn eAnswer   = oDecision.Decide(fileContext);
        if (eAnswer != EnumDecisionReturn.eOK)
        {
            foreach (string file in fileContext.GetFiles())
            {
                // do with file
            }
        }
        #endregion
    }