示例#1
0
文件: Log.cs 项目: jmzhuang/Axiom
        public static Brush ConsoleAction;  // Actions


        /// <summary>
        /// Define Log Path (Method)
        /// </summary>
        public static void DefineLogPath(MainWindow mainwindow, ConfigureWindow configurewindow)
        {
            // Only if Log is Enabled through Configure Checkbox
            if (ConfigureWindow.logEnable == true)
            {
                // If checkbox is enabled but textbox is empty, put log in exe's current directory
                if (string.IsNullOrEmpty(ConfigureWindow.logPath))
                {
                    //configure.logPath = appDir + "\\";
                    //System.Windows.MessageBox.Show(log); //debug

                    ConfigureWindow.logPath = MainWindow.appDir;
                }
                // If textbox is not empty, use User custom path
                else if (!string.IsNullOrEmpty(ConfigureWindow.logPath))
                {
                    // do nothing
                }
            }
            // If checkbox disabled
            else
            {
                ConfigureWindow.logPath = string.Empty;
            }
        }
示例#2
0
        public static string threads;     // Set FFmpeg -threads (public - pass data)

        // --------------------------------------------------------------------------------------------------------
        // Window
        // --------------------------------------------------------------------------------------------------------
        public ConfigureWindow(MainWindow mainwindow) // Pass Constructor from MainWindow
        {
            InitializeComponent();

            this.mainwindow = mainwindow;

            // Set Min/Max Width/Height to prevent Tablets maximizing
            this.MinWidth  = 450;
            this.MinHeight = 200;
            this.MaxWidth  = 450;
            this.MaxHeight = 200;

            // --------------------------------------------------
            // Load From Saved Settings
            // --------------------------------------------------
            // Theme CombBox
            ConfigureWindow.LoadTheme(this);

            // FFmpeg Path
            ConfigureWindow.LoadFFmpegPath(this);

            // PProbe Path
            ConfigureWindow.LoadFFprobePath(this);

            // Log CheckBox
            ConfigureWindow.LoadLogCheckbox(this);

            // Log Path
            ConfigureWindow.LoadLogPath(this);

            // Threads CombBox
            ConfigureWindow.LoadThreads(this);
        }
示例#3
0
        public LogConsole(MainWindow mainwindow, ConfigureWindow configurewindow)
        {
            InitializeComponent();

            // Set Width/Height to prevent Tablets maximizing
            //this.Width = 400;
            //this.Height = 500;
            this.MinWidth  = 200;
            this.MinHeight = 200;

            // -------------------------
            // Text Theme Color
            // -------------------------
            ConfigureWindow.LoadTheme(configurewindow);
        }
示例#4
0
        public DebugConsole(MainWindow mainwindow, ConfigureWindow configurewindow)
        {
            InitializeComponent();

            this.mainwindow = mainwindow;

            //this.Width = 400;
            //this.Height = 500;
            this.MinWidth  = 200;
            this.MinHeight = 200;

            // -------------------------
            // Text Theme Color
            // -------------------------
            ConfigureWindow.LoadTheme(configurewindow);
        }
示例#5
0
文件: Log.cs 项目: jmzhuang/Axiom
        /// <summary>
        /// Create Output Log (Method)
        /// </summary>
        public static void CreateOutputLog(MainWindow mainwindow, ConfigureWindow configure)
        {
            // Log Path
            if (ConfigureWindow.logEnable == true) // Only if Log is Enabled through Configure Checkbox
            {
                // Start Log /////////
                if (MainWindow.script == false) // do not log if Script Button clicked
                {
                    // Start write output log file

                    //Catch Directory Access Errors
                    try
                    {
                        //Write Log Console to File
                        TextRange  t    = new TextRange(mainwindow.logconsole.rtbLog.Document.ContentStart, mainwindow.logconsole.rtbLog.Document.ContentEnd);
                        FileStream file = new FileStream(@ConfigureWindow.logPath + "output.log", FileMode.Create);
                        t.Save(file, System.Windows.DataFormats.Text);
                        file.Close();
                    }
                    catch
                    {
                        // Log Console Message /////////
                        Log.WriteAction = () =>
                        {
                            Log.logParagraph.Inlines.Add(new LineBreak());
                            Log.logParagraph.Inlines.Add(new LineBreak());
                            Log.logParagraph.Inlines.Add(new Bold(new Run("Warning: Saving Output Log to " + "\"" + ConfigureWindow.logPath + "\"" + " is Denied. May require Administrator Privileges."))
                            {
                                Foreground = ConsoleWarning
                            });
                        };
                        Log.LogActions.Add(Log.WriteAction);

                        // Popup Message Dialog Box
                        System.Windows.MessageBox.Show("Error Saving Output Log to " + "\"" + ConfigureWindow.logPath + "\"" + ". May require Administrator Privileges.");
                        // do not halt program
                    }
                }
            }
            // If checkbox disabled
            else
            {
                ConfigureWindow.logPath = string.Empty;
            }
        }
