Exemplo n.º 1
0
        private void FirstRunSetup()
        {
            if (UserSettings.Setting.FirstRun)
            {
                Visibility = Visibility.Visible;

                MessageBoxResult result = TKMessageBox.Show("It looks like this is the first run of PathTools.\n\n" +
                                                            "Would you like to keep a log file?",
                                                            "PathTools - Keep a Log File?",
                                                            MessageBoxButton.YesNoCancel,
                                                            MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    LogFileWindow log = new LogFileWindow
                    {
                        Owner = this
                    };
                    log.cbKeepLog.IsChecked = true;
                    _ = log.ShowDialog();
                }
                else if (result == MessageBoxResult.No)
                {
                    UserSettings.Setting.KeepLogFile = false;
                }
                else if (result == MessageBoxResult.Cancel)
                {
                    Application.Current.Shutdown();
                }

                UserSettings.Setting.FirstRun = false;
            }
        }
Exemplo n.º 2
0
        // *** ContextMenu ***

        private void deleteActionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <TK_Action> actions = GetSelectedActions();

            if (actions.Count > 0)
            {
                string actionsList = actions[0].Name;

                for (int i = 1; i < actions.Count; i++)
                {
                    actionsList += "," + actions[i].Name;
                }

                string potentialS = actions.Count > 1 ? "s" : "";

                if (TKMessageBox.Confirm("Are you sure you want to delete the action" + potentialS + " : " + actionsList + " ?", "Delete Action" + potentialS))
                {
                    DeselectAll();

                    for (int i = 0; i < actions.Count; i++)
                    {
                        library.DeleteAction(actions[i]);
                    }

                    LoadPoses();
                }
            }
            else
            {
                MessageBox.Show("Select some actions to delete");
            }
        }
        /// <summary>
        /// Clicking "Load"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.InitialDirectory = BaseFolder;
            openFileDialog1.FileName         = string.Empty;
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (Data.Load(openFileDialog1.FileName))
                {
                    if (alternateContent != null)
                    {
                        alternateContent.Init(Data);
                        alternateContent.RefreshValues();
                        PrefChanged(PrefPropertyGrid, new PropertyChangedEventArgs("All"));
                    }
                    else
                    {
                        PrefPropertyGrid.Refresh();
                        PrefChanged(PrefPropertyGrid, new PropertyChangedEventArgs("All"));
                    }
                }
                else
                {
                    TKMessageBox.ShowError("Can't load selected Preference !", "Preference error");
                }
            }
        }
Exemplo n.º 4
0
        private static void CheckForDupes(List <SavedPath> curPath)
        {
            var duplicates = curPath.GroupBy(x => x.PathDirectory).Where(x => x.Count() > 1).Select(x => x.Key).ToList();

            if (duplicates.Count > 0)
            {
                List <SavedPath> allDupes = new List <SavedPath>();
                foreach (string dupe in duplicates)
                {
                    foreach (var item in curPath.FindAll(x => x.PathDirectory == dupe))
                    {
                        allDupes.Add(item);
                        logTemp.Warn($"Duplicate found: {item.SeqNumber} {item.PathType} {item.PathDirectory}");
                    }
                }
                Duplicates d = new Duplicates();
                d.dgDupes.ItemsSource = allDupes;
                d.Owner = Application.Current.MainWindow;
                d.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                _ = d.ShowDialog();
            }
            else
            {
                _ = TKMessageBox.Show("No duplicates found.",
                                      "PathTools",
                                      MessageBoxButton.OK,
                                      MessageBoxImage.Check);
            }
        }
Exemplo n.º 5
0
 public static void ViewTextFile(string txtfile)
 {
     if (File.Exists(txtfile))
     {
         try
         {
             using (Process p = new Process())
             {
                 p.StartInfo.FileName        = txtfile;
                 p.StartInfo.UseShellExecute = true;
                 p.StartInfo.ErrorDialog     = false;
                 _ = p.Start();
             }
         }
         catch (Win32Exception ex)
         {
             if (ex.NativeErrorCode == 1155)
             {
                 using (Process p = new Process())
                 {
                     p.StartInfo.FileName        = "notepad.exe";
                     p.StartInfo.Arguments       = txtfile;
                     p.StartInfo.UseShellExecute = true;
                     p.StartInfo.ErrorDialog     = false;
                     _ = p.Start();
                     logTemp.Info($"Falling back to Notepad to open {txtfile}");
                 }
             }
             else
             {
                 _ = TKMessageBox.Show($"Error reading file {txtfile}\n{ex.Message}",
                                       "Error",
                                       MessageBoxButton.OK,
                                       MessageBoxImage.Error);
                 logTemp.Error(ex, $"Unable to open {txtfile}");
             }
         }
         catch (Exception ex)
         {
             _ = TKMessageBox.Show($"Unable to start default application used to open {txtfile}",
                                   "Error",
                                   MessageBoxButton.OK,
                                   MessageBoxImage.Error);
             logTemp.Error(ex, $"Unable to open {txtfile}");
         }
     }
     else
     {
         Debug.WriteLine($">>> File not found: {txtfile}");
         logTemp.Error($"{txtfile} could not be found");
         _ = TKMessageBox.Show($"The file: {txtfile} could not be found.",
                               "Error",
                               MessageBoxButton.OK,
                               MessageBoxImage.Error);
     }
 }
