示例#1
0
    protected virtual void Preferences_OnActivated(object sender, System.EventArgs e)
    {
        PrefWin Pref = new PrefWin();

        Pref.DebugFile = DebugFile;

        Pref.PipeFont   = PipeTextView.Style.FontDescription.ToString();
        Pref.TextFont   = InputTextView.Style.FontDescription.ToString();
        Pref.ErrorsFont = ErrorsTextView.Style.FontDescription.ToString();

        Pref.WrapText = InputTextView.WrapMode != WrapMode.None;
        Pref.CommandAutoCompletion = commandAutoCompletion;

        try
        {
            if (Pref.Run() == (int)ResponseType.Ok)
            {
                DebugFile = Pref.DebugFile;

                PipeTextView.ModifyFont(Pango.FontDescription.FromString(Pref.PipeFont));
                ArgsEntry.ModifyFont(Pango.FontDescription.FromString(Pref.PipeFont));
                InputTextView.ModifyFont(Pango.FontDescription.FromString(Pref.TextFont));
                OutputTextView.ModifyFont(Pango.FontDescription.FromString(Pref.TextFont));
                ErrorsTextView.ModifyFont(Pango.FontDescription.FromString(Pref.ErrorsFont));

                if (Pref.WrapText)
                {
                    InputTextView.WrapMode  = WrapMode.Word;
                    OutputTextView.WrapMode = WrapMode.Word;
                }
                else
                {
                    InputTextView.WrapMode  = WrapMode.None;
                    OutputTextView.WrapMode = WrapMode.None;
                }

                commandAutoCompletion = Pref.CommandAutoCompletion;

                SaveConfiguration();
            }
        }

        finally
        {
            Pref.Destroy();
        }
    }
示例#2
0
    /// <summary>
    /// Configures the application.
    /// </summary>
    private void LoadConfiguration()
    {
        try
        {
            if (!File.Exists(ConfigFile))
            {
                // Configuration file doesn't exist. Create it:

                string configContents =
                    "<Config>" + System.Environment.NewLine +
                    "  <DebugFile>" + applDataFolder + System.IO.Path.DirectorySeparatorChar + "Debug.txt</DebugFile>" + System.Environment.NewLine +
                    "  <TextWrapping>True</TextWrapping>" + System.Environment.NewLine +
                    "  <CmdAutoCompletion>True</CmdAutoCompletion>" + System.Environment.NewLine +
                    "  <PipeFont>FreeMono Bold 10</PipeFont>" + System.Environment.NewLine +
                    "  <TextFont>FreeMono 10</TextFont>" + System.Environment.NewLine +
                    "  <ErrorFont>FreeMono 10</ErrorFont>" + System.Environment.NewLine +
                    "</Config>" + System.Environment.NewLine;

                File.WriteAllText(ConfigFile, configContents);
            }

            // Load the configuration file:

            XmlDocument XmlDoc = new XmlDocument();
            XmlDoc.Load(ConfigFile);
            XmlElement RootElem = XmlDoc["Config"];

            // Configure debugging:

            XmlElement Elem = RootElem["DebugFile"];
            DebugFile = Elem.InnerText;

            // Configure text wrapping:

            Elem = RootElem["TextWrapping"];

            if (Elem.InnerText.ToUpper() == "TRUE")
            {
                InputTextView.WrapMode  = WrapMode.Word;
                OutputTextView.WrapMode = WrapMode.Word;
            }
            else
            {
                InputTextView.WrapMode  = WrapMode.None;
                OutputTextView.WrapMode = WrapMode.None;
            }

            // Configure command auto-completion:

            Elem = RootElem["CmdAutoCompletion"];
            commandAutoCompletion = Elem.InnerText.ToUpper() == "TRUE";

            // Configure fonts:

            string tempStr = LoadFont("PipeFont", RootElem);
            PipeTextView.ModifyFont(Pango.FontDescription.FromString(tempStr));
            ArgsEntry.ModifyFont(Pango.FontDescription.FromString(tempStr));
            InputTextView.ModifyFont(Pango.FontDescription.FromString(LoadFont("TextFont", RootElem)));
            OutputTextView.ModifyFont(Pango.FontDescription.FromString(LoadFont("TextFont", RootElem)));
            ErrorsTextView.ModifyFont(Pango.FontDescription.FromString(LoadFont("ErrorFont", RootElem)));
        }

        catch (Exception)
        {
            throw new PipeWrenchEngineException("Could not create/load app. configuration (" +
                                                ConfigFile + ").");
        }
    }