示例#6
0
        /// <summary>
        /// Load Threads
        /// </summary>
        public static void LoadThreads(ConfigureWindow configurewindow)
        {
            // --------------------------------------------------
            // Safeguard Against Corrupt Saved Settings
            // --------------------------------------------------
            try
            {
                // --------------------------
                // First time use
                // --------------------------
                if (string.IsNullOrEmpty(Settings.Default["threads"].ToString()))
                {
                    ConfigureWindow.threads = "all";

                    // Set ComboBox if Configure Window is Open
                    if (configurewindow != null)
                    {
                        configurewindow.cboThreads.SelectedItem = ConfigureWindow.threads;
                    }

                    // Save for next launch
                    Settings.Default["threads"] = ConfigureWindow.threads;
                    Settings.Default.Save();
                }
                // --------------------------
                // Load Saved Settings Override
                // --------------------------
                else if (!string.IsNullOrEmpty(Settings.Default["threads"].ToString())) // null check
                {
                    ConfigureWindow.threads = Settings.Default["threads"].ToString();

                    // Set ComboBox if Configure Window is Open
                    if (configurewindow != null)
                    {
                        configurewindow.cboThreads.SelectedItem = Settings.Default["threads"].ToString();
                    }
                }
            }
            catch
            {
            }
        }
示例#7
0
        /// <summary>
        /// Load Log Path
        /// </summary>
        public static void LoadLogPath(ConfigureWindow configurewindow)
        {
            // --------------------------------------------------
            // Safeguard Against Corrupt Saved Settings
            // --------------------------------------------------
            try
            {
                // --------------------------
                // First time use
                // --------------------------
                if (string.IsNullOrEmpty(Settings.Default["logPath"].ToString()))
                {
                    ConfigureWindow.logPath = string.Empty;

                    // Set ComboBox if Configure Window is Open
                    if (configurewindow != null)
                    {
                        configurewindow.textBoxLogConfig.Text = ConfigureWindow.logPath;
                    }

                    // Save for next launch
                    Settings.Default["logPath"] = ConfigureWindow.logPath;
                    Settings.Default.Save();
                }
                // --------------------------
                // Load Saved Settings Override
                // --------------------------
                if (!string.IsNullOrEmpty(Settings.Default["logPath"].ToString())) // null check
                {
                    ConfigureWindow.logPath = Settings.Default["logPath"].ToString();

                    // Set ComboBox if Configure Window is Open
                    if (configurewindow != null)
                    {
                        configurewindow.textBoxLogConfig.Text = Settings.Default["logPath"].ToString();
                    }
                }
            }
            catch
            {
            }
        }
示例#8
0
        /// <summary>
        /// Load Log Checkbox
        /// </summary>
        public static void LoadLogCheckbox(ConfigureWindow configurewindow)
        {
            // --------------------------------------------------
            // Safeguard Against Corrupt Saved Settings
            // --------------------------------------------------
            try
            {
                // --------------------------
                // First time use
                // --------------------------
                if (string.IsNullOrEmpty(Convert.ToString(Settings.Default.checkBoxLog)))
                {
                    ConfigureWindow.logEnable = false;

                    // Set ComboBox if Configure Window is Open
                    if (configurewindow != null)
                    {
                        configurewindow.checkBoxLogConfig.IsChecked = false;
                    }

                    // Save for next launch
                    Settings.Default["checkBoxLog"] = ConfigureWindow.logEnable;
                    Settings.Default.Save();
                }
                // --------------------------
                // Load Saved Settings Override
                // --------------------------
                else if (!string.IsNullOrEmpty(Convert.ToString(Settings.Default.checkBoxLog)))
                {
                    ConfigureWindow.logEnable = Convert.ToBoolean(Settings.Default.logEnable);

                    // Set ComboBox if Configure Window is Open
                    if (configurewindow != null)
                    {
                        configurewindow.checkBoxLogConfig.IsChecked = Convert.ToBoolean(Settings.Default.checkBoxLog);
                    }
                }
            }
            catch
            {
            }
        }