Exemplo n.º 6
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
     {
         if (!OpenSequence(folderBrowserDialog1.SelectedPath))
         {
             TKMessageBox.ShowError("Can't found images to read in " + folderBrowserDialog1.SelectedPath, "Open sequence error");
         }
     }
 }
Exemplo n.º 7
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            if (enumValuesPanel.Visible && string.IsNullOrEmpty(enumValuesTB.Text))
            {
                TKMessageBox.ShowError("Please give at least one enum value !", "Parameter type incomplete");
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 8
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args)
        {
            logTemp.Error("Unhandled Exception");
            Exception e = (Exception)args.ExceptionObject;

            logTemp.Error(e.Message);
            if (e.InnerException != null)
            {
                logTemp.Error(e.InnerException.ToString());
            }
            logTemp.Error(e.StackTrace);

            _ = TKMessageBox.Show($"An unexpected error has occurred. \n{e.Message}\nSee the log file for more information.",
                                  "PathTools Error",
                                  MessageBoxButton.OK,
                                  MessageBoxImage.Error);
        }
        //Window Closing
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (cbKeepLog.IsChecked == true && string.IsNullOrEmpty(tbLogFileName.Text))
            {
                _ = TKMessageBox.Show("Please supply a log file name or uncheck 'Keep a log' checkbox",
                                      "Try again please",
                                      MessageBoxButton.OK,
                                      MessageBoxImage.Warning);
                e.Cancel = true;
            }
            else
            {
                UserSettings.SaveSettings();
            }

            Debug.WriteLine("LogFileWindow closing");
        }
Exemplo n.º 10
0
 private void CxmTerminal_Click(object sender, RoutedEventArgs e)
 {
     if (dgPath.SelectedItem != null)
     {
         DisplayPath row     = (DisplayPath)dgPath.SelectedItem;
         string      selPath = Path.GetFullPath(row.PathDirectory).TrimEnd('\\');
         using Process wt             = new Process();
         wt.StartInfo.FileName        = "wt.exe";
         wt.StartInfo.Arguments       = $"-d \"{selPath}\" ";
         wt.StartInfo.UseShellExecute = false;
         try
         {
             _ = wt.Start();
         }
         catch (Win32Exception ex)
         {
             logTemp.Warn(ex, "Unable to launch Windows Terminal. Falling back to CMD.exe");
             using Process cmd              = new Process();
             cmd.StartInfo.FileName         = "cmd.exe";
             cmd.StartInfo.Arguments        = "/k Title PathTools";
             cmd.StartInfo.WorkingDirectory = selPath;
             cmd.StartInfo.UseShellExecute  = true;
             try
             {
                 _ = cmd.Start();
             }
             catch (Exception ex2)
             {
                 logTemp.Warn(ex2, "Unable to launch CMD.exe");
                 _ = TKMessageBox.Show("Unable to launch a terminal. See log file.",
                                       "PathTools Error",
                                       MessageBoxButton.OK,
                                       MessageBoxImage.Error);
             }
         }
         catch (Exception ex)
         {
             _ = TKMessageBox.Show("Unable to launch a terminal. See log file.",
                                   "PathTools Error",
                                   MessageBoxButton.OK,
                                   MessageBoxImage.Error);
             logTemp.Warn(ex, "Unable to launch Windows Terminal.");
         }
     }
 }