示例#9
0
        /// <summary>
        /// Load Theme
        /// </summary>
        public static void LoadTheme(ConfigureWindow configurewindow)
        {
            // --------------------------------------------------
            // Safeguard Against Corrupt Saved Settings
            // --------------------------------------------------
            try
            {
                // --------------------------
                // First time use
                // --------------------------
                if (string.IsNullOrEmpty(Settings.Default["Theme"].ToString()))
                {
                    ConfigureWindow.theme = "Axiom";

                    // Set ComboBox if Configure Window is Open
                    if (configurewindow != null)
                    {
                        configurewindow.cboTheme.SelectedItem = "Axiom";
                    }

                    // Save Theme for next launch
                    Settings.Default["Theme"] = ConfigureWindow.theme;
                    Settings.Default.Save();

                    // Change Theme Resource
                    App.Current.Resources.MergedDictionaries.Clear();
                    App.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
                    {
                        Source = new Uri("Theme" + ConfigureWindow.theme + ".xaml", UriKind.RelativeOrAbsolute)
                    });
                }
                // --------------------------
                // Load Saved Settings Override
                // --------------------------
                else if (!string.IsNullOrEmpty(Settings.Default["Theme"].ToString())) // null check
                {
                    ConfigureWindow.theme = Settings.Default["Theme"].ToString();

                    // Set ComboBox if Configure Window is Open
                    if (configurewindow != null)
                    {
                        configurewindow.cboTheme.SelectedItem = Settings.Default["Theme"].ToString();
                    }

                    // Change Theme Resource
                    App.Current.Resources.MergedDictionaries.Clear();
                    App.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
                    {
                        Source = new Uri("Theme" + ConfigureWindow.theme + ".xaml", UriKind.RelativeOrAbsolute)
                    });
                }

                // -------------------------
                // Log Text Theme Color
                // -------------------------
                if (ConfigureWindow.theme == "Axiom")
                {
                    Log.ConsoleDefault = Brushes.White;                                                  // Default
                    Log.ConsoleTitle   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#007DF2")); // Titles
                    Log.ConsoleWarning = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E3D004")); // Warning
                    Log.ConsoleError   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#F44B35")); // Error
                    Log.ConsoleAction  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#72D4E8")); // Actions
                }
                else if (ConfigureWindow.theme == "FFmpeg")
                {
                    Log.ConsoleDefault = Brushes.White;                                                  // Default
                    Log.ConsoleTitle   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#5cb85c")); // Titles
                    Log.ConsoleWarning = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E3D004")); // Warning
                    Log.ConsoleError   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#F44B35")); // Error
                    Log.ConsoleAction  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#5cb85c")); // Actions
                }
                else if (ConfigureWindow.theme == "Cyberpunk")
                {
                    Log.ConsoleDefault = Brushes.White;                                                  // Default
                    Log.ConsoleTitle   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#9f3ed2")); // Titles
                    Log.ConsoleWarning = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E3D004")); // Warning
                    Log.ConsoleError   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#F44B35")); // Error
                    Log.ConsoleAction  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#9380fd")); // Actions
                }
                else if (ConfigureWindow.theme == "Onyx")
                {
                    Log.ConsoleDefault = Brushes.White;                                                  // Default
                    Log.ConsoleTitle   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#999999")); // Titles
                    Log.ConsoleWarning = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E3D004")); // Warning
                    Log.ConsoleError   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#F44B35")); // Error
                    Log.ConsoleAction  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#777777")); // Actions
                }
                else if (ConfigureWindow.theme == "Circuit")
                {
                    Log.ConsoleDefault = Brushes.White;                                                  // Default
                    Log.ConsoleTitle   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#ad8a4a")); // Titles
                    Log.ConsoleWarning = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E3D004")); // Warning
                    Log.ConsoleError   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#F44B35")); // Error
                    Log.ConsoleAction  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#2ebf93")); // Actions
                }
                else if (ConfigureWindow.theme == "Prelude")
                {
                    Log.ConsoleDefault = Brushes.White;                                                  // Default
                    Log.ConsoleTitle   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#999999")); // Titles
                    Log.ConsoleWarning = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E3D004")); // Warning
                    Log.ConsoleError   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#F44B35")); // Error
                    Log.ConsoleAction  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#777777")); // Actions
                }
                else if (ConfigureWindow.theme == "System")
                {
                    Log.ConsoleDefault = Brushes.White;                                                  // Default
                    Log.ConsoleTitle   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#007DF2")); // Titles
                    Log.ConsoleWarning = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E3D004")); // Warning
                    Log.ConsoleError   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#F44B35")); // Error
                    Log.ConsoleAction  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#72D4E8")); // Actions
                }

                // -------------------------
                // Debug Text Theme Color
                // -------------------------
                if (ConfigureWindow.theme == "Axiom")
                {
                    DebugConsole.Heading  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#007DF2"));
                    DebugConsole.Variable = (SolidColorBrush)(new BrushConverter().ConvertFrom("#72D4E8"));
                    DebugConsole.Value    = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFFF"));
                }
                else if (ConfigureWindow.theme == "FFmpeg")
                {
                    DebugConsole.Heading  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#878787"));
                    DebugConsole.Variable = (SolidColorBrush)(new BrushConverter().ConvertFrom("#5cb85c"));
                    DebugConsole.Value    = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFFF"));
                }
                else if (ConfigureWindow.theme == "Cyberpunk")
                {
                    DebugConsole.Heading  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#9a989c"));
                    DebugConsole.Variable = (SolidColorBrush)(new BrushConverter().ConvertFrom("#9f3ed2"));
                    DebugConsole.Value    = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFFF"));
                }
                else if (ConfigureWindow.theme == "Onyx")
                {
                    DebugConsole.Heading  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#EEEEEE"));
                    DebugConsole.Variable = (SolidColorBrush)(new BrushConverter().ConvertFrom("#999999"));
                    DebugConsole.Value    = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFFF"));
                }
                else if (ConfigureWindow.theme == "Circuit")
                {
                    DebugConsole.Heading  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#ad8a4a"));
                    DebugConsole.Variable = (SolidColorBrush)(new BrushConverter().ConvertFrom("#2ebf93"));
                    DebugConsole.Value    = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFFF"));
                }
                else if (ConfigureWindow.theme == "Prelude")
                {
                    DebugConsole.Heading  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#ad8a4a"));
                    DebugConsole.Variable = (SolidColorBrush)(new BrushConverter().ConvertFrom("#2ebf93"));
                    DebugConsole.Value    = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFFF"));
                }
                else if (ConfigureWindow.theme == "System")
                {
                    DebugConsole.Heading  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#007DF2"));
                    DebugConsole.Variable = (SolidColorBrush)(new BrushConverter().ConvertFrom("#72D4E8"));
                    DebugConsole.Value    = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFFF"));
                }
            }
            catch
            {
            }
        }
示例#10
0
文件: Log.cs 项目: jmzhuang/Axiom
        /// <summary>
        /// Log Write All
        /// </summary>
        public static void LogWriteAll(MainWindow mainwindow, ConfigureWindow configurewindow)
        {
            // -------------------------
            // Background Thread Worker
            // -------------------------
            BackgroundWorker bwlog = new BackgroundWorker();

            bwlog.WorkerSupportsCancellation = true;

            // This allows the worker to report progress during work
            bwlog.WorkerReportsProgress = true;

            // What to do in the background thread
            bwlog.DoWork += new DoWorkEventHandler(delegate(object o, DoWorkEventArgs args)
            {
                BackgroundWorker b = o as BackgroundWorker;

                // Dispatcher Allows Cross-Thread Communication
                mainwindow.Dispatcher.Invoke(() =>
                {
                    // -------------------------
                    // Write All Log Actions to Console
                    // -------------------------
                    mainwindow.logconsole.rtbLog.Document = new FlowDocument(logParagraph); // start
                    mainwindow.logconsole.rtbLog.BeginChange();                             // begin change

                    foreach (Action Write in LogActions)
                    {
                        Write();
                    }

                    mainwindow.logconsole.rtbLog.EndChange(); // end change


                    // Clear
                    if (LogActions != null)
                    {
                        LogActions.Clear();
                        LogActions.TrimExcess();
                    }
                }); //end dispatcher
            });     //end thread


            // -------------------------
            // When Background Worker Completes Task
            // -------------------------
            bwlog.RunWorkerCompleted += new RunWorkerCompletedEventHandler(delegate(object o, RunWorkerCompletedEventArgs args)
            {
                // Scroll Console to End
                mainwindow.logconsole.rtbLog.ScrollToEnd();

                // -------------------------
                // Create Output Log File
                // -------------------------
                DefineLogPath(mainwindow, configurewindow);
                CreateOutputLog(mainwindow, configurewindow); //write output log to text file

                // set script back to 0 for next convert
                MainWindow.script = false;

                // Close the Background Worker
                bwlog.CancelAsync();
                bwlog.Dispose();
            }); //end worker completed task

            bwlog.RunWorkerAsync();
        }