Exemplo n.º 11
0
 private void WriteSavedPathFile()
 {
     // Write the current path to disk for next time
     try
     {
         JsonSerializerOptions opts = new JsonSerializerOptions
         {
             AllowTrailingCommas = true,
             ReadCommentHandling = JsonCommentHandling.Skip,
             WriteIndented       = true
         };
         string json = JsonSerializer.Serialize(GetCurrentPath(), opts);
         File.WriteAllText(savedPathFile, json);
     }
     catch (Exception)
     {
         TKMessageBox.Show("Error saving file", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 12
0
        private void MnuLongPath_Click(object sender, RoutedEventArgs e)
        {
            string regMessage = null;

            try
            {
                using RegistryKey key = Registry.LocalMachine.
                                        OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\FileSystem");
                string longPath = key.GetValue("LongPathsEnabled", "no value present").ToString();
                if (longPath != null)
                {
                    if (longPath == "1")
                    {
                        regMessage = "Long paths ARE enabled.";
                    }
                    else
                    {
                        regMessage = "Long paths are NOT enabled.";
                    }

                    regMessage += "\n\nRegistry location and value:" +
                                  "\n\nHKLM\\SYSTEM\\CurrentControlSet\\Control\\FileSystem\\LongPathsEnable = " +
                                  longPath;
                }
                else
                {
                    regMessage = "Registry value for LongPathsEnabled not found";
                }
            }
            catch (SecurityException)
            {
                regMessage = "Permission to access registry denied";
            }
            catch (UnauthorizedAccessException)
            {
                regMessage = "No registry rights ";
            }
            finally
            {
                _ = TKMessageBox.Show(regMessage, "Long Paths", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 13
0
 private void ReadMeLink_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (Process ps = new Process())
         {
             ps.StartInfo.FileName        = ".\\ReadMe.txt";
             ps.StartInfo.UseShellExecute = true;
             _ = ps.Start();
         }
         e.Handled = true;
         Close();
     }
     catch (System.Exception ex)
     {
         _ = TKMessageBox.Show($"Error opening ReadMe.txt\n{ex}",
                               "PathTools Error",
                               MessageBoxButton.OK,
                               TKUtils.MessageBoxImage.Error);
     }
 }
Exemplo n.º 14
0
 private void OnNavigate(object sender, RequestNavigateEventArgs e)
 {
     Debug.WriteLine($"Opening {e.Uri.AbsoluteUri}");
     try
     {
         using (Process ps = new Process())
         {
             ps.StartInfo.FileName        = e.Uri.AbsoluteUri;
             ps.StartInfo.UseShellExecute = true;
             _ = ps.Start();
         }
         e.Handled = true;
         Close();
     }
     catch (System.Exception ex)
     {
         _ = TKMessageBox.Show($"Error opening the link\n{ex}",
                               "PathTools Error",
                               MessageBoxButton.OK,
                               TKUtils.MessageBoxImage.Error);
     }
 }
Exemplo n.º 15
0
        private void BtnOK_Click(object sender, RoutedEventArgs e)
        {
            if (cbKeepLog.IsChecked == true)
            {
                if (string.IsNullOrEmpty(tbLogFileName.Text))
                {
                    SystemSounds.Asterisk.Play();
                    _ = tbLogFileName.Focus();
                    tbLogFileName.Background = Brushes.LemonChiffon;
                    lblStatus.Foreground     = Brushes.Red;
                    lblStatus.FontWeight     = FontWeights.Bold;
                    lblStatus.FontSize       = 16;
                    lblStatus.Text           = "File name can't be blank";
                    return;
                }

                UserSettings.Setting.LogFile = tbLogFileName.Text;

                if (!File.Exists(tbLogFileName.Text))
                {
                    try
                    {
                        GlobalDiagnosticsContext.Set("LogPerm", tbLogFileName.Text);
                        logPerm.Info($"This log file was created by {AppInfo.AppName} {AppInfo.TitleVersion}");
                    }
                    catch (System.Exception ex)
                    {
                        logTemp.Error("Error creating log file.");
                        logTemp.Error(ex, $"Error creating log file: {UserSettings.Setting.LogFile}");
                        _ = TKMessageBox.Show($"Error creating log file.\n{ex.Message}",
                                              "ERROR",
                                              MessageBoxButton.OK,
                                              MessageBoxImage.Error);
                    }
                }
            }
            Close();
        }
 public override void RemoveFromSelection(List <string> objs)
 {
     TKMessageBox.ShowError("RemoveFromSelection", "RemoveFromSelection called");
 }
Exemplo n.º 17
0
 public virtual void Error(string p)
 {
     TKMessageBox.ShowError(p, "Generic error");
 }
 public override void ExecuteCode(string p, int mode)
 {
     TKMessageBox.ShowError("Ask to execute '" + p + "', mode " + mode.ToString(), "ExecuteCode called");
 }
Exemplo n.º 19
0
        private void MnuPathLen_Click(object sender, RoutedEventArgs e)
        {
            string message = $"The PATH variable is {DisplayPath.TotalPathLength} bytes";

            _ = TKMessageBox.Show(message, "Path Length", MessageBoxButton.OK, MessageBoxImage.Information);
        }
        public override void ExecuteCommand(string p, params string[] args)
        {
            List <string> lArgs = new List <string>(args);

            TKMessageBox.ShowError("Ask to execute command '" + p + "', args : '" + TypesHelper.Join(lArgs) + "'", "ExecuteCommand called");
        }
 public override void Error(string p)
 {
     TKMessageBox.ShowError(p, "Generic error");
 }
 public override void AddToSelection(List <string> objs)
 {
     TKMessageBox.ShowError("AddToSelection", "AddToSelection called");
 }